Fixed tile entity duplicates

This commit is contained in:
zangamj 2016-08-16 17:01:05 -04:00
parent 59fddb6116
commit b38393e29e
2 changed files with 18 additions and 5 deletions

View file

@ -64,12 +64,17 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
}
}
@Override
public boolean hasTileEntity(IBlockState state) {return state.getValue(BlockDoor.HALF) == EnumDoorHalf.LOWER;}
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
placeLink(world, pos);
if(state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER) placeLink(world, pos);
else {
world.setTileEntity(pos, createNewTileEntity(world, 0));
updateAttachedTile(world, pos);
}
}
//Called to update the render information on the tile entity. Could probably implement a data watcher,
//but this works fine and is more versatile I think.

View file

@ -1,6 +1,10 @@
package com.zixiken.dimdoors.tileentities;
import java.util.Random;
import net.minecraft.block.state.IBlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public abstract class DDTileEntityBase extends TileEntity
{
@ -10,4 +14,8 @@ public abstract class DDTileEntityBase extends TileEntity
*/
public abstract float[] getRenderColor(Random rand);
@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) {
return oldState.getBlock() != newSate.getBlock();
}
}