use of me.desht.pneumaticcraft.api.drone.AmadronRetrievalEvent in project pnc-repressurized by TeamPneumatic.
the class EventHandlerPneumaticCraft method onDroneSuicide.
@SubscribeEvent
public void onDroneSuicide(DroneSuicideEvent event) {
if (event.drone instanceof EntityDrone) {
EntityDrone drone = (EntityDrone) event.drone;
AmadronOffer offer = drone.getHandlingOffer();
if (offer != null) {
int times = drone.getOfferTimes();
if (offer.getInput() instanceof ItemStack) {
int requiredCount = ((ItemStack) offer.getInput()).getCount() * times;
for (int i = 0; i < drone.getInv().getSlots(); i++) {
requiredCount -= drone.getInv().getStackInSlot(i).getCount();
}
if (requiredCount <= 0) {
for (int i = 0; i < drone.getInv().getSlots(); i++) {
drone.getInv().setStackInSlot(i, ItemStack.EMPTY);
}
MinecraftForge.EVENT_BUS.post(new AmadronRetrievalEvent(event.drone));
}
} else {
int requiredCount = ((FluidStack) offer.getInput()).amount * times;
if (drone.getTank().getFluidAmount() >= requiredCount) {
MinecraftForge.EVENT_BUS.post(new AmadronRetrievalEvent(event.drone));
}
}
}
}
}
Aggregations