Search in sources :

Example 81 with ChunkPosition

use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.

the class ProgWidgetForEachCoordinate method getOutputWidget.

@Override
public IProgWidget getOutputWidget(IDroneBase drone, List<IProgWidget> allWidgets) {
    List<String> locations = getPossibleJumpLocations();
    if (locations.size() > 0 && ai != null && (traversedPositions.size() == 1 || !aiManager.getCoordinate(elementVariable).equals(new ChunkPosition(0, 0, 0)))) {
        ChunkPosition pos = ai.getCurCoord();
        if (pos != null) {
            aiManager.setCoordinate(elementVariable, pos);
            return ProgWidgetJump.jumpToLabel(drone, allWidgets, locations.get(0));
        }
    }
    traversedPositions.clear();
    return super.getOutputWidget(drone, allWidgets);
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition)

Example 82 with ChunkPosition

use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.

the class AmadronOfferCustom method loadFromNBT.

public static AmadronOfferCustom loadFromNBT(NBTTagCompound tag) {
    AmadronOffer offer = AmadronOffer.loadFromNBT(tag);
    AmadronOfferCustom custom = new AmadronOfferCustom(offer.getInput(), offer.getOutput(), tag.getString("offeringPlayerName"), tag.getString("offeringPlayerId"));
    custom.inStock = tag.getInteger("inStock");
    custom.maxTrades = tag.getInteger("maxTrades");
    custom.pendingPayments = tag.getInteger("pendingPayments");
    if (tag.hasKey("providingDimensionId")) {
        custom.setProvidingPosition(new ChunkPosition(tag.getInteger("providingX"), tag.getInteger("providingY"), tag.getInteger("providingZ")), tag.getInteger("providingDimensionId"));
    }
    if (tag.hasKey("returningDimensionId")) {
        custom.setReturningPosition(new ChunkPosition(tag.getInteger("returningX"), tag.getInteger("returningY"), tag.getInteger("returningZ")), tag.getInteger("returningDimensionId"));
    }
    return custom;
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition)

Example 83 with ChunkPosition

use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.

the class AmadronOfferCustom method loadFromBuf.

public static AmadronOfferCustom loadFromBuf(ByteBuf buf) {
    AmadronOfferCustom offer = new AmadronOfferCustom(PacketSyncAmadronOffers.getFluidOrItemStack(buf), PacketSyncAmadronOffers.getFluidOrItemStack(buf), ByteBufUtils.readUTF8String(buf), ByteBufUtils.readUTF8String(buf));
    if (buf.readBoolean()) {
        offer.setProvidingPosition(new ChunkPosition(buf.readInt(), buf.readInt(), buf.readInt()), buf.readInt());
    }
    if (buf.readBoolean()) {
        offer.setReturningPosition(new ChunkPosition(buf.readInt(), buf.readInt(), buf.readInt()), buf.readInt());
    }
    offer.inStock = buf.readInt();
    offer.maxTrades = buf.readInt();
    offer.pendingPayments = buf.readInt();
    return offer;
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition)

Example 84 with ChunkPosition

use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.

the class ActionWidgetButton method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound tag, int guiLeft, int guiTop) {
    super.readFromNBT(tag, guiLeft, guiTop);
    widget = new GuiButtonSpecial(-1, tag.getInteger("x") + guiLeft, tag.getInteger("y") + guiTop, tag.getInteger("width"), tag.getInteger("height"), tag.getString("text"));
    settingCoordinate = new ChunkPosition(tag.getInteger("settingX"), tag.getInteger("settingY"), tag.getInteger("settingZ"));
    widget.setTooltipText(tag.getString("tooltip"));
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition) GuiButtonSpecial(pneumaticCraft.client.gui.GuiButtonSpecial)

Example 85 with ChunkPosition

use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.

the class TileEntityAirCannon method updateTrackedItems.

private void updateTrackedItems() {
    if (trackedItemIds != null) {
        trackedItems.clear();
        for (Entity entity : (List<Entity>) worldObj.loadedEntityList) {
            if (trackedItemIds.contains(entity.getUniqueID()) && entity instanceof EntityItem) {
                trackedItems.add((EntityItem) entity);
            }
        }
        trackedItemIds = null;
    }
    Iterator<EntityItem> iterator = trackedItems.iterator();
    while (iterator.hasNext()) {
        EntityItem item = iterator.next();
        if (item.worldObj != worldObj || item.isDead) {
            iterator.remove();
        } else {
            Map<ChunkPosition, ForgeDirection> positions = new HashMap<ChunkPosition, ForgeDirection>();
            double range = 0.2;
            for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                double posX = item.posX + d.offsetX * range;
                double posY = item.posY + d.offsetY * range;
                double posZ = item.posZ + d.offsetZ * range;
                positions.put(new ChunkPosition((int) Math.floor(posX), (int) Math.floor(posY), (int) Math.floor(posZ)), d.getOpposite());
            }
            for (Entry<ChunkPosition, ForgeDirection> entry : positions.entrySet()) {
                ChunkPosition pos = entry.getKey();
                TileEntity te = worldObj.getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
                IInventory inv = IOHelper.getInventoryForTE(te);
                ItemStack remainder = IOHelper.insert(inv, item.getEntityItem(), entry.getValue().ordinal(), false);
                if (remainder != null) {
                    item.setEntityItemStack(remainder);
                } else {
                    item.setDead();
                    iterator.remove();
                    lastInsertingInventory = new ChunkPosition(te.xCoord, te.yCoord, te.zCoord);
                    lastInsertingInventorySide = entry.getValue();
                    break;
                }
            }
        }
    }
}
Also used : IInventory(net.minecraft.inventory.IInventory) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) HashMap(java.util.HashMap) ChunkPosition(net.minecraft.world.ChunkPosition) TileEntity(net.minecraft.tileentity.TileEntity) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) NBTTagList(net.minecraft.nbt.NBTTagList) List(java.util.List) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

ChunkPosition (net.minecraft.world.ChunkPosition)94 ItemStack (net.minecraft.item.ItemStack)16 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)12 NBTTagList (net.minecraft.nbt.NBTTagList)10 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)9 TileEntity (net.minecraft.tileentity.TileEntity)9 ArrayList (java.util.ArrayList)8 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)8 HashMap (java.util.HashMap)7 HashSet (java.util.HashSet)7 Map (java.util.Map)7 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 Chunk (net.minecraft.world.chunk.Chunk)4 FluidStack (net.minecraftforge.fluids.FluidStack)4 Stack (java.util.Stack)3 Block (net.minecraft.block.Block)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 IInventory (net.minecraft.inventory.IInventory)3 PathPoint (net.minecraft.pathfinding.PathPoint)3 Vec3 (net.minecraft.util.Vec3)3