use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.
the class DroneAIManager method readFromNBT.
public void readFromNBT(NBTTagCompound tag) {
coordinateVariables.clear();
NBTTagList tagList = tag.getTagList("coords", 10);
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound t = tagList.getCompoundTagAt(i);
coordinateVariables.put(t.getString("key"), new ChunkPosition(t.getInteger("x"), t.getInteger("y"), t.getInteger("z")));
}
GlobalVariableManager.readItemVars(tag, itemVariables);
}
use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.
the class DroneAIManager method getCoordinate.
public ChunkPosition getCoordinate(String varName) {
ChunkPosition pos;
if (varName.startsWith("$")) {
SpecialVariableRetrievalEvent.CoordinateVariable.Drone event = new SpecialVariableRetrievalEvent.CoordinateVariable.Drone(drone, varName.substring(1));
MinecraftForge.EVENT_BUS.post(event);
pos = event.coordinate;
} else if (varName.startsWith("#")) {
pos = GlobalVariableManager.getInstance().getPos(varName.substring(1));
} else {
pos = coordinateVariables.get(varName);
}
return pos != null ? pos : new ChunkPosition(0, 0, 0);
}
use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.
the class EntityDrone method getTargetedBlock.
public ChunkPosition getTargetedBlock() {
int x = dataWatcher.getWatchableObjectInt(14);
int y = dataWatcher.getWatchableObjectInt(15);
int z = dataWatcher.getWatchableObjectInt(16);
return x != 0 || y != 0 || z != 0 ? new ChunkPosition(x, y, z) : null;
}
use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.
the class EntityDrone method interact.
@Override
public boolean interact(EntityPlayer player) {
ItemStack equippedItem = player.getCurrentEquippedItem();
if (!worldObj.isRemote && equippedItem != null) {
if (equippedItem.getItem() == Itemss.GPSTool) {
ChunkPosition gpsLoc = ItemGPSTool.getGPSLocation(equippedItem);
if (gpsLoc != null) {
getNavigator().tryMoveToXYZ(gpsLoc.chunkPosX, gpsLoc.chunkPosY, gpsLoc.chunkPosZ, 0.1D);
}
} else {
int dyeIndex = TileEntityPlasticMixer.getDyeIndex(equippedItem);
if (dyeIndex >= 0) {
setDroneColor(ItemDye.field_150922_c[dyeIndex]);
equippedItem.stackSize--;
if (equippedItem.stackSize <= 0) {
player.setCurrentItemOrArmor(0, null);
}
}
}
}
return false;
}
use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.
the class ContainerAmadron method handleGUIButtonPress.
@Override
public void handleGUIButtonPress(int guiID, EntityPlayer player) {
super.handleGUIButtonPress(guiID, player);
if (guiID == 1) {
for (int i = 0; i < shoppingItems.length; i++) {
if (shoppingItems[i] >= 0) {
AmadronOffer offer = offers.get(shoppingItems[i]);
ChunkPosition itemPos = ItemAmadronTablet.getItemProvidingLocation(player.getCurrentEquippedItem());
World itemWorld = null;
if (itemPos == null) {
itemPos = new ChunkPosition((int) player.posX, (int) player.posY, (int) player.posZ);
itemWorld = player.worldObj;
} else {
itemWorld = PneumaticCraftUtils.getWorldForDimension(ItemAmadronTablet.getItemProvidingDimension(player.getCurrentEquippedItem()));
}
ChunkPosition liquidPos = ItemAmadronTablet.getLiquidProvidingLocation(player.getCurrentEquippedItem());
World liquidWorld = null;
if (liquidPos != null) {
liquidWorld = PneumaticCraftUtils.getWorldForDimension(ItemAmadronTablet.getLiquidProvidingDimension(player.getCurrentEquippedItem()));
}
EntityDrone drone = retrieveOrderItems(offer, shoppingAmounts[i], itemWorld, itemPos, liquidWorld, liquidPos);
if (drone != null)
drone.setHandlingOffer(offer, shoppingAmounts[i], player.getCurrentEquippedItem(), player.getCommandSenderName());
}
}
Arrays.fill(shoppingAmounts, 0);
Arrays.fill(shoppingItems, -1);
} else if (guiID == 2) {
player.openGui(PneumaticCraft.instance, CommonProxy.EnumGuiId.AMADRON_ADD_TRADE.ordinal(), player.worldObj, 0, 0, 0);
}
}
Aggregations