use of logisticspipes.pipes.PipeBlockRequestTable in project LogisticsPipes by RS485.
the class FindMostLikelyRecipeComponents method processPacket.
@Override
public void processPacket(EntityPlayer player) {
TileEntity tile = this.getTileAs(player.getEntityWorld(), TileEntity.class);
CoreRoutedPipe pipe = null;
if (tile instanceof LogisticsCraftingTableTileEntity) {
for (EnumFacing dir : EnumFacing.VALUES) {
TileEntity conn = CoordinateUtils.add(((LogisticsCraftingTableTileEntity) tile).getLPPosition(), dir).getTileEntity(player.getEntityWorld());
if (conn instanceof LogisticsTileGenericPipe) {
if (((LogisticsTileGenericPipe) conn).pipe instanceof PipeItemsCraftingLogistics) {
pipe = (CoreRoutedPipe) ((LogisticsTileGenericPipe) conn).pipe;
break;
}
}
}
} else if (tile instanceof LogisticsTileGenericPipe) {
if (((LogisticsTileGenericPipe) tile).pipe instanceof PipeBlockRequestTable) {
pipe = (CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe;
}
}
List<Integer> list = new ArrayList<Integer>(content.size());
while (list.size() < content.size()) {
list.add(-1);
}
if (pipe == null)
return;
LinkedList<ItemIdentifier> craftable = null;
for (int j = 0; j < content.size(); j++) {
GuiRecipeImport.Canidates canidates = content.get(j);
int maxItemPos = -1;
int max = 0;
for (int i = 0; i < canidates.order.size(); i++) {
ItemIdentifier ident = canidates.order.get(i).getItem();
int newAmount = SimpleServiceLocator.logisticsManager.getAmountFor(ident, pipe.getRouter().getIRoutersByCost());
if (newAmount > max) {
max = newAmount;
maxItemPos = i;
}
}
if (max < 64) {
if (craftable == null) {
craftable = SimpleServiceLocator.logisticsManager.getCraftableItems(pipe.getRouter().getIRoutersByCost());
}
for (ItemIdentifier craft : craftable) {
for (int i = 0; i < canidates.order.size(); i++) {
ItemIdentifier ident = canidates.order.get(i).getItem();
if (craft == ident) {
maxItemPos = i;
break;
}
}
}
}
list.set(j, maxItemPos);
}
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(MostLikelyRecipeComponentsResponse.class).setResponse(list), player);
}
use of logisticspipes.pipes.PipeBlockRequestTable in project LogisticsPipes by RS485.
the class GuiHandler method getServerGuiElement.
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, final int x, final int y, final int z) {
TileEntity tile = null;
if (y != -1) {
tile = world.getTileEntity(new BlockPos(x, y, z));
}
LogisticsTileGenericPipe pipe = null;
if (tile instanceof LogisticsTileGenericPipe) {
pipe = (LogisticsTileGenericPipe) tile;
}
final LogisticsTileGenericPipe fpipe = pipe;
DummyContainer dummy;
int xOffset;
int yOffset;
if (ID > 10000) {
ID -= 10000;
}
// Handle Module Configuration
if (ID == -1) {
return getServerGuiElement(100 * -20 + x, player, world, 0, -1, z);
}
if (ID < 110 && ID > 0) {
switch(ID) {
case GuiIDs.GUI_FluidSupplier_ID:
if (pipe == null || !(pipe.pipe instanceof PipeItemsFluidSupplier)) {
return null;
}
dummy = new DummyContainer(player.inventory, ((PipeItemsFluidSupplier) pipe.pipe).getDummyInventory());
dummy.addNormalSlotsForPlayerInventory(18, 97);
xOffset = 72;
yOffset = 18;
for (int row = 0; row < 3; row++) {
for (int column = 0; column < 3; column++) {
dummy.addDummySlot(column + row * 3, xOffset + column * 18, yOffset + row * 18);
}
}
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(FluidSupplierMode.class).setInteger((((PipeItemsFluidSupplier) pipe.pipe).isRequestingPartials() ? 1 : 0)).setBlockPos(pipe.getPos()), player);
return dummy;
case GuiIDs.GUI_FluidSupplier_MK2_ID:
if (pipe == null || !(pipe.pipe instanceof PipeFluidSupplierMk2)) {
return null;
}
dummy = new DummyContainer(player.inventory, ((PipeFluidSupplierMk2) pipe.pipe).getDummyInventory());
dummy.addNormalSlotsForPlayerInventory(18, 97);
dummy.addFluidSlot(0, ((PipeFluidSupplierMk2) pipe.pipe).getDummyInventory(), 0, 0);
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(FluidSupplierMode.class).setInteger((((PipeFluidSupplierMk2) pipe.pipe).isRequestingPartials() ? 1 : 0)).setBlockPos(pipe.getPos()), player);
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(FluidSupplierMinMode.class).setInteger(((PipeFluidSupplierMk2) pipe.pipe).getMinMode().ordinal()).setBlockPos(pipe.getPos()), player);
return dummy;
case GuiIDs.GUI_SatellitePipe_ID:
if (pipe != null && pipe.pipe instanceof PipeItemsSatelliteLogistics) {
return new DummyContainer(player.inventory, null);
}
if (pipe != null && pipe.pipe instanceof PipeFluidSatellite) {
return new DummyContainer(player.inventory, null);
}
case GuiIDs.GUI_Normal_Orderer_ID:
if (pipe == null || !(pipe.pipe instanceof CoreRoutedPipe)) {
return null;
}
return new DummyContainer(player.inventory, null);
case GuiIDs.GUI_Normal_Mk2_Orderer_ID:
if (pipe == null || !(pipe.pipe instanceof PipeItemsRequestLogisticsMk2)) {
return null;
}
return new DummyContainer(player.inventory, null);
case GuiIDs.GUI_Fluid_Orderer_ID:
if (pipe == null || !(pipe.pipe instanceof PipeFluidRequestLogistics)) {
return null;
}
return new DummyContainer(player.inventory, null);
case GuiIDs.GUI_Freq_Card_ID:
if (pipe == null || !((pipe.pipe instanceof PipeItemsSystemEntranceLogistics) || (pipe.pipe instanceof PipeItemsSystemDestinationLogistics))) {
return null;
}
IInventory inv = null;
if (pipe.pipe instanceof PipeItemsSystemEntranceLogistics) {
inv = ((PipeItemsSystemEntranceLogistics) pipe.pipe).inv;
} else if (pipe.pipe instanceof PipeItemsSystemDestinationLogistics) {
inv = ((PipeItemsSystemDestinationLogistics) pipe.pipe).inv;
}
dummy = new DummyContainer(player.inventory, inv);
dummy.addRestrictedSlot(0, inv, 40, 40, itemStack -> {
if (itemStack.isEmpty()) {
return false;
}
if (itemStack.getItem() != LPItems.itemCard) {
return false;
}
return itemStack.getItemDamage() == LogisticsItemCard.FREQ_CARD;
});
dummy.addNormalSlotsForPlayerInventory(0, 0);
return dummy;
case GuiIDs.GUI_HUD_Settings:
dummy = new DummyContainer(player.inventory, null);
dummy.addRestrictedHotbarForPlayerInventory(10, 160);
dummy.addRestrictedArmorForPlayerInventory(10, 60);
return dummy;
case GuiIDs.GUI_Fluid_Basic_ID:
if (pipe == null || !((pipe.pipe instanceof PipeFluidBasic))) {
return null;
}
dummy = new DummyContainer(player, ((PipeFluidBasic) pipe.pipe).getSinkInv(), new IGuiOpenControler() {
@Override
public void guiOpenedByPlayer(EntityPlayer player) {
((PipeFluidBasic) fpipe.pipe).guiOpenedByPlayer(player);
}
@Override
public void guiClosedByPlayer(EntityPlayer player) {
((PipeFluidBasic) fpipe.pipe).guiClosedByPlayer(player);
}
});
dummy.addFluidSlot(0, ((PipeFluidBasic) pipe.pipe).getSinkInv(), 28, 15);
dummy.addNormalSlotsForPlayerInventory(10, 45);
return dummy;
case GuiIDs.GUI_Fluid_Terminus_ID:
if (pipe == null || !((pipe.pipe instanceof PipeFluidTerminus))) {
return null;
}
dummy = new DummyContainer(player, ((PipeFluidTerminus) pipe.pipe).getSinkInv(), new IGuiOpenControler() {
@Override
public void guiOpenedByPlayer(EntityPlayer player) {
((PipeFluidTerminus) fpipe.pipe).guiOpenedByPlayer(player);
}
@Override
public void guiClosedByPlayer(EntityPlayer player) {
((PipeFluidTerminus) fpipe.pipe).guiClosedByPlayer(player);
}
});
for (int i = 0; i < 9; i++) {
dummy.addFluidSlot(i, ((PipeFluidTerminus) pipe.pipe).getSinkInv(), 8 + i * 18, 13);
}
dummy.addNormalSlotsForPlayerInventory(10, 45);
return dummy;
case GuiIDs.GUI_FIREWALL:
if (pipe == null || !((pipe.pipe instanceof PipeItemsFirewall))) {
return null;
}
dummy = new DummyContainer(player.inventory, ((PipeItemsFirewall) pipe.pipe).inv);
dummy.addNormalSlotsForPlayerInventory(33, 147);
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 6; j++) {
dummy.addDummySlot(i * 6 + j, 0, 0);
}
}
return dummy;
case GuiIDs.GUI_Request_Table_ID:
if (pipe == null || !(pipe.pipe instanceof PipeBlockRequestTable)) {
return null;
}
dummy = new DummyContainer(player, ((PipeBlockRequestTable) pipe.pipe).matrix, (PipeBlockRequestTable) pipe.pipe);
int i = 0;
for (int Y = 0; Y < 3; Y++) {
for (int X = 0; X < 9; X++) {
dummy.addNormalSlot(i++, ((PipeBlockRequestTable) pipe.pipe).inv, 0, 0);
}
}
i = 0;
for (int Y = 0; Y < 3; Y++) {
for (int X = 0; X < 3; X++) {
dummy.addDummySlot(i++, 0, 0);
}
}
dummy.addCallableSlotHandler(0, ((PipeBlockRequestTable) pipe.pipe).resultInv, 0, 0, () -> ((PipeBlockRequestTable) fpipe.pipe).getResultForClick());
dummy.addNormalSlot(0, ((PipeBlockRequestTable) pipe.pipe).toSortInv, 0, 0);
dummy.addNormalSlot(0, ((PipeBlockRequestTable) pipe.pipe).diskInv, 0, 0);
dummy.addNormalSlotsForPlayerInventory(0, 0);
return dummy;
default:
break;
}
}
return null;
}
use of logisticspipes.pipes.PipeBlockRequestTable in project LogisticsPipes by RS485.
the class GuiHandler method getClientGuiElement.
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, final World world, int x, int y, int z) {
if (ID == -1) {
return getClientGuiElement(-100 * 20 + x, player, world, 0, -1, z);
}
TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
LogisticsTileGenericPipe pipe = null;
if (tile instanceof LogisticsTileGenericPipe) {
pipe = (LogisticsTileGenericPipe) tile;
}
if (ID < 110 && ID > 0) {
switch(ID) {
case GuiIDs.GUI_FluidSupplier_ID:
if (pipe == null || !(pipe.pipe instanceof PipeItemsFluidSupplier)) {
return null;
}
return new GuiFluidSupplierPipe(player.inventory, ((PipeItemsFluidSupplier) pipe.pipe).getDummyInventory(), (PipeItemsFluidSupplier) pipe.pipe);
case GuiIDs.GUI_FluidSupplier_MK2_ID:
if (pipe == null || !(pipe.pipe instanceof PipeFluidSupplierMk2)) {
return null;
}
return new GuiFluidSupplierMk2Pipe(player.inventory, ((PipeFluidSupplierMk2) pipe.pipe).getDummyInventory(), (PipeFluidSupplierMk2) pipe.pipe);
case GuiIDs.GUI_SatellitePipe_ID:
if (pipe != null && pipe.pipe instanceof SatellitePipe) {
return new GuiSatellitePipe(((SatellitePipe) pipe.pipe));
}
return null;
case GuiIDs.GUI_Normal_Orderer_ID:
return new NormalGuiOrderer(x, y, z, world.provider.getDimension(), player);
case GuiIDs.GUI_Normal_Mk2_Orderer_ID:
if (pipe == null || !(pipe.pipe instanceof PipeItemsRequestLogisticsMk2)) {
return null;
}
return new NormalMk2GuiOrderer(((PipeItemsRequestLogisticsMk2) pipe.pipe), player);
case GuiIDs.GUI_Fluid_Orderer_ID:
if (pipe == null || !(pipe.pipe instanceof PipeFluidRequestLogistics)) {
return null;
}
return new FluidGuiOrderer(((PipeFluidRequestLogistics) pipe.pipe), player);
case GuiIDs.GUI_Freq_Card_ID:
if (pipe == null || !((pipe.pipe instanceof PipeItemsSystemEntranceLogistics) || (pipe.pipe instanceof PipeItemsSystemDestinationLogistics))) {
return null;
}
IInventory inv = null;
if (pipe.pipe instanceof PipeItemsSystemEntranceLogistics) {
inv = ((PipeItemsSystemEntranceLogistics) pipe.pipe).inv;
} else if (pipe.pipe instanceof PipeItemsSystemDestinationLogistics) {
inv = ((PipeItemsSystemDestinationLogistics) pipe.pipe).inv;
}
return new GuiFreqCardContent(player, inv);
case GuiIDs.GUI_HUD_Settings:
return new GuiHUDSettings(player, x);
case GuiIDs.GUI_Fluid_Basic_ID:
if (pipe == null || !((pipe.pipe instanceof PipeFluidBasic))) {
return null;
}
return new GuiFluidBasic(player, ((PipeFluidBasic) pipe.pipe).getSinkInv());
case GuiIDs.GUI_Fluid_Terminus_ID:
if (pipe == null || !((pipe.pipe instanceof PipeFluidTerminus))) {
return null;
}
return new GuiFluidTerminus(player, ((PipeFluidTerminus) pipe.pipe));
case GuiIDs.GUI_FIREWALL:
if (pipe == null || !((pipe.pipe instanceof PipeItemsFirewall))) {
return null;
}
return new GuiFirewall((PipeItemsFirewall) pipe.pipe, player);
case GuiIDs.GUI_Request_Table_ID:
if (pipe == null || !(pipe.pipe instanceof PipeBlockRequestTable)) {
return null;
}
return new GuiRequestTable(player, ((PipeBlockRequestTable) pipe.pipe));
default:
break;
}
}
return null;
}
use of logisticspipes.pipes.PipeBlockRequestTable in project LogisticsPipes by RS485.
the class LogisticsBlockGenericPipe method collisionRayTrace.
@Override
public RayTraceResult collisionRayTrace(IBlockState state, World world, @Nonnull BlockPos pos, @Nonnull Vec3d start, @Nonnull Vec3d end) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof PipeBlockRequestTable) {
Vec3d vec3d = start.subtract(pos.getX(), pos.getY(), pos.getZ());
Vec3d vec3d1 = end.subtract(pos.getX(), pos.getY(), pos.getZ());
RayTraceResult raytraceresult = FULL_BLOCK_AABB.calculateIntercept(vec3d, vec3d1);
return raytraceresult == null ? null : new RayTraceResult(raytraceresult.hitVec.addVector(pos.getX(), pos.getY(), pos.getZ()), raytraceresult.sideHit, pos);
}
if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe == null) {
// Fallback for defect pipe
return rayTrace(pos, start, end, Block.FULL_BLOCK_AABB);
}
InternalRayTraceResult result = doRayTrace(world, pos, start, end);
if (result == null) {
return mcmpBlockAccess.collisionRayTrace(state, world, pos, start, end);
} else {
RayTraceResult secondResult = mcmpBlockAccess.collisionRayTrace(state, world, pos, start, end);
if (secondResult != null) {
if (secondResult.hitVec.distanceTo(start) < result.rayTraceResult.hitVec.distanceTo(start)) {
return secondResult;
}
}
return result.rayTraceResult;
}
}
use of logisticspipes.pipes.PipeBlockRequestTable in project LogisticsPipes by RS485.
the class LogisticsBlockGenericPipe method getSelectedBoundingBox.
@Nonnull
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, @Nonnull BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof PipeBlockRequestTable) {
return new AxisAlignedBB((double) pos.getX() + 0, (double) pos.getY() + 0, (double) pos.getZ() + 0, (double) pos.getX() + 1, (double) pos.getY() + 1, (double) pos.getZ() + 1);
}
InternalRayTraceResult rayTraceResult = doRayTrace(world, pos, Minecraft.getMinecraft().player);
if (rayTraceResult != null && rayTraceResult.boundingBox != null) {
AxisAlignedBB box = rayTraceResult.boundingBox;
if (rayTraceResult.hitPart == Part.PIPE) {
float scale = 0.001F;
box = box.expand(scale, scale, scale);
}
return box.offset(pos);
}
return super.getSelectedBoundingBox(state, world, pos);
}
Aggregations