Merge branch 'master-MC1.8' of github.com:MightyPirates/OpenComputers into OC1.5-MC1.8

Conflicts:
	build.properties
This commit is contained in:
Florian Nücke 2015-09-06 00:24:48 +02:00
commit 82ce793ee6
8 changed files with 61 additions and 31 deletions

View File

@ -105,8 +105,8 @@ repositories {
url = "http://mobiusstrip.eu/maven"
}
maven {
name = "builtbroken"
url = "http://ci.builtbroken.com/maven/"
name = "dmodoomsirius"
url = "http://ci.dmodoomsirius.me/maven/"
}
maven {
name = "ue"

View File

@ -1,7 +1,7 @@
minecraft.version=1.8
forge.version=11.14.3.1450
oc.version=1.5.16
oc.version=1.5.17
oc.subversion=
ae2.version=rv2-beta-26
@ -33,7 +33,7 @@ mekanism.version=7.1.2
mfr.cf=2229/626
mfr.version=[1.7.10]2.8.0RC8-86
nei.version=1.0.5.82
nek.version=1.0.0b35dev
nek.version=1.0.0b2dev
poweradvantage.version=1.2.0
projred.version=1.7.10-4.6.2.82
qmunitylib.version=0.1.105
@ -48,4 +48,4 @@ wrcbe.version=1.4.1.2
cofhcore.cf=2246/697
cofhcore.version=[1.7.10]3.0.3B4-302-dev
maven.url=file:///home/www/maven.cil.li/web
maven.url=file:///home/www/maven.cil.li/web

View File

@ -6,9 +6,13 @@ import li.cil.oc.common.item.data.HoverBootsData
import net.minecraft.client.model.ModelBiped
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.EnumRarity
import net.minecraft.item.ItemArmor
import net.minecraft.item.ItemStack
import net.minecraft.potion.Potion
import net.minecraft.potion.PotionEffect
import net.minecraft.world.World
import net.minecraftforge.fml.relauncher.Side
import net.minecraftforge.fml.relauncher.SideOnly
@ -61,6 +65,13 @@ class HoverBoots extends ItemArmor(ItemArmor.ArmorMaterial.DIAMOND, 0, 3) with t
else null
}
override def onArmorTick(world: World, player: EntityPlayer, stack: ItemStack): Unit = {
super.onArmorTick(world, player, stack)
if (player.getActivePotionEffect(Potion.moveSlowdown) == null && getCharge(stack) == 0) {
player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId, 20, 1))
}
}
override def showDurabilityBar(stack: ItemStack): Boolean = true
override def getDurabilityForDisplay(stack: ItemStack): Double = {
@ -72,4 +83,15 @@ class HoverBoots extends ItemArmor(ItemArmor.ArmorMaterial.DIAMOND, 0, 3) with t
// Always show energy bar.
override def isDamaged(stack: ItemStack): Boolean = true
// Contradictory as it may seem with the above, this avoids actual damage value changing.
override def isDamageable: Boolean = false
override def setDamage(stack: ItemStack, damage: Int): Unit = {
// Subtract energy when taking damage instead of actually damaging the item.
charge(stack, -damage, simulate = false)
// Set to 0 for old boots that may have been damaged before.
super.setDamage(stack, 0)
}
}

View File

