checking for changes in tool slot in all activation cases now, fixes #124

This commit is contained in:
Florian Nücke 2014-02-19 13:54:57 +01:00
parent 9b437ed8f3
commit 235acf922d

View File

@ -121,24 +121,22 @@ class Player(val robot: tileentity.Robot) extends EntityPlayer(robot.world, Sett
val block = Block.blocksList(blockId)
val canActivate = block != null && Settings.get.allowActivateBlocks
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)) {
return ActivationType.BlockActivated
}
val result =
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) {
val didPlace = tryPlaceBlockWhileHandlingFunnySpecialCases(stack, x, y, z, side, hitX, hitY, hitZ)
if (stack.stackSize <= 0) ForgeEventFactory.onPlayerDestroyItem(this, stack)
if (stack.stackSize <= 0) inventory.setInventorySlotContents(0, null)
if (didPlace) {
return ActivationType.ItemPlaced
}
if (tryUseItem(stack, duration)) {
return ActivationType.ItemUsed
}
}
ActivationType.None
result
}
def useEquippedItem(duration: Double) = {
@ -324,14 +322,16 @@ 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) = {
val fakeEyeHeight = if (rotationPitch < 0 && isSomeKindOfPiston(stack)) 1.82 else 0
setPosition(posX, posY - fakeEyeHeight, posZ)
val didPlace = stack.tryPlaceItemIntoWorld(this, world, x, y, z, side, hitX, hitY, hitZ)
setPosition(posX, posY + fakeEyeHeight, posZ)
if (didPlace) {
robot.addXp(Settings.get.robotActionXp)
stack != null && stack.stackSize > 0 && {
val fakeEyeHeight = if (rotationPitch < 0 && isSomeKindOfPiston(stack)) 1.82 else 0
setPosition(posX, posY - fakeEyeHeight, posZ)
val didPlace = stack.tryPlaceItemIntoWorld(this, world, x, y, z, side, hitX, hitY, hitZ)
setPosition(posX, posY + fakeEyeHeight, posZ)
if (didPlace) {
robot.addXp(Settings.get.robotActionXp)
}
didPlace
}
didPlace
}
private def isSomeKindOfPiston(stack: ItemStack) =