Search in sources :

Example 1 with PipeItemsRemoteOrdererLogistics

use of logisticspipes.pipes.PipeItemsRemoteOrdererLogistics in project LogisticsPipes by RS485.

the class RemoteOrderer method getPipe.

public static PipeItemsRemoteOrdererLogistics getPipe(ItemStack stack) {
    if (stack == null) {
        return null;
    }
    if (!stack.hasTagCompound()) {
        return null;
    }
    if (!stack.stackTagCompound.hasKey("connectedPipe-x") || !stack.stackTagCompound.hasKey("connectedPipe-y") || !stack.stackTagCompound.hasKey("connectedPipe-z")) {
        return null;
    }
    if (!stack.stackTagCompound.hasKey("connectedPipe-world-dim")) {
        return null;
    }
    int dim = stack.stackTagCompound.getInteger("connectedPipe-world-dim");
    World world = DimensionManager.getWorld(dim);
    if (world == null) {
        return null;
    }
    TileEntity tile = world.getTileEntity(stack.stackTagCompound.getInteger("connectedPipe-x"), stack.stackTagCompound.getInteger("connectedPipe-y"), stack.stackTagCompound.getInteger("connectedPipe-z"));
    if (!(tile instanceof LogisticsTileGenericPipe)) {
        return null;
    }
    CoreUnroutedPipe pipe = ((LogisticsTileGenericPipe) tile).pipe;
    if (pipe instanceof PipeItemsRemoteOrdererLogistics) {
        return (PipeItemsRemoteOrdererLogistics) pipe;
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) World(net.minecraft.world.World) PipeItemsRemoteOrdererLogistics(logisticspipes.pipes.PipeItemsRemoteOrdererLogistics)

Example 2 with PipeItemsRemoteOrdererLogistics

use of logisticspipes.pipes.PipeItemsRemoteOrdererLogistics in project LogisticsPipes by RS485.

the class RemoteOrderer method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    if (par1ItemStack == null) {
        return null;
    }
    if (!par1ItemStack.hasTagCompound()) {
        return par1ItemStack;
    }
    PipeItemsRemoteOrdererLogistics pipe = RemoteOrderer.getPipe(par1ItemStack);
    if (pipe != null) {
        if (MainProxy.isServer(par3EntityPlayer.worldObj)) {
            int energyUse = 0;
            if (pipe.getWorld() != par3EntityPlayer.worldObj) {
                energyUse += 2500;
            }
            energyUse += Math.sqrt(Math.pow(pipe.getX() - par3EntityPlayer.posX, 2) + Math.pow(pipe.getY() - par3EntityPlayer.posY, 2) + Math.pow(pipe.getZ() - par3EntityPlayer.posZ, 2));
            if (pipe.useEnergy(energyUse)) {
                MainProxy.sendPacketToPlayer(PacketHandler.getPacket(RequestPipeDimension.class).setInteger(MainProxy.getDimensionForWorld(pipe.getWorld())), par3EntityPlayer);
                par3EntityPlayer.openGui(LogisticsPipes.instance, GuiIDs.GUI_Normal_Orderer_ID, pipe.getWorld(), pipe.getX(), pipe.getY(), pipe.getZ());
            }
        }
    }
    return par1ItemStack;
}
Also used : PipeItemsRemoteOrdererLogistics(logisticspipes.pipes.PipeItemsRemoteOrdererLogistics)

Aggregations

PipeItemsRemoteOrdererLogistics (logisticspipes.pipes.PipeItemsRemoteOrdererLogistics)2 CoreUnroutedPipe (logisticspipes.pipes.basic.CoreUnroutedPipe)1 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)1 TileEntity (net.minecraft.tileentity.TileEntity)1 World (net.minecraft.world.World)1