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