@@ -52,7 +52,7 @@ public class EntityTimber extends Entity implements IEntityAdditionalSpawnData {
5252 private float fallHurtAmount = 2.0F ;
5353 private NBTTagCompound tileEntityData ;
5454 private List <ItemStack > drops = new ArrayList <>();
55- private EnumFacing fellingDirection ;
55+ private EnumFacing fellingDirection = EnumFacing . UP ;
5656
5757 public EntityTimber (World worldIn ) {
5858 super (worldIn );
@@ -124,7 +124,7 @@ public void onUpdate() {
124124
125125 IBlockState state = this .world .getBlockState (currentPos );
126126 if (state .getBlock () == block ) {
127- if (!log ) {
127+ if (!this . world . isRemote && ! log ) {
128128 drops .addAll (block .getDrops (world , currentPos , state , 0 ));
129129 }
130130 this .world .setBlockToAir (currentPos );
@@ -261,7 +261,7 @@ private boolean doTileDrops() {
261261 return world .getGameRules ().getBoolean ("doEntityDrops" );
262262 }
263263
264- public void rotateLog (IBlockState state , BlockPos pos ) {
264+ private void rotateLog (IBlockState state , BlockPos pos ) {
265265 if (state .getBlock () instanceof BlockLog && state .getProperties ().containsKey (BlockLog .LOG_AXIS )) {
266266 BlockLog .EnumAxis axis ;
267267 switch (fellingDirection .getAxis ()) {
@@ -274,8 +274,10 @@ public void rotateLog(IBlockState state, BlockPos pos) {
274274 default :
275275 axis = BlockLog .EnumAxis .Y ;
276276 }
277- IBlockState newState = state .withProperty (BlockLog .LOG_AXIS , axis );
278- world .setBlockState (pos , newState );
277+ if (axis != BlockLog .EnumAxis .Y ) {
278+ IBlockState newState = state .withProperty (BlockLog .LOG_AXIS , axis );
279+ world .setBlockState (pos , newState );
280+ }
279281 }
280282 }
281283
@@ -292,7 +294,7 @@ protected void writeEntityToNBT(NBTTagCompound compound) {
292294 compound .setBoolean ("HurtEntities" , this .hurtEntities );
293295 compound .setFloat ("FallHurtAmount" , this .fallHurtAmount );
294296 compound .setInteger ("FallHurtMax" , this .fallHurtMax );
295- compound .setInteger ("FallingDirection " , this .fellingDirection .ordinal ());
297+ compound .setInteger ("FellingDirection " , this .fellingDirection .ordinal ());
296298
297299 if (this .tileEntityData != null ) {
298300 compound .setTag ("TileEntityData" , this .tileEntityData );
@@ -330,7 +332,7 @@ protected void readEntityFromNBT(NBTTagCompound compound) {
330332 this .tileEntityData = compound .getCompoundTag ("TileEntityData" );
331333 }
332334
333- this .fellingDirection = EnumFacing .VALUES [compound .getInteger ("FallingDirection " )];
335+ this .fellingDirection = EnumFacing .VALUES [compound .getInteger ("FellingDirection " )];
334336
335337 if (block == null || block .getDefaultState ().getMaterial () == Material .AIR ) {
336338 this .fallingBlock = Blocks .LOG .getDefaultState ();
@@ -371,10 +373,14 @@ public boolean ignoreItemEntityData() {
371373 @ Override
372374 public void writeSpawnData (ByteBuf buffer ) {
373375 buffer .writeInt (Block .getStateId (fallingBlock ));
376+ buffer .writeBoolean (log );
377+ buffer .writeByte (fellingDirection .ordinal ());
374378 }
375379
376380 @ Override
377381 public void readSpawnData (ByteBuf additionalData ) {
378- fallingBlock = Block .getStateById (additionalData .getInt (additionalData .readerIndex ()) & 65535 );
382+ fallingBlock = Block .getStateById (additionalData .readInt () & 65535 );
383+ log = additionalData .readBoolean ();
384+ fellingDirection = EnumFacing .VALUES [additionalData .readByte ()];
379385 }
380386}
0 commit comments