Skip to content

Commit

Permalink
+ The One Probe integration
Browse files Browse the repository at this point in the history
- NEI integration
restore original Crafting Pipe behavior
partial commit: Tools + Crafting Module JEI integration
  • Loading branch information
EJaxx committed Nov 8, 2019
1 parent 5fb46a6 commit 1a57ed9
Show file tree
Hide file tree
Showing 19 changed files with 288 additions and 65 deletions.
12 changes: 9 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ repositories {
name = "CurseForge"
url = "https://minecraft.curseforge.com/api/maven/"
}
maven { // TOP
name 'tterrag maven'
url "http://maven.tterrag.com/"
}

maven {
url "http://maven.amadornes.com/"
}
Expand All @@ -160,9 +165,10 @@ dependencies {
implementation 'MCMultiPart2:MCMultiPart:2.5.+:deobf'
deobfProvided 'mezz.jei:jei_1.12.2:4.15.0.268:api'
// already in environment because of NEI
// runtime 'mezz.jei:jei_1.12.2:4.15.0.268'
runtime 'mezz.jei:jei_1.12.2:4.15.0.268'
compile 'codechicken:CodeChickenLib:1.12.2-3.2.+:deobf'
compile 'codechicken:NotEnoughItems:1.12.2-2.4.+:deobf'
// compile 'codechicken:NotEnoughItems:1.12.2-2.4.+:deobf'
deobfCompile "mcjty.theoneprobe:TheOneProbe-1.12:1.12-1.4.28-17"
compile 'codechicken:EnderStorage:1.12.2-2.4.+:deobf'
compile 'net.industrial-craft:industrialcraft-2:2.8.97-ex112:api'
compile 'li.cil.oc:OpenComputers:MC1.12.2-1.7.+:api'
Expand All @@ -174,7 +180,7 @@ dependencies {
compile 'cofh:ThermalFoundation:1.12.2-2.6.+:deobf'
compile 'cofh:ThermalExpansion:1.12.2-5.+:deobf'
compileOnly 'dan200.computercraft:ComputerCraft:1.80pr1-build5'
deobfCompile 'thaumcraft:Thaumcraft:1.12.2:6.1.BETA26'
// deobfCompile 'thaumcraft:Thaumcraft:1.12.2:6.1.BETA26'
runtimeOnly 'baubles:Baubles:1.12:1.5.2'
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.+'
}
Expand Down
9 changes: 9 additions & 0 deletions common/logisticspipes/LPConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,13 @@ public static void loadedCoremod() {
LPConstants.COREMOD_LOADED = true;
}

public static final String ToolFilters[] = {
"GregTech Community Edition:Integrated circuit.+",
"GregTech Community Edition:Extruder Shape .+",
"GregTech Community Edition:Mold .+",
"GregTech Community Edition:.+ Lens.+",
"Logistics Pipes:Logistics Programmer.+",
"{GT.ToolStats:{.+}",
};

}
2 changes: 2 additions & 0 deletions common/logisticspipes/LogisticsPipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLFingerprintViolationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
Expand Down Expand Up @@ -329,6 +330,7 @@ public void preInit(FMLPreInitializationEvent evt) {
SimpleServiceLocator.setLogisticsFluidManager(new LogisticsFluidManager());

MainProxy.proxy.initModelLoader();
logisticspipes.utils.TOPCompatibility.register();
}

