mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-19 04:06:43 -04:00
checking for changes in tool slot in all activation cases now, fixes #124
This commit is contained in:
parent
9b437ed8f3
commit
235acf922d
@ -121,24 +121,22 @@ class Player(val robot: tileentity.Robot) extends EntityPlayer(robot.world, Sett
|
|||||||
val block = Block.blocksList(blockId)
|
val block = Block.blocksList(blockId)
|
||||||
val canActivate = block != null && Settings.get.allowActivateBlocks
|
val canActivate = block != null && Settings.get.allowActivateBlocks
|
||||||
val shouldActivate = canActivate && (!isSneaking || (item == null || item.shouldPassSneakingClickToBlock(world, x, y, z)))
|
val shouldActivate = canActivate && (!isSneaking || (item == null || item.shouldPassSneakingClickToBlock(world, x, y, z)))
|
||||||
if (shouldActivate && block.onBlockActivated(world, x, y, z, this, side, hitX, hitY, hitZ)) {
|
val result =
|
||||||
return ActivationType.BlockActivated
|
if (shouldActivate && block.onBlockActivated(world, x, y, z, this, side, hitX, hitY, hitZ))
|
||||||
}
|
ActivationType.BlockActivated
|
||||||
|
else if (tryPlaceBlockWhileHandlingFunnySpecialCases(stack, x, y, z, side, hitX, hitY, hitZ))
|
||||||
|
ActivationType.ItemPlaced
|
||||||
|
else if (tryUseItem(stack, duration))
|
||||||
|
ActivationType.ItemUsed
|
||||||
|
else
|
||||||
|
ActivationType.None
|
||||||
|
|
||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
val didPlace = tryPlaceBlockWhileHandlingFunnySpecialCases(stack, x, y, z, side, hitX, hitY, hitZ)
|
|
||||||
if (stack.stackSize <= 0) ForgeEventFactory.onPlayerDestroyItem(this, stack)
|
if (stack.stackSize <= 0) ForgeEventFactory.onPlayerDestroyItem(this, stack)
|
||||||
if (stack.stackSize <= 0) inventory.setInventorySlotContents(0, null)
|
if (stack.stackSize <= 0) inventory.setInventorySlotContents(0, null)
|
||||||
if (didPlace) {
|
|
||||||
return ActivationType.ItemPlaced
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tryUseItem(stack, duration)) {
|
result
|
||||||
return ActivationType.ItemUsed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ActivationType.None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def useEquippedItem(duration: Double) = {
|
def useEquippedItem(duration: Double) = {
|
||||||
@ -324,6 +322,7 @@ class Player(val robot: tileentity.Robot) extends EntityPlayer(robot.world, Sett
|
|||||||
}
|
}
|
||||||
|
|
||||||
private def tryPlaceBlockWhileHandlingFunnySpecialCases(stack: ItemStack, x: Int, y: Int, z: Int, side: Int, hitX: Float, hitY: Float, hitZ: Float) = {
|
private def tryPlaceBlockWhileHandlingFunnySpecialCases(stack: ItemStack, x: Int, y: Int, z: Int, side: Int, hitX: Float, hitY: Float, hitZ: Float) = {
|
||||||
|
stack != null && stack.stackSize > 0 && {
|
||||||
val fakeEyeHeight = if (rotationPitch < 0 && isSomeKindOfPiston(stack)) 1.82 else 0
|
val fakeEyeHeight = if (rotationPitch < 0 && isSomeKindOfPiston(stack)) 1.82 else 0
|
||||||
setPosition(posX, posY - fakeEyeHeight, posZ)
|
setPosition(posX, posY - fakeEyeHeight, posZ)
|
||||||
val didPlace = stack.tryPlaceItemIntoWorld(this, world, x, y, z, side, hitX, hitY, hitZ)
|
val didPlace = stack.tryPlaceItemIntoWorld(this, world, x, y, z, side, hitX, hitY, hitZ)
|
||||||
@ -333,6 +332,7 @@ class Player(val robot: tileentity.Robot) extends EntityPlayer(robot.world, Sett
|
|||||||
}
|
}
|
||||||
didPlace
|
didPlace
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private def isSomeKindOfPiston(stack: ItemStack) =
|
private def isSomeKindOfPiston(stack: ItemStack) =
|
||||||
stack.getItem match {
|
stack.getItem match {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user