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