From 3dc8449a60cd97742720aa73f3bcc78fe9efe7ce Mon Sep 17 00:00:00 2001 From: tom5454 Date: Sun, 2 Aug 2020 20:01:07 +0200 Subject: [PATCH] 1.3.9 Upgrade Added blocking mode to Crafting Manager Pipe Fixed crash with Bridge Pipe #33 Fixed crash with Crafting Manager Gui Improved tooltips Fixes #32 Fixes #31 --- build.gradle | 2 +- .../tom/logisticsbridge/LogisticsBridge.java | 2 +- .../gui/GuiCraftingManager.java | 42 ++++- .../module/ModuleCrafterExt.java | 18 ++ .../tom/logisticsbridge/pipe/BridgePipe.java | 114 +++++++----- .../logisticsbridge/pipe/CraftingManager.java | 176 ++++++++++++++++-- .../tom/logisticsbridge/pipe/ResultPipe.java | 4 + .../assets/logisticsbridge/lang/en_us.lang | 25 ++- version-check.json | 5 +- 9 files changed, 312 insertions(+), 76 deletions(-) diff --git a/build.gradle b/build.gradle index 4e1a204..1622027 100644 --- a/build.gradle +++ b/build.gradle @@ -49,7 +49,7 @@ dependencies { compileOnly group: 'cofh', name: 'ThermalDynamics', version: '1.12.2-2.5.5.21', classifier: 'deobf', transitive: false compileOnly group: 'refinedstorage', name: 'refinedstorage', version: '1.6.16-386', transitive: false compileOnly group: 'codechicken', name: 'NotEnoughItems', version: '1.12.2-2.4.3.245', classifier: 'deobf', transitive: false - compileOnly group: 'appeng', name: 'appliedenergistics2', version: 'rv6-stable-7', classifier: 'deobf', transitive: false + compileOnly group: 'appeng', name: 'appliedenergistics2', version: 'rv6-stable-7', transitive: false } tasks.withType(Wrapper) { diff --git a/src/main/java/com/tom/logisticsbridge/LogisticsBridge.java b/src/main/java/com/tom/logisticsbridge/LogisticsBridge.java index 3b36209..14dadeb 100644 --- a/src/main/java/com/tom/logisticsbridge/LogisticsBridge.java +++ b/src/main/java/com/tom/logisticsbridge/LogisticsBridge.java @@ -77,7 +77,7 @@ public class LogisticsBridge { public static final String ID = "logisticsbridge"; public static final String NAME = "Logistics Bridge"; - public static final String VERSION = "1.3.8"; + public static final String VERSION = "1.3.9"; public static final String DEPS = "after:appliedenergistics2;after:refinedstorage@[1.6.15,);required-after:logisticspipes@[0.10.3.39,)"; public static final String UPDATE = "https://github.com/tom5454/LogisticsBridge/blob/master/version-check.json"; public static final Logger log = LogManager.getLogger(NAME); diff --git a/src/main/java/com/tom/logisticsbridge/gui/GuiCraftingManager.java b/src/main/java/com/tom/logisticsbridge/gui/GuiCraftingManager.java index cba588c..655a0a3 100644 --- a/src/main/java/com/tom/logisticsbridge/gui/GuiCraftingManager.java +++ b/src/main/java/com/tom/logisticsbridge/gui/GuiCraftingManager.java @@ -13,6 +13,7 @@ import net.minecraft.client.renderer.RenderItem; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.inventory.ClickType; import net.minecraft.inventory.InventoryBasic; import net.minecraft.inventory.Slot; @@ -27,6 +28,7 @@ import com.tom.logisticsbridge.inventory.ContainerCraftingManager; import com.tom.logisticsbridge.inventory.ContainerCraftingManager.SlotCraftingCard; import com.tom.logisticsbridge.pipe.CraftingManager; +import com.tom.logisticsbridge.pipe.CraftingManager.BlockingMode; import logisticspipes.LPItems; import logisticspipes.modules.LogisticsModule; @@ -192,6 +194,28 @@ public void initGui() { ce = new ConfigExtention(StringUtils.translate("gui.craftingManager.result"), new ItemStack(LogisticsBridge.pipeResult), 1); ce.registerButton(extentionControllerLeft.registerControlledButton(addButton(new SmallGuiButton(2, guiLeft - 45, guiTop + 25, 40, 10, select)))); extentionControllerLeft.addExtention(ce); + + if(pipe.getBlockingMode() != BlockingMode.NULL) { + ce = new ConfigExtention(StringUtils.translate("gui.craftingManager.blocking"), new ItemStack(Blocks.BARRIER), 2) { + + @Override + public String getString() { + return StringUtils.translate("gui.craftingManager.blocking." + pipe.getBlockingMode().name().toLowerCase()); + } + + @Override + public int textOff() { + return 70; + } + + @Override + public int getFinalWidth() { + return 140; + } + }; + ce.registerButton(extentionControllerLeft.registerControlledButton(addButton(new SmallGuiButton(4, guiLeft - 45, guiTop + 11, 40, 10, StringUtils.translate("gui.craftingManager.blocking.change"))))); + extentionControllerLeft.addExtention(ce); + } } @Override protected void actionPerformed(GuiButton button) throws IOException { @@ -202,6 +226,12 @@ protected void actionPerformed(GuiButton button) throws IOException { case 2: openSubGuiForSatelliteSelection(1); return; + + case 4: + BlockingMode m = BlockingMode.VALUES[(pipe.getBlockingMode().ordinal() + 1) % BlockingMode.VALUES.length]; + if(m == BlockingMode.NULL)m = BlockingMode.OFF; + pipe.setPipeID(2, Integer.toString(m.ordinal()), null); + return; } } public RenderItem renderItem() { @@ -231,7 +261,7 @@ public int getFinalHeight() { @Override public void renderForground(int left, int top) { - String pid = pipe.getPipeID(id); + String pid = getString(); if (!isFullyExtended()) { GL11.glEnable(GL12.GL_RESCALE_NORMAL); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F); @@ -248,10 +278,18 @@ public void renderForground(int left, int top) { if (pid == null || pid.isEmpty()) { mc.fontRenderer.drawString(StringUtils.translate("gui.craftingManager.noConnection"), left + 40, top + 22, 0x404040); } else { - mc.fontRenderer.drawString(pid, left + 40 - mc.fontRenderer.getStringWidth(pid)/2, top + 22, 0x404040); + mc.fontRenderer.drawString(pid, left + textOff() - mc.fontRenderer.getStringWidth(pid)/2, top + 22, 0x404040); } } } + + public String getString() { + return pipe.getPipeID(id); + } + + public int textOff() { + return 40; + } } private void openSubGuiForSatelliteSelection(int id) { this.setSubGui(new GuiSelectIDPopup(new BlockPos(this.pipe.getX(), this.pipe.getY(), this.pipe.getZ()), id, 0, diff --git a/src/main/java/com/tom/logisticsbridge/module/ModuleCrafterExt.java b/src/main/java/com/tom/logisticsbridge/module/ModuleCrafterExt.java index aab0bf3..3066eef 100644 --- a/src/main/java/com/tom/logisticsbridge/module/ModuleCrafterExt.java +++ b/src/main/java/com/tom/logisticsbridge/module/ModuleCrafterExt.java @@ -15,8 +15,10 @@ import logisticspipes.interfaces.routing.IFilter; import logisticspipes.interfaces.routing.IRequestFluid; import logisticspipes.interfaces.routing.IRequestItems; +import logisticspipes.modules.ChassiModule; import logisticspipes.modules.ModuleCrafter; import logisticspipes.pipes.basic.CoreRoutedPipe; +import logisticspipes.proxy.MainProxy; import logisticspipes.proxy.SimpleServiceLocator; import logisticspipes.request.DictCraftingTemplate; import logisticspipes.request.ICraftingTemplate; @@ -326,6 +328,22 @@ public void enabledUpdateEntity() { return; } } + + @Override + public void guiClosedByPlayer(EntityPlayer player) { + super.guiClosedByPlayer(player); + if(MainProxy.isClient(_world.getWorld()))return; + if(!(_service instanceof CraftingManager))return; + CraftingManager mngr = (CraftingManager) _service; + ChassiModule m = mngr.getModules(); + for(int i = 0;i<27;i++) { + if(m.getModule(i) == this) { + mngr.save(i); + break; + } + } + } + public static class BufferInformation extends CraftingChassieInformation { public BufferInformation(int craftingSlot, int moduleSlot) { diff --git a/src/main/java/com/tom/logisticsbridge/pipe/BridgePipe.java b/src/main/java/com/tom/logisticsbridge/pipe/BridgePipe.java index 42dcd9e..c2ec46d 100644 --- a/src/main/java/com/tom/logisticsbridge/pipe/BridgePipe.java +++ b/src/main/java/com/tom/logisticsbridge/pipe/BridgePipe.java @@ -25,6 +25,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumFacing.Axis; import net.minecraft.util.text.TextComponentTranslation; import com.tom.logisticsbridge.LogisticsBridge; @@ -485,14 +486,14 @@ public List getCraftedItems() { collect(Collectors.toList()); } public class Req { - private boolean gettingProvItems; + private boolean alreadyProcessing; public List getProvidedItems() { - if(gettingProvItems || !isEnabled())return Collections.emptyList(); + if(alreadyProcessing || !isEnabled())return Collections.emptyList(); if (stillNeedReplace()) { return new ArrayList<>(); } try { - gettingProvItems = true; + alreadyProcessing = true; IRouter myRouter = getRouter(); List exits = new ArrayList<>(myRouter.getIRoutersByCost()); exits.removeIf(e -> e.destination == myRouter); @@ -504,72 +505,82 @@ public List getProvidedItems() { } return list; } finally { - gettingProvItems = false; + alreadyProcessing = false; } } public List getCraftedItems() { - if(!isEnabled())return Collections.emptyList(); + if(alreadyProcessing || !isEnabled())return Collections.emptyList(); if (stillNeedReplace()) { return new ArrayList<>(); } - IRouter myRouter = getRouter(); - List exits = new ArrayList<>(myRouter.getIRoutersByCost()); - exits.removeIf(e -> e.destination == myRouter); - LinkedList items = SimpleServiceLocator.logisticsManager.getCraftableItems(exits); - List list = new ArrayList<>(items.size()); - for (ItemIdentifier item : items) { - ItemStack is = item.unsafeMakeNormalStack(1); - list.add(is); + try { + alreadyProcessing = true; + IRouter myRouter = getRouter(); + List exits = new ArrayList<>(myRouter.getIRoutersByCost()); + exits.removeIf(e -> e.destination == myRouter); + LinkedList items = SimpleServiceLocator.logisticsManager.getCraftableItems(exits); + List list = new ArrayList<>(items.size()); + for (ItemIdentifier item : items) { + ItemStack is = item.unsafeMakeNormalStack(1); + list.add(is); + } + return list; + } finally { + alreadyProcessing = false; } - return list; } /** * @param craft bits: processExtra,onlyCraft,enableCraft * */ public OpResult simulateRequest(ItemStack wanted, int craft, boolean allowPartial) { - if(!isEnabled()){ + if(!isEnabled() || alreadyProcessing){ OpResult r = new OpResult(); r.used = Collections.emptyList(); r.missing = Collections.singletonList(wanted); return r; } - IRouter myRouter = getRouter(); - List exits = new ArrayList<>(myRouter.getIRoutersByCost()); - exits.removeIf(e -> e.destination == myRouter); - Map items = SimpleServiceLocator.logisticsManager.getAvailableItems(exits); - ItemIdentifier req = ItemIdentifier.get(wanted); - int count = items.getOrDefault(req, 0); - if(count == 0 && craft == 0){ - OpResult r = new OpResult(); - r.used = Collections.emptyList(); - r.missing = Collections.singletonList(wanted); - return r; - } - ListLog ll = new ListLog(); - /*System.out.println("BridgePipe.Req.simulateRequest()"); + alreadyProcessing = true; + try { + IRouter myRouter = getRouter(); + List exits = new ArrayList<>(myRouter.getIRoutersByCost()); + exits.removeIf(e -> e.destination == myRouter); + Map items = SimpleServiceLocator.logisticsManager.getAvailableItems(exits); + ItemIdentifier req = ItemIdentifier.get(wanted); + int count = items.getOrDefault(req, 0); + if(count == 0 && craft == 0){ + OpResult r = new OpResult(); + r.used = Collections.emptyList(); + r.missing = Collections.singletonList(wanted); + return r; + } + ListLog ll = new ListLog(); + /*System.out.println("BridgePipe.Req.simulateRequest()"); System.out.println(wanted);*/ - ItemIdentifierStack item = ItemIdentifier.get(wanted).makeStack(craft != 0 ? wanted.getCount() : Math.min(count, wanted.getCount())); - ItemResource reqRes = new ItemResource(item, BridgePipe.this); - RequestTree tree = new RequestTree(reqRes, null, (craft & 0b0010) != 0 ? EnumSet.of(ActiveRequestType.Craft) : RequestTree.defaultRequestFlags, null); - if (!tree.isDone()) { - recurseFailedRequestTree.accept(tree); - } - tree.sendUsedMessage(ll); - OpResult res = ll.asResult(); - if((craft & 0b0100) != 0 && isDefaultRoute){ - List extrasPromises = new ArrayList<>(); - listExras(tree, extrasPromises); - res.extra = extrasPromises.stream().map(e -> e.getItemType().makeNormalStack(e.getAmount())).collect(Collectors.toList()); - } - if(craft == 0 && !allowPartial && wanted.getCount() > count){ - int missingCount = wanted.getCount() - count; - ItemStack missingStack = wanted.copy(); - missingStack.setCount(missingCount); - res.missing.add(missingStack); - } + ItemIdentifierStack item = ItemIdentifier.get(wanted).makeStack(craft != 0 ? wanted.getCount() : Math.min(count, wanted.getCount())); + ItemResource reqRes = new ItemResource(item, BridgePipe.this); + RequestTree tree = new RequestTree(reqRes, null, (craft & 0b0010) != 0 ? EnumSet.of(ActiveRequestType.Craft) : RequestTree.defaultRequestFlags, null); + if (!tree.isDone()) { + recurseFailedRequestTree.accept(tree); + } + tree.sendUsedMessage(ll); + OpResult res = ll.asResult(); + if((craft & 0b0100) != 0 && isDefaultRoute){ + List extrasPromises = new ArrayList<>(); + listExras(tree, extrasPromises); + res.extra = extrasPromises.stream().map(e -> e.getItemType().makeNormalStack(e.getAmount())).collect(Collectors.toList()); + } + if(craft == 0 && !allowPartial && wanted.getCount() > count){ + int missingCount = wanted.getCount() - count; + ItemStack missingStack = wanted.copy(); + missingStack.setCount(missingCount); + res.missing.add(missingStack); + } - return res; + return res; + } finally { + alreadyProcessing = false; + } } public OpResult performRequest(ItemStack wanted, boolean craft) { @@ -739,4 +750,9 @@ public void onWrenchClicked(EntityPlayer entityplayer) { new TextComponentTranslation("gui.itemsink." + (isDefaultRoute ? "Yes" : "No")))); } } + + @Override + public boolean disconnectPipe(TileEntity tile, EnumFacing dir) { + return dir.getAxis() == Axis.Y && tile instanceof IBridge ? true : false; + } } diff --git a/src/main/java/com/tom/logisticsbridge/pipe/CraftingManager.java b/src/main/java/com/tom/logisticsbridge/pipe/CraftingManager.java index 165ce7f..aba61a2 100644 --- a/src/main/java/com/tom/logisticsbridge/pipe/CraftingManager.java +++ b/src/main/java/com/tom/logisticsbridge/pipe/CraftingManager.java @@ -45,10 +45,13 @@ import logisticspipes.network.PacketHandler; import logisticspipes.network.abstractpackets.ModernPacket; import logisticspipes.network.guis.pipe.ChassiGuiProvider; +import logisticspipes.pipefxhandlers.Particles; import logisticspipes.pipes.PipeItemsSatelliteLogistics; import logisticspipes.pipes.PipeLogisticsChassi; +import logisticspipes.pipes.upgrades.UpgradeManager; import logisticspipes.proxy.MainProxy; import logisticspipes.proxy.SimpleServiceLocator; +import logisticspipes.routing.IRouter; import logisticspipes.security.SecuritySettings; import logisticspipes.textures.Textures; import logisticspipes.textures.Textures.TextureType; @@ -61,8 +64,17 @@ public class CraftingManager extends PipeLogisticsChassi implements IIdPipe { public static TextureType TEXTURE = Textures.empty; public String satelliteId, resultId; private UUID satelliteUUID, resultUUID; + private BlockingMode blockingMode = BlockingMode.OFF; + private int sendCooldown = 0; + public CraftingManager(Item item) { super(item); + upgradeManager = new UpgradeManager(this) { + @Override + public boolean hasUpgradeModuleUpgrade() { + return false;//Crashes with gui + } + }; } @Override @@ -112,6 +124,7 @@ public void InventoryChanged(IInventory inventory) { } } } + public LogisticsModule getModuleForItem(ItemStack itemStack, LogisticsModule currentModule, IWorldProvider world, IPipeServiceProvider service) { if (itemStack == null) { return null; @@ -140,6 +153,7 @@ public boolean handleClick(EntityPlayer entityplayer, SecuritySettings settings) handleClick0(entityplayer, settings); return true; } + private boolean handleClick0(EntityPlayer entityplayer, SecuritySettings settings) { if (entityplayer.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND).isEmpty()) { return false; @@ -194,16 +208,20 @@ private boolean tryInsertingModule(EntityPlayer entityplayer) { } return false; } + public static boolean isCraftingModule(ItemStack itemStack){ return itemStack.getItem() == Item.REGISTRY.getObject(LPItems.modules.get(ModuleCrafter.getName())); } + public boolean isUpgradeModule(ItemStack itemStack, int slot){ return ChassiGuiProvider.checkStack(itemStack, this, slot); } public void openGui(EntityPlayer entityPlayer) { + ModernPacket packet = PacketHandler.getPacket(SetIDPacket.class).setName(isBuffered() ? Integer.toString(blockingMode.ordinal()) : "0").setId(2).setPosX(getX()).setPosY(getY()).setPosZ(getZ()); + MainProxy.sendPacketToPlayer(packet, entityPlayer); entityPlayer.openGui(LogisticsBridge.modInstance, GuiIDs.CraftingManager.ordinal(), getWorld(), getX(), getY(), getZ()); - ModernPacket packet = PacketHandler.getPacket(SetIDPacket.class).setName(satelliteId).setId(0).setPosX(getX()).setPosY(getY()).setPosZ(getZ()); + packet = PacketHandler.getPacket(SetIDPacket.class).setName(satelliteId).setId(0).setPosX(getX()).setPosY(getY()).setPosZ(getZ()); MainProxy.sendPacketToPlayer(packet, entityPlayer); packet = PacketHandler.getPacket(SetIDPacket.class).setName(resultId).setId(1).setPosX(getX()).setPosY(getY()).setPosZ(getZ()); MainProxy.sendPacketToPlayer(packet, entityPlayer); @@ -211,7 +229,7 @@ public void openGui(EntityPlayer entityPlayer) { @Override public String getPipeID(int id) { - return id == 0 ? satelliteId : resultId; + return id == 0 ? satelliteId : id == 1 ? resultId : Integer.toString(blockingMode.ordinal()); } @Override @@ -226,13 +244,15 @@ public void setPipeID(int id, String pipeID, EntityPlayer player) { resultUUID = null; } if(id == 0)satelliteId = pipeID; - else resultId = pipeID; + else if(id == 1)resultId = pipeID; + else if(id == 2)blockingMode = BlockingMode.VALUES[Math.abs(pipeID.charAt(0) - '0') % BlockingMode.VALUES.length]; } @Override public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); if(resultId != null)nbttagcompound.setString("resultname", resultId); if(satelliteId != null)nbttagcompound.setString("satellitename", satelliteId); + nbttagcompound.setByte("blockingMode", (byte) blockingMode.ordinal()); } @Override public void readFromNBT(NBTTagCompound nbttagcompound) { @@ -243,6 +263,7 @@ public void readFromNBT(NBTTagCompound nbttagcompound) { resultId = Integer.toString(nbttagcompound.getInteger("resultid")); satelliteId = Integer.toString(nbttagcompound.getInteger("satelliteid")); } + blockingMode = BlockingMode.VALUES[Math.abs(nbttagcompound.getByte("blockingMode")) % BlockingMode.VALUES.length]; } @Override public void collectSpecificInterests(Collection itemidCollection) { @@ -338,33 +359,103 @@ public void addBuffered(List> rec) { buffered.add(rec); } + public IRouter getSatelliteRouterByID(UUID id) { + if(id == null)return null; + int satelliteRouterId = SimpleServiceLocator.routerManager.getIDforUUID(id); + return SimpleServiceLocator.routerManager.getRouter(satelliteRouterId); + } + + public IRouter getResultRouterByID(UUID id) { + if(id == null)return null; + int resultRouterId = SimpleServiceLocator.routerManager.getIDforUUID(id); + return SimpleServiceLocator.routerManager.getRouter(resultRouterId); + } + + private boolean checkBlocking() { + switch (blockingMode) { + case EMPTY_MAIN_SATELLITE: + { + IRouter defSat = getSatelliteRouterByID(getSatelliteUUID()); + if(defSat == null)return false; + if(!(defSat.getPipe() instanceof PipeItemsSatelliteLogistics))return false; + IInventoryUtil inv = ((PipeItemsSatelliteLogistics) defSat.getPipe()).getPointedInventory(); + if (inv != null) { + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stackInSlot = inv.getStackInSlot(i); + if (!stackInSlot.isEmpty()) { + return false; + } + } + } + return true; + } + + case REDSTONE_HIGH: + if(!getWorld().isBlockPowered(getPos()))return false; + return true; + + case REDSTONE_LOW: + if(getWorld().isBlockPowered(getPos()))return false; + return true; + + /*case WAIT_FOR_RESULT://TODO broken + { + IRouter resultR = getResultRouterByID(getResultUUID()); + if(resultR == null)return false; + if(!(resultR.getPipe() instanceof ResultPipe))return false; + if(((ResultPipe) resultR.getPipe()).hasRequests())return false; + return true; + }*/ + + default: + return true; + } + } + @Override public void enabledUpdateEntity() { super.enabledUpdateEntity(); if(!isNthTick(5))return; - if(!buffered.isEmpty() && isBuffered()) { - final NeighborTileEntity pointedItemHandler = getPointedItemHandler(); - if(canUseEnergy(neededEnergy()) && pointedItemHandler != null && pointedItemHandler.isItemHandler()){ - IInventoryUtil util = pointedItemHandler.getInventoryUtil(); - for (List> map : buffered) { - if(map.stream().map(Pair::getValue).allMatch(i -> util.itemCount(i.getItem()) >= i.getStackSize())){ - for (Pair en : map) { - ItemIdentifierStack toSend = en.getValue(); - ItemStack removed = util.getMultipleItems(toSend.getItem(), toSend.getStackSize()); - if (removed != null && !removed.isEmpty()) { - sendStack(removed, en.getKey().getID(), ItemSendMode.Fast, null); + if(isBuffered()) { + if(sendCooldown > 0) { + spawnParticle(Particles.RedParticle, 1); + sendCooldown--; + return; + } + if(blockingMode == BlockingMode.NULL)blockingMode = BlockingMode.OFF; + if(!buffered.isEmpty()) { + boolean allow = checkBlocking(); + if(!allow) { + spawnParticle(Particles.RedParticle, 1); + return; + } + final NeighborTileEntity pointedItemHandler = getPointedItemHandler(); + if(canUseEnergy(neededEnergy()) && pointedItemHandler != null && pointedItemHandler.isItemHandler()){ + IInventoryUtil util = pointedItemHandler.getInventoryUtil(); + for (List> map : buffered) { + if(map.stream().map(Pair::getValue).allMatch(i -> util.itemCount(i.getItem()) >= i.getStackSize())){ + int maxDist = 0; + for (Pair en : map) { + ItemIdentifierStack toSend = en.getValue(); + ItemStack removed = util.getMultipleItems(toSend.getItem(), toSend.getStackSize()); + if (removed != null && !removed.isEmpty()) { + sendStack(removed, en.getKey().getID(), ItemSendMode.Fast, null); + maxDist = Math.max(maxDist, (int) en.getKey().getRouter().getPipe().getPos().distanceSq(getPos())); + } } + useEnergy(neededEnergy(), true); + buffered.remove(map); + if(blockingMode == BlockingMode.EMPTY_MAIN_SATELLITE)sendCooldown = Math.min(maxDist, 16); + break; } - useEnergy(neededEnergy(), true); - buffered.remove(map); - break; } } } } } + /*private int sendStack(ItemIdentifierStack stack, IRequestItems dest, IInventoryUtil util, IAdditionalTargetInformation info, EnumFacing dir) { ItemIdentifier item = stack.getItem(); @@ -405,4 +496,55 @@ public void enabledUpdateEntity() { private int neededEnergy() { return 20; } + + public void save(int i) { + ItemStack st = getModuleInventory().getStackInSlot(i); + if(!st.isEmpty()) { + ItemModuleInformationManager.saveInformation(st, getModules().getModule(i)); + getModuleInventory().setInventorySlotContents(i, st); + } + } + + public static enum BlockingMode { + NULL, + OFF, + //WAIT_FOR_RESULT, + EMPTY_MAIN_SATELLITE, + REDSTONE_LOW, + REDSTONE_HIGH, + ; + public static final BlockingMode[] VALUES = values(); + } + + public BlockingMode getBlockingMode() { + return blockingMode; + } + + /*public class Origin implements IAdditionalTargetInformation { + private final IAdditionalTargetInformation old; + public Origin(IAdditionalTargetInformation old) { + this.old = old; + } + + public void onSent() { + canSendNext = true; + } + + public IAdditionalTargetInformation getOld() { + return old; + } + } + + public IAdditionalTargetInformation wrap(IAdditionalTargetInformation old) { + return new Origin(old); + } + + public static IAdditionalTargetInformation unwrap(IAdditionalTargetInformation info, boolean doFinish) { + if(info instanceof Origin) { + Origin o = (Origin) info; + if(doFinish)o.onSent(); + return o.old; + } + return info; + }*/ } diff --git a/src/main/java/com/tom/logisticsbridge/pipe/ResultPipe.java b/src/main/java/com/tom/logisticsbridge/pipe/ResultPipe.java index 56e4e3d..8a589b2 100644 --- a/src/main/java/com/tom/logisticsbridge/pipe/ResultPipe.java +++ b/src/main/java/com/tom/logisticsbridge/pipe/ResultPipe.java @@ -484,4 +484,8 @@ public void extractCleanup(ItemIdentifierInventory _cleanupInventory, boolean cl getCacheHolder().trigger(CacheTypes.Inventory); } } + + public boolean hasRequests() { + return getItemOrderManager().hasOrders(ResourceType.CRAFTING, ResourceType.EXTRA); + } } diff --git a/src/main/resources/assets/logisticsbridge/lang/en_us.lang b/src/main/resources/assets/logisticsbridge/lang/en_us.lang index 57b2348..e601842 100644 --- a/src/main/resources/assets/logisticsbridge/lang/en_us.lang +++ b/src/main/resources/assets/logisticsbridge/lang/en_us.lang @@ -1,15 +1,19 @@ item.logisticspipes.pipe_lb.bridgepipe.name=Bridge Pipe item.logisticspipes.pipe_lb.bridgepipe.tip1=Type: Bridge -item.logisticspipes.pipe_lb.bridgepipe.tip2= - Attaches to an %cYELLOW AE Bridge %cRESET %cGRAY. +item.logisticspipes.pipe_lb.bridgepipe.tip2= - Attaches to an %cYELLOW AE Bridge %cRESET %cGRAY or %cYELLOW RS Bridge %cRESET %cGRAY. item.logisticspipes.pipe_lb.bridgepipe.tip3= - Creates a bridge between AE or RS, and LP. item.logisticspipes.pipe_lb.bridgepipe.tip4= - Use a wrench to toggle default route mode. item.logisticspipes.pipe_lb.bridgepipe.tip5= This also enables the advanced bridging logic. +item.logisticspipes.pipe_lb.bridgepipe.tip6=Must be placed on the side of the Bridge block +item.logisticspipes.pipe_lb.bridgepipe.tip7=Added by %cBLUE Logistics Bridge item.logisticspipes.pipe_lb.craftingmanager.name=Crafting Manager item.logisticspipes.pipe_lb.craftingmanager.tip1=Type: AutoCrafting item.logisticspipes.pipe_lb.craftingmanager.tip2= - Doesn't need an inventory -item.logisticspipes.pipe_lb.craftingmanager.tip3= - Can contain 27 Crafting modules with 2 Upgrade slots. -item.logisticspipes.pipe_lb.craftingmanager.tip4= - Used with a %cYELLOW Result Pipe %cRESET %cGRAY & %cYELLOW Satellite Pipe %cRESET %cGRAY. +item.logisticspipes.pipe_lb.craftingmanager.tip3= - Can contain 27 Crafting modules with 2 Upgrade slots each. +item.logisticspipes.pipe_lb.craftingmanager.tip4= - Install module upgrades by dropping them on the module slot. +item.logisticspipes.pipe_lb.craftingmanager.tip5= - Used with a %cYELLOW Result Pipe %cRESET %cGRAY & %cYELLOW Satellite Pipe %cRESET %cGRAY. +item.logisticspipes.pipe_lb.craftingmanager.tip6=Added by %cBLUE Logistics Bridge item.upgrade.info.crafting_manager=Crafting Manager item.logisticspipes.pipe_lb.resultpipe.name=Result Logistics Pipe @@ -17,9 +21,14 @@ item.logisticspipes.pipe_lb.resultpipe.tip1=Type: Item Source item.logisticspipes.pipe_lb.resultpipe.tip2= - Attaches to an inventory item.logisticspipes.pipe_lb.resultpipe.tip3= - Sends 16 items into the network to fulfill crafting requests. item.logisticspipes.pipe_lb.resultpipe.tip4= - Used with a %cYELLOW Crafting Manager %cRESET %cGRAY. +item.logisticspipes.pipe_lb.resultpipe.tip5=Added by %cBLUE Logistics Bridge item.logisticspipes.upgrade_lb.buffer_upgrade.name=Crafting Buffer Upgrade item.logisticspipes.upgrade_lb.buffer_upgrade.tip1=Uses attached chest to buffer crafting ingredients. +item.logisticspipes.upgrade_lb.buffer_upgrade.tip2=Allows buffering ingredients until the machine is ready. +item.logisticspipes.upgrade_lb.buffer_upgrade.tip3=Allows %cRED Redstone %cRESET %cGRAY Control of crafting. +item.logisticspipes.upgrade_lb.buffer_upgrade.tip4=Dark red particles indicate blocked state. +item.logisticspipes.upgrade_lb.buffer_upgrade.tip5=Added by %cBLUE Logistics Bridge item.lb.logisticsFakeItem.name=Logistics Craft Token item.lb.package.name=Empty Package @@ -52,4 +61,12 @@ gui.craftingManager.satellite=Default Satellite ID gui.craftingManager.result=Result Pipe ID gui.craftingManager.noConnection=N/C gui.satelliteBus.id=Satellite ID -gui.package=Package Config \ No newline at end of file +gui.package=Package Config +gui.craftingManager.blocking=Blocking Mode +gui.craftingManager.blocking.null=Off +gui.craftingManager.blocking.off=Off +gui.craftingManager.blocking.wait_for_result=Wait for Completion +gui.craftingManager.blocking.empty_main_satellite=Wait for Empty Inventory +gui.craftingManager.blocking.redstone_low=Redstone Active Low +gui.craftingManager.blocking.redstone_high=Redstone Active High +gui.craftingManager.blocking.change=Change \ No newline at end of file diff --git a/version-check.json b/version-check.json index 89ffcc6..081d04a 100644 --- a/version-check.json +++ b/version-check.json @@ -1,10 +1,11 @@ { "homepage": "https://www.curseforge.com/minecraft/mc-mods/logistics-bridge", "promos": { - "1.12.2-latest": "1.3.8", - "1.12.2-recommended": "1.3.8" + "1.12.2-latest": "1.3.9", + "1.12.2-recommended": "1.3.9" }, "1.12.2": { + "1.3.9": "Added blocking mode to Crafting Manager Pipe\nFixed crash with Bridge Pipe\nFixed crash with Crafting Manager Gui\nImproved tooltips", "1.3.8": "Fixed Crafting Buffer Upgrade not sending items correctly", "1.3.7": "Fixed crash", "1.3.6": "Fixed crash with the newest LogisticsPipes version",