@ -3,7 +3,10 @@ package li.cil.oc.common.item.traits
import java.util
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.driver.item.MutableProcessor
import li.cil.oc.integration.opencomputers.DriverCPU
import li.cil.oc.server.machine.Machine
import li.cil.oc.util.Tooltip
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
@ -19,22 +22,26 @@ trait CPULike extends Delegate {
override protected def tooltipData: Seq[Any] = Seq(Settings.get.cpuComponentSupport(cpuTier))
override protected def tooltipExtended(stack: ItemStack, tooltip: util.List[String]) {
tooltip.addAll(Tooltip.get("CPU.Architecture", DriverCPU.getArchitectureName(DriverCPU.architecture(stack))))
tooltip.addAll(Tooltip.get("CPU.Architecture", Machine.getArchitectureName(DriverCPU.architecture(stack))))
}
override def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer) = {
if (player.isSneaking) {
if (!world.isRemote) {
val architectures = DriverCPU.allArchitectures.toList
if (architectures.nonEmpty) {
val currentIndex = architectures.indexOf(DriverCPU.architecture(stack))
val newIndex = (currentIndex + 1) % architectures.length
val archClass = architectures(newIndex)
val archName = DriverCPU.getArchitectureName(archClass)
DriverCPU.setArchitecture(stack, archClass)
player.addChatMessage(new ChatComponentTranslation(Settings.namespace + "tooltip.CPU.Architecture", archName))
api.Driver.driverFor(stack) match {
case driver: MutableProcessor =>
val architectures = driver.allArchitectures.toList
if (architectures.nonEmpty) {
val currentIndex = architectures.indexOf(driver.architecture(stack))
val newIndex = (currentIndex + 1) % architectures.length
val archClass = architectures(newIndex)
val archName = Machine.getArchitectureName(archClass)
driver.setArchitecture(stack, archClass)
player.addChatMessage(new ChatComponentTranslation(Settings.namespace + "tooltip.CPU.Architecture", archName))
}
player.swingItem()
case _ => // No known driver for this processor.
}
player.swingItem()
}
}
stack

View File

@ -12,6 +12,7 @@ import li.cil.oc.common.Slot
import li.cil.oc.common.Tier
import li.cil.oc.common.item
import li.cil.oc.common.item.Delegator
import li.cil.oc.server.machine.Machine
import li.cil.oc.server.machine.luac.NativeLuaArchitecture
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
@ -66,13 +67,6 @@ abstract class DriverCPU extends Item with MutableProcessor {
if (!worksWith(stack)) throw new IllegalArgumentException("Unsupported processor type.")
if (!stack.hasTagCompound) stack.setTagCompound(new NBTTagCompound())
stack.getTagCompound.setString(Settings.namespace + "archClass", architecture.getName)
stack.getTagCompound.setString(Settings.namespace + "archName", getArchitectureName(architecture))
stack.getTagCompound.setString(Settings.namespace + "archName", Machine.getArchitectureName(architecture))
}
// TODO Move to Machine API in 1.6
def getArchitectureName(architecture: Class[_ <: Architecture]) =
architecture.getAnnotation(classOf[Architecture.Name]) match {
case annotation: Architecture.Name => annotation.value
case _ => architecture.getSimpleName
}
}

View File

@ -980,6 +980,13 @@ object Machine extends MachineAPI {
override def architectures = checked.toSeq
// TODO Expose in Machine API in 1.6
def getArchitectureName(architecture: Class[_ <: Architecture]) =
architecture.getAnnotation(classOf[Architecture.Name]) match {
case annotation: Architecture.Name => annotation.value
case _ => architecture.getSimpleName
}
override def create(host: MachineHost) = new Machine(host)
/** Possible states of the computer, and in particular its executor. */

View File

@ -5,7 +5,7 @@ import li.cil.oc.api
import li.cil.oc.api.driver.item.MutableProcessor
import li.cil.oc.api.driver.item.Processor
import li.cil.oc.api.network.Connector
import li.cil.oc.integration.opencomputers.DriverCPU
import li.cil.oc.server.machine.Machine
import li.cil.oc.util.ExtendedLuaState.extendLuaState
import scala.collection.convert.WrapAsScala._
@ -117,7 +117,7 @@ class ComputerAPI(owner: NativeLuaArchitecture) extends NativeLuaAPI(owner) {
case (stack, processor: Processor) => Seq(processor.architecture(stack))
} match {
case Some(architectures) =>
lua.pushValue(architectures.map(DriverCPU.getArchitectureName))
lua.pushValue(architectures.map(Machine.getArchitectureName))
case _ =>
lua.newTable()
}
@ -128,7 +128,7 @@ class ComputerAPI(owner: NativeLuaArchitecture) extends NativeLuaAPI(owner) {
lua.pushScalaFunction(lua => {
machine.host.internalComponents.map(stack => (stack, api.Driver.driverFor(stack))).collectFirst {
case (stack, processor: Processor) =>
lua.pushString(DriverCPU.getArchitectureName(processor.architecture(stack)))
lua.pushString(Machine.getArchitectureName(processor.architecture(stack)))
1
}.getOrElse(0)
})
@ -137,7 +137,7 @@ class ComputerAPI(owner: NativeLuaArchitecture) extends NativeLuaAPI(owner) {
lua.pushScalaFunction(lua => {
val archName = lua.checkString(1)
machine.host.internalComponents.map(stack => (stack, api.Driver.driverFor(stack))).collectFirst {
case (stack, processor: MutableProcessor) => processor.allArchitectures.find(arch => DriverCPU.getArchitectureName(arch) == archName) match {
case (stack, processor: MutableProcessor) => processor.allArchitectures.find(arch => Machine.getArchitectureName(arch) == archName) match {
case Some(archClass) =>
if (archClass != processor.architecture(stack)) {
processor.setArchitecture(stack, archClass)

View File

@ -5,7 +5,7 @@ import li.cil.oc.api
import li.cil.oc.api.driver.item.MutableProcessor
import li.cil.oc.api.driver.item.Processor
import li.cil.oc.api.network.Connector
import li.cil.oc.integration.opencomputers.DriverCPU
import li.cil.oc.server.machine.Machine
import li.cil.oc.util.ScalaClosure._
import li.cil.repack.org.luaj.vm2.LuaValue
import li.cil.repack.org.luaj.vm2.Varargs
@ -65,21 +65,21 @@ class ComputerAPI(owner: LuaJLuaArchitecture) extends LuaJAPI(owner) {
case (stack, processor: MutableProcessor) => processor.allArchitectures.toSeq
case (stack, processor: Processor) => Seq(processor.architecture(stack))
} match {
case Some(architectures) => LuaValue.listOf(architectures.map(DriverCPU.getArchitectureName).map(LuaValue.valueOf).toArray)
case Some(architectures) => LuaValue.listOf(architectures.map(Machine.getArchitectureName).map(LuaValue.valueOf).toArray)
case _ => LuaValue.tableOf()
}
})
computer.set("getArchitecture", (args: Varargs) => {
machine.host.internalComponents.map(stack => (stack, api.Driver.driverFor(stack))).collectFirst {
case (stack, processor: Processor) => LuaValue.valueOf(DriverCPU.getArchitectureName(processor.architecture(stack)))
case (stack, processor: Processor) => LuaValue.valueOf(Machine.getArchitectureName(processor.architecture(stack)))
}.getOrElse(LuaValue.NONE)
})
computer.set("setArchitecture", (args: Varargs) => {
val archName = args.checkjstring(1)
machine.host.internalComponents.map(stack => (stack, api.Driver.driverFor(stack))).collectFirst {
case (stack, processor: MutableProcessor) => processor.allArchitectures.find(arch => DriverCPU.getArchitectureName(arch) == archName) match {
case (stack, processor: MutableProcessor) => processor.allArchitectures.find(arch => Machine.getArchitectureName(arch) == archName) match {
case Some(archClass) =>
if (archClass != processor.architecture(stack)) {
processor.setArchitecture(stack, archClass)