Search in sources :

Example 16 with EntityDrone

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

the class PacketSyncDroneEntityProgWidgets method handleClientSide.

@Override
public void handleClientSide(PacketSyncDroneEntityProgWidgets message, EntityPlayer player) {
    Entity entity = player.world.getEntityByID(message.entityId);
    if (entity instanceof EntityDrone) {
        EntityDrone drone = (EntityDrone) entity;
        List<IProgWidget> widgets = drone.getProgWidgets();
        widgets.clear();
        widgets.addAll(message.progWidgets);
    }
}
Also used : Entity(net.minecraft.entity.Entity) IProgWidget(me.desht.pneumaticcraft.common.progwidgets.IProgWidget) EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone)

Example 17 with EntityDrone

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

the class DroneSpecialVariableHandler method onSpecialVariableRetrieving.

@SubscribeEvent
public void onSpecialVariableRetrieving(SpecialVariableRetrievalEvent.CoordinateVariable.Drone event) {
    if (event.specialVarName.equalsIgnoreCase("owner")) {
        EntityDrone drone = (EntityDrone) event.drone;
        EntityPlayer player = drone.getOwner();
        if (player != null)
            event.coordinate = getPosForEntity(player);
    } else if (event.specialVarName.equalsIgnoreCase("drone")) {
        event.coordinate = getPosForEntity(event.drone);
    } else if (event.specialVarName.toLowerCase().startsWith("player=")) {
        EntityPlayer player = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUsername(event.specialVarName.substring("player=".length()));
        if (player != null)
            event.coordinate = getPosForEntity(player);
    }
}
Also used : EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 18 with EntityDrone

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

the class ContainerAmadron method retrieveOrderItems.

public static EntityDrone retrieveOrderItems(AmadronOffer offer, int times, World itemWorld, BlockPos itemPos, World liquidWorld, BlockPos liquidPos) {
    if (offer.getInput() instanceof ItemStack) {
        if (itemWorld == null || itemPos == null)
            return null;
        ItemStack queryingItems = (ItemStack) offer.getInput();
        int amount = queryingItems.getCount() * times;
        NonNullList<ItemStack> stacks = NonNullList.create();
        while (amount > 0) {
            ItemStack stack = queryingItems.copy();
            stack.setCount(Math.min(amount, stack.getMaxStackSize()));
            stacks.add(stack);
            amount -= stack.getCount();
        }
        return (EntityDrone) DroneRegistry.getInstance().retrieveItemsAmazonStyle(itemWorld, itemPos, stacks.toArray(new ItemStack[stacks.size()]));
    } else {
        if (liquidWorld == null || liquidPos == null)
            return null;
        FluidStack queryingFluid = ((FluidStack) offer.getInput()).copy();
        queryingFluid.amount *= times;
        return (EntityDrone) DroneRegistry.getInstance().retrieveFluidAmazonStyle(liquidWorld, liquidPos, queryingFluid);
    }
}
Also used : EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone) FluidStack(net.minecraftforge.fluids.FluidStack) ItemStack(net.minecraft.item.ItemStack)

Example 19 with EntityDrone

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

the class TileEntityDroneInterface method handleUpdateTag.

@Override
public void handleUpdateTag(NBTTagCompound tag) {
    Entity entity = getWorld().getEntityByID(tag.getInteger("drone"));
    drone = entity instanceof EntityDrone ? (EntityDrone) entity : null;
}
Also used : SPacketUpdateTileEntity(net.minecraft.network.play.server.SPacketUpdateTileEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone)

Example 20 with EntityDrone

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

the class DroneAIPlace method doBlockInteraction.

// TODO 1.8 test
@Override
protected boolean doBlockInteraction(BlockPos pos, double distToBlock) {
    if (drone.getPathNavigator().hasNoPath()) {
        EnumFacing side = ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides());
        for (int i = 0; i < drone.getInv().getSlots(); i++) {
            ItemStack droneStack = drone.getInv().getStackInSlot(i);
            if (droneStack.getItem() instanceof ItemBlock && ((ItemBlock) droneStack.getItem()).getBlock().canPlaceBlockOnSide(drone.world(), pos, ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides()))) {
                if (widget.isItemValidForFilters(droneStack)) {
                    ItemBlock itemBlock = (ItemBlock) droneStack.getItem();
                    Block block = itemBlock.getBlock();
                    if (drone.world().mayPlace(block, pos, false, side, drone instanceof EntityDrone ? (EntityDrone) drone : null)) {
                        int newMeta = itemBlock.getMetadata(droneStack.getMetadata());
                        setFakePlayerAccordingToDir();
                        IBlockState iblockstate1 = block.getStateForPlacement(drone.world(), pos, side, side.getFrontOffsetX(), side.getFrontOffsetY(), side.getFrontOffsetZ(), newMeta, drone.getFakePlayer(), EnumHand.MAIN_HAND);
                        if (itemBlock.placeBlockAt(droneStack, drone.getFakePlayer(), drone.world(), pos, side, side.getFrontOffsetX(), side.getFrontOffsetY(), side.getFrontOffsetZ(), iblockstate1)) {
                            drone.addAir(null, -PneumaticValues.DRONE_USAGE_PLACE);
                            SoundType soundType = block.getSoundType(iblockstate1, drone.world(), pos, drone.getFakePlayer());
                            drone.world().playSound(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, soundType.getPlaceSound(), SoundCategory.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F, false);
                            droneStack.shrink(1);
                            if (droneStack.getCount() <= 0) {
                                drone.getInv().setStackInSlot(i, ItemStack.EMPTY);
                            }
                        }
                        return false;
                    }
                }
            }
        }
        return false;
    } else {
        return true;
    }
}
Also used : SoundType(net.minecraft.block.SoundType) IBlockState(net.minecraft.block.state.IBlockState) 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)

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