use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.
the class ItemSeismicSensor method onItemUse.
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) {
if (!world.isRemote) {
int testingY = y;
while (testingY > 0) {
testingY--;
if (world.getBlock(x, testingY, z) == FluidRegistry.getFluid(Fluids.oil.getName()).getBlock()) {
Set<ChunkPosition> oilPositions = new HashSet<ChunkPosition>();
Stack<ChunkPosition> pendingPositions = new Stack<ChunkPosition>();
pendingPositions.add(new ChunkPosition(x, testingY, z));
while (!pendingPositions.empty()) {
ChunkPosition checkingPos = pendingPositions.pop();
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
ChunkPosition newPos = new ChunkPosition(checkingPos.chunkPosX + d.offsetX, checkingPos.chunkPosY + d.offsetY, checkingPos.chunkPosZ + d.offsetZ);
if (world.getBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ) == Fluids.oil.getBlock() && world.getBlockMetadata(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ) == 0 && oilPositions.add(newPos)) {
pendingPositions.add(newPos);
}
}
}
player.addChatComponentMessage(new ChatComponentTranslation("message.seismicSensor.foundOilDetails", EnumChatFormatting.GREEN.toString() + (y - testingY), EnumChatFormatting.GREEN.toString() + oilPositions.size() / 10 * 10));
return true;
}
}
player.addChatComponentMessage(new ChatComponentTranslation("message.seismicSensor.noOilFound"));
}
// we don't want to use the item.
return true;
}
use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.
the class ProgWidgetAreaItemBase method updateVariables.
private boolean updateVariables() {
boolean varChanged = false;
for (Map.Entry<String, ChunkPosition> entry : areaVariableStates.entrySet()) {
ChunkPosition newValue = aiManager.getCoordinate(entry.getKey());
if (!newValue.equals(entry.getValue())) {
varChanged = true;
entry.setValue(newValue);
}
}
return varChanged;
}
use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.
the class ProgWidgetAreaItemBase method getCache.
public static IBlockAccess getCache(Collection<ChunkPosition> area, World world) {
if (area.size() == 0)
return world;
int minX, minY, minZ, maxX, maxY, maxZ;
Iterator<ChunkPosition> iterator = area.iterator();
ChunkPosition p = iterator.next();
minX = maxX = p.chunkPosX;
minY = maxY = p.chunkPosY;
minZ = maxZ = p.chunkPosZ;
while (iterator.hasNext()) {
p = iterator.next();
minX = Math.min(minX, p.chunkPosX);
minY = Math.min(minY, p.chunkPosY);
minZ = Math.min(minZ, p.chunkPosZ);
maxX = Math.max(maxX, p.chunkPosX);
maxY = Math.max(maxY, p.chunkPosY);
maxZ = Math.max(maxZ, p.chunkPosZ);
}
return new ChunkCache(world, minX, minY, minZ, maxX, maxY, maxZ, 0);
}
use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.
the class ProgWidgetCoordinateCondition method evaluate.
@Override
public boolean evaluate(IDroneBase drone, IProgWidget widget) {
ChunkPosition pos1 = ProgWidgetCoordinateOperator.calculateCoordinate(widget, 0, EnumOperator.PLUS_MINUS);
ChunkPosition pos2 = ProgWidgetCoordinateOperator.calculateCoordinate(widget, 1, EnumOperator.PLUS_MINUS);
if (checkingAxis[0] && !evaluate(pos1.chunkPosX, pos2.chunkPosX))
return false;
if (checkingAxis[1] && !evaluate(pos1.chunkPosY, pos2.chunkPosY))
return false;
if (checkingAxis[2] && !evaluate(pos1.chunkPosZ, pos2.chunkPosZ))
return false;
return true;
}
use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.
the class ItemGPSTool method getGPSLocation.
public static ChunkPosition getGPSLocation(ItemStack gpsTool) {
NBTTagCompound compound = gpsTool.stackTagCompound;
if (compound != null) {
String var = getVariable(gpsTool);
if (!var.equals("") && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
ChunkPosition pos = GlobalVariableManager.getInstance().getPos(var);
setGPSLocation(gpsTool, pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
}
int x = compound.getInteger("x");
int y = compound.getInteger("y");
int z = compound.getInteger("z");
if (x != 0 || y != 0 || z != 0) {
return new ChunkPosition(x, y, z);
} else {
return null;
}
} else {
return null;
}
}
Aggregations