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