Search in sources :

Example 56 with ChunkPosition

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);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) ChunkPosition(net.minecraft.world.ChunkPosition) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 57 with ChunkPosition

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);
}
Also used : SpecialVariableRetrievalEvent(pneumaticCraft.api.drone.SpecialVariableRetrievalEvent) ChunkPosition(net.minecraft.world.ChunkPosition)

Example 58 with ChunkPosition

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;
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition) PathPoint(net.minecraft.pathfinding.PathPoint)

Example 59 with ChunkPosition

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;
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition) ItemStack(net.minecraft.item.ItemStack) PathPoint(net.minecraft.pathfinding.PathPoint)

Example 60 with ChunkPosition

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);
    }
}
Also used : EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) ChunkPosition(net.minecraft.world.ChunkPosition) AmadronOffer(pneumaticCraft.common.recipes.AmadronOffer) World(net.minecraft.world.World)

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