@Override public void updateEntity() { if (id == -1) getBlockType(); checkForAdjacentChests(); prevLidAngle = lidAngle; float lidSpeed = 0.1F; // Play sound when opening chest. if (numUsingPlayers > 0 && lidAngle == 0.0F && adjacentChestZNeg == null && adjacentChestXNeg == null) { double x = xCoord + 0.5D; double z = zCoord + 0.5D; if (adjacentChestZPos != null) z += 0.5D; if (adjacentChestXPos != null) x += 0.5D; worldObj.playSoundEffect( x, yCoord + 0.5D, z, "random.chestopen", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F); } if ((numUsingPlayers == 0 && lidAngle > 0.0F) || (numUsingPlayers > 0 && lidAngle < 1.0F)) { lidAngle = Math.max(0, Math.min(1, lidAngle + ((numUsingPlayers > 0) ? lidSpeed : -lidSpeed))); // Play sound when closing chest. if (lidAngle < 0.5F && prevLidAngle >= 0.5F && adjacentChestZNeg == null && adjacentChestXNeg == null) { double x = xCoord + 0.5D; double z = zCoord + 0.5D; if (adjacentChestZPos != null) z += 0.5D; if (adjacentChestXPos != null) x += 0.5D; worldObj.playSoundEffect( x, yCoord + 0.5D, z, "random.chestclosed", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F); } } }
@Override public void invalidate() { updateContainingBlockInfo(); checkForAdjacentChests(); super.invalidate(); }