@Mod.EventHandler
Expand Down
1 change: 1 addition & 0 deletions common/logisticspipes/gui/GuiCraftingPipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public GuiCraftingPipe(EntityPlayer player, IInventory dummyInventory, ModuleCra

DummyContainer dummy = new DummyContainer(player.inventory, dummyInventory);
dummy.addNormalSlotsForPlayerInventory(8, ySize - 82);
dummy.guiHolderForJEI = this;

// Input slots
for (int l = 0; l < 9; l++) {
Expand Down
22 changes: 18 additions & 4 deletions common/logisticspipes/modplugins/jei/RecipeTransferHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandlerHelper;

import logisticspipes.gui.GuiCraftingPipe;
import logisticspipes.gui.GuiLogisticsCraftingTable;
import logisticspipes.gui.orderer.GuiRequestTable;
import logisticspipes.gui.popup.GuiRecipeImport;
Expand Down Expand Up @@ -54,15 +55,21 @@ public IRecipeTransferError transferRecipe(@Nonnull Container container, @Nonnul

LogisticsBaseGuiScreen gui = dContainer.guiHolderForJEI;

if (gui instanceof GuiLogisticsCraftingTable || gui instanceof GuiRequestTable) {
if (gui instanceof GuiLogisticsCraftingTable || gui instanceof GuiRequestTable || gui instanceof GuiCraftingPipe) {

TileEntity tile;
TileEntity tile = null;
if (gui instanceof GuiLogisticsCraftingTable) {
tile = ((GuiLogisticsCraftingTable) gui)._crafter;
} else {
}
if (gui instanceof GuiRequestTable) {
tile = ((GuiRequestTable) gui)._table.container;
}

if (gui instanceof GuiCraftingPipe) {
System.err.println(recipeLayout.getRecipeCategory().getTitle());
//return null;
}

if (tile == null) {
return recipeTransferHandlerHelper.createInternalError();
}
Expand All @@ -80,10 +87,12 @@ public IRecipeTransferError transferRecipe(@Nonnull Container container, @Nonnul
Map<Integer, ? extends IGuiIngredient<ItemStack>> guiIngredients = guiItemStackGroup.getGuiIngredients();

if (doTransfer) {
int slot = 0;
for (Map.Entry<Integer, ? extends IGuiIngredient<ItemStack>> ps : guiIngredients.entrySet()) {
if (!ps.getValue().isInput()) continue;

int slot = ps.getKey() - 1;
if (recipeLayout.getRecipeCategory().getUid().equals(VanillaRecipeCategoryUid.CRAFTING))
slot = ps.getKey() - 1;

if (slot < 9) {
stack[slot] = ps.getValue().getDisplayedIngredient();
Expand All @@ -108,6 +117,11 @@ public IRecipeTransferError transferRecipe(@Nonnull Container container, @Nonnul
}
}
}
slot++;
}

if (!recipeLayout.getRecipeCategory().getUid().equals(VanillaRecipeCategoryUid.CRAFTING)) {
return recipeTransferHandlerHelper.createInternalError();
}

if (hasCanidates) {
Expand Down
2 changes: 2 additions & 0 deletions common/logisticspipes/modplugins/nei/DebugHelper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package logisticspipes.modplugins.nei;

/*
import java.awt.BorderLayout;
import java.util.List;
import javax.swing.JFrame;
Expand Down Expand Up @@ -159,3 +160,4 @@ private void addNBTToTree(NBTBase nbt, DefaultMutableTreeNode node) throws Secur
}
}
}
*/
4 changes: 3 additions & 1 deletion common/logisticspipes/modplugins/nei/DrawHandler.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package logisticspipes.modplugins.nei;

/*
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
Expand Down Expand Up @@ -37,7 +38,7 @@ public void renderSlotUnderlay(GuiContainer gui, Slot slotActive) {
}
}
}
*/
* /
@Override
public void renderSlotOverlay(GuiContainer gui, Slot slotActive) {
//TODO: Same as above
Expand All @@ -53,3 +54,4 @@ public void renderSlotOverlay(GuiContainer gui, Slot slotActive) {
}
}
}
*/
3 changes: 2 additions & 1 deletion common/logisticspipes/modplugins/nei/LoadingHelper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package logisticspipes.modplugins.nei;

/*
import net.minecraftforge.fml.client.FMLClientHandler;
import codechicken.nei.handler.NEIClientEventHandler;
Expand All @@ -23,3 +23,4 @@ public static void LoadNeiNBTDebugHelper() {
}
}
*/
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package logisticspipes.modplugins.nei;

/*
import net.minecraftforge.fml.common.Mod;
import codechicken.nei.api.IConfigureNEI;
Expand Down Expand Up @@ -52,7 +52,7 @@ public void loadConfig() {
API.registerGuiOverlay(GuiSolderingStation.class, "solderingstation");
API.registerGuiOverlayHandler(GuiLogisticsCraftingTable.class, new LogisticsCraftingOverlayHandler(), "crafting");
API.registerGuiOverlayHandler(GuiRequestTable.class, new LogisticsCraftingOverlayHandler(), "crafting");
*/
* /
}
@Override
Expand All @@ -66,3 +66,4 @@ public String getVersion() {
}
}
*/
14 changes: 14 additions & 0 deletions common/logisticspipes/modules/ChassiModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
import java.util.ArrayList;
import java.util.List;

import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;

import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.ProbeMode;

import logisticspipes.interfaces.IInventoryUtil;
import logisticspipes.interfaces.IPipeServiceProvider;
Expand Down Expand Up @@ -34,6 +41,13 @@ public ChassiModule(int moduleCount, PipeLogisticsChassi parentChassis) {
registerPosition(ModulePositionType.IN_PIPE, 0);
}

public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
for (LogisticsModule module : modules) {
if (module instanceof ModuleCrafter)
((ModuleCrafter)module).addProbeInfo(mode, probeInfo, player, world, blockState, data);
}
}

public void installModule(int slot, LogisticsModule module) {
modules[slot] = module;
}
Expand Down
49 changes: 49 additions & 0 deletions common/logisticspipes/modules/CrafterBarrier.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;

import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;

import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.ProbeMode;
import mcjty.theoneprobe.apiimpl.styles.ItemStyle;

import logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity;
import logisticspipes.logisticspipes.IRoutedItem;
Expand All @@ -18,10 +28,28 @@
import logisticspipes.utils.item.ItemIdentifier;
import logisticspipes.utils.item.ItemIdentifierInventory;
import logisticspipes.utils.item.ItemIdentifierStack;
import network.rs485.logisticspipes.world.CoordinateUtils;
import network.rs485.logisticspipes.world.IntegerCoordinates;
import network.rs485.logisticspipes.world.WorldCoordinatesWrapper;

public class CrafterBarrier {

public Recipe current = null;
private static Map<WorldCoordinatesWrapper, CrafterBarrier> globalBarrierRegistry;

public static CrafterBarrier GetOrCreateBarrier(WorldCoordinatesWrapper wc, EnumFacing direction) {
IntegerCoordinates newCoords = CoordinateUtils.add(new IntegerCoordinates(wc.getCoords()), direction);
return GetOrCreateBarrier(new WorldCoordinatesWrapper(wc.getWorld(), newCoords));
}

public static CrafterBarrier GetOrCreateBarrier(WorldCoordinatesWrapper wc) {
CrafterBarrier value = globalBarrierRegistry.get(wc);
if (value == null) {
value = new CrafterBarrier();
globalBarrierRegistry.put(wc, value);
}
return value;
}

public static class LogisticsModuleValue {
public ModuleCrafter value = null;
Expand Down Expand Up @@ -82,6 +110,7 @@ public void tryUnlock() {
}
parent.current = null;
elements.forEach(o -> o.stack = null);
System.err.println("Unlocked (" + inventory.getIDStackInSlot(9) + ")");
}
}
}
Expand Down Expand Up @@ -218,6 +247,26 @@ public void removeOrder(LogisticsItemOrder logisticsItemOrder) {
elements.get(craftingSlot).orders.remove(logisticsItemOrder);
}
}

public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
ItemIdentifierStack res = inventory.getIDStackInSlot(9);
if (res != null)
probeInfo.text("Locked to: " + res.getItem().getFriendlyName());

Element it;
for (int i = 0; i < 9 && i < inventory.getSizeInventory(); i++) {
res = inventory.getIDStackInSlot(i);
it = elements.get(i);
if (it != null)
probeInfo
.horizontal().item(res.getItem().makeNormalStack(1), new ItemStyle().width(16).height(8)).text(res.getItem().getFriendlyName())
.text(": a" + it.arrived
+ "/t" + it.tickets.stream().mapToInt(o -> o.getItemIdentifierStack().getStackSize()).sum()
+ "/p" + it.orders.stream().filter(o -> o.getType() == IOrderInfoProvider.ResourceType.PROVIDER).mapToInt(LogisticsItemOrder::getAmount).sum()
+ "/c" + it.orders.stream().filter(o -> o.getType() != IOrderInfoProvider.ResourceType.PROVIDER).mapToInt(LogisticsItemOrder::getAmount).sum()
);
}
}
}

