Search in sources :

Example 11 with EntityDrone

use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.

the class AmadronOfferManager method tryRestockCustomOffers.

public void tryRestockCustomOffers() {
    for (AmadronOffer offer : allOffers) {
        if (offer instanceof AmadronOfferCustom) {
            AmadronOfferCustom custom = (AmadronOfferCustom) offer;
            TileEntity input = custom.getProvidingTileEntity();
            TileEntity output = custom.getReturningTileEntity();
            int possiblePickups = ContainerAmadron.capShoppingAmount(custom.invert(), 50, getItemHandler(input), getItemHandler(output), getFluidHandler(input), getFluidHandler(output), null);
            if (possiblePickups > 0) {
                BlockPos pos = new BlockPos(input.getPos().getX(), input.getPos().getY(), input.getPos().getZ());
                EntityDrone drone = ContainerAmadron.retrieveOrderItems(custom, possiblePickups, input.getWorld(), pos, input.getWorld(), pos);
                if (drone != null) {
                    drone.setHandlingOffer(custom.copy(), possiblePickups, null, "Restock");
                }
            }
            custom.invert();
            custom.payout();
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone) BlockPos(net.minecraft.util.math.BlockPos)

Example 12 with EntityDrone

use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.

the class ProgWidgetDroneConditionEntity method getCount.

@Override
protected int getCount(IDroneBase d, IProgWidget widget) {
    EntityDrone drone = (EntityDrone) d;
    int count = 0;
    for (Entity e : drone.getPassengers()) {
        if (((IEntityProvider) widget).isEntityValid(e))
            count++;
    }
    return count;
// return drone.getPassengers().isEmpty() || !((IEntityProvider) widget).isEntityValid(drone.riddenByEntity) ? 0 : 1;
}
Also used : Entity(net.minecraft.entity.Entity) EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone)

Example 13 with EntityDrone

use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.

the class EventHandlerPneumaticCraft method onAmadronSuccess.

@SubscribeEvent
public void onAmadronSuccess(AmadronRetrievalEvent event) {
    EntityDrone drone = (EntityDrone) event.drone;
    AmadronOffer offer = drone.getHandlingOffer();
    boolean shouldDeliver = false;
    if (offer instanceof AmadronOfferCustom) {
        AmadronOffer realOffer = AmadronOfferManager.getInstance().get(offer);
        if (realOffer != null) {
            // If we find the non-inverted offer, that means the Drone just has completed trading with a different player.
            ((AmadronOfferCustom) realOffer).addPayment(drone.getOfferTimes());
            ((AmadronOfferCustom) realOffer).addStock(-drone.getOfferTimes());
            realOffer.onTrade(drone.getOfferTimes(), drone.getBuyingPlayer());
            shouldDeliver = true;
        }
        realOffer = AmadronOfferManager.getInstance().get(((AmadronOfferCustom) offer).copy().invert());
        if (realOffer != null) {
            // If we find the inverted offer, that means the Drone has just restocked.
            ((AmadronOfferCustom) realOffer).addStock(drone.getOfferTimes());
        }
    } else {
        shouldDeliver = true;
    }
    if (shouldDeliver) {
        ItemStack usedTablet = drone.getUsedTablet();
        if (offer.getOutput() instanceof ItemStack) {
            ItemStack offeringItems = (ItemStack) offer.getOutput();
            int producedItems = offeringItems.getCount() * drone.getOfferTimes();
            List<ItemStack> stacks = new ArrayList<ItemStack>();
            while (producedItems > 0) {
                ItemStack stack = offeringItems.copy();
                stack.setCount(Math.min(producedItems, stack.getMaxStackSize()));
                stacks.add(stack);
                producedItems -= stack.getCount();
            }
            BlockPos pos = ItemAmadronTablet.getItemProvidingLocation(usedTablet);
            if (pos != null) {
                World world = DimensionManager.getWorld(ItemAmadronTablet.getItemProvidingDimension(usedTablet));
                DroneRegistry.getInstance().deliverItemsAmazonStyle(world, pos, stacks.toArray(new ItemStack[stacks.size()]));
            }
        } else {
            FluidStack offeringFluid = ((FluidStack) offer.getOutput()).copy();
            offeringFluid.amount *= drone.getOfferTimes();
            BlockPos pos = ItemAmadronTablet.getLiquidProvidingLocation(usedTablet);
            if (pos != null) {
                World world = DimensionManager.getWorld(ItemAmadronTablet.getLiquidProvidingDimension(usedTablet));
                DroneRegistry.getInstance().deliverFluidAmazonStyle(world, pos, offeringFluid);
            }
        }
    }
}
Also used : EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone) FluidStack(net.minecraftforge.fluids.FluidStack) AmadronOffer(me.desht.pneumaticcraft.common.recipes.AmadronOffer) ArrayList(java.util.ArrayList) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World) AmadronOfferCustom(me.desht.pneumaticcraft.common.recipes.AmadronOfferCustom) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 14 with EntityDrone

