@@ -51,7 +51,7 @@ public class EntityTimber extends Entity implements IEntityAdditionalSpawnData {
5151 private float fallHurtAmount = 2.0F ;
5252 private NBTTagCompound tileEntityData ;
5353 private List <ItemStack > drops = new ArrayList <>();
54- private EnumFacing fellingDirection ;
54+ private EnumFacing fellingDirection = EnumFacing . UP ;
5555
5656 public EntityTimber (World worldIn ) {
5757 super (worldIn );
@@ -123,7 +123,7 @@ public void onUpdate() {
123123
124124 IBlockState state = this .worldObj .getBlockState (currentPos );
125125 if (state .getBlock () == block ) {
126- if (!log ) {
126+ if (!this . worldObj . isRemote && ! log ) {
127127 drops .addAll (block .getDrops (worldObj , currentPos , state , 0 ));
128128 }
129129 this .worldObj .setBlockToAir (currentPos );
@@ -260,7 +260,7 @@ private boolean doTileDrops() {
260260 return worldObj .getGameRules ().getBoolean ("doEntityDrops" );
261261 }
262262
263- public void rotateLog (IBlockState state , BlockPos pos ) {
263+ private void rotateLog (IBlockState state , BlockPos pos ) {
264264 if (state .getBlock () instanceof BlockLog && state .getProperties ().containsKey (BlockLog .LOG_AXIS )) {
265265 BlockLog .EnumAxis axis ;
266266 switch (fellingDirection .getAxis ()) {
@@ -273,8 +273,10 @@ public void rotateLog(IBlockState state, BlockPos pos) {
273273 default :
274274 axis = BlockLog .EnumAxis .Y ;
275275 }
276- IBlockState newState = state .withProperty (BlockLog .LOG_AXIS , axis );
277- worldObj .setBlockState (pos , newState );
276+ if (axis != BlockLog .EnumAxis .Y ) {
277+ IBlockState newState = state .withProperty (BlockLog .LOG_AXIS , axis );
278+ worldObj .setBlockState (pos , newState );
279+ }
278280 }
279281 }
280282
@@ -291,7 +293,7 @@ protected void writeEntityToNBT(NBTTagCompound compound) {
291293 compound .setBoolean ("HurtEntities" , this .hurtEntities );
292294 compound .setFloat ("FallHurtAmount" , this .fallHurtAmount );
293295 compound .setInteger ("FallHurtMax" , this .fallHurtMax );
294- compound .setInteger ("FallingDirection " , this .fellingDirection .ordinal ());
296+ compound .setInteger ("FellingDirection " , this .fellingDirection .ordinal ());
295297
296298 if (this .tileEntityData != null ) {
297299 compound .setTag ("TileEntityData" , this .tileEntityData );
@@ -329,7 +331,7 @@ protected void readEntityFromNBT(NBTTagCompound compound) {
329331 this .tileEntityData = compound .getCompoundTag ("TileEntityData" );
330332 }
331333
332- this .fellingDirection = EnumFacing .VALUES [compound .getInteger ("FallingDirection " )];
334+ this .fellingDirection = EnumFacing .VALUES [compound .getInteger ("FellingDirection " )];
333335
334336 if (block == null || block .getDefaultState ().getMaterial () == Material .AIR ) {
335337 this .fallingBlock = Blocks .LOG .getDefaultState ();
@@ -370,10 +372,14 @@ public boolean ignoreItemEntityData() {
370372 @ Override
371373 public void writeSpawnData (ByteBuf buffer ) {
372374 buffer .writeInt (Block .getStateId (fallingBlock ));
375+ buffer .writeBoolean (log );
376+ buffer .writeByte (fellingDirection .ordinal ());
373377 }
374378
375379 @ Override
376380 public void readSpawnData (ByteBuf additionalData ) {
377- fallingBlock = Block .getStateById (additionalData .getInt (additionalData .readerIndex ()) & 65535 );
381+ fallingBlock = Block .getStateById (additionalData .readInt () & 65535 );
382+ log = additionalData .readBoolean ();
383+ fellingDirection = EnumFacing .VALUES [additionalData .readByte ()];
378384 }
379385}
0 commit comments