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