Search in sources :

Example 41 with ChunkPosition

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

the class ProgWidgetCC method getEntityAreaWidget.

private ProgWidgetArea getEntityAreaWidget() {
    ProgWidgetArea widget = new ProgWidgetArea();
    ChunkPosition minPos = getMinPos();
    ChunkPosition maxPos = getMaxPos();
    widget.x1 = minPos.chunkPosX;
    widget.y1 = minPos.chunkPosY;
    widget.z1 = minPos.chunkPosZ;
    widget.x2 = maxPos.chunkPosX;
    widget.y2 = maxPos.chunkPosY;
    widget.z2 = maxPos.chunkPosZ;
    return widget;
}
Also used : ProgWidgetArea(pneumaticCraft.common.progwidgets.ProgWidgetArea) ChunkPosition(net.minecraft.world.ChunkPosition)

Example 42 with ChunkPosition

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

the class TileEntityAirCannon method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound tag) {
    super.readFromNBT(tag);
    redstonePowered = tag.getBoolean("redstonePowered");
    targetRotationAngle = tag.getFloat("targetRotationAngle");
    targetHeightAngle = tag.getFloat("targetHeightAngle");
    rotationAngle = tag.getFloat("rotationAngle");
    heightAngle = tag.getFloat("heightAngle");
    gpsX = tag.getInteger("gpsX");
    gpsY = tag.getInteger("gpsY");
    gpsZ = tag.getInteger("gpsZ");
    if (tag.hasKey("fireOnRightAngle")) {
        //TODO remove legacy
        redstoneMode = tag.getBoolean("fireOnRightAngle") ? 0 : 1;
    } else {
        redstoneMode = tag.getByte("redstoneMode");
    }
    coordWithinReach = tag.getBoolean("targetWithinReach");
    // Read in the ItemStacks in the inventory from NBT
    NBTTagList tagList = tag.getTagList("Items", 10);
    inventory = new ItemStack[getSizeInventory()];
    for (int i = 0; i < tagList.tagCount(); ++i) {
        NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
        byte slot = tagCompound.getByte("Slot");
        if (slot >= 0 && slot < inventory.length) {
            inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
        }
    }
    trackedItemIds = new HashSet<UUID>();
    tagList = tag.getTagList("trackedItems", 10);
    for (int i = 0; i < tagList.tagCount(); i++) {
        NBTTagCompound t = tagList.getCompoundTagAt(i);
        trackedItemIds.add(new UUID(t.getLong("UUIDMost"), t.getLong("UUIDLeast")));
    }
    if (tag.hasKey("inventoryX")) {
        lastInsertingInventory = new ChunkPosition(tag.getInteger("inventoryX"), tag.getInteger("inventoryY"), tag.getInteger("inventoryZ"));
        lastInsertingInventorySide = ForgeDirection.getOrientation(tag.getByte("inventorySide"));
    } else {
        lastInsertingInventory = null;
        lastInsertingInventorySide = null;
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) ChunkPosition(net.minecraft.world.ChunkPosition) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) UUID(java.util.UUID) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)

Example 43 with ChunkPosition

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

the class TileEntityKeroseneLamp method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound tag) {
    super.writeToNBT(tag);
    NBTTagList lights = new NBTTagList();
    for (ChunkPosition pos : managingLights) {
        NBTTagCompound t = new NBTTagCompound();
        t.setInteger("x", pos.chunkPosX);
        t.setInteger("y", pos.chunkPosY);
        t.setInteger("z", pos.chunkPosZ);
        lights.appendTag(t);
    }
    tag.setTag("lights", lights);
    NBTTagCompound tankTag = new NBTTagCompound();
    tank.writeToNBT(tankTag);
    tag.setTag("tank", tankTag);
    tag.setByte("redstoneMode", (byte) redstoneMode);
    tag.setByte("targetRange", (byte) targetRange);
    tag.setByte("range", (byte) range);
    tag.setByte("sideConnected", (byte) sideConnected.ordinal());
    writeInventoryToNBT(tag, inventory);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) ChunkPosition(net.minecraft.world.ChunkPosition) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 44 with ChunkPosition

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

