Fix dupe dropping with psi. Closes #250

This commit is contained in:
Vincent Lee committed 2016-04-23 16:02:02 -05:00
1 parent be155e0abb
commit 16f6289844
4 files changed
+73 -14

No files matched your search

@@ -76,9 +76,22 @@ public class BlockCacophonium extends BlockMod {
}
@Override
public void onBlockHarvested(World par1World, BlockPos pos, IBlockState state, EntityPlayer par6EntityPlayer) {
if(!par6EntityPlayer.capabilities.isCreativeMode)
dropBlockAsItem(par1World, pos, state, 0);
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
if (willHarvest) {
// Copy of super.removedByPlayer but don't set to air yet
// This is so getDrops below will have a TE to work with
onBlockHarvested(world, pos, state, player);
return true;
} else {
return super.removedByPlayer(state, world, pos, player, willHarvest);
}
}
@Override
public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te, ItemStack stack) {
super.harvestBlock(world, player, pos, state, te, stack);
// Now delete the block and TE
world.setBlockToAir(pos);
}
@Override
@@ -138,13 +138,29 @@ public class BlockFloatingSpecialFlower extends BlockFloatingFlower implements I
}
@Override
public void onBlockHarvested(World par1World, BlockPos pos, IBlockState state, EntityPlayer par6EntityPlayer) {
if(!par6EntityPlayer.capabilities.isCreativeMode) {
dropBlockAsItem(par1World, pos, state, 0);
((TileSpecialFlower) par1World.getTileEntity(pos)).onBlockHarvested(par1World, pos, state, par6EntityPlayer);
public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
((TileSpecialFlower) world.getTileEntity(pos)).onBlockHarvested(world, pos, state, player);
}
@Override
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
if (willHarvest) {
// Copy of super.removedByPlayer but don't set to air yet
// This is so getDrops below will have a TE to work with
onBlockHarvested(world, pos, state, player);
return true;
} else {
return super.removedByPlayer(state, world, pos, player, willHarvest);
}
}
@Override
public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te, ItemStack stack) {
super.harvestBlock(world, player, pos, state, te, stack);
// Now delete the block and TE
world.setBlockToAir(pos);
}
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
ArrayList<ItemStack> list = new ArrayList<>();
@@ -233,13 +233,29 @@ public class BlockSpecialFlower extends BlockFlower implements ISpecialFlower, I
}
@Override
public void onBlockHarvested(World par1World, BlockPos pos, IBlockState state, EntityPlayer par6EntityPlayer) {
if(!par6EntityPlayer.capabilities.isCreativeMode) {
dropBlockAsItem(par1World, pos, state, 0);
((TileSpecialFlower) par1World.getTileEntity(pos)).onBlockHarvested(par1World, pos, state, par6EntityPlayer);
public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
((TileSpecialFlower) world.getTileEntity(pos)).onBlockHarvested(world, pos, state, player);
}
@Override
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
if (willHarvest) {
// Copy of super.removedByPlayer but don't set to air yet
// This is so getDrops below will have a TE to work with
onBlockHarvested(world, pos, state, player);
return true;
} else {
return super.removedByPlayer(state, world, pos, player, willHarvest);
}
}
@Override
public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te, ItemStack stack) {
super.harvestBlock(world, player, pos, state, te, stack);
// Now delete the block and TE
world.setBlockToAir(pos);
}
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
ArrayList<ItemStack> list = new ArrayList<>();
@@ -298,6 +314,7 @@ public class BlockSpecialFlower extends BlockFlower implements ISpecialFlower, I
EnumDyeColor oldColor = state.getValue(BotaniaStateProps.COLOR);
if(newColor != oldColor)
world.setBlockState(pos, state.withProperty(BotaniaStateProps.COLOR, newColor), 1 | 2);
return true;
}
return ((TileSpecialFlower) world.getTileEntity(pos)).onBlockActivated(world, pos, state, player, hand, stack, side, hitX, hitY, hitZ);
@@ -110,9 +110,22 @@ public class BlockTinyPotato extends BlockMod implements ILexiconable {
}
@Override
public void onBlockHarvested(World par1World, BlockPos pos, IBlockState state, EntityPlayer par6EntityPlayer) {
if(!par6EntityPlayer.capabilities.isCreativeMode)
dropBlockAsItem(par1World, pos, state, 0);
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
if (willHarvest) {
// Copy of super.removedByPlayer but don't set to air yet
// This is so getDrops below will have a TE to work with
onBlockHarvested(world, pos, state, player);
return true;
} else {
return super.removedByPlayer(state, world, pos, player, willHarvest);
}
}
@Override
public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te, ItemStack stack) {
super.harvestBlock(world, player, pos, state, te, stack);
// Now delete the block and TE
world.setBlockToAir(pos);
}
@Override