Search in sources :

Example 76 with ChunkPosition

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

the class SemiBlockManager method getSemiBlock.

public ISemiBlock getSemiBlock(World world, int x, int y, int z) {
    for (ISemiBlock semiBlock : addingBlocks) {
        if (semiBlock.getWorld() == world && semiBlock.getPos().equals(new ChunkPosition(x, y, z)))
            return semiBlock;
    }
    Chunk chunk = world.getChunkFromBlockCoords(x, z);
    Map<ChunkPosition, ISemiBlock> map = semiBlocks.get(chunk);
    if (map != null) {
        return map.get(new ChunkPosition(x, y, z));
    } else {
        return null;
    }
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition) Chunk(net.minecraft.world.chunk.Chunk)

Example 77 with ChunkPosition

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

the class SemiBlockManager method setSemiBlock.

private void setSemiBlock(World world, int x, int y, int z, ISemiBlock semiBlock, Chunk chunk) {
    if (semiBlock != null && !registeredTypes.containsValue(semiBlock.getClass()))
        throw new IllegalStateException("ISemiBlock \"" + semiBlock + "\" was not registered!");
    ChunkPosition pos = new ChunkPosition(x, y, z);
    if (semiBlock != null) {
        semiBlock.initialize(world, pos);
        addingBlocks.add(semiBlock);
    } else {
        ISemiBlock removedBlock = getOrCreateMap(chunk).get(pos);
        if (removedBlock != null) {
            removedBlock.invalidate();
            for (EntityPlayerMP player : syncList.get(chunk)) {
                NetworkHandler.sendTo(new PacketSetSemiBlock(pos, null), player);
            }
        }
    }
    chunk.setChunkModified();
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) PacketSetSemiBlock(pneumaticCraft.common.network.PacketSetSemiBlock)

Example 78 with ChunkPosition

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

the class ProgWidgetCC method getMaxPos.

private ChunkPosition getMaxPos() {
    int x = Integer.MIN_VALUE;
    int y = Integer.MIN_VALUE;
    int z = Integer.MIN_VALUE;
    for (ChunkPosition p : area) {
        x = Math.max(p.chunkPosX, x);
        y = Math.max(p.chunkPosY, y);
        z = Math.max(p.chunkPosZ, z);
    }
    return new ChunkPosition(x, y, z);
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition)

Example 79 with ChunkPosition

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

the class ProgWidgetCC method getArea.

private Set<ChunkPosition> getArea(int x1, int y1, int z1, int x2, int y2, int z2, String areaType) throws IllegalArgumentException {
    ProgWidgetArea.EnumAreaType type = null;
    for (ProgWidgetArea.EnumAreaType t : ProgWidgetArea.EnumAreaType.values()) {
        if (t.toString().equals(areaType)) {
            type = t;
            break;
        }
    }
    if (type == null)
        throw new IllegalArgumentException("Invalid area type: " + areaType);
    ProgWidgetArea helperWidget = new ProgWidgetArea();
    helperWidget.x1 = x1;
    helperWidget.y1 = y1;
    helperWidget.z1 = z1;
    helperWidget.x2 = x2;
    helperWidget.y2 = y2;
    helperWidget.z2 = z2;
    helperWidget.type = type;
    Set<ChunkPosition> a = new HashSet<ChunkPosition>();
    helperWidget.getArea(a);
    return a;
}
Also used : ProgWidgetArea(pneumaticCraft.common.progwidgets.ProgWidgetArea) ChunkPosition(net.minecraft.world.ChunkPosition) HashSet(java.util.HashSet)

Example 80 with ChunkPosition

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

the class GlobalVariableManager method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound tag) {
    NBTTagList list = new NBTTagList();
    for (Map.Entry<String, ChunkPosition> entry : globalVars.entrySet()) {
        NBTTagCompound t = new NBTTagCompound();
        t.setString("varName", entry.getKey());
        ChunkPosition pos = entry.getValue();
        t.setInteger("x", pos.chunkPosX);
        t.setInteger("y", pos.chunkPosY);
        t.setInteger("z", pos.chunkPosZ);
        list.appendTag(t);
    }
    tag.setTag("globalVars", list);
    writeItemVars(tag, globalItemVars);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) ChunkPosition(net.minecraft.world.ChunkPosition) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Map(java.util.Map) HashMap(java.util.HashMap)

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