use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.
the class HeatBehaviourLiquidTransition method transformSourceBlock.
protected void transformSourceBlock(Block turningBlockSource, Block turningBlockFlowing) {
if (FluidUtils.isSourceBlock(getWorld(), getX(), getY(), getZ())) {
getWorld().setBlock(getX(), getY(), getZ(), turningBlockSource);
onLiquidTransition(getX(), getY(), getZ());
} else {
Set<ChunkPosition> traversed = new HashSet<ChunkPosition>();
Stack<ChunkPosition> pending = new Stack<ChunkPosition>();
pending.push(new ChunkPosition(getX(), getY(), getZ()));
while (!pending.isEmpty()) {
ChunkPosition pos = pending.pop();
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
ChunkPosition newPos = new ChunkPosition(pos.chunkPosX + d.offsetX, pos.chunkPosY + d.offsetY, pos.chunkPosZ + d.offsetZ);
Block checkingBlock = getWorld().getBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ);
if ((checkingBlock == getBlock() || getBlock() == Blocks.flowing_water && checkingBlock == Blocks.water || getBlock() == Blocks.flowing_lava && checkingBlock == Blocks.lava) && traversed.add(newPos)) {
if (FluidUtils.isSourceBlock(getWorld(), newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ)) {
getWorld().setBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ, turningBlockSource);
onLiquidTransition(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ);
return;
} else {
getWorld().setBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ, turningBlockFlowing);
onLiquidTransition(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ);
pending.push(newPos);
}
}
}
}
}
}
use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.
the class CommandGetGlobalVariable method processCommand.
@Override
public void processCommand(ICommandSender sender, String[] args) {
if (sender instanceof EntityPlayerMP) {
if (args.length != 1)
throw new WrongUsageException("command.deliverAmazon.args");
String varName = args[0].startsWith("#") ? args[0].substring(1) : args[0];
ChunkPosition pos = GlobalVariableManager.getInstance().getPos(varName);
ItemStack stack = GlobalVariableManager.getInstance().getItem(varName);
NetworkHandler.sendTo(new PacketCommandGetGlobalVariableOutput(varName, pos, stack), (EntityPlayerMP) sender);
}
}
use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.
the class CommandSetGlobalVariable method processCommand.
@Override
public void processCommand(ICommandSender sender, String[] args) {
if (args.length != 4)
throw new WrongUsageException("command.deliverAmazon.args");
String varName = args[0].startsWith("#") ? args[0].substring(1) : args[0];
ChunkPosition newPos = new ChunkPosition(parseInt(sender, args[1]), parseInt(sender, args[2]), parseInt(sender, args[3]));
GlobalVariableManager.getInstance().set(varName, newPos);
sender.addChatMessage(new ChatComponentTranslation("command.setGlobalVariable.output", varName, newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ));
}
use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.
the class DroneSpecialVariableHandler method getPosForEntity.
private ChunkPosition getPosForEntity(IDrone entity) {
Vec3 pos = entity.getPosition();
int x = (int) Math.floor(pos.xCoord);
int y = (int) Math.floor(pos.yCoord) + 1;
int z = (int) Math.floor(pos.zCoord);
return new ChunkPosition(x, y, z);
}
use of net.minecraft.world.ChunkPosition in project PneumaticCraft by MineMaarten.
the class ItemGPSTool method onItemRightClick.
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (world.isRemote) {
ChunkPosition pos = getGPSLocation(stack);
FMLCommonHandler.instance().showGuiScreen(new GuiGPSTool(pos != null ? pos : new ChunkPosition(0, 0, 0), getVariable(stack)));
}
return stack;
}
Aggregations