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

Conflicts:
	build.properties
This commit is contained in:
Florian Nücke 2015-05-26 15:09:41 +02:00
commit 28d862df67
21 changed files with 87 additions and 23 deletions

Binary file not shown.

View File

@ -1,7 +1,7 @@
minecraft.version=1.7.10
forge.version=10.13.3.1395-1710ls
oc.version=1.5.11
oc.version=1.5.12
oc.subversion=
ae2.version=rv2-beta-26

View File

@ -45,6 +45,7 @@ item.oc.ALU.name=Arithmetic Logic Unit (ALU)
item.oc.Analyzer.name=Analyzer
item.oc.APU0.name=Accelerated Processing Unit (APU) (Tier 1)
item.oc.APU1.name=Accelerated Processing Unit (APU) (Tier 2)
item.oc.APU2.name=Accelerated Processing Unit (APU) (Creative)
item.oc.ArrowKeys.name=Arrow Keys
item.oc.ButtonGroup.name=Button Group
item.oc.CardBase.name=Card Base

Binary file not shown.

After

Width:  |  Height:  |  Size: 887 B

View File

@ -0,0 +1,18 @@
{
"animation": {
"frametime": 1,
"frames": [
{ "index": 0, "time": 3 },
{ "index": 1, "time": 3 },
{ "index": 2, "time": 3 },
{ "index": 3, "time": 3 },
{ "index": 4, "time": 3 },
{ "index": 5, "time": 3 },
{ "index": 4, "time": 3 },
{ "index": 3, "time": 3 },
{ "index": 2, "time": 3 },
{ "index": 1, "time": 3 },
{ "index": 0, "time": 3 }
]
}
}

View File

