Fix manual dropping of items, closes #2173

This commit is contained in:
Vincent Lee committed 2017-02-19 18:31:47 -06:00
1 parent 59a5921713
commit 14fea3891f
3 files changed
+9 -21

No files matched your search

@@ -129,17 +129,14 @@ public class ItemGrassHorn extends ItemMod {
BlockPos currCoords = coords.get(i);
IBlockState state = world.getBlockState(currCoords);
Block block = state.getBlock();
List<ItemStack> items = block.getDrops(world, currCoords, state, 0);
if(block instanceof IHornHarvestable && ((IHornHarvestable) block).hasSpecialHornHarvest(world, currCoords, stack, type))
((IHornHarvestable) block).harvestByHorn(world, currCoords, stack, type);
else {
block.dropBlockAsItem(world, currCoords, state, 0);
world.setBlockToAir(currCoords);
if(ConfigHandler.blockBreakParticles)
world.playEvent(2001, currCoords, Block.getStateId(state));
for(ItemStack stack_ : items)
world.spawnEntityInWorld(new EntityItem(world, currCoords.getX() + 0.5, currCoords.getY() + 0.5, currCoords.getZ() + 0.5, stack_));
}
}
}
@@ -58,25 +58,18 @@ public class LensMine extends Lens {
BlockPos coords = burst.getBurstSourceBlockPos();
if(!coords.equals(pos.getBlockPos()) && !(tile instanceof IManaBlock) && neededHarvestLevel <= harvestLevel && hardness != -1 && hardness < 50F && (burst.isFake() || mana >= 24)) {
List<ItemStack> items = new ArrayList<>();
items.addAll(block.getDrops(world, pos_, world.getBlockState(pos_), 0));
if(!burst.hasAlreadyCollidedAt(pos_)) {
if(!burst.isFake() && !entity.worldObj.isRemote) {
if(!burst.isFake()) {
boolean offBounds = coords.getY() < 0;
boolean doWarp = warp && !offBounds;
for(ItemStack drop : block.getDrops(world, pos_, state, 0))
Block.spawnAsEntity(world, doWarp ? coords : pos_, drop);
world.setBlockToAir(pos_);
if(ConfigHandler.blockBreakParticles)
entity.worldObj.playEvent(2001, pos_, Block.getStateId(state));
boolean offBounds = coords.getY() < 0;
boolean doWarp = warp && !offBounds;
int dropX = doWarp ? coords.getX() : pos_.getX();
int dropY = doWarp ? coords.getY() : pos_.getY();
int dropZ = doWarp ? coords.getZ() : pos_.getZ();
for(ItemStack stack_ : items)
world.spawnEntityInWorld(new EntityItem(world, dropX + 0.5, dropY + 0.5, dropZ + 0.5, stack_));
burst.setMana(mana - 24);
}
}
@@ -224,9 +224,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
if(!blockAt.isAir(world.getBlockState(pos), world, pos) && stateAt.getPlayerRelativeBlockHardness(player, world, pos) > 0 && stateAt != state) {
if(!world.isRemote) {
if(!player.capabilities.isCreativeMode) {
List<ItemStack> drops = blockAt.getDrops(world, pos, stateAt, 0);
for(ItemStack drop : drops)
world.spawnEntityInWorld(new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, drop));
blockAt.dropBlockAsItem(world, pos, stateAt, 0);
removeFromInventory(player, stack, state.getBlock(), state.getBlock().getMetaFromState(state), true);
}
world.playEvent(2001, pos, Block.getStateId(state));