Search in sources :

Example 36 with ChunkPosition

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

the class AmadronOfferCustom method fromJson.

public static AmadronOfferCustom fromJson(JsonObject json) {
    AmadronOffer offer = AmadronOffer.fromJson(json);
    if (offer != null) {
        AmadronOfferCustom custom = new AmadronOfferCustom(offer.input, offer.output, json.get("offeringPlayerName").getAsString(), json.get("offeringPlayerId").getAsString());
        custom.inStock = json.get("inStock").getAsInt();
        custom.maxTrades = json.get("maxTrades").getAsInt();
        custom.pendingPayments = json.get("pendingPayments").getAsInt();
        if (json.has("providingDimensionId")) {
            custom.providingDimensionId = json.get("providingDimensionId").getAsInt();
            custom.providingPosition = new ChunkPosition(json.get("providingX").getAsInt(), json.get("providingY").getAsInt(), json.get("providingZ").getAsInt());
        }
        if (json.has("returningDimensionId")) {
            custom.returningDimensionId = json.get("returningDimensionId").getAsInt();
            custom.returningPosition = new ChunkPosition(json.get("returningX").getAsInt(), json.get("returningY").getAsInt(), json.get("returningZ").getAsInt());
        }
        return custom;
    } else {
        return null;
    }
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition)

Example 37 with ChunkPosition

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

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, input instanceof IInventory ? (IInventory) input : null, output instanceof IInventory ? (IInventory) output : null, input instanceof IFluidHandler ? (IFluidHandler) input : null, output instanceof IFluidHandler ? (IFluidHandler) output : null, null);
            if (possiblePickups > 0) {
                ChunkPosition pos = new ChunkPosition(input.xCoord, input.yCoord, input.zCoord);
                EntityDrone drone = ContainerAmadron.retrieveOrderItems(custom, possiblePickups, input.getWorldObj(), pos, input.getWorldObj(), pos);
                if (drone != null) {
                    drone.setHandlingOffer(custom.copy(), possiblePickups, null, "Restock");
                }
            }
            custom.invert();
            custom.payout();
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) ChunkPosition(net.minecraft.world.ChunkPosition) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Example 38 with ChunkPosition

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

the class GlobalVariableManager method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound tag) {
    globalVars.clear();
    NBTTagList list = tag.getTagList("globalVars", 10);
    for (int i = 0; i < list.tagCount(); i++) {
        NBTTagCompound t = list.getCompoundTagAt(i);
        globalVars.put(t.getString("varName"), new ChunkPosition(t.getInteger("x"), t.getInteger("y"), t.getInteger("z")));
    }
    readItemVars(tag, globalItemVars);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) ChunkPosition(net.minecraft.world.ChunkPosition) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 39 with ChunkPosition

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

the class TextVariableParser method getVariableValue.

private String getVariableValue(String variable) {
    boolean x = variable.endsWith(".x");
    boolean y = variable.endsWith(".y");
    boolean z = variable.endsWith(".z");
    if (x || y || z)
        variable = variable.substring(0, variable.length() - 2);
    relevantVariables.add(variable);
    ChunkPosition pos = variableHolder != null ? variableHolder.getCoordinate(variable) : GlobalVariableManager.getInstance().getPos(variable.startsWith("#") ? variable.substring(1) : variable);
    if (x)
        return pos.chunkPosX + "";
    if (y)
        return pos.chunkPosY + "";
    if (z)
        return pos.chunkPosZ + "";
    return pos.chunkPosX + ", " + pos.chunkPosY + ", " + pos.chunkPosZ;
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition)

Example 40 with ChunkPosition

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

the class ProgWidgetCC method getMinPos.

private ChunkPosition getMinPos() {
    int x = Integer.MAX_VALUE;
    int y = Integer.MAX_VALUE;
    int z = Integer.MAX_VALUE;
    for (ChunkPosition p : area) {
        x = Math.min(p.chunkPosX, x);
        y = Math.min(p.chunkPosY, y);
        z = Math.min(p.chunkPosZ, z);
    }
    return new ChunkPosition(x, y, z);
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition)

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