Search in sources :

Example 16 with ChunkPosition

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);
                    }
                }
            }
        }
    }
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Block(net.minecraft.block.Block) HashSet(java.util.HashSet) Stack(java.util.Stack)

Example 17 with ChunkPosition

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);
    }
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) ChunkPosition(net.minecraft.world.ChunkPosition) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) PacketCommandGetGlobalVariableOutput(pneumaticCraft.common.network.PacketCommandGetGlobalVariableOutput)

Example 18 with ChunkPosition

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));
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ChunkPosition(net.minecraft.world.ChunkPosition)

Example 19 with ChunkPosition

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);
}
Also used : Vec3(net.minecraft.util.Vec3) ChunkPosition(net.minecraft.world.ChunkPosition)

Example 20 with ChunkPosition

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;
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition) GuiGPSTool(pneumaticCraft.client.gui.GuiGPSTool)

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