public static class Element {
Expand Down
24 changes: 23 additions & 1 deletion common/logisticspipes/modules/ModuleCrafter.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
import net.minecraftforge.common.util.Constants;

import lombok.Getter;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.ProbeMode;
import mcjty.theoneprobe.apiimpl.styles.ItemStyle;

import logisticspipes.LPConstants;
import logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity;
import logisticspipes.interfaces.IClientInformationProvider;
import logisticspipes.interfaces.IGuiOpenControler;
Expand Down Expand Up @@ -171,6 +176,12 @@ public ModuleCrafter(PipeItemsCraftingLogistics parent) {
_dummyInventory.addListener(myBarrierRecipe);
}

public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
ItemIdentifierStack res = _dummyInventory.getIDStackInSlot(9);
if (res != null)
probeInfo.horizontal().item(res.getItem().makeNormalStack(1), new ItemStyle().width(16).height(8)).text(res.getItem().getFriendlyName());
}

/**
* assumes that the invProvider is also IRequest items.
*/
Expand Down Expand Up @@ -599,6 +610,16 @@ public ICraftingTemplate addCrafting(IResource toCraft) {
if (resourceStack == null || resourceStack.getStackSize() == 0) {
continue;
}
boolean found = false;
for (String x : LPConstants.ToolFilters) {
ItemIdentifier it = resourceStack.getItem();
if (!x.startsWith("{"))
found |= it.toString().matches(x);
else if (it.tag != null)
found |= resourceStack.getItem().tag.toString().matches(x);
}
if (found)
continue;
IResource req;
if (getUpgradeManager().isFuzzyUpgrade() && fuzzyCraftingFlagArray[i].getBitSet().nextSetBit(0) != -1) {
DictResource dict;
Expand Down Expand Up @@ -1098,7 +1119,8 @@ public void feedOrders(ItemStack extracted, EnumFacing direction) {
continue;
}

if (nextOrder.getDestination() != null && nextOrder.getInformation() instanceof CraftingChassieInformation) {
if (nextOrder.getDestination() != null && nextOrder.getInformation() instanceof CraftingChassieInformation &&
(nextOrder.getDestination() instanceof ModuleCrafter) && ((ModuleCrafter) nextOrder.getDestination()).slot != ModulePositionType.IN_PIPE) {
CrafterBarrier.LogisticsModuleValue destModule = new CrafterBarrier.LogisticsModuleValue();
int maxToSend = CrafterBarrier.maxSend(nextOrder, extracted.getCount(), destModule, true);
if (maxToSend <= 0) {
Expand Down
1 change: 1 addition & 0 deletions common/logisticspipes/modules/ModuleProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public void tick() {
int stacksleft = stacksToExtract();
LogisticsItemOrder firstOrder = null;
LogisticsItemOrder order = null;
// if (_service.isNthTick(20))
while (itemsleft > 0 && stacksleft > 0 && _service.getItemOrderManager().hasOrders(ResourceType.PROVIDER) && (firstOrder == null || firstOrder != order)) {
if (firstOrder == null || firstOrder.getAmount() <= 0) {
firstOrder = order;
Expand Down
4 changes: 2 additions & 2 deletions common/logisticspipes/network/packets/ActivateNBTDebug.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import logisticspipes.LPConstants;
import logisticspipes.config.Configs;
import logisticspipes.modplugins.nei.LoadingHelper;
// import logisticspipes.modplugins.nei.LoadingHelper;
import logisticspipes.network.abstractpackets.ModernPacket;
import logisticspipes.utils.StaticResolve;
import network.rs485.logisticspipes.util.LPDataInput;
Expand All @@ -25,7 +25,7 @@ public void processPacket(EntityPlayer player) {
try {
Class.forName("codechicken.nei.handler.NEIClientEventHandler");
Configs.TOOLTIP_INFO = true;
LoadingHelper.LoadNeiNBTDebugHelper();
// LoadingHelper.LoadNeiNBTDebugHelper();
} catch (ClassNotFoundException ignored) {

} catch (Exception e1) {
Expand Down
Loading

0 comments on commit 1a57ed9

Please sign in to comment.