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;
}
}
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();
}
}
}
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);
}
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;
}
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);
}
Aggregations