annihilation plane performance improvement

This commit is contained in:
serenibyss
2024-01-03 23:26:50 -06:00
parent 27a3f70f0b
commit 1a576705fe
@@ -330,6 +330,12 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
return changed; return changed;
} }
private void handleOverflow(final ItemStack stack, final IAEItemStack overflow) {
if (overflow.getStackSize() != 0L) {
stack.setCount((int) overflow.getStackSize());
}
}
protected boolean isAnnihilationPlane(final TileEntity blockTileEntity, final AEPartLocation side) { protected boolean isAnnihilationPlane(final TileEntity blockTileEntity, final AEPartLocation side) {
if (blockTileEntity instanceof IPartHost) { if (blockTileEntity instanceof IPartHost) {
final IPart p = ((IPartHost) blockTileEntity).getPart(side); final IPart p = ((IPartHost) blockTileEntity).getPart(side);
@@ -371,7 +377,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
if (hasPower && canStore) { if (hasPower && canStore) {
if (modulate) { if (modulate) {
energy.extractAEPower(requiredPower, Actionable.MODULATE, PowerMultiplier.CONFIG); energy.extractAEPower(requiredPower, Actionable.MODULATE, PowerMultiplier.CONFIG);
this.breakBlockAndStoreItems(w, pos); this.breakBlockAndStoreItems(w, pos, items);
AppEng.proxy.sendToAllNearExcept(null, pos.getX(), pos.getY(), pos.getZ(), 64, w, AppEng.proxy.sendToAllNearExcept(null, pos.getX(), pos.getY(), pos.getZ(), 64, w,
new PacketTransitionEffect(pos.getX(), pos.getY(), pos.getZ(), this.getSide(), true)); new PacketTransitionEffect(pos.getX(), pos.getY(), pos.getZ(), this.getSide(), true));
} else { } else {
@@ -471,14 +477,12 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
return canStore; return canStore;
} }
private void breakBlockAndStoreItems(final WorldServer w, final BlockPos pos) { private void breakBlockAndStoreItems(final WorldServer w, final BlockPos pos, final List<ItemStack> drops) {
w.destroyBlock(pos, true); w.destroyBlock(pos, false);
for (final ItemStack drop : drops) {
final AxisAlignedBB box = new AxisAlignedBB(pos).grow(0.2); IAEItemStack overflow = storeItemStack(drop);
for (final Object ei : w.getEntitiesWithinAABB(EntityItem.class, box)) { if (overflow != null) {
if (ei instanceof EntityItem) { handleOverflow(drop, overflow);
final EntityItem entityItem = (EntityItem) ei;
this.storeEntityItem(entityItem);
} }
} }
} }