mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 03:36:47 -04:00
Merge branch 'master' of github.com:MightyPirates/OpenComputers into master-MC1.7.10
Conflicts: src/main/scala/li/cil/oc/server/component/UpgradeSign.scala
This commit is contained in:
commit
2f162ea159
@ -40,7 +40,7 @@ object SaveHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def scheduleSave(container: Container, nbt: NBTTagCompound, name: String, save: NBTTagCompound => Unit) {
|
def scheduleSave(container: Container, nbt: NBTTagCompound, name: String, save: NBTTagCompound => Unit) {
|
||||||
scheduleSave(container.world, math.round(container.xPosition - 0.5).toInt, math.round(container.zPosition - 0.5).toInt, nbt, name, writeNBT(save))
|
scheduleSave(container.world, math.floor(container.xPosition).toInt, math.floor(container.zPosition).toInt, nbt, name, writeNBT(save))
|
||||||
}
|
}
|
||||||
|
|
||||||
def scheduleSave(world: World, x: Int, z: Int, nbt: NBTTagCompound, name: String, data: Array[Byte]) {
|
def scheduleSave(world: World, x: Int, z: Int, nbt: NBTTagCompound, name: String, data: Array[Byte]) {
|
||||||
|
@ -422,7 +422,7 @@ object TextBuffer {
|
|||||||
def onChunkUnload(e: ChunkEvent.Unload) {
|
def onChunkUnload(e: ChunkEvent.Unload) {
|
||||||
val chunk = e.getChunk
|
val chunk = e.getChunk
|
||||||
clientBuffers = clientBuffers.filter(t => {
|
clientBuffers = clientBuffers.filter(t => {
|
||||||
val keep = t.owner.world != e.world || !chunk.isAtLocation(math.round(t.owner.xPosition - 0.5).toInt << 4, math.round(t.owner.zPosition - 0.5).toInt << 4)
|
val keep = t.owner.world != e.world || !chunk.isAtLocation(math.floor(t.owner.xPosition).toInt << 4, math.floor(t.owner.zPosition).toInt << 4)
|
||||||
if (!keep) {
|
if (!keep) {
|
||||||
ClientComponentTracker.remove(t.proxy.nodeAddress)
|
ClientComponentTracker.remove(t.proxy.nodeAddress)
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ object ChunkloaderUpgradeHandler extends LoadingCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def updateLoadedChunk(loader: UpgradeChunkloader) {
|
def updateLoadedChunk(loader: UpgradeChunkloader) {
|
||||||
val robotChunk = new ChunkCoordIntPair(math.round(loader.owner.xPosition - 0.5).toInt >> 4, math.round(loader.owner.zPosition - 0.5).toInt >> 4)
|
val robotChunk = new ChunkCoordIntPair(math.floor(loader.owner.xPosition).toInt >> 4, math.floor(loader.owner.zPosition).toInt >> 4)
|
||||||
loader.ticket.foreach(ticket => {
|
loader.ticket.foreach(ticket => {
|
||||||
ticket.getChunkList.collect {
|
ticket.getChunkList.collect {
|
||||||
case chunk: ChunkCoordIntPair if chunk != robotChunk => ForgeChunkManager.unforceChunk(ticket, chunk)
|
case chunk: ChunkCoordIntPair if chunk != robotChunk => ForgeChunkManager.unforceChunk(ticket, chunk)
|
||||||
|
@ -21,7 +21,7 @@ class Geolyzer(val owner: Container) extends component.ManagedComponent {
|
|||||||
if (math.abs(rx) > Settings.get.geolyzerRange || math.abs(rz) > Settings.get.geolyzerRange) {
|
if (math.abs(rx) > Settings.get.geolyzerRange || math.abs(rz) > Settings.get.geolyzerRange) {
|
||||||
throw new IllegalArgumentException("location out of bounds")
|
throw new IllegalArgumentException("location out of bounds")
|
||||||
}
|
}
|
||||||
val (x, y, z) = ((owner.xPosition - 0.5).toInt, (owner.yPosition - 0.5).toInt, (owner.zPosition - 0.5).toInt)
|
val (x, y, z) = (math.floor(owner.xPosition).toInt, math.floor(owner.yPosition).toInt, math.floor(owner.zPosition).toInt)
|
||||||
val bx = x + rx
|
val bx = x + rx
|
||||||
val bz = z + rz
|
val bz = z + rz
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class UpgradeInventoryController(val owner: Container with Robot) extends compon
|
|||||||
def getInventorySize(context: Context, args: Arguments): Array[AnyRef] = {
|
def getInventorySize(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
val facing = checkSideForInventory(args, 0)
|
val facing = checkSideForInventory(args, 0)
|
||||||
if (facing == owner.facing.getOpposite) result(owner.inventorySize)
|
if (facing == owner.facing.getOpposite) result(owner.inventorySize)
|
||||||
else InventoryUtils.inventoryAt(owner.world, math.round(owner.xPosition - 0.5).toInt + facing.offsetX, math.round(owner.yPosition - 0.5).toInt + facing.offsetY, math.round(owner.zPosition - 0.5).toInt + facing.offsetZ) match {
|
else InventoryUtils.inventoryAt(owner.world, math.floor(owner.xPosition).toInt + facing.offsetX, math.floor(owner.yPosition).toInt + facing.offsetY, math.floor(owner.zPosition).toInt + facing.offsetZ) match {
|
||||||
case Some(inventory) => result(inventory.getSizeInventory)
|
case Some(inventory) => result(inventory.getSizeInventory)
|
||||||
case _ => result(Unit, "no inventory")
|
case _ => result(Unit, "no inventory")
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ class UpgradeInventoryController(val owner: Container with Robot) extends compon
|
|||||||
if (slot < 0 || slot >= owner.inventorySize) result(Unit)
|
if (slot < 0 || slot >= owner.inventorySize) result(Unit)
|
||||||
else result(owner.getStackInSlot(slot + 1 + owner.containerCount))
|
else result(owner.getStackInSlot(slot + 1 + owner.containerCount))
|
||||||
}
|
}
|
||||||
else InventoryUtils.inventoryAt(owner.world, math.round(owner.xPosition - 0.5).toInt + facing.offsetX, math.round(owner.yPosition - 0.5).toInt + facing.offsetY, math.round(owner.zPosition - 0.5).toInt + facing.offsetZ) match {
|
else InventoryUtils.inventoryAt(owner.world, math.floor(owner.xPosition).toInt + facing.offsetX, math.floor(owner.yPosition).toInt + facing.offsetY, math.floor(owner.zPosition).toInt + facing.offsetZ) match {
|
||||||
case Some(inventory) =>
|
case Some(inventory) =>
|
||||||
if (slot < 0 || slot > inventory.getSizeInventory) result(Unit)
|
if (slot < 0 || slot > inventory.getSizeInventory) result(Unit)
|
||||||
else result(inventory.getStackInSlot(slot))
|
else result(inventory.getStackInSlot(slot))
|
||||||
@ -51,7 +51,7 @@ class UpgradeInventoryController(val owner: Container with Robot) extends compon
|
|||||||
val selectedSlot = owner.selectedSlot
|
val selectedSlot = owner.selectedSlot
|
||||||
val stack = owner.getStackInSlot(selectedSlot)
|
val stack = owner.getStackInSlot(selectedSlot)
|
||||||
if (stack != null && stack.stackSize > 0) {
|
if (stack != null && stack.stackSize > 0) {
|
||||||
InventoryUtils.inventoryAt(owner.world, math.round(owner.xPosition - 0.5).toInt + facing.offsetX, math.round(owner.yPosition - 0.5).toInt + facing.offsetY, math.round(owner.zPosition - 0.5).toInt + facing.offsetZ) match {
|
InventoryUtils.inventoryAt(owner.world, math.floor(owner.xPosition).toInt + facing.offsetX, math.floor(owner.yPosition).toInt + facing.offsetY, math.floor(owner.zPosition).toInt + facing.offsetZ) match {
|
||||||
case Some(inventory) if inventory.isUseableByPlayer(owner.player) =>
|
case Some(inventory) if inventory.isUseableByPlayer(owner.player) =>
|
||||||
val slot = args.checkSlot(inventory, 1)
|
val slot = args.checkSlot(inventory, 1)
|
||||||
if (!InventoryUtils.insertIntoInventorySlot(stack, inventory, facing.getOpposite, slot, count)) {
|
if (!InventoryUtils.insertIntoInventorySlot(stack, inventory, facing.getOpposite, slot, count)) {
|
||||||
@ -81,7 +81,7 @@ class UpgradeInventoryController(val owner: Container with Robot) extends compon
|
|||||||
val facing = checkSideForAction(args, 0)
|
val facing = checkSideForAction(args, 0)
|
||||||
val count = args.optionalItemCount(2)
|
val count = args.optionalItemCount(2)
|
||||||
|
|
||||||
InventoryUtils.inventoryAt(owner.world, math.round(owner.xPosition - 0.5).toInt + facing.offsetX, math.round(owner.yPosition - 0.5).toInt + facing.offsetY, math.round(owner.zPosition - 0.5).toInt + facing.offsetZ) match {
|
InventoryUtils.inventoryAt(owner.world, math.floor(owner.xPosition).toInt + facing.offsetX, math.floor(owner.yPosition).toInt + facing.offsetY, math.floor(owner.zPosition).toInt + facing.offsetZ) match {
|
||||||
case Some(inventory) if inventory.isUseableByPlayer(owner.player) =>
|
case Some(inventory) if inventory.isUseableByPlayer(owner.player) =>
|
||||||
val slot = args.checkSlot(inventory, 1)
|
val slot = args.checkSlot(inventory, 1)
|
||||||
if (InventoryUtils.extractFromInventorySlot(owner.player.inventory.addItemStackToInventory, inventory, facing.getOpposite, slot, count)) {
|
if (InventoryUtils.extractFromInventorySlot(owner.player.inventory.addItemStackToInventory, inventory, facing.getOpposite, slot, count)) {
|
||||||
|
@ -16,9 +16,8 @@ class UpgradeSign(val owner: Container with Rotatable) extends component.Managed
|
|||||||
|
|
||||||
@Callback(doc = """function():string -- Get the text on the sign in front of the robot.""")
|
@Callback(doc = """function():string -- Get the text on the sign in front of the robot.""")
|
||||||
def getValue(context: Context, args: Arguments): Array[AnyRef] = {
|
def getValue(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
val facing = owner.facing
|
findSign match {
|
||||||
owner.world.getTileEntity(math.round(owner.xPosition - 0.5).toInt + facing.offsetX, math.round(owner.yPosition - 0.5).toInt + facing.offsetY, math.round(owner.zPosition - 0.5).toInt + facing.offsetZ) match {
|
case Some(sign) => result(sign.signText.mkString("\n"))
|
||||||
case sign: TileEntitySign => result(sign.signText.mkString("\n"))
|
|
||||||
case _ => result(Unit, "no sign")
|
case _ => result(Unit, "no sign")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -26,14 +25,23 @@ class UpgradeSign(val owner: Container with Rotatable) extends component.Managed
|
|||||||
@Callback(doc = """function(value:string):string -- Set the text on the sign in front of the robot.""")
|
@Callback(doc = """function(value:string):string -- Set the text on the sign in front of the robot.""")
|
||||||
def setValue(context: Context, args: Arguments): Array[AnyRef] = {
|
def setValue(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
val text = args.checkString(0).lines.padTo(4, "").map(line => if (line.length > 15) line.substring(0, 15) else line)
|
val text = args.checkString(0).lines.padTo(4, "").map(line => if (line.length > 15) line.substring(0, 15) else line)
|
||||||
val facing = owner.facing
|
findSign match {
|
||||||
val (sx, sy, sz) = (math.round(owner.xPosition - 0.5).toInt + facing.offsetX, math.round(owner.yPosition - 0.5).toInt + facing.offsetY, math.round(owner.zPosition - 0.5).toInt + facing.offsetZ)
|
case Some(sign) =>
|
||||||
owner.world.getTileEntity(sx, sy, sz) match {
|
|
||||||
case sign: TileEntitySign =>
|
|
||||||
text.copyToArray(sign.signText)
|
text.copyToArray(sign.signText)
|
||||||
owner.world.markBlockForUpdate(sx, sy, sz)
|
owner.world.markBlockForUpdate(sign.xCoord, sign.yCoord, sign.zCoord)
|
||||||
result(sign.signText.mkString("\n"))
|
result(sign.signText.mkString("\n"))
|
||||||
case _ => result(Unit, "no sign")
|
case _ => result(Unit, "no sign")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def findSign = {
|
||||||
|
val (x, y, z) = (math.floor(owner.xPosition).toInt, math.floor(owner.yPosition).toInt, math.floor(owner.zPosition).toInt)
|
||||||
|
owner.world.getTileEntity(x, y, z) match {
|
||||||
|
case sign: TileEntitySign => Option(sign)
|
||||||
|
case _ => owner.world.getTileEntity(x + owner.facing.offsetX, y + owner.facing.offsetY, z + owner.facing.offsetZ) match {
|
||||||
|
case sign: TileEntitySign => Option(sign)
|
||||||
|
case _ => None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ class UpgradeSolarGenerator(val owner: Container) extends component.ManagedCompo
|
|||||||
ticksUntilCheck -= 1
|
ticksUntilCheck -= 1
|
||||||
if (ticksUntilCheck <= 0) {
|
if (ticksUntilCheck <= 0) {
|
||||||
ticksUntilCheck = 100
|
ticksUntilCheck = 100
|
||||||
isSunShining = isSunVisible(owner.world, math.round(owner.xPosition - 0.5).toInt, math.round(owner.yPosition - 0.5).toInt + 1, math.round(owner.zPosition - 0.5).toInt)
|
isSunShining = isSunVisible(owner.world, math.floor(owner.xPosition).toInt, math.floor(owner.yPosition).toInt + 1, math.floor(owner.zPosition).toInt)
|
||||||
}
|
}
|
||||||
if (isSunShining) {
|
if (isSunShining) {
|
||||||
node.changeBuffer(Settings.get.solarGeneratorEfficiency)
|
node.changeBuffer(Settings.get.solarGeneratorEfficiency)
|
||||||
|
@ -20,11 +20,11 @@ class WirelessNetworkCard(val owner: Container) extends NetworkCard with Wireles
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
override def x = math.round(owner.xPosition - 0.5).toInt
|
override def x = math.floor(owner.xPosition).toInt
|
||||||
|
|
||||||
override def y = math.round(owner.yPosition - 0.5).toInt
|
override def y = math.floor(owner.yPosition).toInt
|
||||||
|
|
||||||
override def z = math.round(owner.zPosition - 0.5).toInt
|
override def z = math.floor(owner.zPosition).toInt
|
||||||
|
|
||||||
override def world = owner.world
|
override def world = owner.world
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user