Some cleanups, removing some setdeads where the item would kill itself anyway

This commit is contained in:
Vincent Lee committed 2017-01-05 15:18:07 -06:00
1 parent 0e6951ee53
commit 7af2a3683e
10 files changed
+13 -41

No files matched your search

@@ -59,8 +59,6 @@ public class BlockTeruTeruBozu extends BlockMod implements ILexiconable {
ItemStack stack = item.getEntityItem();
if(isSunflower(stack) && removeRain(world) || isBlueOrchid(stack) && startRain(world)) {
stack.shrink(1);
if(stack.isEmpty())
e.setDead();
}
}
}
@@ -77,7 +77,7 @@ public class SubTileHopperhock extends SubTileFunctional {
continue;
}
if(age < 60 + slowdown || age >= 105 && age < 110 || item.isDead)
if(age < 60 + slowdown || age >= 105 && age < 110 || item.isDead || item.getEntityItem().isEmpty())
continue;
ItemStack stack = item.getEntityItem();
@@ -94,7 +94,7 @@ public class SubTileHopperhock extends SubTileFunctional {
boolean canAccept = canAcceptItem(stack, filter, filterType);
ItemStack simulate = ItemHandlerHelper.insertItem(inv.handler, stack.copy(), true);
int availablePut = stack.getAnimationsToGo() - (simulate.isEmpty() ? 0 : simulate.getCount());
int availablePut = stack.getCount() - simulate.getCount();
canAccept &= availablePut > 0;
@@ -117,8 +117,6 @@ public class SubTileHopperhock extends SubTileFunctional {
SubTileSpectranthemum.spawnExplosionParticles(item, 3);
ItemHandlerHelper.insertItem(invToPutItemIn, stack.splitStack(amountToPutIn), false);
item.setEntityItemStack(stack); // Just in case someone subclasses EntityItem and changes something important.
if(item.getEntityItem().isEmpty())
item.setDead();
pulledAny = true;
}
}
@@ -56,10 +56,8 @@ public class SubTilePollidisiac extends SubTileFunctional {
continue;
ItemStack stack = item.getEntityItem();
if(animal.isBreedingItem(stack)) {
if(!stack.isEmpty() && animal.isBreedingItem(stack)) {
stack.shrink(1);
if(stack.isEmpty())
item.setDead();
mana -= manaCost;
@@ -87,7 +87,7 @@ public class SubTileRannuncarpus extends SubTileFunctional {
continue;
}
if(age < 60 + slowdown || item.isDead)
if(age < 60 + slowdown || item.isDead || item.getEntityItem().isEmpty())
continue;
ItemStack stack = item.getEntityItem();
@@ -141,8 +141,6 @@ public class SubTileRannuncarpus extends SubTileFunctional {
((IFlowerPlaceable) stackItem).onBlockPlacedByFlower(stack, this, coords);
stack.shrink(1);
if(stack.isEmpty())
item.setDead();
if(mana > 1)
mana--;
@@ -58,10 +58,10 @@ public class SubTileEndoflame extends SubTileGenerating {
if(age >= 59 + slowdown && !item.isDead) {
ItemStack stack = item.getEntityItem();
if(stack.getItem().hasContainerItem(stack))
if(stack.isEmpty() || stack.getItem().hasContainerItem(stack))
continue;
int burnTime = stack .isEmpty() || stack.getItem() == Item.getItemFromBlock(ModBlocks.spreader) ? 0 : TileEntityFurnace.getItemBurnTime(stack);
int burnTime = stack.getItem() == Item.getItemFromBlock(ModBlocks.spreader) ? 0 : TileEntityFurnace.getItemBurnTime(stack);
if(burnTime > 0 && stack.getCount() > 0) {
this.burnTime = Math.min(FUEL_CAP, burnTime) / 2;
@@ -69,9 +69,6 @@ public class SubTileEndoflame extends SubTileGenerating {
stack.shrink(1);
supertile.getWorld().playSound(null, supertile.getPos(), BotaniaSoundEvents.endoflame, SoundCategory.BLOCKS, 0.2F, 1F);
if(stack.isEmpty())
item.setDead();
didSomething = true;
} else {
item.world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, item.posX, item.posY + 0.1, item.posZ, 0.0D, 0.0D, 0.0D);
@@ -82,8 +82,6 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary {
} else {
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
stack.shrink(1);
if(stack.isEmpty())
item.setDead();
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
}
@@ -128,8 +126,6 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary {
if(!world.isRemote) {
stack.shrink(1);
if(stack.isEmpty())
item.setDead();
for(int i = 0; i < getSizeInventory(); i++)
if(itemHandler.getStackInSlot(i).isEmpty()) {
@@ -151,8 +147,6 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary {
itemHandler.setStackInSlot(i, ItemStack.EMPTY);
stack.shrink(1);
if(stack.isEmpty())
item.setDead();
ItemStack output = recipe.getOutput().copy();
EntityItem outputItem = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, output);
@@ -102,8 +102,7 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver {
for(EntityItem item : items)
if(!item.isDead && !item.getEntityItem().isEmpty()) {
ItemStack stack = item.getEntityItem();
if(addItem(null, stack, null) && stack.isEmpty())
item.setDead();
addItem(null, stack, null);
}
}
@@ -115,8 +115,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver
for(EntityItem item : items)
if(!item.isDead && !item.getEntityItem().isEmpty() && item.getEntityItem().getItem() != Item.getItemFromBlock(ModBlocks.livingrock)) {
ItemStack stack = item.getEntityItem();
if(addItem(null, stack, null) && stack.isEmpty())
item.setDead();
addItem(null, stack, null);
}
}
@@ -246,10 +245,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver
}
}
ItemStack livingrockItem = livingrock.getEntityItem();
livingrockItem.shrink(1);
if(livingrockItem.isEmpty())
livingrock.setDead();
livingrock.getEntityItem().shrink(1);
}
craftingFanciness();
@@ -168,8 +168,6 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
if(stack.getItem() instanceof IManaDissolvable) {
((IManaDissolvable) stack.getItem()).onDissolveTick(this, stack, item);
if(stack.isEmpty())
item.setDead();
}
int age;
@@ -188,8 +186,6 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
recieveMana(-mana);
stack.shrink(1);
if(stack.isEmpty())
item.setDead();
ItemStack output = recipe.getOutput().copy();
EntityItem outputItem = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, output);
@@ -135,20 +135,18 @@ public class ItemFlowerBag extends ItemMod {
IItemHandler bagInv = bag.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
ItemStack result = bagInv.insertItem(color, entityStack, false);
int numPickedUp = entityStack.getCount() - result.getCount();
if(result.isEmpty())
event.getItem().setDead();
else
event.getItem().setEntityItemStack(result);
event.getItem().setEntityItemStack(result);
if(result != entityStack) {
if(numPickedUp > 0) {
event.setCanceled(true);
if (!event.getItem().isSilent()) {
event.getItem().world.playSound(null, event.getEntityPlayer().posX, event.getEntityPlayer().posY, event.getEntityPlayer().posZ,
SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F,
((event.getItem().world.rand.nextFloat() - event.getItem().world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
}
((EntityPlayerMP) event.getEntityPlayer()).connection.sendPacket(new SPacketCollectItem(event.getItem().getEntityId(), event.getEntityPlayer().getEntityId(), entityStack.getCount()));
((EntityPlayerMP) event.getEntityPlayer()).connection.sendPacket(new SPacketCollectItem(event.getItem().getEntityId(), event.getEntityPlayer().getEntityId(), numPickedUp));
event.getEntityPlayer().openContainer.detectAndSendChanges();
return;