the class TileEntityPneumaticDoorBase method shouldOpen.

private boolean shouldOpen() {
    switch(redstoneMode) {
        case 0:
        case 1:
            int range = TileEntityConstants.RANGE_PNEUMATIC_DOOR_BASE + this.getUpgrades(ItemMachineUpgrade.UPGRADE_RANGE);
            AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xCoord - range, yCoord - range, zCoord - range, xCoord + range + 1, yCoord + range + 1, zCoord + range + 1);
            List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, aabb);
            for (EntityPlayer player : players) {
                if (PneumaticCraftUtils.getProtectingSecurityStations(worldObj, xCoord, yCoord, zCoord, player, false, false) == 0) {
                    if (redstoneMode == 0) {
                        return true;
                    } else {
                        ((BlockPneumaticDoor) Blockss.pneumaticDoor).isTrackingPlayerEye = true;
                        //max range = range * sqrt(2).
                        ChunkPosition lookedPosition = PneumaticCraftUtils.getEntityLookedBlock(player, range * 1.41F);
                        ((BlockPneumaticDoor) Blockss.pneumaticDoor).isTrackingPlayerEye = false;
                        if (lookedPosition != null) {
                            if (lookedPosition.equals(new ChunkPosition(xCoord, yCoord, zCoord))) {
                                return true;
                            } else {
                                if (door != null) {
                                    if (lookedPosition.equals(new ChunkPosition(door.xCoord, door.yCoord, door.zCoord)))
                                        return true;
                                    if (lookedPosition.equals(new ChunkPosition(door.xCoord, door.yCoord + (door.getBlockMetadata() < 6 ? 1 : -1), door.zCoord)))
                                        return true;
                                }
                            }
                        }
                    }
                }
            }
            return false;
        case 2:
            return opening;
    }
    return false;
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) ChunkPosition(net.minecraft.world.ChunkPosition) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 45 with ChunkPosition

use of net.minecraft.world.ChunkPosition in project ArsMagica2 by Mithion.

the class TileEntityEverstone method propagatePoweredByEverstone.

private void propagatePoweredByEverstone(boolean powered, ArrayList<ChunkPosition> completedUpdates) {
    ChunkPosition myPosition = new ChunkPosition(xCoord, yCoord, zCoord);
    if (completedUpdates.contains(myPosition)) {
        return;
    }
    completedUpdates.add(myPosition);
    poweredFromEverstone = powered;
    onBreak();
    if (worldObj.isRemote) {
        AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "radiant", xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f);
        if (particle != null) {
            particle.setMaxAge(20);
            particle.setDontRequireControllers();
            particle.setIgnoreMaxAge(false);
        }
    }
    for (int i = -1; i <= 1; i++) {
        for (int j = -1; j <= 1; j++) {
            for (int k = -1; k <= 1; k++) {
                ChunkPosition targetPosition = new ChunkPosition(xCoord + i, yCoord + j, zCoord + k);
                Block blockID = worldObj.getBlock(targetPosition.chunkPosX, targetPosition.chunkPosY, targetPosition.chunkPosZ);
                if (blockID == BlocksCommonProxy.everstone && !completedUpdates.contains(targetPosition)) {
                    TileEntityEverstone everstone = ((TileEntityEverstone) worldObj.getTileEntity(targetPosition.chunkPosX, targetPosition.chunkPosY, targetPosition.chunkPosZ));
                    if (everstone != null)
                        everstone.propagatePoweredByEverstone(powered, completedUpdates);
                }
            }
        }
    }
}
Also used : AMParticle(am2.particles.AMParticle) ChunkPosition(net.minecraft.world.ChunkPosition) Block(net.minecraft.block.Block)

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