mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 11:15:12 -04:00
Made robot not send null to the client when its inventory changes.
Closes #2360.
This commit is contained in:
parent
30e3e129c8
commit
41599b0c10
@ -11,6 +11,8 @@ import li.cil.oc.client.Textures
|
||||
import li.cil.oc.common.EventHandler
|
||||
import li.cil.oc.common.tileentity
|
||||
import li.cil.oc.util.RenderState
|
||||
import li.cil.oc.util.StackOption
|
||||
import li.cil.oc.util.StackOption._
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.renderer._
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType
|
||||
@ -343,8 +345,8 @@ object RobotRenderer extends TileEntitySpecialRenderer[tileentity.RobotProxy] {
|
||||
|
||||
if (MinecraftForgeClient.getRenderPass == 0 && !robot.renderingErrored && x * x + y * y + z * z < 24 * 24) {
|
||||
val itemRenderer = Minecraft.getMinecraft.getItemRenderer
|
||||
Option(robot.getStackInSlot(0)) match {
|
||||
case Some(stack) =>
|
||||
StackOption(robot.getStackInSlot(0)) match {
|
||||
case SomeStack(stack) =>
|
||||
|
||||
RenderState.pushAttrib()
|
||||
GlStateManager.pushMatrix()
|
||||
|
@ -6,6 +6,8 @@ import li.cil.oc.Settings
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.common.Slot
|
||||
import li.cil.oc.common.Tier
|
||||
import li.cil.oc.util.StackOption
|
||||
import li.cil.oc.util.StackOption._
|
||||
import net.minecraft.inventory.IInventory
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.text.ITextComponent
|
||||
@ -60,8 +62,8 @@ abstract class Template {
|
||||
}
|
||||
|
||||
protected def exists(inventory: IInventory, p: ItemStack => Boolean) = {
|
||||
(0 until inventory.getSizeInventory).exists(slot => Option(inventory.getStackInSlot(slot)) match {
|
||||
case Some(stack) => p(stack)
|
||||
(0 until inventory.getSizeInventory).exists(slot => StackOption(inventory.getStackInSlot(slot)) match {
|
||||
case SomeStack(stack) => p(stack)
|
||||
case _ => false
|
||||
})
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ import li.cil.oc.util.BlockPosition
|
||||
import li.cil.oc.util.ExtendedNBT._
|
||||
import li.cil.oc.util.ExtendedWorld._
|
||||
import li.cil.oc.util.InventoryUtils
|
||||
import li.cil.oc.util.StackOption
|
||||
import li.cil.oc.util.StackOption._
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.BlockLiquid
|
||||
import net.minecraft.client.Minecraft
|
||||
@ -357,8 +359,8 @@ class Robot extends traits.Computer with traits.PowerInformation with traits.Rot
|
||||
}
|
||||
if (!appliedToolEnchantments) {
|
||||
appliedToolEnchantments = true
|
||||
Option(getStackInSlot(0)) match {
|
||||
case Some(item) => player_.getAttributeMap.applyAttributeModifiers(item.getAttributeModifiers(EntityEquipmentSlot.MAINHAND))
|
||||
StackOption(getStackInSlot(0)) match {
|
||||
case SomeStack(item) => player_.getAttributeMap.applyAttributeModifiers(item.getAttributeModifiers(EntityEquipmentSlot.MAINHAND))
|
||||
case _ =>
|
||||
}
|
||||
}
|
||||
@ -578,10 +580,10 @@ class Robot extends traits.Computer with traits.PowerInformation with traits.Rot
|
||||
if (isServer) {
|
||||
if (isToolSlot(slot)) {
|
||||
player_.getAttributeMap.removeAttributeModifiers(stack.getAttributeModifiers(EntityEquipmentSlot.MAINHAND))
|
||||
ServerPacketSender.sendRobotInventory(this, slot, null)
|
||||
ServerPacketSender.sendRobotInventory(this, slot, ItemStack.EMPTY)
|
||||
}
|
||||
if (isUpgradeSlot(slot)) {
|
||||
ServerPacketSender.sendRobotInventory(this, slot, null)
|
||||
ServerPacketSender.sendRobotInventory(this, slot, ItemStack.EMPTY)
|
||||
}
|
||||
if (isFloppySlot(slot)) {
|
||||
common.Sound.playDiskEject(this)
|
||||
@ -675,10 +677,10 @@ class Robot extends traits.Computer with traits.PowerInformation with traits.Rot
|
||||
|
||||
override def componentSlot(address: String): Int = components.indexWhere(_.exists(env => env.node != null && env.node.address == address))
|
||||
|
||||
override def hasRedstoneCard: Boolean = (containerSlots ++ componentSlots).exists(slot => Option(getStackInSlot(slot)).fold(false)(DriverRedstoneCard.worksWith(_, getClass)))
|
||||
override def hasRedstoneCard: Boolean = (containerSlots ++ componentSlots).exists(slot => StackOption(getStackInSlot(slot)).fold(false)(DriverRedstoneCard.worksWith(_, getClass)))
|
||||
|
||||
private def computeInventorySize() = math.min(maxInventorySize, (containerSlots ++ componentSlots).foldLeft(0)((acc, slot) => acc + (Option(getStackInSlot(slot)) match {
|
||||
case Some(stack) => Option(Driver.driverFor(stack, getClass)) match {
|
||||
private def computeInventorySize() = math.min(maxInventorySize, (containerSlots ++ componentSlots).foldLeft(0)((acc, slot) => acc + (StackOption(getStackInSlot(slot)) match {
|
||||
case SomeStack(stack) => Option(Driver.driverFor(stack, getClass)) match {
|
||||
case Some(driver: item.Inventory) => driver.inventoryCapacity(stack)
|
||||
case _ => 0
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package li.cil.oc.server.agent
|
||||
import li.cil.oc.api.internal
|
||||
import li.cil.oc.util.ExtendedInventory._
|
||||
import li.cil.oc.util.InventoryUtils
|
||||
import li.cil.oc.util.StackOption
|
||||
import li.cil.oc.util.StackOption._
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.entity.player.InventoryPlayer
|
||||
import net.minecraft.item.Item
|
||||
@ -32,8 +34,8 @@ class Inventory(val agent: internal.Agent) extends InventoryPlayer(null) {
|
||||
|
||||
override def decrementAnimations() {
|
||||
for (slot <- 0 until getSizeInventory) {
|
||||
Option(getStackInSlot(slot)) match {
|
||||
case Some(stack) => try stack.updateAnimation(agent.world, if (!agent.world.isRemote) agent.player else null, slot, slot == 0) catch {
|
||||
StackOption(getStackInSlot(slot)) match {
|
||||
case SomeStack(stack) => try stack.updateAnimation(agent.world, if (!agent.world.isRemote) agent.player else null, slot, slot == 0) catch {
|
||||
case ignored: NullPointerException => // Client side item updates that need a player instance...
|
||||
}
|
||||
case _ =>
|
||||
|
Loading…
x
Reference in New Issue
Block a user