@ -49,6 +49,7 @@ object Constants {
final val Alu = "alu"
final val Analyzer = "analyzer"
final val AngelUpgrade = "angelUpgrade"
final val APUCreative = "apuCreative"
final val APUTier1 = "apu1"
final val APUTier2 = "apu2"
final val ArrowKeys = "arrowKeys"

View File

@ -17,7 +17,7 @@ object Print {
def render(data: PrintData, state: Boolean, facing: ForgeDirection, x: Int, y: Int, z: Int, block: Block, renderer: RenderBlocks): Unit = {
val shapes = if (state) data.stateOn else data.stateOff
if (shapes.size == 0) {
if (shapes.isEmpty) {
printBlock.textureOverride = Option(resolveTexture("missingno"))
renderer.setRenderBounds(0, 0, 0, 1, 1, 1)
renderer.renderStandardBlock(block, x, y, z)

View File

@ -2,10 +2,12 @@ package li.cil.oc.common.block
import java.util.Random
import li.cil.oc.Constants
import li.cil.oc.api
import li.cil.oc.common.tileentity
import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedWorld._
import li.cil.oc.util.InventoryUtils
import net.minecraft.block.Block
import net.minecraft.block.material.Material
import net.minecraft.entity.player.EntityPlayer
@ -88,10 +90,12 @@ class Keyboard extends SimpleBlock(Material.rock) with traits.SpecialBlock {
override def onNeighborBlockChange(world: World, x: Int, y: Int, z: Int, block: Block) =
world.getTileEntity(x, y, z) match {
case keyboard: tileentity.Keyboard if canPlaceBlockOnSide(world, x, y, z, keyboard.facing.getOpposite) => // Can stay.
case keyboard: tileentity.Keyboard =>
if (!canPlaceBlockOnSide(world, x, y, z, keyboard.facing.getOpposite)) {
world.setBlockToAir(x, y, z)
InventoryUtils.spawnStackInWorld(BlockPosition(x, y, z, world), api.Items.get(Constants.BlockName.Keyboard).createItemStack(1))
}
case _ =>
dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0)
world.setBlockToAir(x, y, z)
}
override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) =

View File

@ -28,7 +28,7 @@ class ServerRack extends RedstoneAware with traits.SpecialBlock with traits.Powe
@SideOnly(Side.CLIENT)
override def getMixedBrightnessForBlock(world: IBlockAccess, x: Int, y: Int, z: Int) = {
world.getTileEntity(x, y, z) match {
if (y >= 0 && y < world.getHeight) world.getTileEntity(x, y, z) match {
case rack: tileentity.ServerRack =>
def brightness(x: Int, y: Int, z: Int) = world.getLightBrightnessForSkyBlocks(x, y, z, getLightValue(world, x, y, z))
val value = brightness(x + rack.facing.offsetX, y + rack.facing.offsetY, z + rack.facing.offsetZ)
@ -37,6 +37,7 @@ class ServerRack extends RedstoneAware with traits.SpecialBlock with traits.Powe
((skyBrightness * 3 / 4) << 20) | ((blockBrightness * 3 / 4) << 4)
case _ => super.getMixedBrightnessForBlock(world, x, y, z)
}
else super.getMixedBrightnessForBlock(world, x, y, z)
}
override def isBlockSolid(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = side != ForgeDirection.SOUTH

View File

@ -288,6 +288,8 @@ object Items extends ItemAPI {
Option(get(Constants.ItemName.SignUpgrade).createItemStack(1)),
Option(get(Constants.ItemName.PistonUpgrade).createItemStack(1)),
Option(get(Constants.BlockName.Geolyzer).createItemStack(1)),
Option(get(Constants.ItemName.NavigationUpgrade).createItemStack(1)),
Option(get(Constants.ItemName.GraphicsCardTier2).createItemStack(1)),
Option(get(Constants.ItemName.RedstoneCardTier2).createItemStack(1)),
@ -533,5 +535,8 @@ object Items extends ItemAPI {
// 1.5.11
Recipes.addItem(new item.HoverBoots(), Constants.ItemName.HoverBoots, "oc:hoverBoots")
// 1.5.12
registerItem(new item.APU(multi, Tier.Three), Constants.ItemName.APUCreative)
}
}

View File

@ -1,11 +1,20 @@
package li.cil.oc.common.item
import li.cil.oc.common.Tier
import li.cil.oc.util.Rarity
import net.minecraft.item.EnumRarity
import net.minecraft.item.ItemStack
import scala.language.existentials
class APU(val parent: Delegator, val tier: Int) extends traits.Delegate with traits.ItemTier with traits.CPULike with traits.GPULike {
override val unlocalizedName = super[Delegate].unlocalizedName + tier
override def cpuTier = tier + 1
override def rarity(stack: ItemStack): EnumRarity =
if (tier == Tier.Three) Rarity.byTier(Tier.Four)
else super.rarity(stack)
override def cpuTier = math.min(Tier.Three, tier + 1)
override def gpuTier = tier

View File

@ -43,7 +43,7 @@ class Server(val parent: Delegator, val tier: Int) extends traits.Delegate {
val itemName = item.getDisplayName
items += itemName -> (if (items.contains(itemName)) items(itemName) + 1 else 1)
}
if (items.size > 0) {
if (items.nonEmpty) {
tooltip.addAll(Tooltip.get("Server.Components"))
for (itemName <- items.keys.toArray.sorted) {
tooltip.add("- " + items(itemName) + "x " + itemName)

View File

@ -17,7 +17,14 @@ object TabletTemplate extends Template {
override protected val suggestedComponents = Array(
"BIOS" -> hasComponent(Constants.ItemName.EEPROM) _,
"Keyboard" -> hasComponent(Constants.BlockName.Keyboard) _,
"GraphicsCard" -> ((inventory: IInventory) => Array(Constants.ItemName.GraphicsCardTier1, Constants.ItemName.GraphicsCardTier2, Constants.ItemName.GraphicsCardTier3).exists(name => hasComponent(name)(inventory))),
"GraphicsCard" -> ((inventory: IInventory) => Array(
Constants.ItemName.APUCreative,
Constants.ItemName.APUTier1,
Constants.ItemName.APUTier2,
Constants.ItemName.GraphicsCardTier1,
Constants.ItemName.GraphicsCardTier2,
Constants.ItemName.GraphicsCardTier3).
exists(name => hasComponent(name)(inventory))),
"OS" -> hasFileSystem _)
override protected def hostClass = classOf[internal.Tablet]

View File

@ -23,7 +23,14 @@ abstract class Template {
"BIOS" -> hasComponent(Constants.ItemName.EEPROM) _,
"Screen" -> hasComponent(Constants.BlockName.ScreenTier1) _,
"Keyboard" -> hasComponent(Constants.BlockName.Keyboard) _,
"GraphicsCard" -> ((inventory: IInventory) => Array(Constants.ItemName.GraphicsCardTier1, Constants.ItemName.GraphicsCardTier2, Constants.ItemName.GraphicsCardTier3).exists(name => hasComponent(name)(inventory))),
"GraphicsCard" -> ((inventory: IInventory) => Array(
Constants.ItemName.APUCreative,
Constants.ItemName.APUTier1,
Constants.ItemName.APUTier2,
Constants.ItemName.GraphicsCardTier1,
Constants.ItemName.GraphicsCardTier2,
Constants.ItemName.GraphicsCardTier3).
exists(name => hasComponent(name)(inventory))),
"Inventory" -> hasInventory _,
"OS" -> hasFileSystem _)

View File

@ -16,6 +16,7 @@ import li.cil.oc.common.tileentity.traits
import li.cil.oc.integration.opencomputers.DriverRedstoneCard
import li.cil.oc.integration.stargatetech2.DriverAbstractBusCard
import li.cil.oc.integration.util.Waila
import li.cil.oc.server.agent
import li.cil.oc.server.{PacketSender => ServerPacketSender}
import li.cil.oc.util.ExtendedNBT._
import net.minecraft.entity.player.EntityPlayer
@ -194,7 +195,10 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
}
override def isUseableByPlayer(player: EntityPlayer) =
super.isUseableByPlayer(player) && canInteract(player.getCommandSenderName)
super.isUseableByPlayer(player) && (player match {
case fakePlayer: agent.Player => canInteract(fakePlayer.agent.ownerName())
case _ => canInteract(player.getCommandSenderName)
})
override protected def onRotationChanged() {
super.onRotationChanged()

View File

@ -34,7 +34,7 @@ object Mods {
val ComputerCraft = new SimpleMod(IDs.ComputerCraft)
val CraftingCosts = new SimpleMod(IDs.CraftingCosts)
val DeepStorageUnit = new ClassBasedMod(IDs.DeepStorageUnit, "powercrystals.minefactoryreloaded.api.IDeepStorageUnit")()
val ElectricalAge = new SimpleMod(IDs.ElectricalAge)
val ElectricalAge = new SimpleMod(IDs.ElectricalAge, providesPower = true)
val EnderIO = new SimpleMod(IDs.EnderIO)
val EnderStorage = new SimpleMod(IDs.EnderStorage)
val Factorization = new SimpleMod(IDs.Factorization, providesPower = true)

View File

@ -55,7 +55,7 @@ trait NetworkControl[AETile >: Null <: TileEntity with IGridProxyable with IActi
case Some(pattern) => pattern.getOutputs.find(_.isSameType(stack)).get
case _ => stack.copy.setStackSize(0) // Should not be possible, but hey...
}
new Craftable(tile, result)
new NetworkControl.Craftable(tile, result)
}).toArray)
}
@ -101,8 +101,11 @@ trait NetworkControl[AETile >: Null <: TileEntity with IGridProxyable with IActi
filter.get("name").forall(_.equals(Item.itemRegistry.getNameForObject(stack.getItem))) &&
filter.get("label").forall(_.equals(stack.getItemStack.getDisplayName))
}
}
class Craftable(var controller: AETile, var stack: IAEItemStack) extends AbstractValue with ICraftingRequester {
object NetworkControl {
class Craftable(var controller: TileEntity with IGridProxyable with IActionHost, var stack: IAEItemStack) extends AbstractValue with ICraftingRequester {
def this() = this(null, null)
private val links = mutable.Set.empty[ICraftingLink]
@ -186,8 +189,8 @@ trait NetworkControl[AETile >: Null <: TileEntity with IGridProxyable with IActi
EventHandler.schedule(() => {
val world = DimensionManager.getWorld(dimension)
val tileEntity = world.getTileEntity(x, y, z)
if (tileEntity != null && tileEntity.isInstanceOf[AETile]) {
controller = tileEntity.asInstanceOf[AETile]
if (tileEntity != null && tileEntity.isInstanceOf[TileEntity with IGridProxyable with IActionHost]) {
controller = tileEntity.asInstanceOf[TileEntity with IGridProxyable with IActionHost]
}
})
}

View File

@ -14,12 +14,14 @@ import net.minecraft.item.ItemStack
object DriverAPU extends DriverCPU with HostAware with EnvironmentAware {
override def worksWith(stack: ItemStack) = isOneOf(stack,
api.Items.get(Constants.ItemName.APUTier1),
api.Items.get(Constants.ItemName.APUTier2))
api.Items.get(Constants.ItemName.APUTier2),
api.Items.get(Constants.ItemName.APUCreative))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
gpuTier(stack) match {
case Tier.One => new component.GraphicsCard.Tier1()
case Tier.Two => new component.GraphicsCard.Tier2()
case Tier.Three => new component.GraphicsCard.Tier3()
case _ => null
}

View File

@ -3,13 +3,14 @@ package li.cil.oc.integration.opencomputers
import li.cil.oc.Constants
import li.cil.oc.api
import li.cil.oc.api.driver.EnvironmentHost
import li.cil.oc.api.driver.item.HostAware
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 net.minecraft.item.ItemStack
object DriverUpgradeHover extends Item {
object DriverUpgradeHover extends Item with HostAware {
override def worksWith(stack: ItemStack) = isOneOf(stack,
api.Items.get(Constants.ItemName.HoverUpgradeTier1),
api.Items.get(Constants.ItemName.HoverUpgradeTier2))

View File

@ -77,7 +77,7 @@ private[oc] object Registry extends api.detail.DriverAPI {
val hostAware = items.collect {
case driver: HostAware if driver.worksWith(stack) => driver
}
if (hostAware.size > 0) {
if (hostAware.nonEmpty) {
hostAware.find(_.worksWith(stack, host)).orNull
}
else driverFor(stack)
@ -112,7 +112,7 @@ private[oc] object Registry extends api.detail.DriverAPI {
memo.get(valueRef)
}
else valueRef match {
case null | Unit | None => null
case null | None => null
case arg: java.lang.Boolean => arg
case arg: java.lang.Byte => arg

View File

@ -26,6 +26,7 @@ import li.cil.oc.api.prefab
import li.cil.oc.common.EventHandler
import li.cil.oc.common.SaveHandler
import li.cil.oc.common.Slot
import li.cil.oc.common.Tier
import li.cil.oc.common.tileentity
import li.cil.oc.server.PacketSender
import li.cil.oc.server.driver.Registry
@ -112,7 +113,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
}))
maxCallBudget = components.foldLeft(0.0)((sum, item) => sum + (Option(item) match {
case Some(stack) => Option(Driver.driverFor(stack, host.getClass)) match {
case Some(driver: Processor) if driver.slot(stack) == Slot.CPU => Settings.get.callBudgets(driver.tier(stack))
case Some(driver: Processor) if driver.slot(stack) == Slot.CPU => Settings.get.callBudgets(driver.tier(stack) max Tier.One min Tier.Three)
case _ => 0
}
case _ => 0
@ -832,7 +833,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
}
private def close() = state.synchronized(
if (state.size == 0 || state.top != Machine.State.Stopped) {
if (state.isEmpty || state.top != Machine.State.Stopped) {
this.synchronized {
state.clear()
state.push(Machine.State.Stopped)