mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-14 09:46:53 -04:00
Merge branch 'master-MC1.11' into master-MC1.12
This commit is contained in:
commit
1a3aafe6a5
@ -12,7 +12,6 @@ import com.mojang.authlib.GameProfile
|
|||||||
import com.typesafe.config._
|
import com.typesafe.config._
|
||||||
import li.cil.oc.Settings.DebugCardAccess
|
import li.cil.oc.Settings.DebugCardAccess
|
||||||
import li.cil.oc.common.Tier
|
import li.cil.oc.common.Tier
|
||||||
import li.cil.oc.integration.Mods
|
|
||||||
import li.cil.oc.server.component.DebugCard
|
import li.cil.oc.server.component.DebugCard
|
||||||
import li.cil.oc.server.component.DebugCard.AccessContext
|
import li.cil.oc.server.component.DebugCard.AccessContext
|
||||||
import org.apache.commons.codec.binary.Hex
|
import org.apache.commons.codec.binary.Hex
|
||||||
|
@ -7,8 +7,7 @@ import li.cil.oc.api
|
|||||||
import li.cil.oc.common.GuiType
|
import li.cil.oc.common.GuiType
|
||||||
import li.cil.oc.common.component
|
import li.cil.oc.common.component
|
||||||
import li.cil.oc.common.entity
|
import li.cil.oc.common.entity
|
||||||
import li.cil.oc.common.inventory.DatabaseInventory
|
import li.cil.oc.common.inventory.{DatabaseInventory, DiskDriveMountableInventory, ServerInventory}
|
||||||
import li.cil.oc.common.inventory.ServerInventory
|
|
||||||
import li.cil.oc.common.item
|
import li.cil.oc.common.item
|
||||||
import li.cil.oc.common.item.Delegator
|
import li.cil.oc.common.item.Delegator
|
||||||
import li.cil.oc.common.tileentity
|
import li.cil.oc.common.tileentity
|
||||||
@ -57,6 +56,13 @@ object GuiHandler extends CommonGuiHandler {
|
|||||||
|
|
||||||
override def isUsableByPlayer(player: EntityPlayer) = t.isUsableByPlayer(player)
|
override def isUsableByPlayer(player: EntityPlayer) = t.isUsableByPlayer(player)
|
||||||
}, Option(t), slot)
|
}, Option(t), slot)
|
||||||
|
case t: tileentity.Rack if id == GuiType.DiskDriveMountableInRack.id =>
|
||||||
|
val slot = GuiType.extractSlot(y)
|
||||||
|
new gui.DiskDrive(player.inventory, new DiskDriveMountableInventory {
|
||||||
|
override def container: ItemStack = t.getStackInSlot(slot)
|
||||||
|
|
||||||
|
override def isUsableByPlayer(player: EntityPlayer): Boolean = t.isUsableByPlayer(player)
|
||||||
|
})
|
||||||
case t: tileentity.Waypoint if id == GuiType.Waypoint.id =>
|
case t: tileentity.Waypoint if id == GuiType.Waypoint.id =>
|
||||||
new gui.Waypoint(t)
|
new gui.Waypoint(t)
|
||||||
case _ => null
|
case _ => null
|
||||||
@ -101,6 +107,11 @@ object GuiHandler extends CommonGuiHandler {
|
|||||||
new gui.Tablet(player.inventory, item.Tablet.get(stack, player))
|
new gui.Tablet(player.inventory, item.Tablet.get(stack, player))
|
||||||
}
|
}
|
||||||
else null
|
else null
|
||||||
|
case Some(_: item.DiskDriveMountable) if id == GuiType.DiskDriveMountable.id =>
|
||||||
|
new gui.DiskDrive(player.inventory, new DiskDriveMountableInventory {
|
||||||
|
override def container = itemStackInUse
|
||||||
|
override def isUsableByPlayer(activePlayer : EntityPlayer): Boolean = activePlayer == player
|
||||||
|
})
|
||||||
case Some(terminal: item.Terminal) if id == GuiType.Terminal.id =>
|
case Some(terminal: item.Terminal) if id == GuiType.Terminal.id =>
|
||||||
val stack = itemStackInUse
|
val stack = itemStackInUse
|
||||||
if (stack.hasTagCompound) {
|
if (stack.hasTagCompound) {
|
||||||
|
@ -2,10 +2,10 @@ package li.cil.oc.client.gui
|
|||||||
|
|
||||||
import li.cil.oc.Localization
|
import li.cil.oc.Localization
|
||||||
import li.cil.oc.common.container
|
import li.cil.oc.common.container
|
||||||
import li.cil.oc.common.tileentity
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer
|
import net.minecraft.entity.player.InventoryPlayer
|
||||||
|
import net.minecraft.inventory.IInventory
|
||||||
|
|
||||||
class DiskDrive(playerInventory: InventoryPlayer, val drive: tileentity.DiskDrive) extends DynamicGuiContainer(new container.DiskDrive(playerInventory, drive)) {
|
class DiskDrive(playerInventory: InventoryPlayer, val drive: IInventory) extends DynamicGuiContainer(new container.DiskDrive(playerInventory, drive)) {
|
||||||
override def drawSecondaryForegroundLayer(mouseX: Int, mouseY: Int) = {
|
override def drawSecondaryForegroundLayer(mouseX: Int, mouseY: Int) = {
|
||||||
super.drawSecondaryForegroundLayer(mouseX, mouseY)
|
super.drawSecondaryForegroundLayer(mouseX, mouseY)
|
||||||
fontRenderer.drawString(
|
fontRenderer.drawString(
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package li.cil.oc.common
|
package li.cil.oc.common
|
||||||
|
|
||||||
import li.cil.oc.common.inventory.DatabaseInventory
|
import li.cil.oc.common.inventory.{DatabaseInventory, DiskDriveMountableInventory, ServerInventory}
|
||||||
import li.cil.oc.common.inventory.ServerInventory
|
|
||||||
import li.cil.oc.common.item.Delegator
|
import li.cil.oc.common.item.Delegator
|
||||||
import li.cil.oc.server.component.Server
|
|
||||||
import li.cil.oc.util.BlockPosition
|
import li.cil.oc.util.BlockPosition
|
||||||
import li.cil.oc.util.ExtendedWorld._
|
import li.cil.oc.util.ExtendedWorld._
|
||||||
|
import li.cil.oc.server.component.{DiskDriveMountable, Server}
|
||||||
import net.minecraft.entity.player.EntityPlayer
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
import net.minecraft.item.ItemStack
|
import net.minecraft.item.ItemStack
|
||||||
import net.minecraft.world.World
|
import net.minecraft.world.World
|
||||||
@ -42,6 +41,10 @@ abstract class GuiHandler extends IGuiHandler {
|
|||||||
val slot = GuiType.extractSlot(y)
|
val slot = GuiType.extractSlot(y)
|
||||||
val server = t.getMountable(slot).asInstanceOf[Server]
|
val server = t.getMountable(slot).asInstanceOf[Server]
|
||||||
new container.Server(player.inventory, server, Option(server))
|
new container.Server(player.inventory, server, Option(server))
|
||||||
|
case t: tileentity.Rack if id == GuiType.DiskDriveMountableInRack.id =>
|
||||||
|
val slot = GuiType.extractSlot(y)
|
||||||
|
val drive = t.getMountable(slot).asInstanceOf[DiskDriveMountable]
|
||||||
|
new container.DiskDrive(player.inventory, drive)
|
||||||
case _ => null
|
case _ => null
|
||||||
}
|
}
|
||||||
case Some(GuiType.Category.Entity) =>
|
case Some(GuiType.Category.Entity) =>
|
||||||
@ -71,6 +74,12 @@ abstract class GuiHandler extends IGuiHandler {
|
|||||||
new container.Tablet(player.inventory, item.Tablet.get(stack, player))
|
new container.Tablet(player.inventory, item.Tablet.get(stack, player))
|
||||||
else
|
else
|
||||||
null
|
null
|
||||||
|
case Some(drive: item.DiskDriveMountable) if id == GuiType.DiskDriveMountable.id =>
|
||||||
|
new container.DiskDrive(player.inventory, new DiskDriveMountableInventory {
|
||||||
|
override def container: ItemStack = itemStackInUse
|
||||||
|
|
||||||
|
override def isUsableByPlayer(player: EntityPlayer) = player == player
|
||||||
|
})
|
||||||
case _ => null
|
case _ => null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@ object GuiType extends ScalaEnum {
|
|||||||
val Database = new EnumVal { def name = "Database"; def subType = GuiType.Category.Item }
|
val Database = new EnumVal { def name = "Database"; def subType = GuiType.Category.Item }
|
||||||
val Disassembler = new EnumVal { def name = "Disassembler"; def subType = GuiType.Category.Block }
|
val Disassembler = new EnumVal { def name = "Disassembler"; def subType = GuiType.Category.Block }
|
||||||
val DiskDrive = new EnumVal { def name = "DiskDrive"; def subType = GuiType.Category.Block }
|
val DiskDrive = new EnumVal { def name = "DiskDrive"; def subType = GuiType.Category.Block }
|
||||||
|
val DiskDriveMountable = new EnumVal { def name = "DiskDriveMountable"; def subType = GuiType.Category.Item }
|
||||||
|
val DiskDriveMountableInRack = new EnumVal { def name = "DiskDriveMountableInRack"; def subType = GuiType.Category.Block }
|
||||||
val Drive = new EnumVal { def name = "Drive"; def subType = GuiType.Category.Item }
|
val Drive = new EnumVal { def name = "Drive"; def subType = GuiType.Category.Item }
|
||||||
val Drone = new EnumVal { def name = "Drone"; def subType = GuiType.Category.Entity }
|
val Drone = new EnumVal { def name = "Drone"; def subType = GuiType.Category.Entity }
|
||||||
val Manual = new EnumVal { def name = "Manual"; def subType = GuiType.Category.None }
|
val Manual = new EnumVal { def name = "Manual"; def subType = GuiType.Category.None }
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package li.cil.oc.common.container
|
package li.cil.oc.common.container
|
||||||
|
|
||||||
import li.cil.oc.common.Slot
|
import li.cil.oc.common.Slot
|
||||||
import li.cil.oc.common.tileentity
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer
|
import net.minecraft.entity.player.InventoryPlayer
|
||||||
|
import net.minecraft.inventory.IInventory
|
||||||
|
|
||||||
class DiskDrive(playerInventory: InventoryPlayer, drive: tileentity.DiskDrive) extends Player(playerInventory, drive) {
|
class DiskDrive(playerInventory: InventoryPlayer, drive: IInventory) extends Player(playerInventory, drive) {
|
||||||
addSlotToContainer(80, 35, Slot.Floppy)
|
addSlotToContainer(80, 35, Slot.Floppy)
|
||||||
addPlayerInventorySlots(8, 84)
|
addPlayerInventorySlots(8, 84)
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package li.cil.oc.common.inventory
|
||||||
|
|
||||||
|
import li.cil.oc.api.Driver
|
||||||
|
import li.cil.oc.common.tileentity
|
||||||
|
import li.cil.oc.common.Slot
|
||||||
|
import net.minecraft.item.ItemStack
|
||||||
|
|
||||||
|
trait DiskDriveMountableInventory extends ItemStackInventory {
|
||||||
|
def tier: Int = 1
|
||||||
|
|
||||||
|
override def getSizeInventory = 1
|
||||||
|
|
||||||
|
override protected def inventoryName = "DiskDrive"
|
||||||
|
|
||||||
|
override def getInventoryStackLimit = 1
|
||||||
|
|
||||||
|
override def isItemValidForSlot(slot: Int, stack: ItemStack): Boolean = (slot, Option(Driver.driverFor(stack, classOf[tileentity.DiskDrive]))) match {
|
||||||
|
case (0, Some(driver)) => driver.slot(stack) == Slot.Floppy
|
||||||
|
case _ => false
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,21 @@
|
|||||||
package li.cil.oc.common.item
|
package li.cil.oc.common.item
|
||||||
|
|
||||||
class DiskDriveMountable(val parent: Delegator) extends traits.Delegate
|
import li.cil.oc.OpenComputers
|
||||||
|
import li.cil.oc.common.GuiType
|
||||||
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
|
import net.minecraft.item.ItemStack
|
||||||
|
import net.minecraft.util.{ActionResult, EnumActionResult, EnumHand}
|
||||||
|
import net.minecraft.world.World
|
||||||
|
|
||||||
|
class DiskDriveMountable(val parent: Delegator) extends traits.Delegate {
|
||||||
|
override def maxStackSize = 1
|
||||||
|
|
||||||
|
override def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer) = {
|
||||||
|
// Open the GUI immediately on the client, too, to avoid the player
|
||||||
|
// changing the current slot before it actually opens, which can lead to
|
||||||
|
// desynchronization of the player inventory.
|
||||||
|
player.openGui(OpenComputers, GuiType.DiskDriveMountable.id, world, 0, 0, 0)
|
||||||
|
player.swingArm(EnumHand.MAIN_HAND)
|
||||||
|
ActionResult.newResult(EnumActionResult.SUCCESS, stack)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -275,7 +275,7 @@ class Robot extends traits.Computer with traits.PowerInformation with traits.Rot
|
|||||||
else {
|
else {
|
||||||
getWorld.setBlockToAir(newPosition)
|
getWorld.setBlockToAir(newPosition)
|
||||||
}
|
}
|
||||||
created && this.position == newPosition
|
created && this.pos == newPosition
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
blockRobotProxy.moving.set(None)
|
blockRobotProxy.moving.set(None)
|
||||||
|
@ -2,10 +2,9 @@ package li.cil.oc.server.component
|
|||||||
|
|
||||||
import java.util
|
import java.util
|
||||||
|
|
||||||
import li.cil.oc.Constants
|
import li.cil.oc.{Constants, OpenComputers, api}
|
||||||
import li.cil.oc.api.driver.DeviceInfo.DeviceAttribute
|
import li.cil.oc.api.driver.DeviceInfo.DeviceAttribute
|
||||||
import li.cil.oc.api.driver.DeviceInfo.DeviceClass
|
import li.cil.oc.api.driver.DeviceInfo.DeviceClass
|
||||||
import li.cil.oc.api
|
|
||||||
import li.cil.oc.api.Driver
|
import li.cil.oc.api.Driver
|
||||||
import li.cil.oc.api.component.RackBusConnectable
|
import li.cil.oc.api.component.RackBusConnectable
|
||||||
import li.cil.oc.api.component.RackMountable
|
import li.cil.oc.api.component.RackMountable
|
||||||
@ -20,8 +19,7 @@ import li.cil.oc.api.network.Node
|
|||||||
import li.cil.oc.api.network.Visibility
|
import li.cil.oc.api.network.Visibility
|
||||||
import li.cil.oc.api.prefab
|
import li.cil.oc.api.prefab
|
||||||
import li.cil.oc.api.prefab.AbstractManagedEnvironment
|
import li.cil.oc.api.prefab.AbstractManagedEnvironment
|
||||||
import li.cil.oc.common.Slot
|
import li.cil.oc.common.{GuiType, Slot, Sound}
|
||||||
import li.cil.oc.common.Sound
|
|
||||||
import li.cil.oc.common.inventory.ComponentInventory
|
import li.cil.oc.common.inventory.ComponentInventory
|
||||||
import li.cil.oc.common.inventory.ItemStackInventory
|
import li.cil.oc.common.inventory.ItemStackInventory
|
||||||
import li.cil.oc.util.BlockPosition
|
import li.cil.oc.util.BlockPosition
|
||||||
@ -182,7 +180,11 @@ class DiskDriveMountable(val rack: api.internal.Rack, val slot: Int) extends Abs
|
|||||||
}
|
}
|
||||||
isDiskInDrive || isHoldingDisk
|
isDiskInDrive || isHoldingDisk
|
||||||
}
|
}
|
||||||
else false
|
else {
|
||||||
|
val position = BlockPosition(rack)
|
||||||
|
player.openGui(OpenComputers, GuiType.DiskDriveMountableInRack.id, rack.world, position.x, GuiType.embedSlot(position.y, slot), position.z)
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
@ -48,7 +48,7 @@ object InventoryUtils {
|
|||||||
def inventoryAt(position: BlockPosition, side: EnumFacing): Option[IItemHandler] = position.world match {
|
def inventoryAt(position: BlockPosition, side: EnumFacing): Option[IItemHandler] = position.world match {
|
||||||
case Some(world) if world.blockExists(position) => world.getTileEntity(position) match {
|
case Some(world) if world.blockExists(position) => world.getTileEntity(position) match {
|
||||||
case tile: TileEntity if tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) => Option(tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side))
|
case tile: TileEntity if tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) => Option(tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side))
|
||||||
case tile: IInventory => Option(asItemHandler(tile))
|
case tile: IInventory => Option(asItemHandler(tile, side))
|
||||||
case _ => world.getEntitiesWithinAABB(classOf[Entity], position.bounds)
|
case _ => world.getEntitiesWithinAABB(classOf[Entity], position.bounds)
|
||||||
.filter(e => !e.isDead && e.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side))
|
.filter(e => !e.isDead && e.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side))
|
||||||
.map(_.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side))
|
.map(_.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user