use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.

the class DroneAIPlace method isValidPosition.

@Override
protected boolean isValidPosition(BlockPos pos) {
    if (drone.world().isAirBlock(pos)) {
        boolean failedOnPlacement = false;
        for (int i = 0; i < drone.getInv().getSlots(); i++) {
            ItemStack droneStack = drone.getInv().getStackInSlot(i);
            if (droneStack.getItem() instanceof ItemBlock) {
                if (widget.isItemValidForFilters(droneStack)) {
                    Block placingBlock = ((ItemBlock) droneStack.getItem()).getBlock();
                    EnumFacing side = ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides());
                    if (drone.world().mayPlace(placingBlock, pos, false, side, drone instanceof EntityDrone ? (EntityDrone) drone : null)) {
                        return true;
                    } else {
                        if (drone.world().mayPlace(placingBlock, pos, true, side, drone instanceof EntityDrone ? (EntityDrone) drone : null)) {
                            drone.addDebugEntry("gui.progWidget.place.debug.cantPlaceBlock", pos);
                        } else {
                            drone.addDebugEntry("gui.progWidget.place.debug.entityInWay", pos);
                        }
                        failedOnPlacement = true;
                    }
                }
            }
        }
        if (!failedOnPlacement)
            abort();
    }
    return false;
}
Also used : EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone) EnumFacing(net.minecraft.util.EnumFacing) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 15 with EntityDrone

use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.

the class PacketUpdateDebuggingDrone method handleServerSide.

@Override
public void handleServerSide(PacketUpdateDebuggingDrone message, EntityPlayer player) {
    ItemStack stack = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
    if (!stack.isEmpty()) {
        NBTUtil.setInteger(stack, NBTKeys.PNEUMATIC_HELMET_DEBUGGING_DRONE, message.entityId);
        Entity entity = player.world.getEntityByID(message.entityId);
        if (entity instanceof EntityDrone) {
            ((EntityDrone) entity).trackAsDebugged((EntityPlayerMP) player);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EntityDrone (me.desht.pneumaticcraft.common.entity.living.EntityDrone)26 ItemStack (net.minecraft.item.ItemStack)10 Entity (net.minecraft.entity.Entity)6 BlockPos (net.minecraft.util.math.BlockPos)4 World (net.minecraft.world.World)4 AmadronOffer (me.desht.pneumaticcraft.common.recipes.AmadronOffer)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 IProgWidget (me.desht.pneumaticcraft.common.progwidgets.IProgWidget)2 Block (net.minecraft.block.Block)2 ItemBlock (net.minecraft.item.ItemBlock)2 TileEntity (net.minecraft.tileentity.TileEntity)2 EnumFacing (net.minecraft.util.EnumFacing)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 ArrayList (java.util.ArrayList)1 IEntityTrackEntry (me.desht.pneumaticcraft.api.client.pneumaticHelmet.IEntityTrackEntry)1 IGuiScreen (me.desht.pneumaticcraft.api.client.pneumaticHelmet.IGuiScreen)1 AmadronRetrievalEvent (me.desht.pneumaticcraft.api.drone.AmadronRetrievalEvent)1 EntityPathNavigateDrone (me.desht.pneumaticcraft.common.ai.EntityPathNavigateDrone)1