#1501 Travel Anchor drops in creative

This commit is contained in:
tterrag1098 committed 2014-12-27 13:04:52 -05:00
1 parent 92f5935d73
commit e0d160cb65
1 file changed
+9 -20
@@ -8,7 +8,6 @@ import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -165,36 +164,26 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt
}
return null;
}
/**
* Remove the tile entity too.
*/
@Override
public void breakBlock(World world, int x, int y, int z, Block par5, int par6) {
if(!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) {
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean doHarvest) {
if(!world.isRemote && (!player.capabilities.isCreativeMode)) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileTravelAnchor) {
TileTravelAnchor tef = (TileTravelAnchor) te;
TileTravelAnchor anchor = (TileTravelAnchor) te;
ItemStack itemStack;
Block srcBlk = tef.getSourceBlock();
Block srcBlk = anchor.getSourceBlock();
if(srcBlk != null) {
itemStack = createItemStackForSourceBlock(tef.getSourceBlock(), tef.getSourceBlockMetadata());
itemStack = createItemStackForSourceBlock(anchor.getSourceBlock(), anchor.getSourceBlockMetadata());
} else {
itemStack = new ItemStack(this);
}
float f = 0.7F;
double d0 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
double d1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
double d2 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
EntityItem entityitem = new EntityItem(world, x + d0, y + d1, z + d2, itemStack);
entityitem.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(entityitem);
dropBlockAsItem(world, x, y, z, itemStack);
}
}
world.removeTileEntity(x, y, z);
return super.removedByPlayer(world, player, x, y, z, doHarvest);
}
@Override