From e0449b11c19bca414deabd67ed40e89cdb0c7645 Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Tue, 24 Sep 2024 08:37:10 +0800 Subject: [PATCH 01/12] update --- build.gradle | 2 +- .../eucrafting/CoverToMachineAdaptor.java | 5 +- .../BufferedDualInputHatch.java | 180 ++++++++++++++++-- .../gt/metatileentity/DualInputHatch.java | 85 ++++++--- .../metatileentity/MultiCircuitInputBus.java | 54 +++++- .../gt/metatileentity/RemoteInputHatch.java | 6 +- .../multi/IngredientDistributor.java | 3 +- .../proghatches/main/mixin/MixinPlugin.java | 7 +- .../assets/proghatches/lang/en_US.lang | 4 + .../assets/proghatches/lang/zh_CN.lang | 2 + 10 files changed, 299 insertions(+), 49 deletions(-) diff --git a/build.gradle b/build.gradle index ce227af..d6cc584 100644 --- a/build.gradle +++ b/build.gradle @@ -373,7 +373,7 @@ catch (Exception ignored) { // Pulls version first from the VERSION env and then git tag String identifiedVersion = null -String versionOverride = '0.0.19' +String versionOverride = '0.0.19p1' try { // Produce a version based on the tag, or for branches something like 0.2.2-configurable-maven-and-extras.38+43090270b6-dirty if (versionOverride == null) { diff --git a/src/main/java/reobf/proghatches/eucrafting/CoverToMachineAdaptor.java b/src/main/java/reobf/proghatches/eucrafting/CoverToMachineAdaptor.java index ed421cf..2d86e28 100644 --- a/src/main/java/reobf/proghatches/eucrafting/CoverToMachineAdaptor.java +++ b/src/main/java/reobf/proghatches/eucrafting/CoverToMachineAdaptor.java @@ -92,7 +92,10 @@ public CoverToMachineAdaptor(T te,@Nullable InventoryAdaptor invItems, this.invFluids = invFluids; this.te=te; this.fd=fd; - }T te;ForgeDirection fd; private final InventoryAdaptor invItems; + } + T te; + + ForgeDirection fd; private final InventoryAdaptor invItems; private final IFluidHandler invFluids; @Override public Iterator iterator() { diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java index 5a7c06c..b592f0c 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java @@ -14,6 +14,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Objects; import java.util.Optional; import java.util.Queue; import java.util.function.Consumer; @@ -33,6 +34,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.launchwrapper.Launch; import net.minecraft.nbt.JsonToNBT; @@ -51,8 +53,11 @@ import net.minecraftforge.fluids.IFluidTank; import net.minecraftforge.oredict.OreDictionary; +import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Multimap; +import com.google.common.collect.Multiset; import com.gtnewhorizons.modularui.api.ModularUITextures; import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; @@ -81,7 +86,6 @@ import com.gtnewhorizons.modularui.common.widget.SlotWidget; import com.gtnewhorizons.modularui.common.widget.SyncedWidget; import com.gtnewhorizons.modularui.common.widget.TextWidget; - import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -225,6 +229,7 @@ public BufferedDualInputHatch(String aName, int aTier, int aSlots, String[] aDes public class DualInvBuffer implements IDualInputInventory { public long tickFirstClassify=-1; + protected FluidTank[] mStoredFluidInternal; protected ItemStack[] mStoredItemInternal; protected FluidTank[] mStoredFluidInternalSingle; @@ -451,18 +456,7 @@ private boolean isItemStackEqualIngoreAmount(ItemStack p_77959_1_,ItemStack thiz return false ? false : (thiz.getItem() != p_77959_1_.getItem() ? false : (thiz.getItemDamage() != p_77959_1_.getItemDamage() ? false : (thiz.stackTagCompound == null && p_77959_1_.stackTagCompound != null ? false : thiz.stackTagCompound == null || thiz.stackTagCompound.equals(p_77959_1_.stackTagCompound)))); } - private boolean fluidEquals(FluidTank a, FluidTank b) { - // if(a==b)return false; - // if(a==null||b==null)return false; - if (a.getFluidAmount() != b.getFluidAmount()) - return false; - if (a.getFluid() == null && a.getFluid() == null) - return true; - if (a.getFluid() != null && (!a.getFluid().equals(b.getFluid()))) - return false; - - return true; - } + /** * classify() with less check, for better performance @@ -1533,7 +1527,7 @@ public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDat +tag.getInteger("sleepTime") ); - + int idle[]=new int[1]; IntStream.range(0, tag.getInteger("inv_size")).forEach(s -> { NBTTagCompound sub = (NBTTagCompound) tag.getTag("No" + s); boolean noClear = sub.getBoolean("noClear"); @@ -1548,6 +1542,8 @@ public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDat info = LangManager.translateToLocal("programmable_hatches.buffer.waila.001"); break; case 0b010: + idle[0]++; + if(idle[0]>5)return; info = LangManager.translateToLocal("programmable_hatches.buffer.waila.010"); break; case 0b011: @@ -1599,8 +1595,9 @@ public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDat Arrays.stream(lock_fluid.split("\n")).map(ss -> " " + ss).forEach(currenttip::add); }); - ; + if(idle[0]>5) + currenttip.add(LangManager.translateToLocalFormatted("programmable_hatches.buffer.waila.hidden",(idle[0]-5)+"")); } @@ -1620,6 +1617,13 @@ public void updateSlots() { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + + mergeSame().forEachRemaining(s->{ + + System.out.println(s); + + + }); BaseMetaTileEntity tile = (BaseMetaTileEntity) this.getBaseMetaTileEntity(); if (tile.isServerSide()) { if (!tile.privateAccess() || aPlayer.getDisplayName().equalsIgnoreCase(tile.getOwnerName())) { @@ -1709,11 +1713,153 @@ public boolean isInputEmpty() { } return true; } - @Override + /*@Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ) { return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); - } + }*/ + @SuppressWarnings("unchecked") + public Iterator mergeSame(){ + + + class Wrapper{ + DualInvBuffer d; + public Wrapper(DualInvBuffer s) { + d=s; + } + + @Override + public int hashCode() { + int hash=0; + for(int i=0;i>>1; + if(a!=0)hash|=0x80000000; + } + for(int i=0;i>>1; + if(a!=0)hash|=0x80000000; + } + + return hash; + } + + @Override + public boolean equals(Object obj) { + if(obj==this){return true;} + boolean empty=true; + DualInvBuffer a=d; + DualInvBuffer b=((Wrapper) obj).d; + for(int i=0;i0) + empty=false; + + } + for(int i=0;i a=HashMultimap + .create(); + inv0.stream().filter((DualInvBuffer::isAccessibleForMulti)) + .forEach( + s->{ + a.put(new Wrapper(s), s); + } + ); + return (Iterator) a.asMap().values().stream().map( + s->{ + return new IDualInputInventory(){ + void init(){ + Iterator itr = s.iterator(); + int icount=0; + ItemStack[][] idata=new ItemStack[s.size()][]; + int fcount=0; + FluidStack[][] fdata=new FluidStack[s.size()][]; + for(int i=0;i 0 ? optional @@ -170,7 +178,7 @@ public DualInputHatch(int id, String name, String nameRegional, int tier, boole Registration.items.add(new ItemStack(GregTech_API.sBlockMachines, 1, id)); this.mMultiFluid = mMultiFluid; initTierBasedField(); - } + }*/ public DualInputHatch(int id, String name, String nameRegional, int tier, int slot, boolean mMultiFluid, String... optional) { @@ -298,16 +306,25 @@ public void saveNBTData(NBTTagCompound aNBT) { aNBT.setTag("mFluid" + i, mStoredFluid[i].writeToNBT(new NBTTagCompound())); } } - + try{ NBTTagList greggy=aNBT.getTagList("Inventory", 10); - for(int i=0;ishared.broken) + ); + builder.widget(new FakeSyncWidget.BooleanSyncer(()->shared.broken, s->shared.broken=s) + + .setSynced(true, false)); return builder.build(); @@ -1459,7 +1487,7 @@ public void updateSlots() { }else*/ super.updateSlots(); } - private void fillStacksIntoFirstSlotsExtraCircuit() { + /*private void fillStacksIntoFirstSlotsExtraCircuit() { final int L = mInventory.length - 4; HashMap slots = new HashMap<>(L); HashMap stacks = new HashMap<>(L); @@ -1488,14 +1516,16 @@ private void fillStacksIntoFirstSlotsExtraCircuit() { mInventory[slot].stackSize = toSet; slots.merge(sID, toSet, (a, b) -> a - b); } - } + }*/ CheckRecipeResult lastresult; @Override public final CheckRecipeResult endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase controller) { if(recipe){recipe=false; - return lastresult=endRecipeProcessingImpl(controller); + lastresult=endRecipeProcessingImpl(controller); + if(lastresult.wasSuccessful()==false)controller.stopMachine(ShutDownReasonRegistry.CRITICAL_NONE); + return lastresult; } return lastresult; @@ -2015,18 +2045,25 @@ public ArrayList deserListF(NBTTagCompound tag){ } return ls; } - + boolean broken; public ItemStack[] getItems(){ ArrayList all=new ArrayList<>(); all.addAll(circuitInv); - all.addAll(cachedItems); all.add(mInventory[getCircuitSlot()]); + if(recipe==false){broken=true; + return all.toArray(new ItemStack[0]); + } + all.addAll(cachedItems); return all.toArray(new ItemStack[0]); } public FluidStack[] getFluid(){ + if(recipe==false){ + broken=true; + return new FluidStack[0]; + } ArrayList all=new ArrayList<>(); all.addAll(cachedFluid); return all.toArray(new FluidStack[0]);} diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/MultiCircuitInputBus.java b/src/main/java/reobf/proghatches/gt/metatileentity/MultiCircuitInputBus.java index 1456e09..318ffbd 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/MultiCircuitInputBus.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/MultiCircuitInputBus.java @@ -1,24 +1,34 @@ package reobf.proghatches.gt.metatileentity; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; +import java.util.function.Consumer; +import java.util.function.Supplier; import java.util.stream.IntStream; import java.util.stream.Stream; import com.google.common.collect.ImmutableMap; +import com.gtnewhorizons.modularui.api.drawable.UITexture; import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; +import com.gtnewhorizons.modularui.api.widget.Widget; import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.CycleButtonWidget; import com.gtnewhorizons.modularui.common.widget.SlotWidget; import gregtech.api.GregTech_API; +import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.util.GT_TooltipDataCache; import gregtech.api.util.GT_Utility; import gregtech.api.util.GT_TooltipDataCache.TooltipData; import net.minecraft.item.ItemStack; @@ -34,10 +44,52 @@ public ItemStackHandler getInventoryHandler() { // TODO Auto-generated method stub return super.getInventoryHandler(); } + +int uiButtonCount; +private Widget createToggleButton(Supplier getter, Consumer setter, UITexture picture, + Supplier tooltipDataSupplier) { + return new CycleButtonWidget().setToggle(getter, setter) + .setStaticTexture(picture) + .setVariableBackground(GT_UITextures.BUTTON_STANDARD_TOGGLE) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(7 + (uiButtonCount++ * BUTTON_SIZE), 62) + .setSize(BUTTON_SIZE, BUTTON_SIZE) + .setGTTooltip(tooltipDataSupplier); + } +private void addSortStacksButton(ModularWindow.Builder builder) { + builder.widget( + createToggleButton( + () -> !disableSort, + val -> disableSort = !val, + GT_UITextures.OVERLAY_BUTTON_SORTING_MODE, + () -> mTooltipCache.getData(SORTING_MODE_TOOLTIP))); +} + +private void addOneStackLimitButton(ModularWindow.Builder builder) { + builder.widget(createToggleButton(() -> !disableLimited, val -> { + disableLimited = !val; + updateSlots(); + }, GT_UITextures.OVERLAY_BUTTON_ONE_STACK_LIMIT, () -> mTooltipCache.getData(ONE_STACK_LIMIT_TOOLTIP))); +} +private static final String SORTING_MODE_TOOLTIP = "GT5U.machines.sorting_mode.tooltip"; +private static final String ONE_STACK_LIMIT_TOOLTIP = "GT5U.machines.one_stack_limit.tooltip"; +private static final int BUTTON_SIZE = 18; @Override public void addUIWidgets(Builder builder, UIBuildContext buildContext) { - + buildContext.addCloseListener(() -> uiButtonCount = 0); + addSortStacksButton(builder); + addOneStackLimitButton(builder); super.addUIWidgets(builder, buildContext); + + + switch (mTier) { + case 0 : getBaseMetaTileEntity().add1by1Slot(builder); + case 1 : getBaseMetaTileEntity().add2by2Slots(builder); + case 2 : getBaseMetaTileEntity().add3by3Slots(builder); + default : getBaseMetaTileEntity().add4by4Slots(builder); +} + + ProghatchesUtil.attachZeroSizedStackRemover(builder, buildContext); for(int i=1;i<4;i++) builder.widget( diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/RemoteInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/RemoteInputHatch.java index eeba267..3234295 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/RemoteInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/RemoteInputHatch.java @@ -66,6 +66,7 @@ import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Utility; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; import gregtech.common.tileentities.machines.IRecipeProcessingAwareHatch; import reobf.proghatches.gt.metatileentity.util.RecursiveLinkExcpetion; import reobf.proghatches.lang.LangManager; @@ -636,8 +637,9 @@ public CheckRecipeResult endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase co }); - if (fail.get()) - return CheckRecipeResultRegistry.CRASH; + if (fail.get()){ + controller.stopMachine(ShutDownReasonRegistry.CRITICAL_NONE); + return CheckRecipeResultRegistry.CRASH;} tmp = null; return CheckRecipeResultRegistry.SUCCESSFUL; diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java b/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java index 57ded8b..72d9c2c 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java @@ -442,8 +442,7 @@ public CheckRecipeResult endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase co */ @SuppressWarnings("unchecked") private boolean distribute() { - //Optional in = getInput(); - //in.ifPresent(s->s.startRecipeProcessing()); + startRecipeProcessing(); Iterator possibleSource=null; try{ diff --git a/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java b/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java index 9a4abf7..3ed3b8b 100644 --- a/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java +++ b/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java @@ -168,8 +168,13 @@ public List getMixins() { if(ff)retLate.add("MixinAEAdaptorSkipStackSizeCheck"); if(ff)retLate.add("MixinAwarenessForDualHatch"); - if (!"true".equals(pp.get("noRemoveUnusedCacheInModularUIContainer"))) + + + /*if (!"true".equals(pp.get("noRemoveUnusedCacheInModularUIContainer"))) if(ff)retLate.add("MixinRemoveUnunsedItemStackCache"); + + */ + if(ff)retLate.add("MixinAE2FCCompat"); if (!"true".equals(pp.get("noRecipeFilterForDualHatch"))) { diff --git a/src/main/resources/assets/proghatches/lang/en_US.lang b/src/main/resources/assets/proghatches/lang/en_US.lang index bbdd3c2..8e5a1e3 100644 --- a/src/main/resources/assets/proghatches/lang/en_US.lang +++ b/src/main/resources/assets/proghatches/lang/en_US.lang @@ -561,3 +561,7 @@ hatch.dualinput.slave.fluid.name=Fluid Input Slave proghatch.chunk_loading_alert.info=Alerting Anchor: Chunk [%s] is not properly unloaded. proghatch.chunk_loading_alert.info.none=Alerting Anchor: No improperly-unloaded chunks. proghatch.waypoint.info=Alerting Anchor Mark +programmable_hatches.buffer.waila.hidden=§rAnd %s more §2Idle§r Buffers... +proghatch.dualhatch.optinv.broken=§4This Multiblock Machine does not support Upgrades! Please create issue if you see this. + + \ No newline at end of file diff --git a/src/main/resources/assets/proghatches/lang/zh_CN.lang b/src/main/resources/assets/proghatches/lang/zh_CN.lang index a922630..4fe0242 100644 --- a/src/main/resources/assets/proghatches/lang/zh_CN.lang +++ b/src/main/resources/assets/proghatches/lang/zh_CN.lang @@ -559,3 +559,5 @@ hatch.dualinput.slave.fluid.name=流体输入镜像 proghatch.chunk_loading_alert.info=警告锚:位于[%s]的区块未被正确卸载 proghatch.chunk_loading_alert.info.none=警告锚: 没有非正常卸载区块 proghatch.waypoint.info=警告锚标记 +programmable_hatches.buffer.waila.hidden=§r以及%s个空闲的§2就绪§r缓存... +proghatch.dualhatch.optinv.broken=§4这个多方块不兼容升级!如果看到这行字请提issue From e746be4d25430d73476e1736a5d660abcd4d561c Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Tue, 24 Sep 2024 12:40:07 +0800 Subject: [PATCH 02/12] update --- build.gradle | 2 +- .../multi/IngredientDistributor.java | 40 +++++++++++++++++-- .../assets/proghatches/lang/en_US.lang | 6 ++- .../assets/proghatches/lang/zh_CN.lang | 4 ++ 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index d6cc584..85e937d 100644 --- a/build.gradle +++ b/build.gradle @@ -373,7 +373,7 @@ catch (Exception ignored) { // Pulls version first from the VERSION env and then git tag String identifiedVersion = null -String versionOverride = '0.0.19p1' +String versionOverride = '0.0.19p2' try { // Produce a version based on the tag, or for branches something like 0.2.2-configurable-maven-and-extras.38+43090270b6-dirty if (versionOverride == null) { diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java b/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java index 72d9c2c..1727b3e 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java @@ -716,6 +716,14 @@ static void ser(PacketBuffer pb,TransferCheckResult thiz){ } +} +private ItemStack cp(ItemStack c){ + if(c!=null)return c.copy(); + return null; +} +private IAEItemStack cp(IAEItemStack c){ + if(c!=null)return c.copy(); + return null; } static Field f,f2; @SuppressWarnings({ "unchecked", "unused" }) @@ -730,15 +738,21 @@ private TransferCheckResult checkMEBus(GT_MetaTileEntity_Hatch_OutputBus_ME bus, try { IItemList itemCache =(IItemList) f.get(bus); Iterator itr = itemCache.iterator(); + //if(check!=null) while(itr.hasNext()){IAEItemStack next; if((next=itr.next()).isSameType(check)==false){ - return TransferCheckResult.ofFail("cache.diff.bus",index,check.copy(),next.copy()); + if(check==null) + return TransferCheckResult.ofFail("cache.diff.bus.null",index,cp(next)); + return TransferCheckResult.ofFail("cache.diff.bus",index,cp(next),cp(check)); } } itr = bus.getProxy().getStorage().getItemInventory().getStorageList().iterator(); + //if(check!=null) while(itr.hasNext()){IAEItemStack next; if((next=itr.next()).isSameType(check)==false){ - return TransferCheckResult.ofFail("net.diff.bus",index,check.copy(),next.copy()); + if(check==null) + return TransferCheckResult.ofFail("net.diff.bus.null",index,cp(next)); + return TransferCheckResult.ofFail("net.diff.bus",index,cp(next),cp(check)); } } if(check!=null){ @@ -771,15 +785,22 @@ private TransferCheckResult checkMEHatch(GT_MetaTileEntity_Hatch_Output_ME bus,F try { IItemList itemCache =(IItemList) f2.get(bus); Iterator itr = itemCache.iterator(); + //if(check!=null) while(itr.hasNext()){IAEFluidStack next; if(!sameType(next=itr.next(),(check))){ - return TransferCheckResult.ofFail("cache.diff.hatch",index,check.copy(),next.copy()); + if(check==null) + return TransferCheckResult.ofFail("net.diff.hatch.null",index,cp(next)); + return TransferCheckResult.ofFail("cache.diff.hatch",index,cp(next),cp(check)); } } + itr = bus.getProxy().getStorage().getFluidInventory().getStorageList().iterator(); + //if(check!=null) while(itr.hasNext()){IAEFluidStack next; if(!sameType(next=itr.next(),(check))){ - return TransferCheckResult.ofFail("net.diff.hatch",index,check.copy(),next.copy()); + if(check==null) + return TransferCheckResult.ofFail("net.diff.hatch.null",index,cp(next)); + return TransferCheckResult.ofFail("net.diff.hatch",index,cp(next),cp(check)); } }if(check!=null){ IAEFluidStack notadded = bus.getProxy().getStorage().getFluidInventory().injectItems( @@ -797,6 +818,17 @@ private TransferCheckResult checkMEHatch(GT_MetaTileEntity_Hatch_Output_ME bus,F return TransferCheckResult.ofSuccess(); } +private IAEFluidStack cp(IAEFluidStack c) { + + if(c!=null)return c.copy(); + return null; +} + +private FluidStack cp(FluidStack c) { + + if(c!=null)return c.copy(); + return null; +} static BaseActionSource fakeSource=new BaseActionSource(); static Method[] cache; diff --git a/src/main/resources/assets/proghatches/lang/en_US.lang b/src/main/resources/assets/proghatches/lang/en_US.lang index 8e5a1e3..c9178b6 100644 --- a/src/main/resources/assets/proghatches/lang/en_US.lang +++ b/src/main/resources/assets/proghatches/lang/en_US.lang @@ -563,5 +563,7 @@ proghatch.chunk_loading_alert.info.none=Alerting Anchor: No improperly-unloaded proghatch.waypoint.info=Alerting Anchor Mark programmable_hatches.buffer.waila.hidden=§rAnd %s more §2Idle§r Buffers... proghatch.dualhatch.optinv.broken=§4This Multiblock Machine does not support Upgrades! Please create issue if you see this. - - \ No newline at end of file +proghatch.ingbuf.fail.net.diff.bus.null=The bus#%s has %s in its ME storage while it should be empty. +proghatch.ingbuf.fail.cache.diff.bus.null=The bus#%s has %s in its cache while it should be empty. +proghatch.ingbuf.fail.net.diff.hatch.null=The hatch#%s has %s in its ME storage while it should be empty. +proghatch.ingbuf.fail.cache.diff.hatch.null=The hatch#%s has %s in its cache while it should be empty. diff --git a/src/main/resources/assets/proghatches/lang/zh_CN.lang b/src/main/resources/assets/proghatches/lang/zh_CN.lang index 4fe0242..7a26d63 100644 --- a/src/main/resources/assets/proghatches/lang/zh_CN.lang +++ b/src/main/resources/assets/proghatches/lang/zh_CN.lang @@ -561,3 +561,7 @@ proghatch.chunk_loading_alert.info.none=警告锚: 没有非正常卸载区块 proghatch.waypoint.info=警告锚标记 programmable_hatches.buffer.waila.hidden=§r以及%s个空闲的§2就绪§r缓存... proghatch.dualhatch.optinv.broken=§4这个多方块不兼容升级!如果看到这行字请提issue +proghatch.ingbuf.fail.net.diff.bus.null=%s号ME输出总线内部缓存含有:%s 尽管不需要向此网络输出但其应该被清空 +proghatch.ingbuf.fail.cache.diff.bus.null=%s号ME输出总线内部缓存含有:%s 尽管不需要向此网络输出但其应该被清空 +proghatch.ingbuf.fail.net.diff.hatch.null=%s号ME输出仓内部缓存含有:%s 尽管不需要向此网络输出但其应该被清空 +proghatch.ingbuf.fail.cache.diff.hatch.null=%s号ME输出仓内部缓存含有:%s 尽管不需要向此网络输出但其应该被清空 From b395fec8e20093d02abd2672dee52419dd2d4541 Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Thu, 26 Sep 2024 18:04:41 +0800 Subject: [PATCH 03/12] update --- build.gradle | 2 +- .../proghatches/block/TileReactorSyncer.java | 75 ++++++++++++- .../multi/IngredientDistributor.java | 8 +- .../java/reobf/proghatches/main/MyMod.java | 20 ++++ .../proghatches/main/mixin/MixinPlugin.java | 1 + .../mixin/mixins/MixinFixPipeCoverBug.java | 6 +- .../mixins/part2/MixinPresetsInject.java | 104 ++++++++++++++++++ .../assets/proghatches/lang/en_US.lang | 6 + .../assets/proghatches/lang/zh_CN.lang | 7 +- 9 files changed, 217 insertions(+), 12 deletions(-) create mode 100644 src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinPresetsInject.java diff --git a/build.gradle b/build.gradle index 85e937d..a047352 100644 --- a/build.gradle +++ b/build.gradle @@ -373,7 +373,7 @@ catch (Exception ignored) { // Pulls version first from the VERSION env and then git tag String identifiedVersion = null -String versionOverride = '0.0.19p2' +String versionOverride = '0.0.19p3' try { // Produce a version based on the tag, or for branches something like 0.2.2-configurable-maven-and-extras.38+43090270b6-dirty if (versionOverride == null) { diff --git a/src/main/java/reobf/proghatches/block/TileReactorSyncer.java b/src/main/java/reobf/proghatches/block/TileReactorSyncer.java index f469748..48356da 100644 --- a/src/main/java/reobf/proghatches/block/TileReactorSyncer.java +++ b/src/main/java/reobf/proghatches/block/TileReactorSyncer.java @@ -8,10 +8,14 @@ import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.drawable.UITexture; import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; +import com.gtnewhorizons.modularui.api.forge.PlayerMainInvWrapper; +import com.gtnewhorizons.modularui.api.math.Pos2d; import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.CycleButtonWidget; import com.gtnewhorizons.modularui.common.widget.DrawableWidget; import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; import com.gtnewhorizons.modularui.common.widget.FluidSlotWidget; @@ -23,14 +27,17 @@ import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.gui.modularui.GUITextureSet; +import gregtech.common.gui.modularui.widget.CoverCycleButtonWidget; import ic2.core.block.reactor.tileentity.TileEntityNuclearReactorElectric; import ic2.core.block.reactor.tileentity.TileEntityReactorAccessHatch; import ic2.core.block.reactor.tileentity.TileEntityReactorChamberElectric; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import reobf.proghatches.block.TileIOHub.UIFactory; import reobf.proghatches.gt.metatileentity.util.MappingItemHandler; +import reobf.proghatches.lang.LangManager; import reobf.proghatches.main.MyMod; public class TileReactorSyncer extends TileEntity implements ITileWithModularUI{ @@ -44,14 +51,19 @@ public void validate() { MyMod.callbacks.put(this,this::pretick); } - + boolean skipCycleZero; public void pretick(){ if((!isDead)&&(!isInvalid())){ TileEntityNuclearReactorElectric reactor=findTarget(); + if(reactor!=null) tick=reactor.updateTicker%20;else tick=-1; - + int new_power=tick!=-1?values[tick]:0; + if(cycles==0&&skipCycleZero){ + new_power=0; + } + if(tick==0)cycles++; if(power!=new_power){ @@ -61,6 +73,7 @@ public void pretick(){ } power=new_power; + } } @@ -86,9 +99,15 @@ public TileEntityNuclearReactorElectric findTarget(){ return null; } + int cycles; + @Override + public void invalidate() { + cycles=0; + super.invalidate(); + } @Override public void onChunkUnload() { - + cycles=0; super.onChunkUnload(); isDead = true; } @@ -99,7 +118,30 @@ public void updateEntity() { isDead = false; } + public static SlotGroup playerHotBarGroup(EntityPlayer player, IDrawable background) { + PlayerMainInvWrapper wrapper = new PlayerMainInvWrapper(player.inventory); + SlotGroup slotGroup = new SlotGroup(); + /* for (int row = 0; row < 3; row++) { + for (int col = 0; col < 9; col++) { + SlotWidget slot = new SlotWidget(new BaseSlot(wrapper, col + (row + 1) * 9)) + .setPos(new Pos2d(col * 18, row * 18)); + slotGroup.addSlot(slot); + if (background != null) { + slot.setBackground(background); + } + } + }*/ + + for (int i = 0; i < 9; i++) { + SlotWidget slot = new SlotWidget(new BaseSlot(wrapper, i)).setPos(new Pos2d(i * 18, 0)); + slotGroup.addSlot(slot); + if (background != null) { + slot.setBackground(background); + } + } + return slotGroup; + } @Override public ModularWindow createWindow(UIBuildContext buildContext) { return new UIFactory(buildContext).createWindow(); @@ -117,7 +159,12 @@ public ModularWindow createWindow() { builder.setBackground(ModularUITextures.VANILLA_BACKGROUND); // builder.setGuiTint(getUIBuildContext().getGuiColorization()); if (doesBindPlayerInventory()) - builder.bindPlayerInventory(getUIBuildContext().getPlayer()); + { + builder.widget(playerHotBarGroup(uiBuildContext.getPlayer(), null) + .setPos(new Pos2d(3, getGUIHeight()-18-3))); + // builder.bindPlayerInventory(null) + + } addTitleToUI(builder); addUIWidgets(builder); @@ -138,6 +185,24 @@ public ModularWindow createWindow() { * @param builderx */ protected void addUIWidgets(ModularWindow.Builder builderx) { + + builderx.widget(((CycleButtonWidget) new CoverCycleButtonWidget().setSynced(false, true)) + .setGetter(() -> skipCycleZero ? 1 : 0).setSetter(s ->skipCycleZero = s == 1).setLength(2) + .setTextureGetter(i -> { + if (i == 1) + return GT_UITextures.OVERLAY_BUTTON_EXPORT; + return GT_UITextures.OVERLAY_BUTTON_IMPORT; + }) + + .addTooltip(1, LangManager.translateToLocal("tile.reactor_syncer.skip.true")) + .addTooltip(0, LangManager.translateToLocal("tile.reactor_syncer.skip.false")) + .addTooltip( LangManager.translateToLocal("tile.reactor_syncer.skip.0")) + .addTooltip( LangManager.translateToLocal("tile.reactor_syncer.skip.1")) + .addTooltip( LangManager.translateToLocal("tile.reactor_syncer.skip.2")) + .setPos(3, getGUIHeight()-60) + + ); + Scrollable builder=new Scrollable().setHorizontalScroll(); for(int i=0;i<20;i++){ @@ -244,6 +309,7 @@ public void writeToNBT(NBTTagCompound compound) { for(int i=0;i<20;i++){ compound.setInteger("##"+i, values[i]); } + compound.setBoolean("skipCycleZero",skipCycleZero); super.writeToNBT(compound); } @Override @@ -251,6 +317,7 @@ public void readFromNBT(NBTTagCompound compound) { for(int i=0;i<20;i++){ values[i]=compound.getInteger("##"+i ); } + skipCycleZero=compound.getBoolean("skipCycleZero"); super.readFromNBT(compound); } } diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java b/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java index 1727b3e..5e18f1c 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java @@ -740,7 +740,7 @@ private TransferCheckResult checkMEBus(GT_MetaTileEntity_Hatch_OutputBus_ME bus, Iterator itr = itemCache.iterator(); //if(check!=null) while(itr.hasNext()){IAEItemStack next; - if((next=itr.next()).isSameType(check)==false){ + if((next=itr.next()).isSameType(check)==false&&next.getStackSize()>0){ if(check==null) return TransferCheckResult.ofFail("cache.diff.bus.null",index,cp(next)); return TransferCheckResult.ofFail("cache.diff.bus",index,cp(next),cp(check)); @@ -749,7 +749,7 @@ private TransferCheckResult checkMEBus(GT_MetaTileEntity_Hatch_OutputBus_ME bus, itr = bus.getProxy().getStorage().getItemInventory().getStorageList().iterator(); //if(check!=null) while(itr.hasNext()){IAEItemStack next; - if((next=itr.next()).isSameType(check)==false){ + if((next=itr.next()).isSameType(check)==false&&next.getStackSize()>0){ if(check==null) return TransferCheckResult.ofFail("net.diff.bus.null",index,cp(next)); return TransferCheckResult.ofFail("net.diff.bus",index,cp(next),cp(check)); @@ -787,7 +787,7 @@ private TransferCheckResult checkMEHatch(GT_MetaTileEntity_Hatch_Output_ME bus,F Iterator itr = itemCache.iterator(); //if(check!=null) while(itr.hasNext()){IAEFluidStack next; - if(!sameType(next=itr.next(),(check))){ + if(!sameType(next=itr.next(),(check))&&next.getStackSize()>0){ if(check==null) return TransferCheckResult.ofFail("net.diff.hatch.null",index,cp(next)); return TransferCheckResult.ofFail("cache.diff.hatch",index,cp(next),cp(check)); @@ -797,7 +797,7 @@ private TransferCheckResult checkMEHatch(GT_MetaTileEntity_Hatch_Output_ME bus,F itr = bus.getProxy().getStorage().getFluidInventory().getStorageList().iterator(); //if(check!=null) while(itr.hasNext()){IAEFluidStack next; - if(!sameType(next=itr.next(),(check))){ + if(!sameType(next=itr.next(),(check))&&next.getStackSize()>0){ if(check==null) return TransferCheckResult.ofFail("net.diff.hatch.null",index,cp(next)); return TransferCheckResult.ofFail("net.diff.hatch",index,cp(next),cp(check)); diff --git a/src/main/java/reobf/proghatches/main/MyMod.java b/src/main/java/reobf/proghatches/main/MyMod.java index 4c125fd..82e25ca 100644 --- a/src/main/java/reobf/proghatches/main/MyMod.java +++ b/src/main/java/reobf/proghatches/main/MyMod.java @@ -1,17 +1,25 @@ package reobf.proghatches.main; import java.io.File; +import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.net.Proxy; import java.util.ArrayDeque; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Deque; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import java.util.WeakHashMap; +import java.util.function.BiConsumer; +import java.util.stream.Collector; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import javax.annotation.Nullable; @@ -54,6 +62,8 @@ import com.glodblock.github.crossmod.opencomputers.DriverLevelMaintainer; import com.glodblock.github.inventory.FluidConvertingInventoryAdaptor; import com.glodblock.github.loader.ItemAndBlockHolder; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; import com.gtnewhorizon.structurelib.alignment.constructable.IMultiblockInfoContainer; import appeng.api.AEApi; @@ -86,6 +96,7 @@ import appeng.util.item.AEItemStack; import appeng.util.item.ItemList; import codechicken.multipart.MultipartGenerator; +import codechicken.nei.recipe.StackInfo; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.SidedProxy; @@ -150,6 +161,7 @@ import reobf.proghatches.oc.ItemGTRedstoneCard; import reobf.proghatches.oc.WirelessPeripheralManager; import reobf.proghatches.util.ProghatchesUtil; + import tconstruct.armor.player.TPlayerStats; import thaumcraft.common.entities.golems.ItemGolemCore; @@ -249,10 +261,16 @@ public void preInit(FMLPreInitializationEvent event) { public static Map OCApi = new HashMap<>(); + /** + * @param event + */ @Mod.EventHandler public void init(FMLInitializationEvent event) { proxy.init(event); + + + AEApi.instance().partHelper().registerNewLayer("reobf.proghatches.fmp.LazerLayer", "reobf.proghatches.eucrafting.ILazer"); @@ -348,6 +366,8 @@ public void join(PlayerLoggedInEvent e) { public void postInit(FMLPostInitializationEvent event) { proxy.postInit(event); + + // Api.INSTANCE.registries().p2pTunnel().addNewAttunement(null, null); // ShutDownReasonRegistry.register(ACCESS_LOOP); NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); diff --git a/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java b/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java index 3ed3b8b..35ac4bf 100644 --- a/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java +++ b/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java @@ -194,6 +194,7 @@ public List getMixins() { retLate.add("MixinStorageChangeEvent"); retLate.add("MixinOptimize"); retLate.add("part2.MixinIsWailaCall"); + retLate.add("part2.MixinPresetsInject"); retLate.add("part2.MixinOC"); retLate.add("part2.MixinRecursiveSlotClickProtection"); retLate.add("part2.MixinMultiPattern"); diff --git a/src/main/java/reobf/proghatches/main/mixin/mixins/MixinFixPipeCoverBug.java b/src/main/java/reobf/proghatches/main/mixin/mixins/MixinFixPipeCoverBug.java index 54688ff..6297d3f 100644 --- a/src/main/java/reobf/proghatches/main/mixin/mixins/MixinFixPipeCoverBug.java +++ b/src/main/java/reobf/proghatches/main/mixin/mixins/MixinFixPipeCoverBug.java @@ -8,12 +8,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.CoverableTileEntity; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.util.ForgeDirection; @Mixin(value=BaseMetaPipeEntity.class,remap=false,priority=999) -public class MixinFixPipeCoverBug { +public class MixinFixPipeCoverBug{ ForgeDirection realSide; @@ -21,7 +22,8 @@ public class MixinFixPipeCoverBug { @Inject(remap=false,method="onRightclick",at=@At(value="INVOKE",target = "onPlayerAttach")) public void onRightclick0(EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ,CallbackInfoReturnable cc) { - + realSide=side; + if(((CoverableTileEntity)(Object)this).getCoverIDAtSide(side) == 0) realSide=GT_Utility.determineWrenchingSide(side, aX, aY, aZ); } diff --git a/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinPresetsInject.java b/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinPresetsInject.java new file mode 100644 index 0000000..0212799 --- /dev/null +++ b/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinPresetsInject.java @@ -0,0 +1,104 @@ +package reobf.proghatches.main.mixin.mixins.part2; + +import java.lang.reflect.Constructor; +import java.util.Collection; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import codechicken.nei.recipe.StackInfo; +import gregtech.api.GregTech_API; +import net.minecraft.item.ItemStack; +import reobf.proghatches.main.Config; +import reobf.proghatches.main.MyMod; +import reobf.proghatches.main.registration.Registration; + +@Mixin( + targets="codechicken.nei.CollapsibleItems" + ,remap=false + ) + +public class MixinPresetsInject { + + private static int[][] range={ + {Config.metaTileEntityOffset+ Registration.DualInputHatchOffset, + Config.metaTileEntityOffset+ Registration.DualInputHatchOffset+16}, + {Config.metaTileEntityOffset+ Registration.QuadDualInputHatchOffset, + Config.metaTileEntityOffset+ Registration.QuadDualInputHatchOffset+16}, + {Config.metaTileEntityOffset+ Registration.BufferedDualInputHatchOffset, + Config.metaTileEntityOffset+ Registration.BufferedDualInputHatchOffset+16}, + {Config.metaTileEntityOffset+ Registration.BufferedQuadDualInputHatchMKIIOffset, + Config.metaTileEntityOffset+ Registration.BufferedQuadDualInputHatchMKIIOffset+16}, + {Config.metaTileEntityOffset+ Registration.TenaciousOffset, + Config.metaTileEntityOffset+ Registration.FilterOffset+4}, + {Config.metaTileEntityOffset+ Registration.IngBufferOffset, + Config.metaTileEntityOffset+ Registration.IngBufferOffset+2}, + {Config.metaTileEntityOffset+ Registration.BufferedQuadDualInputHatchOffset, + Config.metaTileEntityOffset+ Registration.BufferedQuadDualInputHatchOffset+16}, + {Config.metaTileEntityOffset+ Registration.MEChest, + Config.metaTileEntityOffset+ Registration.MEChest+10}, + {Config.metaTileEntityOffset+ Registration.METank, + Config.metaTileEntityOffset+ Registration.METank+10}, + {Config.metaTileEntityOffset+ Registration.MultiCircuitBusOffset, + Config.metaTileEntityOffset+ Registration.MultiCircuitBusOffset+4}, + {Config.metaTileEntityOffset+ Registration.PrefabOffset, + Config.metaTileEntityOffset+ Registration.PrefabOffset+6}, + + }; + + + +@Inject(method="/^(?!$)reload/",at = { @At(value="HEAD") }) private void a(CallbackInfo C) +{ + + try { + Class c=Class.forName("codechicken.nei.PresetsList"); + Collection m=(Collection) c.getDeclaredField("presets").get(null); + Constructor cst=Class.forName("codechicken.nei.PresetsList$Preset").getConstructor(); + BiConsumer> add=(a,b)->{ + Object o; + try { + o = cst.newInstance(); + o.getClass().getDeclaredField("name").set(o,a); + o.getClass().getDeclaredField("items").set(o,b); + o.getClass().getDeclaredField("mode").set(o, + Class.forName("codechicken.nei.PresetsList$PresetMode").getDeclaredField("GROUP").get(null) + ); + m.add(o); + } catch (Exception e) { + e.printStackTrace(); + } + }; + for(int r[]:range) + add.accept("", + IntStream.range(r[0], r[1]) + .mapToObj(s->StackInfo.getItemStackGUID(new ItemStack(GregTech_API.sBlockMachines,1,s))) + .collect(Collectors.toSet()) + + ) + ; + + + + + + + + + + + + } catch (Exception e) { + MyMod.LOG.info("Failed to add collapseable item info to NEI. Safe to ignore if you are playing with 2.6.1 or less."); + e.printStackTrace(); + //270 only, nothing to worry about~ + } + +} +} diff --git a/src/main/resources/assets/proghatches/lang/en_US.lang b/src/main/resources/assets/proghatches/lang/en_US.lang index c9178b6..56ea730 100644 --- a/src/main/resources/assets/proghatches/lang/en_US.lang +++ b/src/main/resources/assets/proghatches/lang/en_US.lang @@ -567,3 +567,9 @@ proghatch.ingbuf.fail.net.diff.bus.null=The bus#%s has %s in its ME storage whil proghatch.ingbuf.fail.cache.diff.bus.null=The bus#%s has %s in its cache while it should be empty. proghatch.ingbuf.fail.net.diff.hatch.null=The hatch#%s has %s in its ME storage while it should be empty. proghatch.ingbuf.fail.cache.diff.hatch.null=The hatch#%s has %s in its cache while it should be empty. +tile.reactor_syncer.skip.true=No Redstone in the first Reactor Cycle: true +tile.reactor_syncer.skip.false=No Redstone in the first Reactor Cycle: false +tile.reactor_syncer.skip.0=Reactor updates every 20 ticks, however every time you load the game the counter shuffles. +tile.reactor_syncer.skip.1=This option gives you one update cycle to restore everything. +tile.reactor_syncer.skip.2=Especially useful if the game was saved in a bad tick, and the counter happens to be 0 at random. + diff --git a/src/main/resources/assets/proghatches/lang/zh_CN.lang b/src/main/resources/assets/proghatches/lang/zh_CN.lang index 7a26d63..bdec361 100644 --- a/src/main/resources/assets/proghatches/lang/zh_CN.lang +++ b/src/main/resources/assets/proghatches/lang/zh_CN.lang @@ -542,7 +542,7 @@ tile.proghatches.card_reader.name=传感器卡片读卡器 proghatch.eucrafting.warn=§c实验性物品 默认禁用 需要在配置中打开Mixin才能工作 tile.reactor_syncer.tooltip.0=根据IC2核反应堆更新计数器输出红石信号 tile.reactor_syncer.tooltip.1=有助于不停机情况下直接操作反应堆内容物 -tile.reactor_syncer.tooltip.2=注意:原版红石每2tick更新 最好使用红石P2P,红石导管和红色合金导线 +tile.reactor_syncer.tooltip.2=注意:原版红石每2tick更新 最好使用红石P2P,红石导管和红色合金导线等响应速度为1tick的传导媒介 tile.reactor_syncer.tooltip=3 tile.proghatch.reactor_syncer.name=反应堆更新同步器 hatch.dualinput.slave.inv.mapping.name=二合一输入区映射镜像 @@ -565,3 +565,8 @@ proghatch.ingbuf.fail.net.diff.bus.null=%s号ME输出总线内部缓存含有:%s proghatch.ingbuf.fail.cache.diff.bus.null=%s号ME输出总线内部缓存含有:%s 尽管不需要向此网络输出但其应该被清空 proghatch.ingbuf.fail.net.diff.hatch.null=%s号ME输出仓内部缓存含有:%s 尽管不需要向此网络输出但其应该被清空 proghatch.ingbuf.fail.cache.diff.hatch.null=%s号ME输出仓内部缓存含有:%s 尽管不需要向此网络输出但其应该被清空 +tile.reactor_syncer.skip.true=第一个反应堆更新周期不输出信号: true +tile.reactor_syncer.skip.false=第一个反应堆更新周期不输出信号: false +tile.reactor_syncer.skip.0=反应堆每20tick更新,但每次读档计数器会被随机重置 +tile.reactor_syncer.skip.1=这个选项空出第一个更新周期不输出信号,以便你恢复现场,拯救你的反应堆于水火 +tile.reactor_syncer.skip.2=尤其是考虑到可能再换棒到一半时存档,再读档时计数器会正好随机到0 From 94d4b0d51da15f78e2d8562a8fb6f0f69a593714 Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Thu, 26 Sep 2024 20:22:25 +0800 Subject: [PATCH 04/12] update --- gradle/wrapper/gradle-wrapper.properties | 2 +- .../proghatches/ae/BlockCyclicPatternSubmitter.java | 2 ++ src/main/java/reobf/proghatches/main/CommonProxy.java | 2 +- src/main/java/reobf/proghatches/main/MyMod.java | 9 ++++++--- .../java/reobf/proghatches/main/mixin/MixinPlugin.java | 4 ++-- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e09..a80b22c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/reobf/proghatches/ae/BlockCyclicPatternSubmitter.java b/src/main/java/reobf/proghatches/ae/BlockCyclicPatternSubmitter.java index 780ecc9..02cf215 100644 --- a/src/main/java/reobf/proghatches/ae/BlockCyclicPatternSubmitter.java +++ b/src/main/java/reobf/proghatches/ae/BlockCyclicPatternSubmitter.java @@ -5,6 +5,8 @@ import static net.minecraftforge.common.util.ForgeDirection.DOWN; import static net.minecraftforge.common.util.ForgeDirection.UP; +import java.util.Map; + import com.gtnewhorizons.modularui.api.UIInfos; import com.gtnewhorizons.modularui.common.internal.network.NetworkUtils; diff --git a/src/main/java/reobf/proghatches/main/CommonProxy.java b/src/main/java/reobf/proghatches/main/CommonProxy.java index e28d455..c0a12db 100644 --- a/src/main/java/reobf/proghatches/main/CommonProxy.java +++ b/src/main/java/reobf/proghatches/main/CommonProxy.java @@ -62,7 +62,7 @@ public void preInit(FMLPreInitializationEvent event) { Config.synchronizeConfiguration(event.getSuggestedConfigurationFile()); MyMod.LOG.info(Config.greeting); - MyMod.LOG.info("I am " + Tags.MODNAME + " at version " + Tags.VERSION); + MyMod.LOG.info("I am " + MyMod.MODNAME + " at version " + Tags.VERSION); GameRegistry.registerTileEntity(TileIOHub.class, "proghatches.iohub"); GameRegistry.registerTileEntity(TileWirelessPeripheralStation.class, "proghatches.peripheral_station"); diff --git a/src/main/java/reobf/proghatches/main/MyMod.java b/src/main/java/reobf/proghatches/main/MyMod.java index 82e25ca..186d5b1 100644 --- a/src/main/java/reobf/proghatches/main/MyMod.java +++ b/src/main/java/reobf/proghatches/main/MyMod.java @@ -165,13 +165,16 @@ import tconstruct.armor.player.TPlayerStats; import thaumcraft.common.entities.golems.ItemGolemCore; -@Mod(modid = Tags.MODID, version = Tags.VERSION, name = Tags.MODNAME, acceptedMinecraftVersions = "[1.7.10]", dependencies = "required-after:appliedenergistics2;required-after:gregtech;", acceptableRemoteVersions = "*" +@Mod(modid = MyMod.MODID, version = Tags.VERSION, name = MyMod.MODNAME, acceptedMinecraftVersions = "[1.7.10]", dependencies = "required-after:appliedenergistics2;required-after:gregtech;", acceptableRemoteVersions = "*" /* * ,dependencies= "required-after:neenergistics;" */ ) public class MyMod { - public static final Logger LOG = LogManager.getLogger(Tags.MODID); + + final public static String MODID="programmablehatches"; + final public static String MODNAME="ProgrammableHatches"; + public static final Logger LOG = LogManager.getLogger(MODID); public static MyMod instance; { //GT_MetaTileEntity_MultiBlockBase.class.getDeclaredFields(); @@ -210,7 +213,7 @@ public int getItemStackLimit() { // public static ShutDownReason ACCESS_LOOP=new // SimpleShutDownReason("proghatch.access_loop", true){public String getID() // {return "proghatch.access_loop";};}; - public static SimpleNetworkWrapper net = new SimpleNetworkWrapper(Tags.MODID); + public static SimpleNetworkWrapper net = new SimpleNetworkWrapper( MyMod.MODID); public static Item progcircuit; public static Item toolkit; diff --git a/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java b/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java index 35ac4bf..e5ad90c 100644 --- a/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java +++ b/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java @@ -35,7 +35,7 @@ import cpw.mods.fml.relauncher.FMLLaunchHandler; import reobf.proghatches.Tags; - +import reobf.proghatches.main.MyMod; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; @@ -308,7 +308,7 @@ private boolean loadJarOf( Map classTrait) { } } - public static final Logger LOG = LogManager.getLogger(Tags.MODID + "Mixin"); + public static final Logger LOG = LogManager.getLogger( MyMod.MODID + "Mixin"); private static final Path MODS_DIRECTORY_PATH = new File(Launch.minecraftHome, "mods/").toPath(); public static List findJarOf(final Map classTrait) { From 5f269dfcb9ec9a59f823c6349f1125b97d36ad44 Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Mon, 30 Sep 2024 16:45:48 +0800 Subject: [PATCH 05/12] update --- build.gradle | 2 +- .../proghatches/ae/PartAmountMaintainer.java | 16 +- .../BufferedDualInputHatch.java | 50 ++- .../CommunicationPortHatch.java | 87 ++++ .../metatileentity/RestrictedInputBusME.java | 97 ++++- .../RestrictedInputHatchME.java | 95 +++-- .../gt/metatileentity/SuperChestME.java | 1 + .../multi/IngredientDistributor.java | 387 ++++++++++++++++-- .../reobf/proghatches/main/CommonProxy.java | 3 +- .../main/registration/PHRecipes.java | 6 +- .../main/registration/Registration.java | 10 +- .../assets/proghatches/lang/en_US.lang | 10 + .../assets/proghatches/lang/en_US/M_ID.lang | 3 +- .../assets/proghatches/lang/zh_CN.lang | 11 + .../assets/proghatches/lang/zh_CN/M_ID.lang | 3 +- .../proghatches/textures/restrict_mode0.png | Bin 0 -> 668 bytes .../proghatches/textures/restrict_mode1.png | Bin 0 -> 875 bytes 17 files changed, 690 insertions(+), 91 deletions(-) create mode 100644 src/main/java/reobf/proghatches/gt/metatileentity/CommunicationPortHatch.java create mode 100644 src/main/resources/assets/proghatches/textures/restrict_mode0.png create mode 100644 src/main/resources/assets/proghatches/textures/restrict_mode1.png diff --git a/build.gradle b/build.gradle index a047352..a3f752f 100644 --- a/build.gradle +++ b/build.gradle @@ -373,7 +373,7 @@ catch (Exception ignored) { // Pulls version first from the VERSION env and then git tag String identifiedVersion = null -String versionOverride = '0.0.19p3' +String versionOverride = '0.0.19p4' try { // Produce a version based on the tag, or for branches something like 0.2.2-configurable-maven-and-extras.38+43090270b6-dirty if (versionOverride == null) { diff --git a/src/main/java/reobf/proghatches/ae/PartAmountMaintainer.java b/src/main/java/reobf/proghatches/ae/PartAmountMaintainer.java index a8135c6..7dc190f 100644 --- a/src/main/java/reobf/proghatches/ae/PartAmountMaintainer.java +++ b/src/main/java/reobf/proghatches/ae/PartAmountMaintainer.java @@ -181,7 +181,7 @@ public void requestForMissing(IAEStack primitive){ - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({ "rawtypes", "unchecked", "deprecation" }) @Override public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) { @@ -191,7 +191,10 @@ public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) boolean red=this.getHost().hasRedstone(this.getSide()); boolean should=shouldProceed(red,lastredstone); lastredstone=red; - if(!should){return TickRateModulation.SAME;} + if(!should){ + handlerHash.clear(); + inv.clear(); + return TickRateModulation.SAME;} if(getProxy().isActive()==false)return TickRateModulation.SAME; for(StorageChannel ch:new StorageChannel[]{StorageChannel.FLUIDS,StorageChannel.ITEMS}) { @@ -200,8 +203,9 @@ public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) IItemList list; if(inv instanceof IMEMonitor){ - inv.injectItems(EMPTY.get(ch), Actionable.MODULATE, source);//dirty hack, trigger update - list = ((IMEMonitor) inv).getStorageList(); + // inv.injectItems(EMPTY.get(ch), Actionable.MODULATE, source);//dirty hack, trigger update + // cache is invalid! just use the deprecated way to get the inv + list = ((IMEMonitor) inv).getAvailableItems(ch.createList()); }else{ list=inv.getAvailableItems(ch.createList()); @@ -415,7 +419,7 @@ public ModularWindow createWindow(UIBuildContext buildContext) { builder.widget( TextWidget.dynamicString(()->{ try{ - PartP2PTunnel p2p = getProxy().getP2P().getInput(freq); + PartP2PTunnel p2p =freq==0?null: getProxy().getP2P().getInput(freq); if(p2p.isActive()&&p2p.isPowered()){ return StatCollector.translateToLocal("proghatches.amountmaintainer.redstone.online"); }}catch(Exception e){} @@ -643,7 +647,7 @@ public int getSlotLimit(int slot) { public Boolean getSignal(){ try { - PartP2PTunnel p2p = getProxy().getP2P().getInput(freq); + PartP2PTunnel p2p =freq==0?null: getProxy().getP2P().getInput(freq); if(p2p!=null){ if(p2p.isActive()&&p2p.isPowered()){ diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java index b592f0c..c2d4a7e 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java @@ -86,6 +86,8 @@ import com.gtnewhorizons.modularui.common.widget.SlotWidget; import com.gtnewhorizons.modularui.common.widget.SyncedWidget; import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import appeng.me.storage.DriveWatcher; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -129,7 +131,7 @@ public int getInventoryFluidLimit() { return (int) Math.min(val, Integer.MAX_VALUE); */ //return super.getInventoryFluidLimit(); - + return (int) ((int) (32000 * Math.pow(2, mTier) / (mMultiFluid ? 4 : 1))); } public int fluidLimit() { @@ -1224,6 +1226,7 @@ public void loadNBTData(NBTTagCompound aNBT) { final int ii = i; inv0.get(i).fromTag((NBTTagCompound) aNBT.getTag("BUFFER_" + ii)); } + merge = aNBT.getBoolean("merge"); justHadNewItems = aNBT.getBoolean("justHadNewItems"); updateEveryTick = aNBT.getBoolean("updateEveryTick"); preventSleep=aNBT.getInteger("preventSleep"); @@ -1236,7 +1239,8 @@ public void saveNBTData(NBTTagCompound aNBT) { for (int i = 0; i < bufferNum; i++) aNBT.setTag("BUFFER_" + i, inv0.get(i).toTag()); - + + aNBT.setBoolean("merge", merge); aNBT.setBoolean("justHadNewItems", justHadNewItems); aNBT.setBoolean("updateEveryTick", updateEveryTick); aNBT.setInteger("preventSleep",preventSleep ); @@ -1359,12 +1363,20 @@ public int compareTo(PiorityBuffer o) { private Predicate not(Predicate s) { return s.negate(); } - +boolean merge; @Override public Iterator inventories() { markDirty(); dirty=true; + + + if(merge){ + return mergeSame(); + + } + + if(Config.experimentalOptimize){ return inv0.stream().filter(DualInvBuffer::isAccessibleForMulti) @@ -1615,15 +1627,16 @@ public void updateSlots() { super.updateSlots(); } + @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - mergeSame().forEachRemaining(s->{ + /*mergeSame().forEachRemaining(s->{ - System.out.println(s); + System.out.println(Arrays.toString(s.getItemInputs())); - }); + });*/ BaseMetaTileEntity tile = (BaseMetaTileEntity) this.getBaseMetaTileEntity(); if (tile.isServerSide()) { if (!tile.privateAccess() || aPlayer.getDisplayName().equalsIgnoreCase(tile.getOwnerName())) { @@ -1656,6 +1669,30 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye } } + if (tCurrentItem != null) { + boolean suc = false; + for (int id : OreDictionary.getOreIDs(tCurrentItem)) { + if (OreDictionary.getOreName(id).equals(ToolDictNames.craftingToolSaw.toString())) { + suc = true; + break; + } + ; + } + if (suc) { + GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer); + GT_Utility.sendSoundToPlayers(tile.getWorld(), SoundResource.IC2_TOOLS_CHAINSAW_CHAINSAW_USE_TWO, 1.0F, -1, + tile.getXCoord(), tile.getYCoord(), tile.getZCoord()); + /*merge = !merge; + + GT_Utility.sendChatToPlayer(aPlayer, "merge:" + merge); + + aPlayer.addChatMessage(new ChatComponentTranslation("programmable_hatches.gt.merge")); +*/ + markDirty(); + return true; + } + + } } } @@ -1800,6 +1837,7 @@ public boolean equals(Object obj) { ); return (Iterator) a.asMap().values().stream().map( s->{ + if(s.size()==1){return s.iterator().next();} return new IDualInputInventory(){ void init(){ Iterator itr = s.iterator(); diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/CommunicationPortHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/CommunicationPortHatch.java new file mode 100644 index 0000000..569cc47 --- /dev/null +++ b/src/main/java/reobf/proghatches/gt/metatileentity/CommunicationPortHatch.java @@ -0,0 +1,87 @@ +package reobf.proghatches.gt.metatileentity; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.render.TextureFactory; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import reobf.proghatches.main.registration.Registration; + +public class CommunicationPortHatch extends GT_MetaTileEntity_Hatch{ + public CommunicationPortHatch(int aID, String aName, String aNameRegional, int aTier + ) { + super(aID, aName, aNameRegional, aTier, 0, new String[0] ); + Registration.items.add(new ItemStack(GregTech_API.sBlockMachines, 1, aID)); + } + public CommunicationPortHatch(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + + } + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + + return new CommunicationPortHatch(mName, mTier, mDescriptionArray, mTextures); + } + private static final IIconContainer textureFont = new Textures.BlockIcons.CustomIcon("icons/NeutronSensorFont"); + private static final IIconContainer textureFont_Glow = new Textures.BlockIcons.CustomIcon( + "icons/NeutronSensorFont_GLOW"); + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, TextureFactory.of(textureFont), TextureFactory.builder() + .addIcon(textureFont_Glow) + .glow() + .build() }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, TextureFactory.of(textureFont) }; + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + @Override + public boolean allowGeneralRedstoneOutput() { + return true; + } + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + public void setRS(boolean porton) { + + for(ForgeDirection s:ForgeDirection.values()) + this.getBaseMetaTileEntity().setInternalOutputRedstoneSignal(s, (byte) (porton?15:0)); + + ((BaseMetaTileEntity) this.getBaseMetaTileEntity()). updateNeighbours(0xff,0xff);//set all bits to 1 to update all 6 sides + + } + @Override + public void initDefaultModes(NBTTagCompound aNBT) { + for(ForgeDirection s:ForgeDirection.values()) + this.getBaseMetaTileEntity().setInternalOutputRedstoneSignal(s, (byte) 0); + } + +} diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/RestrictedInputBusME.java b/src/main/java/reobf/proghatches/gt/metatileentity/RestrictedInputBusME.java index 790efe7..d5ecfe5 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/RestrictedInputBusME.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/RestrictedInputBusME.java @@ -2,6 +2,7 @@ import static gregtech.api.enums.GT_Values.TIER_COLORS; import static gregtech.api.enums.GT_Values.VN; +import static gregtech.api.enums.Mods.GregTech; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_INPUT_FLUID_HATCH; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_INPUT_FLUID_HATCH_ACTIVE; import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; @@ -30,11 +31,15 @@ import net.minecraftforge.fluids.FluidStack; import reobf.proghatches.gt.metatileentity.util.polyfill.NumericWidget; import reobf.proghatches.lang.LangManager; +import reobf.proghatches.main.MyMod; import reobf.proghatches.main.registration.Registration; import sun.misc.Unsafe; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.AdaptableUITexture; import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.drawable.Text; import com.gtnewhorizons.modularui.api.math.Alignment; @@ -48,6 +53,7 @@ import com.gtnewhorizons.modularui.api.widget.Widget; import com.gtnewhorizons.modularui.common.fluid.FluidStackTank; import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.CycleButtonWidget; import com.gtnewhorizons.modularui.common.widget.DrawableWidget; import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; import com.gtnewhorizons.modularui.common.widget.FluidSlotWidget; @@ -156,10 +162,15 @@ public ItemStack updateInformationSlot(int aIndex, ItemStack aStack) { if(s!=null&&s.stackSize0&&multiples){ + if(s!=null&&restrict_lowbound>0&&multiples==1){ s.stackSize=(s.stackSize/restrict_lowbound)*restrict_lowbound; } - + if(s!=null&&restrict_lowbound>0&&multiples==2){ + // s.stackSize=(s.stackSize/restrict_lowbound)*restrict_lowbound; + + s.stackSize=1<<(31-Integer.numberOfLeadingZeros(s.stackSize/restrict_lowbound)); + s.stackSize*=restrict_lowbound; + } @@ -197,6 +208,8 @@ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { buildContext.addSyncedWindow(CONFIG_WINDOW_ID, this::createStackSizeConfigurationWindow); + + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { if (clickData.mouseButton == 0) { if (!widget.isClient()) { @@ -215,6 +228,32 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont StatCollector.translateToLocal("proghatches.restricted.configure"))) .setSize(16, 16) .setPos(80, 10)); + + + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (clickData.mouseButton == 0) { + if (!widget.isClient()) { + + for (int index = 0; index < SLOT_COUNT; index++) { + updateInformationSlot(index, mInventory[index]); + } + } + }}) + .setBackground(() -> { + { + return new IDrawable[] { + GT_UITextures.BUTTON_STANDARD + }; + } + }) + .addTooltips( + Arrays.asList( + StatCollector.translateToLocal("proghatches.restricted.refresh.0"), + StatCollector.translateToLocal("proghatches.restricted.refresh.1"))) + .setSize(16, 16) + .setPos(80, 10+18)); + + // .widget(new FakeSyncWidget.BooleanSyncer(() -> autoPullFluidList, this::setAutoPullFluidList)); @@ -270,32 +309,48 @@ protected ModularWindow createStackSizeConfigurationWindow(final EntityPlayer pl return builder.build(); - } - boolean multiples; - ButtonWidget createMultiplesModeButton(IWidgetBuilder builder,int HEIGHT) { - - Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + } + + - multiples=!multiples; - }).attachSyncer(new FakeSyncWidget.BooleanSyncer(()->multiples, val -> { - multiples=val; - }), builder) - .setBackground(() -> { - if (multiples) { + + int multiples; + Widget createMultiplesModeButton(IWidgetBuilder builder,int HEIGHT) { + + Widget button = new CycleButtonWidget() + .setLength(3) + .addTooltip( + 0,LangManager.translateToLocal("proghatches.restricted.multiples.exact")) + .addTooltip( + 1,LangManager.translateToLocal("proghatches.restricted.multiples")) + .addTooltip( + 2,LangManager.translateToLocal("proghatches.restricted.multiples.alt")) + .setGetter(()->multiples) + .setSetter(s->multiples=s) + + .setBackground(() -> { + if (multiples==1) { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD_PRESSED, + mode0 }; + } + + else if (multiples==2) { return new IDrawable[] { GT_UITextures.BUTTON_STANDARD_PRESSED, - GT_UITextures.OVERLAY_BUTTON_POWER_SWITCH_ON }; - } else { + mode1 }; + } + + else { return new IDrawable[] { GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_POWER_SWITCH_OFF }; } }) - .addTooltip(LangManager.translateToLocal("proghatches.restricted.multiples")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) .setPos(new Pos2d(3, HEIGHT-3-16)).setSize(16, 16); - return (ButtonWidget) button; + return button; } int restrict=Integer.MAX_VALUE; int restrict_lowbound=1; @@ -304,7 +359,7 @@ public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); aNBT.setInteger("restrict", restrict); aNBT.setInteger("restrict_l", restrict_lowbound); - aNBT.setBoolean("multiples", multiples); + aNBT.setInteger("multiples", multiples); } @Override public void loadNBTData(NBTTagCompound aNBT) { @@ -312,8 +367,12 @@ public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); restrict=aNBT.getInteger( "restrict"); restrict_lowbound=aNBT.getInteger( "restrict_l"); - multiples=aNBT.getBoolean("multiples"); + multiples=aNBT.getInteger("multiples"); } +static AdaptableUITexture mode0= AdaptableUITexture +.of("proghatches", "restrict_mode0", 18, 18, 1); +static AdaptableUITexture mode1= AdaptableUITexture +.of("proghatches", "restrict_mode1", 18, 18, 1); } diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/RestrictedInputHatchME.java b/src/main/java/reobf/proghatches/gt/metatileentity/RestrictedInputHatchME.java index a4643e1..7c431b8 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/RestrictedInputHatchME.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/RestrictedInputHatchME.java @@ -34,6 +34,7 @@ import com.google.common.collect.ImmutableMap; import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.AdaptableUITexture; import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.drawable.Text; import com.gtnewhorizons.modularui.api.math.Alignment; @@ -47,6 +48,7 @@ import com.gtnewhorizons.modularui.api.widget.Widget; import com.gtnewhorizons.modularui.common.fluid.FluidStackTank; import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.CycleButtonWidget; import com.gtnewhorizons.modularui.common.widget.DrawableWidget; import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; import com.gtnewhorizons.modularui.common.widget.FluidSlotWidget; @@ -143,8 +145,14 @@ public void updateInformationSlot(int index) { if(resultFluid!=null&&resultFluid.amount0&&multiples){ + if(resultFluid!=null&&restrict_lowbound>0&&multiples==1){ resultFluid.amount=(resultFluid.amount/restrict_lowbound)*restrict_lowbound; + } + if(resultFluid!=null&&restrict_lowbound>0&&multiples==2){ + // s.stackSize=(s.stackSize/restrict_lowbound)*restrict_lowbound; + + resultFluid.amount=1<<(31-Integer.numberOfLeadingZeros(resultFluid.amount/restrict_lowbound)); + resultFluid.amount*=restrict_lowbound; } storedInformationFluids[index] = resultFluid; } catch (final GridAccessException ignored) {} @@ -197,34 +205,70 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont .setSize(16, 16) .setPos(80, 10)); // .widget(new FakeSyncWidget.BooleanSyncer(() -> autoPullFluidList, this::setAutoPullFluidList)); - + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (clickData.mouseButton == 0) { + if (!widget.isClient()) { + + for (int index = 0; index < SLOT_COUNT; index++) { + updateInformationSlot(index); + } + } + }}) + .setBackground(() -> { + { + return new IDrawable[] { + GT_UITextures.BUTTON_STANDARD + }; + } + }) + .addTooltips( + Arrays.asList( + StatCollector.translateToLocal("proghatches.restricted.refresh.0"), + StatCollector.translateToLocal("proghatches.restricted.refresh.1"))) + .setSize(16, 16) + .setPos(80, 10+18)); + super.addUIWidgets(builder, buildContext); } - boolean multiples; - ButtonWidget createMultiplesModeButton(IWidgetBuilder builder,int HEIGHT) { + int multiples; + Widget createMultiplesModeButton(IWidgetBuilder builder,int HEIGHT) { - Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { - - multiples=!multiples; - }).attachSyncer(new FakeSyncWidget.BooleanSyncer(()->multiples, val -> { - multiples=val; - }), builder) - .setBackground(() -> { - if (multiples) { - return new IDrawable[] { GT_UITextures.BUTTON_STANDARD_PRESSED, - GT_UITextures.OVERLAY_BUTTON_POWER_SWITCH_ON }; - } else { - return new IDrawable[] { GT_UITextures.BUTTON_STANDARD, - GT_UITextures.OVERLAY_BUTTON_POWER_SWITCH_OFF }; - } - }) - .addTooltip(LangManager.translateToLocal("proghatches.restricted.multiples")) + Widget button = new CycleButtonWidget() + .setLength(3) + .addTooltip( + 0,LangManager.translateToLocal("proghatches.restricted.multiples.exact")) + .addTooltip( + 1,LangManager.translateToLocal("proghatches.restricted.multiples")) + .addTooltip( + 2,LangManager.translateToLocal("proghatches.restricted.multiples.alt")) + .setGetter(()->multiples) + .setSetter(s->multiples=s) + + .setBackground(() -> { + if (multiples==1) { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD_PRESSED, + mode0 }; + } + + else if (multiples==2) { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD_PRESSED, + mode1 }; + } + + else { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD, + GT_UITextures.OVERLAY_BUTTON_POWER_SWITCH_OFF }; + } + }) + + + .setTooltipShowUpDelay(TOOLTIP_DELAY) .setPos(new Pos2d(3, HEIGHT-3-16)).setSize(16, 16); - return (ButtonWidget) button; + return button; } protected ModularWindow createStackSizeConfigurationWindow(final EntityPlayer player) { final int WIDTH = 78; @@ -278,7 +322,7 @@ public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); aNBT.setInteger("restrict", restrict); aNBT.setInteger("restrict_l", restrict_lowbound); - aNBT.setBoolean("multiples", multiples); + aNBT.setInteger("multiples", multiples); } @Override public void loadNBTData(NBTTagCompound aNBT) { @@ -286,8 +330,11 @@ public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); restrict=aNBT.getInteger( "restrict"); restrict_lowbound=aNBT.getInteger( "restrict_l"); - multiples=aNBT.getBoolean("multiples"); + multiples=aNBT.getInteger("multiples"); } - +static AdaptableUITexture mode0= AdaptableUITexture +.of("proghatches", "restrict_mode0", 18, 18, 1); +static AdaptableUITexture mode1= AdaptableUITexture +.of("proghatches", "restrict_mode1", 18, 18, 1); } diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/SuperChestME.java b/src/main/java/reobf/proghatches/gt/metatileentity/SuperChestME.java index a083573..9636c0a 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/SuperChestME.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/SuperChestME.java @@ -280,6 +280,7 @@ public void updateFilter(ItemStack fs){ IMEInventoryHandler handler =new MEInventoryHandler(new UnlimitedWrapper() , StorageChannel .ITEMS){ + public boolean getSticky() {return sticky&&!suppressSticky;}; public int getPriority() {return piority;}; { diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java b/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java index 5e18f1c..bb7c454 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java @@ -22,6 +22,8 @@ import com.google.common.collect.ImmutableList; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment; +import com.gtnewhorizon.structurelib.structure.IItemSource; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.IStructureElement; import com.gtnewhorizon.structurelib.structure.IStructureElementChain; @@ -62,6 +64,8 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; @@ -77,14 +81,18 @@ import gregtech.common.tileentities.machines.IDualInputHatch; import gregtech.common.tileentities.machines.IDualInputInventory; import gregtech.common.tileentities.machines.IRecipeProcessingAwareHatch; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.PacketBuffer; +import net.minecraft.util.IChatComponent; import net.minecraft.util.StatCollector; +import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import reobf.proghatches.block.BlockIOHub; +import reobf.proghatches.gt.metatileentity.CommunicationPortHatch; import reobf.proghatches.gt.metatileentity.DualInputHatch; import reobf.proghatches.gt.metatileentity.util.IRecipeProcessingAwareDualHatch; import reobf.proghatches.lang.LangManager; @@ -99,7 +107,51 @@ public IngredientDistributor(String aName) { super(aName); } - + public static IStructureElement ofFrameAdder(Materials aFrameMaterial,Consumer onadded) { + IStructureElement frame = GT_StructureUtility.ofFrame(aFrameMaterial); + + return new IStructureElement() { + + @Override + public boolean check(T t, World world, int x, int y, int z) { + boolean b=frame.check(t, world, x, y, z); + if(b)onadded.accept(t); + return b; + } + @Override + public com.gtnewhorizon.structurelib.structure.IStructureElement.BlocksToPlace getBlocksToPlace(T t, + World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) { + + return frame.getBlocksToPlace(t, world, x, y, z, trigger, env); + } + @Override + public com.gtnewhorizon.structurelib.structure.IStructureElement.PlaceResult survivalPlaceBlock(T t, + World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) { + + return frame.survivalPlaceBlock(t, world, x, y, z, trigger, env); + } + @SuppressWarnings("deprecation") + @Override + public com.gtnewhorizon.structurelib.structure.IStructureElement.PlaceResult survivalPlaceBlock(T t, + World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor, + Consumer chatter) { + + return frame.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter); + } + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + + return frame.spawnHint(aFrameMaterial, world, x, y, z, trigger); + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + + return frame.placeBlock(aFrameMaterial, world, x, y, z, trigger); + } + }; + + } public static boolean addDual(IngredientDistributor thiz,IGregTechTileEntity aTileEntity, short aBaseCasingIndex){ if (aTileEntity == null) return false; IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); @@ -118,6 +170,7 @@ public static boolean addDual(IngredientDistributor thiz,IGregTechTileEntity aTi } + CommunicationPortHatch port; boolean allMEHatch=true; boolean hasHatchThisLayer; boolean hasBusThisLayer; @@ -146,7 +199,10 @@ public boolean addOutputHatchToMachineList(IGregTechTileEntity aTileEntity, int } return ok; }; - + + boolean isLiteVersion; + + @SuppressWarnings("unchecked") IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition. builder() .addShape("first", StructureUtility.transpose (new String[][] { { "m","f","c"}, { "m","f","c"}, { "m","f","c"}} )) @@ -157,8 +213,26 @@ public boolean addOutputHatchToMachineList(IGregTechTileEntity aTileEntity, int .addShape("last", StructureUtility.transpose (new String[][] { { " "," "," "}, { " ","f"," "}, { " ","f"," "} })) - .addElement('c', ofBlock(GregTech_API.sBlockCasings4, 12)) - .addElement('f', GT_StructureUtility.ofFrame(Materials.Terbium)) + .addElement('c', + + + + + + ofBlock(GregTech_API.sBlockCasings4, 12) + + + + + ) + .addElement('f',StructureUtility.ofChain( + GT_StructureUtility.ofFrame(Materials.Terbium), + ofFrameAdder(Materials.Yttrium,s->((IngredientDistributor) s).onCheapFrameFound()) + + + + + )) .addElement('h', buildHatchAdder(IngredientDistributor.class) .atLeast(GT_HatchElement.OutputBus.withAdder(IngredientDistributor::addBus) @@ -187,9 +261,59 @@ public boolean addOutputHatchToMachineList(IGregTechTileEntity aTileEntity, int .addElement('m', buildHatchAdder(IngredientDistributor.class) .atLeast(GT_HatchElement.Maintenance,GT_HatchElement.Energy) .casingIndex(CASING_INDEX).dot(3) - .buildAndChain(GregTech_API.sBlockCasings4, 12)) + .buildAndChain( + buildHatchAdder(IngredientDistributor.class) + .atLeast( + new IHatchElement(){ + + @Override + public List> mteClasses() { + + return ImmutableList.of(CommunicationPortHatch.class); + } + + @Override + public IGT_HatchAdder adder() { + + return (s,w,u)->{ + if(s==null)return false; + if(s.port!=null)return false; + s.port=(CommunicationPortHatch) w.getMetaTileEntity(); + if(s.port==null)return false; + s.port.updateTexture(CASING_INDEX); + return true; + + }; + } + + @Override + public String name() { + + return "commport"; + } + + @Override + public long count(IngredientDistributor t) { + + return port==null?0:1; + }} + ) + + .hatchItemFilter(s->( + //have to return this or will this not be displayed in NEI 'availale hatches' list + is->is.getItemDamage()==Registration.CommunicationPortHatchOffset+Config.metaTileEntityOffset + )) + + + + .casingIndex(CASING_INDEX).dot(3).build(), + + ofBlock(GregTech_API.sBlockCasings4, 12) + ) + ) .addElement('◎', buildHatchAdder(IngredientDistributor.class) + .atLeast( new IHatchElement(){ @@ -237,6 +361,10 @@ public IngredientDistributor(int aID, String aName, String aNameRegional) { + private void onCheapFrameFound() { + isLiteVersion=true; + return ; + } @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { @@ -335,6 +463,8 @@ public void construct(ItemStack stackSize, boolean hintsOnly) { } @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + isLiteVersion=false; + port=null; if(checkPiece("first", 1, 1, 0)&& checkPiece("second", 0, 1, 0)&& checkPiece("third", -1, 1, 0) @@ -348,8 +478,13 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a index--; }; - + if(port!=null&&allMEHatch==false){return false;} return checkPiece("last", index, 1, 0)&&this.mEnergyHatches.size()>0; + + + + + @@ -400,20 +535,66 @@ protected void drawTexts(DynamicPositionedColumn screenElements, SlotWidget inve */ - - +boolean yield; +int count; +int cd; +int cdmax=1; @Override -protected void runMachine(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { -super.runMachine(aBaseMetaTileEntity, aTick); -if(!mMachine)return; + protected void runMachine(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.runMachine(aBaseMetaTileEntity, aTick); + if (!mMachine) + return; + + if (ready > 0 && aBaseMetaTileEntity.isAllowedToWork()) { + boolean trylock = false; + boolean porton = false; + if (port != null && !lockRecipe && isAllMEOutputEmpty() == true + && (!port.getBaseMetaTileEntity().getRedstone() || count > 0) && !isInputEmpty()) { + count++; + porton = true; + if (count > 100) { + count = 0; + trylock = true; + } + } else { + count = 0; + } + if(port!=null){ + yield=(!porton&&count==0&&port.getBaseMetaTileEntity().getRedstone()&&!lockRecipe); + + + port.setRS(porton);} + if(trylock){ + + cd=0; + cdmax=1; + } + if ((port != null && lockRecipe && isAllMEOutputEmpty() == false) || port == null || trylock) + if(++cd>=cdmax){ + cd=0; + if (distribute()) { + ready--; + if (port != null) { + if (trylock) + lockRecipe = true; + + } + lastfail = null; + cd=0; + cdmax=1; + }else{ + if(cdmax<16)cdmax*=2; + } + } -if(ready>0&&aBaseMetaTileEntity.isAllowedToWork()){ - if(distribute()){ - ready--; - lastfail=null; - } -} + if (port != null) { + if (isAllMEOutputEmpty()) { + lockRecipe = false; + } + } + + } } /* @SuppressWarnings({ "unchecked", "rawtypes", "unused" }) @@ -440,6 +621,33 @@ public CheckRecipeResult endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase co } */ + +public boolean isInputEmpty(){ + startRecipeProcessing(); + + + try{ + if(mDualInputHatches.size()==1){ + return !mDualInputHatches.get(0).getFirstNonEmptyInventory().isPresent(); + } + if(mInputBusses.size()==1){ + GT_MetaTileEntity_Hatch_InputBus bus = mInputBusses.get(0); + for(int i=0;i0){return false;} + } + } + if(mInputHatches.size()==1){ + ArrayList bus =getStoredFluids(); + for(int i=0;i0){return false;} + } + } + return true; + }finally{ + endRecipeProcessing(); + + } +} @SuppressWarnings("unchecked") private boolean distribute() { @@ -725,16 +933,58 @@ private IAEItemStack cp(IAEItemStack c){ if(c!=null)return c.copy(); return null; } +private boolean isAllMEOutputEmpty(){ + + for(GT_MetaTileEntity_Hatch_OutputBus o:mOutputBusses){ + if(o instanceof GT_MetaTileEntity_Hatch_OutputBus_ME){ + + IItemList itemCache; + try { + itemCache = (IItemList) f.get(o); + if(itemCache.isEmpty()==false){return false;} + itemCache=o.getProxy().getStorage().getItemInventory().getStorageList(); + if(itemCache.isEmpty()==false){return false;} + + } catch (Exception e) {e.printStackTrace(); + } + }else return false; + } + + for(GT_MetaTileEntity_Hatch_Output o:mOutputHatches){ + if(o instanceof GT_MetaTileEntity_Hatch_Output_ME){ + + IItemList itemCache; + try { + itemCache = (IItemList) f2.get(o); + if(itemCache.isEmpty()==false){return false;} + itemCache=o.getProxy().getStorage().getFluidInventory().getStorageList(); + if(itemCache.isEmpty()==false){return false;} + } catch (Exception e) {e.printStackTrace(); + } + }else return false; + } + return true; +} + static Field f,f2; -@SuppressWarnings({ "unchecked", "unused" }) -private TransferCheckResult checkMEBus(GT_MetaTileEntity_Hatch_OutputBus_ME bus,ItemStack check,int index){ - if(f==null) +static{ +if(f==null) try { f=GT_MetaTileEntity_Hatch_OutputBus_ME.class.getDeclaredField("itemCache"); f.setAccessible(true); } catch (Exception e) { e.printStackTrace(); } +if(f2==null) + try { + f2=GT_MetaTileEntity_Hatch_Output_ME.class.getDeclaredField("fluidCache"); + f2.setAccessible(true); + } catch (Exception e) { + e.printStackTrace(); + }} +@SuppressWarnings({ "unchecked", "unused" }) +private TransferCheckResult checkMEBus(GT_MetaTileEntity_Hatch_OutputBus_ME bus,ItemStack check,int index){ + try { IItemList itemCache =(IItemList) f.get(bus); Iterator itr = itemCache.iterator(); @@ -775,13 +1025,7 @@ private TransferCheckResult checkMEBus(GT_MetaTileEntity_Hatch_OutputBus_ME bus, } @SuppressWarnings({ "unchecked", "unused" }) private TransferCheckResult checkMEHatch(GT_MetaTileEntity_Hatch_Output_ME bus,FluidStack check,int index){ - if(f2==null) - try { - f2=GT_MetaTileEntity_Hatch_Output_ME.class.getDeclaredField("fluidCache"); - f2.setAccessible(true); - } catch (Exception e) { - e.printStackTrace(); - } + try { IItemList itemCache =(IItemList) f2.get(bus); Iterator itr = itemCache.iterator(); @@ -1047,6 +1291,10 @@ public void loadNBTData(NBTTagCompound aNBT) { blocking=aNBT.getBoolean("blocking"); emptyRun=aNBT.getBoolean("emptyRun"); allMEHatch=aNBT.getBoolean("allMEHatch"); + count=aNBT.getInteger("count"); + cd=aNBT.getInteger("cd"); + cdmax=aNBT.getInteger("cdmax"); + lockRecipe=aNBT.getBoolean("lockRecipe"); super.loadNBTData(aNBT); } @Override @@ -1055,11 +1303,18 @@ public void saveNBTData(NBTTagCompound aNBT) { aNBT.setBoolean("blocking", blocking); aNBT.setBoolean("emptyRun", emptyRun); aNBT.setBoolean("allMEHatch", allMEHatch); + + aNBT.setInteger("count", count); + aNBT.setInteger("cd", cd); + aNBT.setInteger("cdmax", cdmax); + aNBT.setBoolean("lockRecipe", lockRecipe); super.saveNBTData(aNBT); } + +boolean lockRecipe; @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - + if(isLiteVersion)blocking=false; if( !aBaseMetaTileEntity.getWorld().isRemote&&mMachine){ if (!allMEHatch) { blocking=false; @@ -1117,7 +1372,40 @@ public void addUIWidgets(com.gtnewhorizons.modularui.api.screen.ModularWindow.Bu val -> { blocking=val; }).setSynced(true, true)) - ; + .widget(new FakeSyncWidget.BooleanSyncer( + ()->lockRecipe, + val -> { + lockRecipe=val; + }).setSynced(true, false)) + .widget(new FakeSyncWidget.BooleanSyncer( + ()->port!=null, + val -> { + clientport=val; + }).setSynced(true, false)) + + .widget(new FakeSyncWidget.IntegerSyncer( + ()->count, + val -> { + count=val; + }).setSynced(true, false)) + .widget(new FakeSyncWidget.IntegerSyncer( + ()->cd, + val -> { + cd=val; + }).setSynced(true, false)) + .widget(new FakeSyncWidget.IntegerSyncer( + ()->cdmax, + val -> { + cdmax=val; + }).setSynced(true, false)) + .widget(new FakeSyncWidget.BooleanSyncer( + ()->yield, + val -> { + yield=val; + }).setSynced(true, false)) + ; + + } ButtonWidget createBlockingModeButton(IWidgetBuilder builder) { @@ -1164,6 +1452,8 @@ public static boolean addBus(IngredientDistributor thiz, IGregTechTileEntity aTi if(thiz.hasBusThisLayer){return false;} return thiz.addOutputBusToMachineList(aTileEntity, s); } + +boolean clientport; protected void drawTexts(DynamicPositionedColumn screenElements, SlotWidget inventorySlot) { super.drawTexts(screenElements, inventorySlot); @@ -1177,5 +1467,44 @@ protected void drawTexts(DynamicPositionedColumn screenElements, SlotWidget inve .setEnabled(widget -> { return (getBaseMetaTileEntity().isAllowedToWork())&&lastfail!=null; })); + + screenElements.widget( + TextWidget.dynamicString(()-> + { if(yield)return StatCollector.translateToLocal("proghatch.ingbuf.yield"); + if(count>0)return StatCollector.translateToLocal("proghatch.ingbuf.acquring"); + if(lockRecipe)return StatCollector.translateToLocal("proghatch.ingbuf.locked"); + + return StatCollector.translateToLocal("proghatch.ingbuf.idle"); + } + + ).setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> clientport)); + + + + screenElements.widget( + TextWidget.dynamicString(()-> + "lock:"+lockRecipe + + ).setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> clientport)); + + screenElements.widget( + TextWidget.dynamicString(()-> + "count:"+count + + ).setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> clientport)); + + screenElements.widget( + TextWidget.dynamicString(()-> + cd+"/"+cdmax + + ).setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> clientport)); + + + + } } diff --git a/src/main/java/reobf/proghatches/main/CommonProxy.java b/src/main/java/reobf/proghatches/main/CommonProxy.java index c0a12db..69218af 100644 --- a/src/main/java/reobf/proghatches/main/CommonProxy.java +++ b/src/main/java/reobf/proghatches/main/CommonProxy.java @@ -116,7 +116,8 @@ public void preInit(FMLPreInitializationEvent event) { GameRegistry.registerItem(MyMod.eu_token = new ItemEUToken().setUnlocalizedName("eu_token").setTextureName("?"), "eu_token"); - GameRegistry.registerItem(MyMod.book = new ItemBookTutorial().setUnlocalizedName("writtenBook") + GameRegistry.registerItem(MyMod.book = new ItemBookTutorial() + .setUnlocalizedName("writtenBook") .setTextureName("book_written").setMaxStackSize(16), "book_tutorial"); GameRegistry.registerItem( MyMod.upgrades = new ItemUpgrades().setUnlocalizedName("prog_upgrades").setTextureName("?"), diff --git a/src/main/java/reobf/proghatches/main/registration/PHRecipes.java b/src/main/java/reobf/proghatches/main/registration/PHRecipes.java index 9a4d130..1506f62 100644 --- a/src/main/java/reobf/proghatches/main/registration/PHRecipes.java +++ b/src/main/java/reobf/proghatches/main/registration/PHRecipes.java @@ -14,6 +14,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.function.Supplier; import javax.print.DocFlavor.INPUT_STREAM; @@ -60,7 +61,9 @@ public class PHRecipes implements Runnable { Robot_Arm_LV.get(1), Robot_Arm_MV.get(1), Robot_Arm_HV.get(1), Robot_Arm_EV.get(1), Robot_Arm_IV.get(1), Robot_Arm_LuV.get(1), Robot_Arm_ZPM.get(1), Robot_Arm_UV.get(1), Robot_Arm_UHV.get(1), Robot_Arm_UEV.get(1), Robot_Arm_UIV.get(1), Robot_Arm_UMV.get(1), Robot_Arm_UXV.get(1), Robot_Arm_MAX.get(1) }; - Materials[][] mat = { + Materials[][] mat =null; + + Supplier metget=()->new Materials[][]{ { Primitive }, { Basic }, { Good }, @@ -113,6 +116,7 @@ public void run() { MyMod.LOG.info("Found new dreamcraft Nano-Piko-Quantum circuit, use oredict: Exotic-Cosmic-Transcendent."); mat=matNewVersion;} else{ + mat=metget.get(); MyMod.LOG.info("Good ol' version."); } diff --git a/src/main/java/reobf/proghatches/main/registration/Registration.java b/src/main/java/reobf/proghatches/main/registration/Registration.java index 870aeef..d3eaf99 100644 --- a/src/main/java/reobf/proghatches/main/registration/Registration.java +++ b/src/main/java/reobf/proghatches/main/registration/Registration.java @@ -31,6 +31,7 @@ import reobf.proghatches.gt.cover.SmartArmCover; import reobf.proghatches.gt.cover.WirelessControlCover; import reobf.proghatches.gt.metatileentity.BufferedDualInputHatch; +import reobf.proghatches.gt.metatileentity.CommunicationPortHatch; import reobf.proghatches.gt.metatileentity.DataHatchME; import reobf.proghatches.gt.metatileentity.DualInputHachOC; import reobf.proghatches.gt.metatileentity.DualInputHatch; @@ -99,7 +100,7 @@ public class Registration implements Runnable { public final static int PatternMappingSlaveOffset=167; public static final int SlaveBusOffset = 168; public static final int SlaveHatchOffset = 169; - + public static final int CommunicationPortHatchOffset= 170; @SuppressWarnings("deprecation") @Override public void run() { @@ -438,7 +439,12 @@ public void run() { "hatch.dualinput.slave.fluid", LangManager.translateToLocal("hatch.dualinput.slave.fluid.name")); - + new CommunicationPortHatch( + Config.metaTileEntityOffset + CommunicationPortHatchOffset, + "hatch.commport", + LangManager.translateToLocalFormatted("hatch.commport.name"), 4 + + ); /*for (int i = 0; i < 4; i++) { new DualInputHatch( diff --git a/src/main/resources/assets/proghatches/lang/en_US.lang b/src/main/resources/assets/proghatches/lang/en_US.lang index 56ea730..31e92f7 100644 --- a/src/main/resources/assets/proghatches/lang/en_US.lang +++ b/src/main/resources/assets/proghatches/lang/en_US.lang @@ -572,4 +572,14 @@ tile.reactor_syncer.skip.false=No Redstone in the first Reactor Cycle: false tile.reactor_syncer.skip.0=Reactor updates every 20 ticks, however every time you load the game the counter shuffles. tile.reactor_syncer.skip.1=This option gives you one update cycle to restore everything. tile.reactor_syncer.skip.2=Especially useful if the game was saved in a bad tick, and the counter happens to be 0 at random. +proghatches.restricted.refresh.0=Refresh Slots +proghatches.restricted.refresh.1=Just to query currently available amount, actual amount may vary in runtime. +programmable_hatches.gt.merge=Merge buffers locking same recipe and display one single buffer to multiblock. +proghatches.restricted.multiples.alt=Restrict amount to a power of 2 multiply of Minimum amount +proghatches.restricted.multiples.exact=No restriction +hatch.commport.name=Statusbus Communication Port +proghatch.ingbuf.yield=State: Yield. Because the Statusbus is acquired by another host. +proghatch.ingbuf.acquring=State: Acquring. Prevent other hosts from locking new recipe. +proghatch.ingbuf.locked=State: Locked. Will unlock if output network is empty. +proghatch.ingbuf.idle=State: Idle. diff --git a/src/main/resources/assets/proghatches/lang/en_US/M_ID.lang b/src/main/resources/assets/proghatches/lang/en_US/M_ID.lang index c610237..997e1e2 100644 --- a/src/main/resources/assets/proghatches/lang/en_US/M_ID.lang +++ b/src/main/resources/assets/proghatches/lang/en_US/M_ID.lang @@ -7,9 +7,10 @@ beginVariableStructureBlock(3¶3¶5¶16¶3¶3¶false)->(IIIIIIZ) addStructureInfo(The structure is too complex!)->(Ljava/lang/String;) addOtherStructurePart(Robust Tungstensteel Machine Casing¶Use Blueprint to preview)->(Ljava/lang/String;Ljava/lang/String;) addOtherStructurePart(Tungstensteel Turbine Casing¶Use Blueprint to preview)->(Ljava/lang/String;Ljava/lang/String;) -addOtherStructurePart(Terbium Frame¶Use Blueprint to preview)->(Ljava/lang/String;Ljava/lang/String;) +addOtherStructurePart(Terbium Frame/Yttrium Frame¶Use Blueprint to preview)->(Ljava/lang/String;Ljava/lang/String;) addOtherStructurePart(Input Hatch/Bus/Dual Hatch¶Dot 2)->(Ljava/lang/String;Ljava/lang/String;) addOtherStructurePart(Output Bus/Hatch¶Dot 1, every slice might contain up to one Bus and one Hatch)->(Ljava/lang/String;Ljava/lang/String;) +addStructureInfo(Use ALL Terbium Frames to unlock Blocking Mode.)->(Ljava/lang/String;) addStructureInfo(Blocking Mode is only available if all Buses/Hatches are of ME version. )->(Ljava/lang/String;) addEnergyHatch(Dot 3¶3)->(Ljava/lang/String;[I) addMaintenanceHatch(Dot 3¶3)->(Ljava/lang/String;[I) \ No newline at end of file diff --git a/src/main/resources/assets/proghatches/lang/zh_CN.lang b/src/main/resources/assets/proghatches/lang/zh_CN.lang index bdec361..5ce6a39 100644 --- a/src/main/resources/assets/proghatches/lang/zh_CN.lang +++ b/src/main/resources/assets/proghatches/lang/zh_CN.lang @@ -570,3 +570,14 @@ tile.reactor_syncer.skip.false=第一个反应堆更新周期不输出信号: fa tile.reactor_syncer.skip.0=反应堆每20tick更新,但每次读档计数器会被随机重置 tile.reactor_syncer.skip.1=这个选项空出第一个更新周期不输出信号,以便你恢复现场,拯救你的反应堆于水火 tile.reactor_syncer.skip.2=尤其是考虑到可能再换棒到一半时存档,再读档时计数器会正好随机到0 +proghatches.restricted.refresh.0=刷新 +proghatches.restricted.refresh.1=只是查询当前能够拉取的数量 实际数量取决于运行时 +programmable_hatches.gt.merge=合并锁定同一配方的缓存,向多方块显示为单个缓存 +proghatches.restricted.multiples.alt=限制拉取数量为数量下限的2的幂次倍 +proghatches.restricted.multiples.exact=不限制 +hatch.commport.name=状态总线通讯端口 +proghatch.ingbuf.yield=状态: 总线已让渡给其它主机 总线被释放前此主机不会工作 +proghatch.ingbuf.acquring=状态: 总线被此机占据 以阻止其它主机锁定新配方 释放总线前会尝试锁定新配方 +proghatch.ingbuf.locked=状态: 配方已锁定 无视总线状态 仅处理锁定配方 在输出清空后回到空闲状态 +proghatch.ingbuf.idle=状态: 总线空闲 + diff --git a/src/main/resources/assets/proghatches/lang/zh_CN/M_ID.lang b/src/main/resources/assets/proghatches/lang/zh_CN/M_ID.lang index 566e921..cd80f5a 100644 --- a/src/main/resources/assets/proghatches/lang/zh_CN/M_ID.lang +++ b/src/main/resources/assets/proghatches/lang/zh_CN/M_ID.lang @@ -9,10 +9,11 @@ addStructureInfo(结构太复杂了!)->(Ljava/lang/String;) addStructureInfo(机器头部为3x3x3结构,中间部分长度不定,尾部两个框架)->(Ljava/lang/String;) addOtherStructurePart(钨钢涡轮方块¶机器头部,至少13个,使用蓝图预览)->(Ljava/lang/String;Ljava/lang/String;) addOtherStructurePart(强化钨钢机械方块¶每个输出片1~3个,使用蓝图预览)->(Ljava/lang/String;Ljava/lang/String;) -addOtherStructurePart(铽框架¶使用蓝图预览)->(Ljava/lang/String;Ljava/lang/String;) +addOtherStructurePart(铽框架/钇框架¶使用蓝图预览)->(Ljava/lang/String;Ljava/lang/String;) addOtherStructurePart(输入仓/总线/总成¶2号)->(Ljava/lang/String;Ljava/lang/String;) addOtherStructurePart(输出仓/总线¶1号,替换中间部分强化钨钢机械方块, 每一片中至多包含一个仓与一个总线)->(Ljava/lang/String;Ljava/lang/String;) addStructureInfo(若对中间部分的仓室限制感到疑惑,参考装配线即可)->(Ljava/lang/String;) +addStructureInfo(必须全部使用铽框架以解锁阻挡模式)->(Ljava/lang/String;) addStructureInfo(仅当所有输出仓/总线是ME版本时,才能启用阻挡模式)->(Ljava/lang/String;) addEnergyHatch(3号,机器头部正面钨钢涡轮方块¶3)->(Ljava/lang/String;[I) addMaintenanceHatch(3号,机器头部正面钨钢涡轮方块¶3)->(Ljava/lang/String;[I) \ No newline at end of file diff --git a/src/main/resources/assets/proghatches/textures/restrict_mode0.png b/src/main/resources/assets/proghatches/textures/restrict_mode0.png new file mode 100644 index 0000000000000000000000000000000000000000..fbb058956b7730914852acceb4c0d351d33911c9 GIT binary patch literal 668 zcmV;N0%QG&P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0x?NMK~z{r?bXXm z6=58Q@sk$jEwa0IF zRzX2fQc;m6YId`-dY;ov9CSPz54f2xe3&!W_nmov?|Tw);>3xw(peR3*We}!g5O#A zg9~^S?3dvdif|WS@dZuz0I%_Rr!gMvuY>XUYIx6Ec>OQ@j}0HgWjw)e%-}YvaU7p8 zhbdgaS**tvoPp=&gY6AW!)Hvwd*0z5+E9YX>_7+XsSoNzJ~rVoUg8pVA&lqu;v)QN zHt5@3#|dnNU#|;4@CYZdWDcPpKE&+-_!T~57)KG6X4nD0!T^rI;SAG&F?>h62aMyi zFwZau8?3=8^kFvGjv`$q@DRS~PY(p~?Z3fVaM+TG>VSoHAKl17D;$m<48e}2i`UxO z)W%bj4LgxcR0qs!+`&_9fDg1dt>BDisSY@fR{dr;BX*(~R((bj)dA=1RvduZ4@pd)TN$QICD_ zKF^oJ&KqlF8{GGIIPbkC561i4&kx_iaXpCh$-RGt_XZ!~eBKS0W0%yhvyJG5=N&em z;hO&(cHaL2@Au8iu?MaZFW?`X=M^VToH#3)MB*>vs(InrnXL-|0000Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0{}@xK~z{r?blg| zO>rE+@x$1MEMs2>FCOe!9`HhmC<-N-5-*~ZB#)vfdGO*%@}?|r42?0&gZ0IpkR_3^ z4HKH|%lF%yf1SAZ99{0E_|<3T%whzYob zo7f2leF&dWUy5z$F6h~E89l{&xD|V$2?d26FULfjfLZ+jcX1l-`_3rZ0Bw9O&cgyT z5|x;T>###J&>p`%9F-OA3{GM&TvtDLx)}vzXTs~5HFD$c49iN!Uy?#L|czxaMWpGgPU*}cD5~kI_$(OI1@JLlI+1@xXrTir6cUPOR@-=3HW`O z3$C?|U%^Vaon|6A&AGyav?#eNmZBRn6EIhp50h{SF2yknKw7vgE}w5WRj|w!)OZNj zaUJes6?}2X7p}3(a~#XyPWh$A{j$kc3+ws?j7F|-S*(aPSOKeEXxw};C$g6AhcI#W zp&GtEnUF`}!IBIcus(R7xnieXz7Wou?|sflY9uq;=^PFZn$2()_QH{kMHr2vw1MsL zp0jv}@S5c_t&YxI4?jqY&}+YBvTeg|xCT7s|o36li>mL7|wuO&9XfRV=yIQHvEqF9e{7ddBYAk zqVUgyUvlqTcI|*8@xXCetPvKOXIKLZm$PQUG9Ln`-{l#Fn%&+__z{H+m1-vBt=kQ%SQ{Sg2F002ovPDHLkV1h`a Bk=y_P literal 0 HcmV?d00001 From b3cc91ae5d55f7e29752c298dfe946d5edb1feb3 Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Mon, 30 Sep 2024 17:52:16 +0800 Subject: [PATCH 06/12] update --- repositories.gradle | 9 ++++----- .../gt/metatileentity/multi/IngredientDistributor.java | 4 ++++ src/main/resources/assets/proghatches/lang/en_US.lang | 2 +- src/main/resources/assets/proghatches/lang/zh_CN.lang | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/repositories.gradle b/repositories.gradle index c884390..0bf4d73 100644 --- a/repositories.gradle +++ b/repositories.gradle @@ -1,5 +1,4 @@ -// Add any additional repositories for your dependencies here - -repositories { - -} +maven { + name "ModMaven" + url "https://modmaven.dev" +} \ No newline at end of file diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java b/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java index bb7c454..57e866c 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java @@ -1315,6 +1315,10 @@ public void saveNBTData(NBTTagCompound aNBT) { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if(isLiteVersion)blocking=false; + if(blocking==false&&port!=null){ + + LargeProgrammingCircuitProvider.shut(this,"proghatch.commport"); + } if( !aBaseMetaTileEntity.getWorld().isRemote&&mMachine){ if (!allMEHatch) { blocking=false; diff --git a/src/main/resources/assets/proghatches/lang/en_US.lang b/src/main/resources/assets/proghatches/lang/en_US.lang index 31e92f7..6a96330 100644 --- a/src/main/resources/assets/proghatches/lang/en_US.lang +++ b/src/main/resources/assets/proghatches/lang/en_US.lang @@ -582,4 +582,4 @@ proghatch.ingbuf.yield=State: Yield. Because the Statusbus is acquired by anothe proghatch.ingbuf.acquring=State: Acquring. Prevent other hosts from locking new recipe. proghatch.ingbuf.locked=State: Locked. Will unlock if output network is empty. proghatch.ingbuf.idle=State: Idle. - +GT5U.gui.text.proghatch.commport=Cannot run in non-Blocking Mode with Statusbus Communication Port. diff --git a/src/main/resources/assets/proghatches/lang/zh_CN.lang b/src/main/resources/assets/proghatches/lang/zh_CN.lang index 5ce6a39..2659865 100644 --- a/src/main/resources/assets/proghatches/lang/zh_CN.lang +++ b/src/main/resources/assets/proghatches/lang/zh_CN.lang @@ -580,4 +580,4 @@ proghatch.ingbuf.yield=状态: 总线已让渡给其它主机 总线被释放前 proghatch.ingbuf.acquring=状态: 总线被此机占据 以阻止其它主机锁定新配方 释放总线前会尝试锁定新配方 proghatch.ingbuf.locked=状态: 配方已锁定 无视总线状态 仅处理锁定配方 在输出清空后回到空闲状态 proghatch.ingbuf.idle=状态: 总线空闲 - +GT5U.gui.text.proghatch.commport=无法在非阻挡模式下和状态总线通讯端口运行 From b1774bae129871ac83456a61175454f2440c9638 Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Mon, 30 Sep 2024 17:56:04 +0800 Subject: [PATCH 07/12] update --- repositories.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/repositories.gradle b/repositories.gradle index 0bf4d73..cad8fdf 100644 --- a/repositories.gradle +++ b/repositories.gradle @@ -1,4 +1,8 @@ +// Add any additional repositories for your dependencies here + +repositories { maven { name "ModMaven" url "https://modmaven.dev" -} \ No newline at end of file +} +} From 5f19340353f7abfc91ed60551e76c29f162f4181 Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Mon, 30 Sep 2024 18:18:21 +0800 Subject: [PATCH 08/12] update --- repositories.gradle | 4 ---- settings.gradle | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/repositories.gradle b/repositories.gradle index cad8fdf..c227b16 100644 --- a/repositories.gradle +++ b/repositories.gradle @@ -1,8 +1,4 @@ // Add any additional repositories for your dependencies here repositories { -maven { - name "ModMaven" - url "https://modmaven.dev" -} } diff --git a/settings.gradle b/settings.gradle index e334397..76df392 100644 --- a/settings.gradle +++ b/settings.gradle @@ -7,7 +7,8 @@ pluginManagement { url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/" allowInsecureProtocol = true mavenContent { - includeGroup("com.gtnewhorizons.retrofuturagradle") + includeGroup("com.gtnewhorizons") + includeGroupByRegex("com\\.gtnewhorizons\\..+") } } gradlePluginPortal() From 43050fa630166e6e5af321a23502450abf61fe8f Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Mon, 30 Sep 2024 18:24:12 +0800 Subject: [PATCH 09/12] update --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 76df392..5053ca7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,7 +4,7 @@ pluginManagement { maven { // RetroFuturaGradle name "GTNH Maven" - url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/" + url "https://nexus.gtnewhorizons.com/repository/public/" allowInsecureProtocol = true mavenContent { includeGroup("com.gtnewhorizons") From 4c3d50bb5cfa9653d4f60cb35a402a5b95210db7 Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Mon, 30 Sep 2024 18:49:33 +0800 Subject: [PATCH 10/12] update --- build.gradle | 1611 +---------------------------------------------- settings.gradle | 14 +- 2 files changed, 4 insertions(+), 1621 deletions(-) diff --git a/build.gradle b/build.gradle index a3f752f..34151b8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,1613 +1,4 @@ -//version: 1701530445 -/* - DO NOT CHANGE THIS FILE! - Also, you may replace this file at any time if there is an update available. - Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/master/build.gradle for updates. - */ -/* -I changed this file anyway -*/ -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar -import com.gtnewhorizons.retrofuturagradle.ObfuscationAttribute -import com.gtnewhorizons.retrofuturagradle.mcp.ReobfuscatedJar -import com.gtnewhorizons.retrofuturagradle.minecraft.RunMinecraftTask -import com.gtnewhorizons.retrofuturagradle.util.Distribution -import com.matthewprenger.cursegradle.CurseArtifact -import com.matthewprenger.cursegradle.CurseRelation -import com.modrinth.minotaur.dependencies.ModDependency -import com.modrinth.minotaur.dependencies.VersionDependency -import org.gradle.internal.logging.text.StyledTextOutput.Style -import org.gradle.internal.logging.text.StyledTextOutputFactory -import org.gradle.internal.xml.XmlTransformer -import org.jetbrains.gradle.ext.Application -import org.jetbrains.gradle.ext.Gradle - -import javax.inject.Inject -import java.nio.file.Files -import java.nio.file.Paths -import java.util.concurrent.TimeUnit - - -buildscript { - repositories { - maven { - // GTNH RetroFuturaGradle and ASM Fork - name "GTNH Maven" - url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/" - allowInsecureProtocol = true - } - mavenLocal() - } -} plugins { - id 'java-library' - id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.7" - id 'eclipse' - id 'scala' - id 'maven-publish' - id 'org.jetbrains.kotlin.jvm' version '1.8.0' apply false - id 'org.jetbrains.kotlin.kapt' version '1.8.0' apply false - id 'com.google.devtools.ksp' version '1.8.0-1.0.9' apply false - id 'org.ajoberstar.grgit' version '4.1.1' // 4.1.1 is the last jvm8 supporting version, unused, available for addon.gradle - id 'com.github.johnrengelman.shadow' version '8.1.1' apply false - id 'com.palantir.git-version' version '3.0.0' apply false - id 'de.undercouch.download' version '5.4.0' - id 'com.github.gmazzo.buildconfig' version '3.1.0' apply false // Unused, available for addon.gradle - id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version - id 'com.modrinth.minotaur' version '2.+' apply false - id 'com.matthewprenger.cursegradle' version '1.4.0' apply false - id 'com.gtnewhorizons.retrofuturagradle' version '1.3.24' -} - -print("You might want to check out './gradlew :faq' if your build fails.\n") - -boolean settingsupdated = verifySettingsGradle() -settingsupdated = verifyGitAttributes() || settingsupdated -if (settingsupdated) - throw new GradleException("Settings has been updated, please re-run task.") - -// In submodules, .git is a file pointing to the real git dir -if (project.file('.git/HEAD').isFile() || project.file('.git').isFile()) { - apply plugin: 'com.palantir.git-version' -} - -def out = services.get(StyledTextOutputFactory).create('an-output') - -def projectJavaVersion = JavaLanguageVersion.of(8) - -boolean disableSpotless = project.hasProperty("disableSpotless") ? project.disableSpotless.toBoolean() : false -boolean disableCheckstyle = project.hasProperty("disableCheckstyle") ? project.disableCheckstyle.toBoolean() : false - -final String CHECKSTYLE_CONFIG = """ - - - - - - - - - - - -""" - -checkPropertyExists("modName") -checkPropertyExists("modId") -checkPropertyExists("modGroup") -checkPropertyExists("autoUpdateBuildScript") -checkPropertyExists("minecraftVersion") -checkPropertyExists("forgeVersion") -checkPropertyExists("replaceGradleTokenInFile") -checkPropertyExists("gradleTokenVersion") -checkPropertyExists("apiPackage") -checkPropertyExists("accessTransformersFile") -checkPropertyExists("usesMixins") -checkPropertyExists("mixinPlugin") -checkPropertyExists("mixinsPackage") -checkPropertyExists("coreModClass") -checkPropertyExists("containsMixinsAndOrCoreModOnly") -checkPropertyExists("usesShadowedDependencies") -checkPropertyExists("developmentEnvironmentUserName") - -propertyDefaultIfUnset("generateGradleTokenClass", "") -propertyDefaultIfUnset("includeWellKnownRepositories", true) -propertyDefaultIfUnset("noPublishedSources", false) -propertyDefaultIfUnset("usesMixinDebug", project.usesMixins) -propertyDefaultIfUnset("forceEnableMixins", false) -propertyDefaultIfUnset("channel", "stable") -propertyDefaultIfUnset("mappingsVersion", "12") -propertyDefaultIfUnset("usesMavenPublishing", true) -propertyDefaultIfUnset("mavenPublishUrl", "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases") -propertyDefaultIfUnset("modrinthProjectId", "") -propertyDefaultIfUnset("modrinthRelations", "") -propertyDefaultIfUnset("curseForgeProjectId", "") -propertyDefaultIfUnset("curseForgeRelations", "") -propertyDefaultIfUnset("minimizeShadowedDependencies", true) -propertyDefaultIfUnset("relocateShadowedDependencies", true) -// Deprecated properties (kept for backwards compat) -propertyDefaultIfUnset("gradleTokenModId", "") -propertyDefaultIfUnset("gradleTokenModName", "") -propertyDefaultIfUnset("gradleTokenGroupName", "") - -propertyDefaultIfUnset("enableModernJavaSyntax", false) // On by default for new projects only -propertyDefaultIfUnset("enableGenericInjection", false) // On by default for new projects only - -// this is meant to be set using the user wide property file. by default we do nothing. -propertyDefaultIfUnset("ideaOverrideBuildType", "") // Can be nothing, "gradle" or "idea" - -project.extensions.add(com.diffplug.blowdryer.Blowdryer, "Blowdryer", com.diffplug.blowdryer.Blowdryer) // Make blowdryer available in "apply from:" scripts -if (!disableSpotless) { - apply plugin: 'com.diffplug.spotless' - apply from: Blowdryer.file('spotless.gradle') -} - -if (!disableCheckstyle) { - apply plugin: 'checkstyle' - tasks.named("checkstylePatchedMc") { enabled = false } - tasks.named("checkstyleMcLauncher") { enabled = false } - tasks.named("checkstyleIdeVirtualMain") { enabled = false } - tasks.named("checkstyleInjectedTags") { enabled = false } - checkstyle { - config = resources.text.fromString(CHECKSTYLE_CONFIG) - } -} - -String javaSourceDir = "src/main/java/" -String scalaSourceDir = "src/main/scala/" -String kotlinSourceDir = "src/main/kotlin/" - -if (usesShadowedDependencies.toBoolean()) { - apply plugin: "com.github.johnrengelman.shadow" -} - -java { - toolchain { - if (enableModernJavaSyntax.toBoolean()) { - languageVersion.set(JavaLanguageVersion.of(17)) - } else { - languageVersion.set(projectJavaVersion) - } - vendor.set(JvmVendorSpec.AZUL) - } - if (!noPublishedSources) { - withSourcesJar() - } -} - -tasks.withType(JavaCompile).configureEach { - options.encoding = "UTF-8" -} - -tasks.withType(ScalaCompile).configureEach { - options.encoding = "UTF-8" -} - -pluginManager.withPlugin('org.jetbrains.kotlin.jvm') { - // If Kotlin is enabled in the project - kotlin { - jvmToolchain(8) - } - // Kotlin hacks our source sets, so we hack Kotlin's tasks - def disabledKotlinTaskList = [ - "kaptGenerateStubsMcLauncherKotlin", - "kaptGenerateStubsPatchedMcKotlin", - "kaptGenerateStubsInjectedTagsKotlin", - "compileMcLauncherKotlin", - "compilePatchedMcKotlin", - "compileInjectedTagsKotlin", - "kaptMcLauncherKotlin", - "kaptPatchedMcKotlin", - "kaptInjectedTagsKotlin", - "kspMcLauncherKotlin", - "kspPatchedMcKotlin", - "kspInjectedTagsKotlin", - ] - tasks.configureEach { task -> - if (task.name in disabledKotlinTaskList) { - task.enabled = false - } - } -} - -configurations { - create("runtimeOnlyNonPublishable") { - description = "Runtime only dependencies that are not published alongside the jar" - canBeConsumed = false - canBeResolved = false - } - - create("devOnlyNonPublishable") { - description = "Runtime and compiletime dependencies that are not published alongside the jar (compileOnly + runtimeOnlyNonPublishable)" - canBeConsumed = false - canBeResolved = false - } - compileOnly.extendsFrom(devOnlyNonPublishable) - runtimeOnlyNonPublishable.extendsFrom(devOnlyNonPublishable) -} - -if (enableModernJavaSyntax.toBoolean()) { - repositories { - mavenCentral { - mavenContent { - includeGroup("me.eigenraven.java8unsupported") - } - } - } - - dependencies { - annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:1.0.0' - // workaround for https://github.com/bsideup/jabel/issues/174 - annotationProcessor 'net.java.dev.jna:jna-platform:5.13.0' - compileOnly('com.github.bsideup.jabel:jabel-javac-plugin:1.0.0') { - transitive = false // We only care about the 1 annotation class - } - // Allow using jdk.unsupported classes like sun.misc.Unsafe in the compiled code, working around JDK-8206937. - patchedMinecraft('me.eigenraven.java8unsupported:java-8-unsupported-shim:1.0.0') - } - - tasks.withType(JavaCompile).configureEach { - if (it.name in ["compileMcLauncherJava", "compilePatchedMcJava"]) { - return - } - sourceCompatibility = 17 // for the IDE support - options.release.set(8) - - javaCompiler.set(javaToolchains.compilerFor { - languageVersion.set(JavaLanguageVersion.of(17)) - vendor.set(JvmVendorSpec.AZUL) - }) - } -} - -eclipse { - classpath { - downloadSources = true - downloadJavadoc = true - } -} - -final String modGroupPath = modGroup.toString().replace('.' as char, '/' as char) -final String apiPackagePath = apiPackage.toString().replace('.' as char, '/' as char) - -String targetPackageJava = javaSourceDir + modGroupPath -String targetPackageScala = scalaSourceDir + modGroupPath -String targetPackageKotlin = kotlinSourceDir + modGroupPath -if (!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) { - throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin) -} - -if (apiPackage) { - targetPackageJava = javaSourceDir + modGroupPath + "/" + apiPackagePath - targetPackageScala = scalaSourceDir + modGroupPath + "/" + apiPackagePath - targetPackageKotlin = kotlinSourceDir + modGroupPath + "/" + apiPackagePath - if (!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) { - throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin) - } -} - -if (accessTransformersFile) { - for (atFile in accessTransformersFile.split(" ")) { - String targetFile = "src/main/resources/META-INF/" + atFile.trim() - if (!getFile(targetFile).exists()) { - throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile) - } - tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(targetFile) - tasks.srgifyBinpatchedJar.accessTransformerFiles.from(targetFile) - } -} else { - boolean atsFound = false - for (File at : sourceSets.getByName("main").resources.files) { - if (at.name.toLowerCase().endsWith("_at.cfg")) { - atsFound = true - tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(at) - tasks.srgifyBinpatchedJar.accessTransformerFiles.from(at) - } - } - for (File at : sourceSets.getByName("api").resources.files) { - if (at.name.toLowerCase().endsWith("_at.cfg")) { - atsFound = true - tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(at) - tasks.srgifyBinpatchedJar.accessTransformerFiles.from(at) - } - } - if (atsFound) { - logger.warn("Found and added access transformers in the resources folder, please configure gradle.properties to explicitly mention them by name") - } -} - -if (usesMixins.toBoolean()) { - if (mixinsPackage.isEmpty()) { - throw new GradleException("\"usesMixins\" requires \"mixinsPackage\" to be set!") - } - final String mixinPackagePath = mixinsPackage.toString().replaceAll("\\.", "/") - final String mixinPluginPath = mixinPlugin.toString().replaceAll("\\.", "/") - - targetPackageJava = javaSourceDir + modGroupPath + "/" + mixinPackagePath - targetPackageScala = scalaSourceDir + modGroupPath + "/" + mixinPackagePath - targetPackageKotlin = kotlinSourceDir + modGroupPath + "/" + mixinPackagePath - if (!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) { - throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin) - } - - if (!mixinPlugin.isEmpty()) { - String targetFileJava = javaSourceDir + modGroupPath + "/" + mixinPluginPath + ".java" - String targetFileScala = scalaSourceDir + modGroupPath + "/" + mixinPluginPath + ".scala" - String targetFileScalaJava = scalaSourceDir + modGroupPath + "/" + mixinPluginPath + ".java" - String targetFileKotlin = kotlinSourceDir + modGroupPath + "/" + mixinPluginPath + ".kt" - if (!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) { - throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin) - } - } -} - -if (coreModClass) { - final String coreModPath = coreModClass.toString().replaceAll("\\.", "/") - String targetFileJava = javaSourceDir + modGroupPath + "/" + coreModPath + ".java" - String targetFileScala = scalaSourceDir + modGroupPath + "/" + coreModPath + ".scala" - String targetFileScalaJava = scalaSourceDir + modGroupPath + "/" + coreModPath + ".java" - String targetFileKotlin = kotlinSourceDir + modGroupPath + "/" + coreModPath + ".kt" - if (!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) { - throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin) - } -} - -configurations.configureEach { - resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS) - - // Make sure GregTech build won't time out - System.setProperty("org.gradle.internal.http.connectionTimeout", 120000 as String) - System.setProperty("org.gradle.internal.http.socketTimeout", 120000 as String) -} - -// Fix Jenkins' Git: chmod a file should not be detected as a change and append a '.dirty' to the version -try { - // 'git config core.fileMode false'.execute() -} -catch (Exception ignored) { - out.style(Style.Failure).println("git isn't installed at all") -} - -// Pulls version first from the VERSION env and then git tag -String identifiedVersion = null -String versionOverride = '0.0.19p4' -try { - // Produce a version based on the tag, or for branches something like 0.2.2-configurable-maven-and-extras.38+43090270b6-dirty - if (versionOverride == null) { - def gitDetails = versionDetails() - def isDirty = gitVersion().endsWith(".dirty") // No public API for this, isCleanTag has a different meaning - String branchName = gitDetails.branchName ?: (System.getenv('GIT_BRANCH') ?: 'git') - if (branchName.startsWith('origin/')) { - branchName = branchName.minus('origin/') - } - branchName = branchName.replaceAll("[^a-zA-Z0-9-]+", "-") // sanitize branch names for semver - identifiedVersion = gitDetails.lastTag ?: '${gitDetails.gitHash}' - if (gitDetails.commitDistance > 0) { - identifiedVersion += "-${branchName}.${gitDetails.commitDistance}+${gitDetails.gitHash}" - if (isDirty) { - identifiedVersion += "-dirty" - } - } else if (isDirty) { - identifiedVersion += "-${branchName}+${gitDetails.gitHash}-dirty" - } - } else { - identifiedVersion = versionOverride - } -} -catch (Exception ignored) { - out.style(Style.Failure).text( - 'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' + - 'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' + - 'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)' - ) - //versionOverride = '0.0.1' - identifiedVersion = versionOverride -} -version = identifiedVersion -ext { - modVersion = identifiedVersion -} - -if (identifiedVersion == versionOverride) { - out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7') -} - -group = "com.github.GTNewHorizons" -if (project.hasProperty("customArchiveBaseName") && customArchiveBaseName) { - base { - archivesName = customArchiveBaseName - } -} else { - base { - archivesName = modId - } -} - - -minecraft { - if (replaceGradleTokenInFile) { - for (f in replaceGradleTokenInFile.split(',')) { - tagReplacementFiles.add f - } - } - if (gradleTokenModId) { - injectedTags.put gradleTokenModId, modId - } - if (gradleTokenModName) { - injectedTags.put gradleTokenModName, modName - } - if (gradleTokenVersion) { - injectedTags.put gradleTokenVersion, modVersion - } - if (gradleTokenGroupName) { - injectedTags.put gradleTokenGroupName, modGroup - } - if (enableGenericInjection.toBoolean()) { - injectMissingGenerics.set(true) - } - - username = developmentEnvironmentUserName.toString() - - lwjgl3Version = "3.3.2" - - // Enable assertions in the current mod - extraRunJvmArguments.add("-ea:${modGroup}") - - if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) { - if (usesMixinDebug.toBoolean()) { - extraRunJvmArguments.addAll([ - "-Dmixin.debug.countInjections=true", - "-Dmixin.debug.verbose=true", - "-Dmixin.debug.export=true" - ]) - } - } - - // Blowdryer is present in some old mod builds, do not propagate it further as a dependency - // IC2 has no reobf jars in its Maven - groupsToExcludeFromAutoReobfMapping.addAll(["com.diffplug", "com.diffplug.durian", "net.industrial-craft"]) -} - -if (generateGradleTokenClass) { - tasks.injectTags.outputClassName.set(generateGradleTokenClass) -} - -// Custom reobf auto-mappings -configurations.configureEach { - dependencies.configureEach { dep -> - if (dep instanceof org.gradle.api.artifacts.ExternalModuleDependency) { - if (dep.group == "net.industrial-craft" && dep.name == "industrialcraft-2") { - // https://www.curseforge.com/minecraft/mc-mods/industrial-craft/files/2353971 - project.dependencies.reobfJarConfiguration("curse.maven:ic2-242638:2353971") - } - } - } - def obfuscationAttr = it.attributes.getAttribute(ObfuscationAttribute.OBFUSCATION_ATTRIBUTE) - if (obfuscationAttr != null && obfuscationAttr.name == ObfuscationAttribute.SRG) { - resolutionStrategy.eachDependency { DependencyResolveDetails details -> - // Remap CoFH core cursemaven dev jar to the obfuscated version for runObfClient/Server - if (details.requested.group == 'curse.maven' && details.requested.name.endsWith('-69162') && details.requested.version == '2388751') { - details.useVersion '2388750' - details.because 'Pick obfuscated jar' - } - } - } -} - -// Ensure tests have access to minecraft classes -sourceSets { - test { - java { - compileClasspath += sourceSets.patchedMc.output + sourceSets.mcLauncher.output - runtimeClasspath += sourceSets.patchedMc.output + sourceSets.mcLauncher.output - } - } -} - -if (file('addon.gradle.kts').exists()) { - apply from: 'addon.gradle.kts' -} else if (file('addon.gradle').exists()) { - apply from: 'addon.gradle' -} - -// File for local tweaks not commited to Git -if (file('addon.local.gradle.kts').exists()) { - apply from: 'addon.local.gradle.kts' -} else if (file('addon.local.gradle').exists()) { - apply from: 'addon.local.gradle' -} - -// Allow unsafe repos but warn -repositories.configureEach { repo -> - if (repo instanceof org.gradle.api.artifacts.repositories.UrlArtifactRepository) { - if (repo.getUrl() != null && repo.getUrl().getScheme() == "http" && !repo.allowInsecureProtocol) { - logger.warn("Deprecated: Allowing insecure connections for repo '${repo.name}' - add 'allowInsecureProtocol = true'") - repo.allowInsecureProtocol = true - } - } -} - -if (file('repositories.gradle.kts').exists()) { - apply from: 'repositories.gradle.kts' -} else if (file('repositories.gradle').exists()) { - apply from: 'repositories.gradle' -} else { - logger.error("Neither repositories.gradle.kts nor repositories.gradle was found, make sure you extracted the full ExampleMod template.") - throw new RuntimeException("Missing repositories.gradle[.kts]") -} - -configurations { - runtimeClasspath.extendsFrom(runtimeOnlyNonPublishable) - testRuntimeClasspath.extendsFrom(runtimeOnlyNonPublishable) - for (config in [compileClasspath, runtimeClasspath, testCompileClasspath, testRuntimeClasspath]) { - if (usesShadowedDependencies.toBoolean()) { - config.extendsFrom(shadowImplementation) - // TODO: remove Compile after all uses are refactored to Implementation - config.extendsFrom(shadeCompile) - config.extendsFrom(shadowCompile) - } - } - // A "bag-of-dependencies"-style configuration for backwards compatibility, gets put in "api" - create("compile") { - description = "Deprecated: use api or implementation instead, gets put in api" - canBeConsumed = false - canBeResolved = false - visible = false - } - create("testCompile") { - description = "Deprecated: use testImplementation instead" - canBeConsumed = false - canBeResolved = false - visible = false - } - api.extendsFrom(compile) - testImplementation.extendsFrom(testCompile) -} - -afterEvaluate { - if (!configurations.compile.allDependencies.empty || !configurations.testCompile.allDependencies.empty) { - logger.warn("This project uses deprecated `compile` dependencies, please migrate to using `api` and `implementation`") - logger.warn("For more details, see https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/master/dependencies.gradle") - } -} - -repositories { - maven { - name 'Overmind forge repo mirror' - url 'https://gregtech.overminddl1.com/' - } - maven { - name = "GTNH Maven" - url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/" - allowInsecureProtocol = true - } - maven { - name 'sonatype' - url 'https://oss.sonatype.org/content/repositories/snapshots/' - content { - includeGroup "org.lwjgl" - } - } - if (includeWellKnownRepositories.toBoolean()) { - exclusiveContent { - forRepository { - maven { - name "CurseMaven" - url "https://cursemaven.com" - } - } - filter { - includeGroup "curse.maven" - } - } - exclusiveContent { - forRepository { - maven { - name = "Modrinth" - url = "https://api.modrinth.com/maven" - } - } - filter { - includeGroup "maven.modrinth" - } - } - maven { - name = "ic2" - url = getURL("https://maven.ic2.player.to/", "https://maven2.ic2.player.to/") - content { - includeGroup "net.industrial-craft" - } - metadataSources { - mavenPom() - artifact() - } - } - maven { - name "MMD Maven" - url "https://maven.mcmoddev.com/" - } - } -} - -def mixinProviderGroup = "io.github.legacymoddingmc" -def mixinProviderModule = "unimixins" -def mixinProviderVersion = "0.1.13" -def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}" -def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev" -ext.mixinProviderSpec = mixinProviderSpec - -def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json' - -dependencies { - if (usesMixins.toBoolean()) { - annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3') - annotationProcessor('com.google.guava:guava:24.1.1-jre') - annotationProcessor('com.google.code.gson:gson:2.8.6') - annotationProcessor(mixinProviderSpec) - if (usesMixinDebug.toBoolean()) { - runtimeOnlyNonPublishable('org.jetbrains:intellij-fernflower:1.2.1.16') - } - } - if (usesMixins.toBoolean()) { - implementation(modUtils.enableMixins(mixinProviderSpec, mixingConfigRefMap)) - } else if (forceEnableMixins.toBoolean()) { - runtimeOnlyNonPublishable(mixinProviderSpec) - } -} - -pluginManager.withPlugin('org.jetbrains.kotlin.kapt') { - if (usesMixins.toBoolean()) { - dependencies { - kapt(mixinProviderSpec) - } - } -} - -// Replace old mixin mods with unimixins -// https://docs.gradle.org/8.0.2/userguide/resolution_rules.html#sec:substitution_with_classifier -configurations.all { - resolutionStrategy.dependencySubstitution { - substitute module('com.gtnewhorizon:gtnhmixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods") - substitute module('com.github.GTNewHorizons:Mixingasm') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods") - substitute module('com.github.GTNewHorizons:SpongePoweredMixin') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods") - substitute module('com.github.GTNewHorizons:SpongeMixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods") - substitute module('io.github.legacymoddingmc:unimixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Our previous unimixins upload was missing the dev classifier") - } -} - -dependencies { - constraints { - def minGtnhLibVersion = "0.0.14" - implementation("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") { - because("fixes duplicate mod errors in java 17 configurations using old gtnhlib") - } - runtimeOnly("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") { - because("fixes duplicate mod errors in java 17 configurations using old gtnhlib") - } - devOnlyNonPublishable("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") { - because("fixes duplicate mod errors in java 17 configurations using old gtnhlib") - } - runtimeOnlyNonPublishable("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") { - because("fixes duplicate mod errors in java 17 configurations using old gtnhlib") - } - } -} - -if (file('dependencies.gradle.kts').exists()) { - apply from: 'dependencies.gradle.kts' -} else if (file('dependencies.gradle').exists()) { - apply from: 'dependencies.gradle' -} else { - logger.error("Neither dependencies.gradle.kts nor dependencies.gradle was found, make sure you extracted the full ExampleMod template.") - throw new RuntimeException("Missing dependencies.gradle[.kts]") -} - -tasks.register('generateAssets') { - group = "GTNH Buildscript" - description = "Generates a mixin config file at /src/main/resources/mixins.modid.json if needed" - onlyIf { usesMixins.toBoolean() } - doLast { - def mixinConfigFile = getFile("/src/main/resources/mixins." + modId + ".json") - if (!mixinConfigFile.exists()) { - def mixinPluginLine = "" - if (!mixinPlugin.isEmpty()) { - // We might not have a mixin plugin if we're using early/late mixins - mixinPluginLine += """\n "plugin": "${modGroup}.${mixinPlugin}", """ - } - - mixinConfigFile.text = """{ - "required": true, - "minVersion": "0.8.5-GTNH", - "package": "${modGroup}.${mixinsPackage}",${mixinPluginLine} - "refmap": "${mixingConfigRefMap}", - "target": "@env(DEFAULT)", - "compatibilityLevel": "JAVA_8", - "mixins": [], - "client": [], - "server": [] -} -""" - } - } -} - -if (usesMixins.toBoolean()) { - tasks.named("processResources").configure { - dependsOn("generateAssets") - } - - tasks.named("compileJava", JavaCompile).configure { - options.compilerArgs += [ - // Elan: from what I understand they are just some linter configs so you get some warning on how to properly code - "-XDenableSunApiLintControl", - "-XDignore.symbol.file" - ] - } -} - -tasks.named("processResources", ProcessResources).configure { - // this will ensure that this task is redone when the versions change. - inputs.property "version", project.version - inputs.property "mcversion", project.minecraft.mcVersion - exclude("spotless.gradle") - - // replace stuff in mcmod.info, nothing else. replaces ${key} with value in text - filesMatching("mcmod.info") { - expand "minecraftVersion": project.minecraft.mcVersion, - "modVersion": modVersion, - "modId": modId, - "modName": modName - } - - if (usesMixins.toBoolean()) { - dependsOn("compileJava", "compileScala") - } -} - -ext.java17Toolchain = (JavaToolchainSpec spec) -> { - spec.languageVersion.set(JavaLanguageVersion.of(17)) - spec.vendor.set(JvmVendorSpec.matching("jetbrains")) -} - -ext.java17DependenciesCfg = configurations.create("java17Dependencies") { - extendsFrom(configurations.getByName("runtimeClasspath")) // Ensure consistent transitive dependency resolution - canBeConsumed = false -} -ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies") { - canBeConsumed = false -} - -dependencies { - def lwjgl3ifyVersion = '1.5.7' - if (modId != 'lwjgl3ify') { - java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}") - } - if (modId != 'hodgepodge') { - java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.35') - } - - java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false} -} - -ext.java17JvmArgs = [ - // Java 9+ support - "--illegal-access=warn", - "-Djava.security.manager=allow", - "-Dfile.encoding=UTF-8", - "--add-opens", "java.base/jdk.internal.loader=ALL-UNNAMED", - "--add-opens", "java.base/java.net=ALL-UNNAMED", - "--add-opens", "java.base/java.nio=ALL-UNNAMED", - "--add-opens", "java.base/java.io=ALL-UNNAMED", - "--add-opens", "java.base/java.lang=ALL-UNNAMED", - "--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED", - "--add-opens", "java.base/java.text=ALL-UNNAMED", - "--add-opens", "java.base/java.util=ALL-UNNAMED", - "--add-opens", "java.base/jdk.internal.reflect=ALL-UNNAMED", - "--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", - "--add-opens", "jdk.naming.dns/com.sun.jndi.dns=ALL-UNNAMED,java.naming", - "--add-opens", "java.desktop/sun.awt.image=ALL-UNNAMED", - "--add-modules", "jdk.dynalink", - "--add-opens", "jdk.dynalink/jdk.dynalink.beans=ALL-UNNAMED", - "--add-modules", "java.sql.rowset", - "--add-opens", "java.sql.rowset/javax.sql.rowset.serial=ALL-UNNAMED" -] - -ext.hotswapJvmArgs = [ - // DCEVM advanced hot reload - "-XX:+AllowEnhancedClassRedefinition", - "-XX:HotswapAgent=fatjar" -] - -ext.setupHotswapAgentTask = tasks.register("setupHotswapAgent") { - group = "GTNH Buildscript" - description = "Installs a recent version of HotSwapAgent into the Java 17 JetBrains runtime directory" - def hsaUrl = 'https://github.com/HotswapProjects/HotswapAgent/releases/download/1.4.2-SNAPSHOT/hotswap-agent-1.4.2-SNAPSHOT.jar' - def targetFolderProvider = javaToolchains.launcherFor(java17Toolchain).map {it.metadata.installationPath.dir("lib/hotswap")} - def targetFilename = "hotswap-agent.jar" - onlyIf { - !targetFolderProvider.get().file(targetFilename).asFile.exists() - } - doLast { - def targetFolder = targetFolderProvider.get() - targetFolder.asFile.mkdirs() - download.run { - src hsaUrl - dest targetFolder.file(targetFilename).asFile - overwrite false - tempAndMove true - } - } -} - -public abstract class RunHotswappableMinecraftTask extends RunMinecraftTask { - // IntelliJ doesn't seem to allow commandline arguments so we also support an env variable - private boolean enableHotswap = Boolean.valueOf(System.getenv("HOTSWAP")); - - @Input - public boolean getEnableHotswap() { return enableHotswap } - @Option(option = "hotswap", description = "Enables HotSwapAgent for enhanced class reloading under a debugger") - public boolean setEnableHotswap(boolean enable) { enableHotswap = enable } - - @Inject - public RunHotswappableMinecraftTask(Distribution side, String superTask, org.gradle.api.invocation.Gradle gradle) { - super(side, gradle) - - this.lwjglVersion = 3 - this.javaLauncher = project.javaToolchains.launcherFor(project.java17Toolchain) - this.extraJvmArgs.addAll(project.java17JvmArgs) - this.extraJvmArgs.addAll(project.provider(() -> enableHotswap ? project.hotswapJvmArgs : [])) - - this.classpath(project.java17PatchDependenciesCfg) - if (side == Distribution.CLIENT) { - this.classpath(project.minecraftTasks.lwjgl3Configuration) - } - // Use a raw provider instead of map to not create a dependency on the task - this.classpath(project.provider(() -> project.tasks.named(superTask, RunMinecraftTask).get().classpath)) - this.classpath.filter { file -> - !file.path.contains("2.9.4-nightly-20150209") // Remove lwjgl2 - } - this.classpath(project.java17DependenciesCfg) - } - - public void setup(Project project) { - super.setup(project) - if (project.usesMixins.toBoolean()) { - this.extraJvmArgs.addAll(project.provider(() -> { - def mixinCfg = project.configurations.detachedConfiguration(project.dependencies.create(project.mixinProviderSpec)) - mixinCfg.canBeConsumed = false - mixinCfg.transitive = false - enableHotswap ? ["-javaagent:" + mixinCfg.singleFile.absolutePath] : [] - })) - } - } -} - -def runClient17Task = tasks.register("runClient17", RunHotswappableMinecraftTask, Distribution.CLIENT, "runClient") -runClient17Task.configure { - setup(project) - group = "Modded Minecraft" - description = "Runs the modded client using Java 17, lwjgl3ify and Hodgepodge" - dependsOn(setupHotswapAgentTask, mcpTasks.launcherSources.classesTaskName, minecraftTasks.taskDownloadVanillaAssets, mcpTasks.taskPackagePatchedMc, 'jar') - mainClass = "GradleStart" - username = minecraft.username - userUUID = minecraft.userUUID -} - -def runServer17Task = tasks.register("runServer17", RunHotswappableMinecraftTask, Distribution.DEDICATED_SERVER, "runServer") -runServer17Task.configure { - setup(project) - group = "Modded Minecraft" - description = "Runs the modded server using Java 17, lwjgl3ify and Hodgepodge" - dependsOn(setupHotswapAgentTask, mcpTasks.launcherSources.classesTaskName, minecraftTasks.taskDownloadVanillaAssets, mcpTasks.taskPackagePatchedMc, 'jar') - mainClass = "GradleStartServer" - extraArgs.add("nogui") -} - -def getManifestAttributes() { - def manifestAttributes = [:] - if (!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) { - manifestAttributes += ["FMLCorePluginContainsFMLMod": true] - } - - if (accessTransformersFile) { - manifestAttributes += ["FMLAT": accessTransformersFile.toString()] - } - - if (coreModClass) { - manifestAttributes += ["FMLCorePlugin": modGroup + "." + coreModClass] - } - - if (usesMixins.toBoolean()) { - manifestAttributes += [ - "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", - "MixinConfigs" : "mixins." + modId + ".json", - "ForceLoadAsMod": !containsMixinsAndOrCoreModOnly.toBoolean() - ] - } - return manifestAttributes -} - -tasks.named("jar", Jar).configure { - manifest { - attributes(getManifestAttributes()) - } -} - -if (usesShadowedDependencies.toBoolean()) { - tasks.named("shadowJar", ShadowJar).configure { - manifest { - attributes(getManifestAttributes()) - } - - if (minimizeShadowedDependencies.toBoolean()) { - minimize() // This will only allow shading for actually used classes - } - configurations = [ - project.configurations.shadowImplementation, - project.configurations.shadowCompile, - project.configurations.shadeCompile - ] - archiveClassifier.set('dev') - if (relocateShadowedDependencies.toBoolean()) { - relocationPrefix = modGroup + ".shadow" - enableRelocation = true - } - } - configurations.runtimeElements.outgoing.artifacts.clear() - configurations.apiElements.outgoing.artifacts.clear() - configurations.runtimeElements.outgoing.artifact(tasks.named("shadowJar", ShadowJar)) - configurations.apiElements.outgoing.artifact(tasks.named("shadowJar", ShadowJar)) - tasks.named("jar", Jar) { - enabled = false - finalizedBy(tasks.shadowJar) - } - tasks.named("reobfJar", ReobfuscatedJar) { - inputJar.set(tasks.named("shadowJar", ShadowJar).flatMap({it.archiveFile})) - } - AdhocComponentWithVariants javaComponent = (AdhocComponentWithVariants) project.components.findByName("java") - javaComponent.withVariantsFromConfiguration(configurations.shadowRuntimeElements) { - skip() - } - for (runTask in ["runClient", "runServer", "runClient17", "runServer17"]) { - tasks.named(runTask).configure { - dependsOn("shadowJar") - } - } -} -ext.publishableDevJar = usesShadowedDependencies.toBoolean() ? tasks.shadowJar : tasks.jar -ext.publishableObfJar = tasks.reobfJar - -tasks.register('apiJar', Jar) { - from(sourceSets.main.allSource) { - include modGroupPath + "/" + apiPackagePath + '/**' - } - - from(sourceSets.main.output) { - include modGroupPath + "/" + apiPackagePath + '/**' - } - - from(sourceSets.main.resources.srcDirs) { - include("LICENSE") - } - - getArchiveClassifier().set('api') -} - -artifacts { - if (!noPublishedSources) { - archives tasks.named("sourcesJar") - } - if (apiPackage) { - archives tasks.named("apiJar") - } -} - -idea { - module { - downloadJavadoc = true - downloadSources = true - inheritOutputDirs = true - } - project { - settings { - if (ideaOverrideBuildType != "") { - delegateActions { - if ("gradle".equalsIgnoreCase(ideaOverrideBuildType)) { - delegateBuildRunToGradle = true - testRunner = org.jetbrains.gradle.ext.ActionDelegationConfig.TestRunner.GRADLE - } else if ("idea".equalsIgnoreCase(ideaOverrideBuildType)) { - delegateBuildRunToGradle = false - testRunner = org.jetbrains.gradle.ext.ActionDelegationConfig.TestRunner.PLATFORM - } else { - throw GradleScriptException('Accepted value for ideaOverrideBuildType is one of gradle or idea.') - } - } - } - runConfigurations { - "0. Build and Test"(Gradle) { - taskNames = ["build"] - } - "1. Run Client"(Gradle) { - taskNames = ["runClient"] - } - "2. Run Server"(Gradle) { - taskNames = ["runServer"] - } - "1a. Run Client (Java 17)"(Gradle) { - taskNames = ["runClient17"] - } - "2a. Run Server (Java 17)"(Gradle) { - taskNames = ["runServer17"] - } - "1b. Run Client (Java 17, Hotswap)"(Gradle) { - taskNames = ["runClient17"] - envs = ["HOTSWAP": "true"] - } - "2b. Run Server (Java 17, Hotswap)"(Gradle) { - taskNames = ["runServer17"] - envs = ["HOTSWAP": "true"] - } - "3. Run Obfuscated Client"(Gradle) { - taskNames = ["runObfClient"] - } - "4. Run Obfuscated Server"(Gradle) { - taskNames = ["runObfServer"] - } - if (!disableSpotless) { - "5. Apply spotless"(Gradle) { - taskNames = ["spotlessApply"] - } - } - def coreModArgs = "" - if (coreModClass) { - coreModArgs = ' "-Dfml.coreMods.load=' + modGroup + '.' + coreModClass + '"' - } - "Run Client (IJ Native)"(Application) { - mainClass = "GradleStart" - moduleName = project.name + ".ideVirtualMain" - afterEvaluate { - workingDirectory = tasks.runClient.workingDir.absolutePath - programParameters = tasks.runClient.calculateArgs(project).collect { '"' + it + '"' }.join(' ') - jvmArgs = tasks.runClient.calculateJvmArgs(project).collect { '"' + it + '"' }.join(' ') + - ' ' + tasks.runClient.systemProperties.collect { '"-D' + it.key + '=' + it.value.toString() + '"' }.join(' ') + - coreModArgs - } - } - "Run Server (IJ Native)"(Application) { - mainClass = "GradleStartServer" - moduleName = project.name + ".ideVirtualMain" - afterEvaluate { - workingDirectory = tasks.runServer.workingDir.absolutePath - programParameters = tasks.runServer.calculateArgs(project).collect { '"' + it + '"' }.join(' ') - jvmArgs = tasks.runServer.calculateJvmArgs(project).collect { '"' + it + '"' }.join(' ') + - ' ' + tasks.runServer.systemProperties.collect { '"-D' + it.key + '=' + it.value.toString() + '"' }.join(' ') + - coreModArgs - } - } - } - compiler.javac { - afterEvaluate { - javacAdditionalOptions = "-encoding utf8" - moduleJavacAdditionalOptions = [ - (project.name + ".main"): tasks.compileJava.options.compilerArgs.collect { '"' + it + '"' }.join(' ') - ] - } - } - withIDEADir { File ideaDir -> - if (!ideaDir.path.contains(".idea")) { - // If an .ipr file exists, the project root directory is passed here instead of the .idea subdirectory - ideaDir = new File(ideaDir, ".idea") - } - if (ideaDir.isDirectory()) { - def miscFile = new File(ideaDir, "misc.xml") - if (miscFile.isFile()) { - boolean dirty = false - def miscTransformer = new XmlTransformer() - miscTransformer.addAction { root -> - Node rootNode = root.asNode() - def rootManager = rootNode - .component.find { it.@name == 'ProjectRootManager' } - if (!rootManager) { - rootManager = rootNode.appendNode('component', ['name': 'ProjectRootManager', 'version': '2']) - dirty = true - } - def output = rootManager.output - if (!output) { - output = rootManager.appendNode('output') - dirty = true - } - if (!output.@url) { - // Only modify the output url if it doesn't yet have one, or if the existing one is blank somehow. - // This is a sensible default for most setups - output.@url = 'file://$PROJECT_DIR$/build/ideaBuild' - dirty = true - } - } - def result = miscTransformer.transform(miscFile.text) - if (dirty) { - miscFile.write(result) - } - } else { - miscFile.text = """ - - - - - -""" - } - } - } - } - } -} - -tasks.named("processIdeaSettings").configure { - dependsOn("injectTags") -} - -tasks.named("ideVirtualMainClasses").configure { - // Make IntelliJ "Build project" build the mod jars - dependsOn("jar", "reobfJar") - if (!disableSpotless) { - dependsOn("spotlessCheck") - } -} - -// workaround variable hiding in pom processing -def projectConfigs = project.configurations - -publishing { - publications { - create("maven", MavenPublication) { - from components.java - - if (apiPackage) { - artifact apiJar - } - - groupId = System.getenv("ARTIFACT_GROUP_ID") ?: project.group - artifactId = System.getenv("ARTIFACT_ID") ?: project.name - // Using the identified version, not project.version as it has the prepended 1.7.10 - version = System.getenv("RELEASE_VERSION") ?: identifiedVersion - } - } - repositories { - if (usesMavenPublishing.toBoolean() && System.getenv("MAVEN_USER") != null) { - maven { - url = mavenPublishUrl - allowInsecureProtocol = mavenPublishUrl.startsWith("http://") // Mostly for the GTNH maven - credentials { - username = System.getenv("MAVEN_USER") ?: "NONE" - password = System.getenv("MAVEN_PASSWORD") ?: "NONE" - } - } - } - } -} - -if (modrinthProjectId.size() != 0 && System.getenv("MODRINTH_TOKEN") != null) { - apply plugin: 'com.modrinth.minotaur' - - File changelogFile = new File(System.getenv("CHANGELOG_FILE") ?: "CHANGELOG.md") - - modrinth { - token = System.getenv("MODRINTH_TOKEN") - projectId = modrinthProjectId - versionNumber = identifiedVersion - versionType = identifiedVersion.endsWith("-pre") ? "beta" : "release" - changelog = changelogFile.exists() ? changelogFile.getText("UTF-8") : "" - uploadFile = publishableObfJar - additionalFiles = getSecondaryArtifacts() - gameVersions = [minecraftVersion] - loaders = ["forge"] - debugMode = false - } - - if (modrinthRelations.size() != 0) { - String[] deps = modrinthRelations.split(";") - deps.each { dep -> - if (dep.size() == 0) { - return - } - String[] parts = dep.split(":") - String[] qual = parts[0].split("-") - addModrinthDep(qual[0], qual[1], parts[1]) - } - } - if (usesMixins.toBoolean()) { - addModrinthDep("required", "project", "unimixins") - } - tasks.modrinth.dependsOn(build) - tasks.publish.dependsOn(tasks.modrinth) -} - -if (curseForgeProjectId.size() != 0 && System.getenv("CURSEFORGE_TOKEN") != null) { - apply plugin: 'com.matthewprenger.cursegradle' - - File changelogFile = new File(System.getenv("CHANGELOG_FILE") ?: "CHANGELOG.md") - - curseforge { - apiKey = System.getenv("CURSEFORGE_TOKEN") - project { - id = curseForgeProjectId - if (changelogFile.exists()) { - changelogType = "markdown" - changelog = changelogFile - } - releaseType = identifiedVersion.endsWith("-pre") ? "beta" : "release" - addGameVersion minecraftVersion - addGameVersion "Forge" - mainArtifact publishableObfJar - for (artifact in getSecondaryArtifacts()) addArtifact artifact - } - - options { - javaIntegration = false - forgeGradleIntegration = false - debug = false - } - } - - if (curseForgeRelations.size() != 0) { - String[] deps = curseForgeRelations.split(";") - deps.each { dep -> - if (dep.size() == 0) { - return - } - String[] parts = dep.split(":") - addCurseForgeRelation(parts[0], parts[1]) - } - } - if (usesMixins.toBoolean()) { - addCurseForgeRelation("requiredDependency", "unimixins") - } - tasks.curseforge.dependsOn(build) - tasks.publish.dependsOn(tasks.curseforge) -} - -def addModrinthDep(String scope, String type, String name) { - com.modrinth.minotaur.dependencies.Dependency dep; - if (!(scope in ["required", "optional", "incompatible", "embedded"])) { - throw new Exception("Invalid modrinth dependency scope: " + scope) - } - switch (type) { - case "project": - dep = new ModDependency(name, scope) - break - case "version": - dep = new VersionDependency(name, scope) - break - default: - throw new Exception("Invalid modrinth dependency type: " + type) - } - project.modrinth.dependencies.add(dep) -} - -def addCurseForgeRelation(String type, String name) { - if (!(type in ["requiredDependency", "embeddedLibrary", "optionalDependency", "tool", "incompatible"])) { - throw new Exception("Invalid CurseForge relation type: " + type) - } - CurseArtifact artifact = project.curseforge.curseProjects[0].mainArtifact - CurseRelation rel = (artifact.curseRelations ?: (artifact.curseRelations = new CurseRelation())) - rel."$type"(name) -} - -// Updating - -def buildscriptGradleVersion = "8.5" - -tasks.named('wrapper', Wrapper).configure { - gradleVersion = buildscriptGradleVersion -} - -tasks.register('updateBuildScript') { - group = 'GTNH Buildscript' - description = 'Updates the build script to the latest version' - - if (gradle.gradleVersion != buildscriptGradleVersion && !Boolean.getBoolean('DISABLE_BUILDSCRIPT_GRADLE_UPDATE')) { - dependsOn('wrapper') - } - - doLast { - if (performBuildScriptUpdate()) return - - print("Build script already up-to-date!") - } -} - -if (!project.getGradle().startParameter.isOffline() && !Boolean.getBoolean('DISABLE_BUILDSCRIPT_UPDATE_CHECK') && isNewBuildScriptVersionAvailable()) { - if (autoUpdateBuildScript.toBoolean()) { - performBuildScriptUpdate() - } else { - out.style(Style.SuccessHeader).println("Build script update available! Run 'gradle updateBuildScript'") - if (gradle.gradleVersion != buildscriptGradleVersion) { - out.style(Style.SuccessHeader).println("updateBuildScript can update gradle from ${gradle.gradleVersion} to ${buildscriptGradleVersion}\n") - } - } -} - -// If you want to add more cases to this task, implement them as arguments if total amount to print gets too large -tasks.register('faq') { - group = 'GTNH Buildscript' - description = 'Prints frequently asked questions about building a project' - - doLast { - print("If your build fails to fetch dependencies, run './gradlew updateDependencies'. " + - "Or you can manually check if the versions are still on the distributing sites - " + - "the links can be found in repositories.gradle and build.gradle:repositories, " + - "but not build.gradle:buildscript.repositories - those ones are for gradle plugin metadata.\n\n" + - "If your build fails to recognize the syntax of new Java versions, enable Jabel in your " + - "gradle.properties. See how it's done in GTNH ExampleMod/gradle.properties. " + - "However, keep in mind that Jabel enables only syntax features, but not APIs that were introduced in " + - "Java 9 or later.") - } -} - -static URL availableBuildScriptUrl() { - new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/build.gradle") -} - -static URL exampleSettingsGradleUrl() { - new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/settings.gradle.example") -} - -static URL exampleGitAttributesUrl() { - new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/.gitattributes") -} - - -boolean verifyGitAttributes() { - def gitattributesFile = getFile(".gitattributes") - if (!gitattributesFile.exists()) { - println("Downloading default .gitattributes") - exampleGitAttributesUrl().withInputStream { i -> gitattributesFile.withOutputStream { it << i } } - exec { - workingDir '.' - commandLine 'git', 'add', '--renormalize', '.' - } - return true - } - return false -} - -boolean verifySettingsGradle() { - def settingsFile = getFile("settings.gradle") - if (!settingsFile.exists()) { - println("Downloading default settings.gradle") - exampleSettingsGradleUrl().withInputStream { i -> settingsFile.withOutputStream { it << i } } - return true - } - return false -} - -boolean performBuildScriptUpdate() { - return true - if (isNewBuildScriptVersionAvailable()) { - def buildscriptFile = getFile("build.gradle") - availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } } - def out = services.get(StyledTextOutputFactory).create('buildscript-update-output') - out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!") - boolean settingsupdated = verifySettingsGradle() - settingsupdated = verifyGitAttributes() || settingsupdated - if (settingsupdated) - throw new GradleException("Settings has been updated, please re-run task.") - return true - } - return false -} - -boolean isNewBuildScriptVersionAvailable() { - return false - Map parameters = ["connectTimeout": 2000, "readTimeout": 2000] - - String currentBuildScript = getFile("build.gradle").getText() - String currentBuildScriptHash = getVersionHash(currentBuildScript) - String availableBuildScriptHash - try { - String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText() - availableBuildScriptHash = getVersionHash(availableBuildScript) - } catch (IOException e) { - logger.warn("Could not check for buildscript update availability: {}", e.message) - return false - } - - boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash - return !isUpToDate -} - -static String getVersionHash(String buildScriptContent) { - String versionLine = buildScriptContent.find("^//version: [a-z0-9]*") - if (versionLine != null) { - return versionLine.split(": ").last() - } - return "" -} - -// Parameter Deobfuscation - -tasks.register('deobfParams') { - group = 'GTNH Buildscript' - description = 'Rename all obfuscated parameter names inherited from Minecraft classes' - doLast { // TODO - - String mcpDir = "$project.gradle.gradleUserHomeDir/caches/minecraft/de/oceanlabs/mcp/mcp_$channel/$mappingsVersion" - String mcpZIP = "$mcpDir/mcp_$channel-$mappingsVersion-${minecraftVersion}.zip" - String paramsCSV = "$mcpDir/params.csv" - - download.run { - src "https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_$channel/$mappingsVersion-$minecraftVersion/mcp_$channel-$mappingsVersion-${minecraftVersion}.zip" - dest mcpZIP - overwrite false - } - - if (!file(paramsCSV).exists()) { - println("Extracting MCP archive ...") - copy { - from(zipTree(mcpZIP)) - into(mcpDir) - } - } - - println("Parsing params.csv ...") - Map params = new HashMap<>() - Files.lines(Paths.get(paramsCSV)).forEach { line -> - String[] cells = line.split(",") - if (cells.length > 2 && cells[0].matches("p_i?\\d+_\\d+_")) { - params.put(cells[0], cells[1]) - } - } - - out.style(Style.Success).println("Modified ${replaceParams(file("$projectDir/src/main/java"), params)} files!") - out.style(Style.Failure).println("Don't forget to verify that the code still works as before!\n It could be broken due to duplicate variables existing now\n or parameters taking priority over other variables.") - } -} - -static int replaceParams(File file, Map params) { - int fileCount = 0 - - if (file.isDirectory()) { - for (File f : file.listFiles()) { - fileCount += replaceParams(f, params) - } - return fileCount - } - println("Visiting ${file.getName()} ...") - try { - String content = new String(Files.readAllBytes(file.toPath())) - int hash = content.hashCode() - params.forEach { key, value -> - content = content.replaceAll(key, value) - } - if (hash != content.hashCode()) { - Files.write(file.toPath(), content.getBytes("UTF-8")) - return 1 - } - } catch (Exception e) { - e.printStackTrace() - } - return 0 -} - -// Dependency Deobfuscation (Deprecated, use the new RFG API documented in dependencies.gradle) - -def deobf(String sourceURL) { - try { - URL url = new URL(sourceURL) - String fileName = url.getFile() - - //get rid of directories: - int lastSlash = fileName.lastIndexOf("/") - if (lastSlash > 0) { - fileName = fileName.substring(lastSlash + 1) - } - //get rid of extension: - if (fileName.endsWith(".jar") || fileName.endsWith(".litemod")) { - fileName = fileName.substring(0, fileName.lastIndexOf(".")) - } - - String hostName = url.getHost() - if (hostName.startsWith("www.")) { - hostName = hostName.substring(4) - } - List parts = Arrays.asList(hostName.split("\\.")) - Collections.reverse(parts) - hostName = String.join(".", parts) - - return deobf(sourceURL, "$hostName/$fileName") - } catch (Exception ignored) { - return deobf(sourceURL, "deobf/${sourceURL.hashCode()}") - } -} - -def deobfMaven(String repoURL, String mavenDep) { - if (!repoURL.endsWith("/")) { - repoURL += "/" - } - String[] parts = mavenDep.split(":") - parts[0] = parts[0].replace('.', '/') - def jarURL = repoURL + parts[0] + "/" + parts[1] + "/" + parts[2] + "/" + parts[1] + "-" + parts[2] + ".jar" - return deobf(jarURL) -} - -def deobfCurse(String curseDep) { - return dependencies.rfg.deobf("curse.maven:$curseDep") -} - -// The method above is to be preferred. Use this method if the filename is not at the end of the URL. -def deobf(String sourceURL, String rawFileName) { - String bon2Version = "2.5.1" - String fileName = URLDecoder.decode(rawFileName, "UTF-8") - String cacheDir = "$project.gradle.gradleUserHomeDir/caches" - String obfFile = "$cacheDir/modules-2/files-2.1/${fileName}.jar" - - download.run { - src sourceURL - dest obfFile - quiet true - overwrite false - } - return dependencies.rfg.deobf(files(obfFile)) -} -// Helper methods - -def checkPropertyExists(String propertyName) { - if (!project.hasProperty(propertyName)) { - throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties") - } -} - -def propertyDefaultIfUnset(String propertyName, defaultValue) { - if (!project.hasProperty(propertyName) || project.property(propertyName) == "") { - project.ext.setProperty(propertyName, defaultValue) - } -} - -def getFile(String relativePath) { - return new File(projectDir, relativePath) -} - -def getSecondaryArtifacts() { - // Because noPublishedSources from the beginning of the script is somehow not visible here... - boolean noPublishedSources = project.hasProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false - def secondaryArtifacts = [publishableDevJar] - if (!noPublishedSources) secondaryArtifacts += [sourcesJar] - if (apiPackage) secondaryArtifacts += [apiJar] - return secondaryArtifacts -} - -def getURL(String main, String fallback) { - return pingURL(main, 10000) ? main : fallback -} - -// credit: https://stackoverflow.com/a/3584332 -def pingURL(String url, int timeout) { - url = url.replaceFirst("^https", "http") // Otherwise an exception may be thrown on invalid SSL certificates. - try { - HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection() - connection.setConnectTimeout(timeout) - connection.setReadTimeout(timeout) - connection.setRequestMethod("HEAD") - int responseCode = connection.getResponseCode() - return 200 <= responseCode && responseCode <= 399 - } catch (IOException ignored) { - return false - } -} - -// For easier scripting of things that require variables defined earlier in the buildscript -if (file('addon.late.gradle.kts').exists()) { - apply from: 'addon.late.gradle.kts' -} else if (file('addon.late.gradle').exists()) { - apply from: 'addon.late.gradle' -} - -// File for local tweaks not commited to Git -if (file('addon.late.local.gradle.kts').exists()) { - apply from: 'addon.late.local.gradle.kts' -} else if (file('addon.late.local.gradle').exists()) { - apply from: 'addon.late.local.gradle' + id 'com.gtnewhorizons.gtnhconvention' } diff --git a/settings.gradle b/settings.gradle index 5053ca7..ec9681d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,10 +5,9 @@ pluginManagement { // RetroFuturaGradle name "GTNH Maven" url "https://nexus.gtnewhorizons.com/repository/public/" - allowInsecureProtocol = true mavenContent { - includeGroup("com.gtnewhorizons") - includeGroupByRegex("com\\.gtnewhorizons\\..+") + includeGroup("com.gtnewhorizons") + includeGroupByRegex("com\\.gtnewhorizons\\..+") } } gradlePluginPortal() @@ -18,12 +17,5 @@ pluginManagement { } plugins { - id 'com.diffplug.blowdryerSetup' version '1.6.0' - id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' // Provides java toolchains -} - -blowdryerSetup { - repoSubfolder 'gtnhShared' - github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.2') - //devLocal '.' // Use this when testing config updates locally + id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.27' } From ef9343761c62ba1fc7b079aa12445be1152cd2b5 Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Tue, 1 Oct 2024 15:11:19 +0800 Subject: [PATCH 11/12] update --- build.gradle | 2 +- .../gt/metatileentity/DualInputHatch.java | 92 +++++++++++++++--- ...rnDualInputHatchInventoryMappingSlave.java | 4 +- .../multi/IngredientDistributor.java | 2 +- .../assets/proghatches/lang/en_US.lang | 4 + .../assets/proghatches/lang/zh_CN.lang | 4 + .../assets/proghatches/textures/states.png | Bin 0 -> 235 bytes 7 files changed, 90 insertions(+), 18 deletions(-) create mode 100644 src/main/resources/assets/proghatches/textures/states.png diff --git a/build.gradle b/build.gradle index 34151b8..322d508 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ - plugins { id 'com.gtnewhorizons.gtnhconvention' } + diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java index 62cda59..68360ba 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java @@ -18,8 +18,10 @@ import java.util.ListIterator; import java.util.NoSuchElementException; import java.util.Optional; +import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; +import java.util.function.IntConsumer; import java.util.function.Supplier; import java.util.stream.IntStream; import java.util.stream.Stream; @@ -51,8 +53,10 @@ import com.google.common.collect.Iterables; import com.google.gson.internal.Streams; import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.AdaptableUITexture; import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.drawable.SizedDrawable; import com.gtnewhorizons.modularui.api.drawable.Text; import com.gtnewhorizons.modularui.api.drawable.UITexture; import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; @@ -106,8 +110,10 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.SoundResource; +import gregtech.api.enums.Textures; import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.IConfigurationCircuitSupport; +import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.modularui.IAddGregtechLogo; import gregtech.api.interfaces.modularui.IAddUIWidgets; @@ -297,7 +303,7 @@ public ItemStack loadItemStackFromNBT(NBTTagCompound tag) { public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); aNBT.setTag("shared", shared.ser()); - aNBT.setBoolean("fluidLimit", fluidLimit); + aNBT.setInteger("fluidLimit", fluidLimit); aNBT.setBoolean("program", program); aNBT.setBoolean("mMultiFluid", mMultiFluid); if (mStoredFluid != null) { @@ -339,7 +345,7 @@ public void loadNBTData(NBTTagCompound aNBT) { if(aNBT.hasKey("x")==false)return; super.loadNBTData(aNBT); shared.deser(aNBT.getCompoundTag("shared")); - fluidLimit= aNBT.getBoolean("fluidLimit"); + fluidLimit= aNBT.getInteger("fluidLimit"); program = aNBT.getBoolean("program"); mMultiFluid = aNBT.getBoolean("mMultiFluid"); if (mStoredFluid != null) { @@ -380,7 +386,14 @@ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return neo; } - + private CycleButtonWidget createButton(Supplier getter, IntConsumer setter, Function picture, + List tooltip, int offset,int len) { + return (CycleButtonWidget) new CycleButtonWidget().setLength(len).setGetter(getter).setSetter(s->setter.accept(s)) + + .setTextureGetter(picture) + .setBackground(GT_UITextures.BUTTON_STANDARD).setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(7 + offset * 18, 62).setSize(18, 18).addTooltips(tooltip); + } private Widget createButton(Supplier getter, Consumer setter, UITexture picture, Supplier tooltipDataSupplier, int offset) { return new CycleButtonWidget().setToggle(getter, setter).setStaticTexture(picture) @@ -461,7 +474,29 @@ public static class MarkerWidget extends Widget{ public MarkerWidget(DualInputHatch dualInputHatch) { thiz=dualInputHatch; } - } + } + private static final SizedDrawable t0 = + new SizedDrawable( + AdaptableUITexture.of("appliedenergistics2", "guis/states", 16, 16, 0) + .getSubArea(3/16f, 9/16f, 4/16f, 10/16f) + ,16,16,1,1 + ) + ; + private static final SizedDrawable t1 = + new SizedDrawable( + AdaptableUITexture.of("proghatches", "states", 16, 16, 0) + ,16,16,1,1 + ) + ; + private static final SizedDrawable t2 = + new SizedDrawable( + AdaptableUITexture.of("appliedenergistics2", "guis/states", 16, 16, 0) + .getSubArea(4/16f, 9/16f, 5/16f, 10/16f) + ,16,16,1,1 + ) + ; + + @Override public void addUIWidgets(Builder builder, UIBuildContext buildContext) { builder.widget(new MarkerWidget(this)); @@ -505,14 +540,25 @@ public void addUIWidgets(Builder builder, UIBuildContext buildContext) { , val -> { fluidLimit = val; //updateSlots(); - }, GT_UITextures.OVERLAY_BUTTON_CHECKMARK, - ImmutableList.of( - StatCollector.translateToLocal("programmable_hatches.gt.fluidlimit.0"), - StatCollector.translateToLocal("programmable_hatches.gt.fluidlimit.1") - ) + }, s->{ + if(s==0)return t0; + if(s==1)return t1; + return t2; + + }, + ImmutableList.of(StatCollector.translateToLocal("programmable_hatches.gt.fluidlimit.neo") + /*tatCollector.translateToLocal("programmable_hatches.gt.fluidlimit.0"), + StatCollector.translateToLocal("programmable_hatches.gt.fluidlimit.1"), + StatCollector.translateToLocal("programmable_hatches.gt.fluidlimit.2")*/ ) - , 0) + , 0,3) + .addTooltip(0, StatCollector.translateToLocal("programmable_hatches.gt.fluidlimit.neo.0")) + .addTooltip(1, StatCollector.translateToLocal("programmable_hatches.gt.fluidlimit.neo.1")) + + .addTooltip(2, StatCollector.translateToLocal("programmable_hatches.gt.fluidlimit.neo.2")) + + .setPos(7+ 1 * 18, 62 - 18 - moveButtons() * 18)); @@ -1230,14 +1276,14 @@ public void setInventorySlotContents(int aIndex, ItemStack aStack) { public void onFill() { } - boolean fluidLimit=true; + int fluidLimit=1; @Override public int fill(FluidStack aFluid, boolean doFill) { if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || !canTankBeFilled() || !isFluidInputAllowed(aFluid)) return 0; - if(!fluidLimit){int oldamount=aFluid.amount; + if(fluidLimit==0){int oldamount=aFluid.amount; aFluid=aFluid.copy(); for(ListeningFluidTank tk:this.mStoredFluid){ if(tk.getFluidAmount()==0)tk.setFluid(null); @@ -1250,7 +1296,7 @@ public int fill(FluidStack aFluid, boolean doFill) { } - if(fluidLimit){ + if(fluidLimit==1){ if (!hasFluid(aFluid) && getFirstEmptySlot() != -1) { int tFilled = Math.min(aFluid.amount, getCapacity()); @@ -1274,7 +1320,25 @@ public int fill(FluidStack aFluid, boolean doFill) { return tFilled; } } - + if(fluidLimit==2){ + + int oldamount=aFluid.amount; + aFluid=aFluid.copy(); + for(ListeningFluidTank tk:this.mStoredFluid){ + if(tk.getFluidAmount()==0){ + tk.setFluid(null); + if((aFluid.amount-=tk.fill(aFluid, doFill))<=0){ + break; + }; + } + } + for(ListeningFluidTank tk:this.mStoredFluid){ + if((aFluid.amount-=tk.fill(aFluid, doFill))<=0){ + break; + }; + } + return oldamount-aFluid.amount; + } return 0; } diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatchInventoryMappingSlave.java b/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatchInventoryMappingSlave.java index 1dc5fb2..7b1672d 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatchInventoryMappingSlave.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatchInventoryMappingSlave.java @@ -780,7 +780,7 @@ public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCraf int ilimit = master.getInventoryStackLimit(); int flimit = master.getInventoryFluidLimit(); boolean isplit = master.disableLimited; - boolean fsplit = !master.fluidLimit; + boolean fsplit = master.fluidLimit==0; for (int index = 0; index < table.getSizeInventory(); index++) { ItemStack is = (table.getStackInSlot(index)); if (is == null) @@ -990,7 +990,7 @@ public int pushPatternMulti(ICraftingPatternDetails patternDetails, InventoryCra int ilimit = master.getInventoryStackLimit(); int flimit = master.getInventoryFluidLimit(); boolean isplit = master.disableLimited; - boolean fsplit = !master.fluidLimit; + boolean fsplit = master.fluidLimit==0; for (int index = 0; index < table.getSizeInventory(); index++) { ItemStack is = (table.getStackInSlot(index)); if (is == null) diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java b/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java index 57e866c..be60433 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/multi/IngredientDistributor.java @@ -1315,7 +1315,7 @@ public void saveNBTData(NBTTagCompound aNBT) { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if(isLiteVersion)blocking=false; - if(blocking==false&&port!=null){ + if(blocking==false&&port!=null&&aBaseMetaTileEntity.isAllowedToWork()){ LargeProgrammingCircuitProvider.shut(this,"proghatch.commport"); } diff --git a/src/main/resources/assets/proghatches/lang/en_US.lang b/src/main/resources/assets/proghatches/lang/en_US.lang index 6a96330..6671e3d 100644 --- a/src/main/resources/assets/proghatches/lang/en_US.lang +++ b/src/main/resources/assets/proghatches/lang/en_US.lang @@ -583,3 +583,7 @@ proghatch.ingbuf.acquring=State: Acquring. Prevent other hosts from locking new proghatch.ingbuf.locked=State: Locked. Will unlock if output network is empty. proghatch.ingbuf.idle=State: Idle. GT5U.gui.text.proghatch.commport=Cannot run in non-Blocking Mode with Statusbus Communication Port. +programmable_hatches.gt.fluidlimit.neo=Fluid filling policy +programmable_hatches.gt.fluidlimit.neo.0=Normal: Fill fluid slots of lower index, then higher. +programmable_hatches.gt.fluidlimit.neo.1=Limiting: Only fill slot of same fluid, if no same fluid present then fill the first empty slot. +programmable_hatches.gt.fluidlimit.neo.2=Empty first: Fill empty fluid slots first, then try Nomal mode. diff --git a/src/main/resources/assets/proghatches/lang/zh_CN.lang b/src/main/resources/assets/proghatches/lang/zh_CN.lang index 2659865..e34af8d 100644 --- a/src/main/resources/assets/proghatches/lang/zh_CN.lang +++ b/src/main/resources/assets/proghatches/lang/zh_CN.lang @@ -581,3 +581,7 @@ proghatch.ingbuf.acquring=状态: 总线被此机占据 以阻止其它主机锁 proghatch.ingbuf.locked=状态: 配方已锁定 无视总线状态 仅处理锁定配方 在输出清空后回到空闲状态 proghatch.ingbuf.idle=状态: 总线空闲 GT5U.gui.text.proghatch.commport=无法在非阻挡模式下和状态总线通讯端口运行 +programmable_hatches.gt.fluidlimit.neo=流体注入策略 +programmable_hatches.gt.fluidlimit.neo.0=常规: 按照槽位序号从小到大依次注入 +programmable_hatches.gt.fluidlimit.neo.1=限制: 仅注入含有相同流体的槽,如果没有则注入第一个空槽 +programmable_hatches.gt.fluidlimit.neo.2=空优先: 总是先注入空流体槽,再尝试常规模式(结果高度依赖于物流设备的具体实现,请不要假设二合一接口以外的设备能符合期望) diff --git a/src/main/resources/assets/proghatches/textures/states.png b/src/main/resources/assets/proghatches/textures/states.png new file mode 100644 index 0000000000000000000000000000000000000000..1a44d52e6c84424f0b6cec814f3c25521d719c90 GIT binary patch literal 235 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1quc!3Iwk#}EturIP~r8WcF%R<4cyawGB6GTC+8 z`4XHC%rF-EEpu4$zkNxQ^RqWbh3jT-)H7Yro_0&D$nsdmf~#TuQazu3bFF`)x$;5G z_9&Tl-<+0{DNWf|7^cru>ESr~WO8fqXTfS;5#wDh=D+w)JlS!KHy}riQ~A(4_mcgu cl9>va^AbJ&ol8FE0dxz4r>mdKI;Vst00*~LWdHyG literal 0 HcmV?d00001 From 1ab834d88b2caae80532e326e5837f675450199b Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Fri, 4 Oct 2024 01:34:47 +0800 Subject: [PATCH 12/12] update --- .../gt/metatileentity/DecoyInputBusME.java | 540 ++++ .../gt/metatileentity/DecoyInputHatchME.java | 516 ++++ .../gt/metatileentity/DualInputHatch.java | 14 +- .../util/IMEHatchOverrided.java | 12 + .../util/ListeningFluidTank.java | 10 +- .../java/reobf/proghatches/main/MyMod.java | 3 +- .../proghatches/main/mixin/MixinPlugin.java | 1 + .../mixins/part2/MixinMEBusOverride.java | 80 + .../main/registration/PHRecipes.java | 2470 +++++++++-------- .../main/registration/Registration.java | 17 + .../assets/proghatches/lang/en_US.lang | 4 + .../assets/proghatches/lang/en_US/DIBME.lang | 8 + .../assets/proghatches/lang/en_US/DIHME.lang | 8 + .../assets/proghatches/lang/zh_CN.lang | 4 + .../assets/proghatches/lang/zh_CN/DIBME.lang | 16 + .../assets/proghatches/lang/zh_CN/DIHME.lang | 11 + 16 files changed, 2496 insertions(+), 1218 deletions(-) create mode 100644 src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputBusME.java create mode 100644 src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputHatchME.java create mode 100644 src/main/java/reobf/proghatches/gt/metatileentity/util/IMEHatchOverrided.java create mode 100644 src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinMEBusOverride.java create mode 100644 src/main/resources/assets/proghatches/lang/en_US/DIBME.lang create mode 100644 src/main/resources/assets/proghatches/lang/en_US/DIHME.lang create mode 100644 src/main/resources/assets/proghatches/lang/zh_CN/DIBME.lang create mode 100644 src/main/resources/assets/proghatches/lang/zh_CN/DIHME.lang diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputBusME.java b/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputBusME.java new file mode 100644 index 0000000..11380ca --- /dev/null +++ b/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputBusME.java @@ -0,0 +1,540 @@ +package reobf.proghatches.gt.metatileentity; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.NavigableMap; +import java.util.NavigableSet; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentSkipListMap; + +import javax.naming.OperationNotSupportedException; + +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; + +import org.spongepowered.asm.mixin.Unique; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.TreeMultimap; +import com.google.common.collect.TreeMultiset; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; + +import appeng.api.config.Actionable; +import appeng.api.config.FuzzyMode; +import appeng.api.definitions.Items; +import appeng.api.networking.security.BaseActionSource; +import appeng.api.networking.security.IActionHost; +import appeng.api.networking.security.MachineSource; +import appeng.api.networking.storage.IStorageGrid; +import appeng.api.storage.ICellProvider; +import appeng.api.storage.IMEInventoryHandler; +import appeng.api.storage.IMEMonitor; +import appeng.api.storage.IStorageMonitorable; +import appeng.api.storage.StorageChannel; +import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IAEStack; +import appeng.api.storage.data.IItemList; +import appeng.me.GridAccessException; +import appeng.me.cache.GridStorageCache; +import appeng.me.helpers.AENetworkProxy; +import appeng.me.storage.MEInventoryHandler; +import appeng.me.storage.MEPassThrough; +import appeng.util.item.AEItemStack; +import appeng.util.item.ItemList; +import appeng.util.item.MeaningfulItemIterator; +import appeng.util.item.OreReference; +import gregtech.api.GregTech_API; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_InputBus_ME; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.oredict.OreDictionary; +import reobf.proghatches.gt.metatileentity.util.IMEHatchOverrided; +import reobf.proghatches.main.registration.Registration; + +public class DecoyInputBusME extends GT_MetaTileEntity_Hatch_InputBus_ME implements IMEHatchOverrided { + + public DecoyInputBusME(int aID, /* boolean autoPullAvailable, */ String aName, String aNameRegional) { + super(aID, /* autoPullAvailable */true, aName, aNameRegional); + Registration.items.add(new ItemStack(GregTech_API.sBlockMachines, 1, aID)); + desc = reobf.proghatches.main.Config.get("DIBME", ImmutableMap.of()); + } + + String[] desc; + + @Override + public String[] getDescription() { + + return desc; + } + + public DecoyInputBusME(String aName, /* boolean autoPullAvailable, */ int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, true, aTier, aDescription, aTextures); + + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new DecoyInputBusME(mName, mTier, mDescriptionArray, mTextures); + } + + @Unique + private static Field f; + + static { + try { + f = GridStorageCache.class.getDeclaredField("activeCellProviders"); + } catch (Exception e) { + e.printStackTrace(); + throw new AssertionError(e); + + } + f.setAccessible(true); + } + + @Unique + private static Set get(GridStorageCache thiz) { + + try { + return (Set) f.get(thiz); + } catch (Exception e) { + throw new AssertionError(e); + } + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void overridedBehoviour(int minPull) { + AENetworkProxy proxy = getProxy(); + + try { + GridStorageCache st = (GridStorageCache) proxy.getStorage(); + + TreeMultimap> orderMap = TreeMultimap.create((a, b) -> -a + b, + (a, b) -> a.hashCode() - b.hashCode()); + for (final ICellProvider cc : get(st)) { + + List list = cc + .getCellArray(StorageChannel.ITEMS); + + for(IMEInventoryHandler l:list){ + if(!(l instanceof MEInventoryHandler))continue; + /* if(l instanceof MEInventoryHandler){ + MEInventoryHandler hh=(MEInventoryHandler) l; + if((hh.getInternal() instanceof MEPassThrough)) continue; + }*/ + + orderMap.put(cc.getPriority(), l); + } + + } + + boolean keepFirstEmpty=false; + if(reserveFirst&&orderMap.isEmpty()==false) + { + if(orderMap.get(orderMap.keySet().first()).stream() + .filter(s->s.getAvailableItems(StorageChannel.ITEMS.createList()).getFirstItem()!=null) + .findAny().isPresent()==false + ){ + keepFirstEmpty=true; + } + } + + + ArrayList added = new ArrayList<>(); + IItemList all = new IItemList() { + + private final NavigableMap records = new ConcurrentSkipListMap<>(); + + @Override + public void add(final IAEItemStack option) { + if (option == null) { + return; + } + + final IAEItemStack st = this.records.get(option); + + if (st != null) { + st.add(option); + return; + } + added.add(option.copy()); + final IAEItemStack opt = option.copy(); + + this.putItemRecord(opt); + } + + @Override + public IAEItemStack findPrecise(final IAEItemStack itemStack) { + if (itemStack == null) { + return null; + } + + return this.records.get(itemStack); + } + + @Override + public Collection findFuzzy(final IAEItemStack filter, final FuzzyMode fuzzy) { + throw new Error(); + } + + @Override + public boolean isEmpty() { + return !this.iterator().hasNext(); + } + + @Override + public void addStorage(final IAEItemStack option) { + if (option == null) { + return; + } + + final IAEItemStack st = this.records.get(option); + + if (st != null) { + st.incStackSize(option.getStackSize()); + return; + } + added.add(option.copy()); + final IAEItemStack opt = option.copy(); + + this.putItemRecord(opt); + } + + /* + * public void clean() { Iterator i = iterator(); + * while (i.hasNext()) { StackType AEI = i.next(); if ( + * !AEI.isMeaningful() ) i.remove(); } } + */ + + @Override + public void addCrafting(final IAEItemStack option) { + if (option == null) { + return; + } + + final IAEItemStack st = this.records.get(option); + + if (st != null) { + st.setCraftable(true); + return; + } + + final IAEItemStack opt = option.copy(); + opt.setStackSize(0); + opt.setCraftable(true); + + this.putItemRecord(opt); + } + + @Override + public void addRequestable(final IAEItemStack option) { + if (option == null) { + return; + } + + final IAEItemStack st = this.records.get(option); + + if (st != null) { + st.setCountRequestable(st.getCountRequestable() + option.getCountRequestable()); + st.setCountRequestableCrafts( + st.getCountRequestableCrafts() + option.getCountRequestableCrafts()); + return; + } + + final IAEItemStack opt = option.copy(); + opt.setStackSize(0); + opt.setCraftable(false); + opt.setCountRequestable(option.getCountRequestable()); + opt.setCountRequestableCrafts(option.getCountRequestableCrafts()); + + this.putItemRecord(opt); + } + + @Override + public IAEItemStack getFirstItem() { + for (final IAEItemStack stackType : this) { + return stackType; + } + + return null; + } + + @Override + public int size() { + return this.records.size(); + } + + @Override + public Iterator iterator() { + return new MeaningfulItemIterator<>(this.records.values().iterator()); + } + + @Override + public void resetStatus() { + for (final IAEItemStack i : this) { + i.reset(); + } + } + + public void clear() { + this.records.clear(); + } + + private IAEItemStack putItemRecord(final IAEItemStack itemStack) { + return this.records.put(itemStack, itemStack); + } + + private Collection findFuzzyDamage(final AEItemStack filter, final FuzzyMode fuzzy, + final boolean ignoreMeta) { + throw new Error(); + } + }; + + for (Entry> ent : orderMap.entries()) { + ent.getValue().getAvailableItems(all); + if (added.size() > 16) { + break; + } + } + int index = 0; + if(keepFirstEmpty){ + this.mInventory[0] = null; + index++; + + } + Iterator iterator = added.iterator(); + while (iterator.hasNext() && index < 16) { + IAEItemStack currItem = iterator.next(); + // if(all.findPrecise(currItem)!=null){continue;} + if (currItem.getStackSize() >= minPull) { + ItemStack itemstack = GT_Utility.copyAmount(1, currItem.getItemStack()); + this.mInventory[index] = itemstack; + index++; + } + } + for (int i = index; i < 16; i++) { + mInventory[i] = null; + } + + } catch (final GridAccessException ignored) { + } + + /* + * try { GridStorageCache st = (GridStorageCache) proxy.getStorage(); + * IItemList all=StorageChannel.ITEMS.createList(); + * + * for (final ICellProvider cc : get(st)) { for (final + * IMEInventoryHandler h : + * cc.getCellArray(StorageChannel.ITEMS)) { if(!(h instanceof + * IMEInventoryHandler))continue; if(h instanceof MEInventoryHandler){ + * MEInventoryHandler hh=(MEInventoryHandler) h; if((hh.getInternal() + * instanceof MEPassThrough)) continue; } h.getAvailableItems(all); } } + * + * int index = 0; Iterator it = all.iterator(); + * + * while (it.hasNext() && index < 16) { IAEItemStack currItem = + * it.next(); if (currItem.getStackSize() >= minPull) { ItemStack + * itemstack = GT_Utility.copyAmount(1, currItem.getItemStack()); + * this.mInventory[index] = itemstack; index++; } } if(index==16)return; + * if(reserveFirst&&index==0){ mInventory[0] = null; index++; + * + * } IMEMonitor sg = proxy.getStorage() + * .getItemInventory(); Iterator iterator = + * sg.getStorageList() .iterator(); + * + * while (iterator.hasNext() && index < 16) { IAEItemStack currItem = + * iterator.next(); if(all.findPrecise(currItem)!=null){continue;} if + * (currItem.getStackSize() >= minPull) { ItemStack itemstack = + * GT_Utility.copyAmount(1, currItem.getItemStack()); + * this.mInventory[index] = itemstack; index++; } } for (int i = index; + * i < 16; i++) { mInventory[i] = null; } + * + * } catch (final GridAccessException ignored) {} + */ + + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (clickData.mouseButton == 0) { + if (!widget.isClient()) { + + for (int index = 0; index < 16; index++) { + updateInformationSlot(index, mInventory[index]); + } + } + } + }).setBackground(() -> { + { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD }; + } + }).addTooltips(Arrays.asList(StatCollector.translateToLocal("proghatches.restricted.refresh.0"), + StatCollector.translateToLocal("proghatches.restricted.refresh.1"))).setSize(16, 16) + .setPos(80, 10 + 18)); + + // .widget(new FakeSyncWidget.BooleanSyncer(() -> autoPullFluidList, + // this::setAutoPullFluidList)); + + super.addUIWidgets(builder, buildContext); + + } + + boolean reserveFirst; + private BaseActionSource requestSource; + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + reserveFirst = !reserveFirst; + aPlayer.addChatMessage(new ChatComponentTranslation( + "proghatches.decoy.reservefirst." + (reserveFirst ? "enabled" : "disabled"))); + + return; + } + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); + } + + @Override + public CheckRecipeResult endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase controller) { + // TODO Auto-generated method stub + return super.endRecipeProcessing(controller); + } + private BaseActionSource getRequestSource() { + if (requestSource == null) requestSource = new MachineSource((IActionHost) getBaseMetaTileEntity()); + return requestSource; + } + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + + /*try { + System.out.println(overridedExtract( + ((IStorageGrid) this.getProxy().getNode().getGrid().getCache(IStorageGrid.class)).getItemInventory(), + + AEItemStack.create(new ItemStack(net.minecraft.init.Items.apple,10)),Actionable.MODULATE, + requestSource + )); + } catch (Exception e) { + + e.printStackTrace(); + }*/ + + return super.onRightclick(aBaseMetaTileEntity, aPlayer); + } + + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable mode, BaseActionSource src) { + long requested = request.getStackSize(); + long num = request.getStackSize(); + try { + AENetworkProxy proxy = getProxy(); + GridStorageCache st; + ArrayList ordered = new ArrayList(); + + st = (GridStorageCache) proxy.getStorage(); + for (final ICellProvider cc : get(st)) { + ordered.addAll(cc.getCellArray(StorageChannel.ITEMS)); + } + ordered.sort((IMEInventoryHandler a, IMEInventoryHandler b) -> a.getPriority() - b.getPriority()); + + + boolean somethingChanged=true; + done: while (true) { + if(somethingChanged){ + somethingChanged=false; + }else{break done;} + if(num<=0){break done;} + ArrayList most = new ArrayList<>(); + long most_ = -1; + long sec_ = 0; + for (IMEInventoryHandler o : ordered) { + IAEStack ex = o.extractItems(request.copy().setStackSize(Long.MAX_VALUE), Actionable.SIMULATE, src); + if (ex != null) { + if (most_ == -1) { + most_ = ex.getStackSize(); + most.add(o); + } else if (most_ == ex.getStackSize()) { + most.add(o); + } else if (most_ < ex.getStackSize()) { + sec_ = most_; + most = new ArrayList<>();most.add(o); + most_ = ex.getStackSize(); + }else if(sec_==0)sec_=ex.getStackSize(); + } + } + if (most_ == -1) + break done; + + + most.sort((a,b)->a.getPriority()-b.getPriority()); + { + long eachmax = most_ - sec_; + int nums = most.size(); + + if (num >= eachmax * nums) { + + for (IMEInventoryHandler s : most) { + IAEStack ret = s.extractItems(request.copy().setStackSize(eachmax), Actionable.MODULATE, + src); + if (ret != null){somethingChanged=true; + num -= ret.getStackSize();} + } + } else if (num > nums) { + for (IMEInventoryHandler s : most) { + IAEStack ret = s.extractItems(request.copy().setStackSize(num / nums), Actionable.MODULATE, + src); + if (ret != null){somethingChanged=true; + num -= ret.getStackSize();} + } + } else { + for (IMEInventoryHandler s : most) { + IAEStack ret = s.extractItems(request.copy().setStackSize(1), Actionable.MODULATE, src); + if (ret != null) { + num -= ret.getStackSize(); + if (num <= 0){somethingChanged=true; + break done;} + } + } + + } + + } + + } + + } catch (GridAccessException e) { + + } + if(requested==num)return null; + return request.copy().setStackSize(requested-num); + } + +} diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputHatchME.java b/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputHatchME.java new file mode 100644 index 0000000..3edd1df --- /dev/null +++ b/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputHatchME.java @@ -0,0 +1,516 @@ +package reobf.proghatches.gt.metatileentity; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.NavigableMap; +import java.util.Set; +import java.util.TreeSet; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentSkipListMap; + +import org.spongepowered.asm.mixin.Unique; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.TreeMultimap; +import com.google.common.collect.TreeMultiset; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; + +import appeng.api.config.Actionable; +import appeng.api.config.FuzzyMode; +import appeng.api.networking.security.BaseActionSource; +import appeng.api.networking.storage.IStorageGrid; +import appeng.api.storage.ICellProvider; +import appeng.api.storage.IMEInventoryHandler; +import appeng.api.storage.IMEMonitor; +import appeng.api.storage.StorageChannel; +import appeng.api.storage.data.IAEFluidStack; +import appeng.api.storage.data.IAEFluidStack; +import appeng.api.storage.data.IAEStack; +import appeng.api.storage.data.IItemList; +import appeng.me.GridAccessException; +import appeng.me.cache.GridStorageCache; +import appeng.me.helpers.AENetworkProxy; +import appeng.me.storage.MEInventoryHandler; +import appeng.me.storage.MEPassThrough; +import appeng.util.SortedArrayList; +import appeng.util.item.AEFluidStack; +import appeng.util.item.MeaningfulFluidIterator; +import appeng.util.item.MeaningfulItemIterator; +import gregtech.api.GregTech_API; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_InputBus_ME; +import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_Input_ME; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import reobf.proghatches.gt.metatileentity.util.IMEHatchOverrided; +import reobf.proghatches.main.registration.Registration; + +public class DecoyInputHatchME extends GT_MetaTileEntity_Hatch_Input_ME implements IMEHatchOverrided{ + + public DecoyInputHatchME(int aID, /*boolean autoPullAvailable,*/ String aName, String aNameRegional) { + super(aID, /*autoPullAvailable*/true, aName, aNameRegional); + Registration.items.add(new ItemStack(GregTech_API.sBlockMachines, 1, aID)); + desc=reobf.proghatches.main.Config.get("DIHME", ImmutableMap.of()); + } + String[] desc; + @Override + public String[] getDescription() { + + return desc; + } + public DecoyInputHatchME(String aName, /*boolean autoPullAvailable,*/ int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, true, aTier, aDescription, aTextures); + + } + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new DecoyInputHatchME(mName, mTier, mDescriptionArray, mTextures); + } + + @Unique + private static Field f; + + static { + try { + f=GridStorageCache.class.getDeclaredField("activeCellProviders"); + } catch (Exception e) {e.printStackTrace(); + throw new AssertionError(e); + + } + f.setAccessible(true); + } + @Unique + private static Set get(GridStorageCache thiz){ + + try { + return (Set) f.get(thiz); + } catch (Exception e) { + throw new AssertionError(e); + } + } + + @Override + public void overridedBehoviour(int minPull) { + AENetworkProxy proxy = getProxy(); + + try { + GridStorageCache st = (GridStorageCache) proxy.getStorage(); + + TreeMultimap> orderMap = TreeMultimap.create((a, b) -> -a + b, + (a, b) -> a.hashCode() - b.hashCode()); + for (final ICellProvider cc : get(st)) { + + List list = cc + .getCellArray(StorageChannel.FLUIDS); + + for(IMEInventoryHandler l:list){ + if(!(l instanceof MEInventoryHandler))continue; + /* if(l instanceof MEInventoryHandler){ + MEInventoryHandler hh=(MEInventoryHandler) l; + if((hh.getInternal() instanceof MEPassThrough)) continue; + }*/ + + orderMap.put(cc.getPriority(), l); + } + + } + + boolean keepFirstEmpty=false; + if(reserveFirst&&orderMap.isEmpty()==false) + { + if(orderMap.get(orderMap.keySet().first()).stream() + .filter(s->s.getAvailableItems(StorageChannel.FLUIDS.createList()).getFirstItem()!=null) + .findAny().isPresent()==false + ){ + keepFirstEmpty=true; + } + } + + + ArrayList added = new ArrayList<>(); + IItemList all = new IItemList() { + + private final NavigableMap records = new ConcurrentSkipListMap<>(); + + @Override + public void add(final IAEFluidStack option) { + if (option == null) { + return; + } + + final IAEFluidStack st = this.records.get(option); + + if (st != null) { + st.add(option); + return; + } + added.add(option.copy()); + final IAEFluidStack opt = option.copy(); + + this.putItemRecord(opt); + } + + @Override + public IAEFluidStack findPrecise(final IAEFluidStack itemStack) { + if (itemStack == null) { + return null; + } + + return this.records.get(itemStack); + } + + @Override + public Collection findFuzzy(final IAEFluidStack filter, final FuzzyMode fuzzy) { + throw new Error(); + } + + @Override + public boolean isEmpty() { + return !this.iterator().hasNext(); + } + + @Override + public void addStorage(final IAEFluidStack option) { + if (option == null) { + return; + } + + final IAEFluidStack st = this.records.get(option); + + if (st != null) { + st.incStackSize(option.getStackSize()); + return; + } + added.add(option.copy()); + final IAEFluidStack opt = option.copy(); + + this.putItemRecord(opt); + } + + /* + * public void clean() { Iterator i = iterator(); + * while (i.hasNext()) { StackType AEI = i.next(); if ( + * !AEI.isMeaningful() ) i.remove(); } } + */ + + @Override + public void addCrafting(final IAEFluidStack option) { + if (option == null) { + return; + } + + final IAEFluidStack st = this.records.get(option); + + if (st != null) { + st.setCraftable(true); + return; + } + + final IAEFluidStack opt = option.copy(); + opt.setStackSize(0); + opt.setCraftable(true); + + this.putItemRecord(opt); + } + + @Override + public void addRequestable(final IAEFluidStack option) { + if (option == null) { + return; + } + + final IAEFluidStack st = this.records.get(option); + + if (st != null) { + st.setCountRequestable(st.getCountRequestable() + option.getCountRequestable()); + st.setCountRequestableCrafts( + st.getCountRequestableCrafts() + option.getCountRequestableCrafts()); + return; + } + + final IAEFluidStack opt = option.copy(); + opt.setStackSize(0); + opt.setCraftable(false); + opt.setCountRequestable(option.getCountRequestable()); + opt.setCountRequestableCrafts(option.getCountRequestableCrafts()); + + this.putItemRecord(opt); + } + + @Override + public IAEFluidStack getFirstItem() { + for (final IAEFluidStack stackType : this) { + return stackType; + } + + return null; + } + + @Override + public int size() { + return this.records.size(); + } + + @Override + public Iterator iterator() { + return new MeaningfulFluidIterator<>(this.records.values().iterator()); + } + + @Override + public void resetStatus() { + for (final IAEFluidStack i : this) { + i.reset(); + } + } + + public void clear() { + this.records.clear(); + } + + private IAEFluidStack putItemRecord(final IAEFluidStack itemStack) { + return this.records.put(itemStack, itemStack); + } + + private Collection findFuzzyDamage(final AEFluidStack filter, final FuzzyMode fuzzy, + final boolean ignoreMeta) { + throw new Error(); + } + }; + + for (Entry> ent : orderMap.entries()) { + ent.getValue().getAvailableItems(all); + if (added.size() > 16) { + break; + } + } + int index = 0; + if(keepFirstEmpty){ + this.storedFluids[0] = null; + index++; + + } + Iterator iterator = added.iterator(); + while (iterator.hasNext() && index < 16) { + IAEFluidStack currItem = iterator.next(); + // if(all.findPrecise(currItem)!=null){continue;} + if (currItem.getStackSize() >= minPull) { + FluidStack itemstack = GT_Utility.copyAmount(1, currItem.getFluidStack()); + this.storedFluids[index] = itemstack; + index++; + } + } + for (int i = index; i < 16; i++) { + storedFluids[i] = null; + } + + } catch (final GridAccessException ignored) { + } + /* AENetworkProxy proxy = getProxy(); + try { + GridStorageCache st = (GridStorageCache) proxy.getStorage(); + IItemList all=StorageChannel.FLUIDS.createList(); + + for (final ICellProvider cc : get(st)) { + for (final IMEInventoryHandler h : cc.getCellArray(StorageChannel.FLUIDS)) { + if(!(h instanceof IMEInventoryHandler))continue; + if(h instanceof MEInventoryHandler){ + MEInventoryHandler hh=(MEInventoryHandler) h; + if((hh.getInternal() instanceof MEPassThrough)) + continue; + } + h.getAvailableItems(all); + } + } + + int index = 0; + Iterator it = all.iterator(); + + while (it.hasNext() && index < 16) { + IAEFluidStack currItem = it.next(); + if (currItem.getStackSize() >= minPull) { + FluidStack itemstack = GT_Utility.copyAmount(1, currItem.getFluidStack()); + this.storedFluids[index] = itemstack; + index++; + } + } + if(index==16)return; + if(reserveFirst&&index==0){ + storedFluids[0] = null; + index++; + + } + IMEMonitor sg = proxy.getStorage() + .getFluidInventory(); + Iterator iterator = sg.getStorageList() + .iterator(); + + while (iterator.hasNext() && index < 16) { + IAEFluidStack currItem = iterator.next(); + if(all.findPrecise(currItem)!=null){continue;} + if (currItem.getStackSize() >= minPull) { + FluidStack itemstack = GT_Utility.copyAmount(1, currItem.getFluidStack()); + this.storedFluids[index] = itemstack; + index++; + } + } + for (int i = index; i < 16; i++) { + storedFluids[i] = null; + } + + } catch (final GridAccessException ignored) {}*/ + + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + + + + + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (clickData.mouseButton == 0) { + if (!widget.isClient()) { + + for (int index = 0; index < 16; index++) { + updateInformationSlot(index); + } + } + }}) + .setBackground(() -> { + { + return new IDrawable[] { + GT_UITextures.BUTTON_STANDARD + }; + } + }) + .addTooltips( + Arrays.asList( + StatCollector.translateToLocal("proghatches.restricted.refresh.0"), + StatCollector.translateToLocal("proghatches.restricted.refresh.1"))) + .setSize(16, 16) + .setPos(80, 10+18)); + + + // .widget(new FakeSyncWidget.BooleanSyncer(() -> autoPullFluidList, this::setAutoPullFluidList)); + + + super.addUIWidgets(builder, buildContext); + + } + boolean reserveFirst; +@Override +public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if(aPlayer.isSneaking()){ + reserveFirst=!reserveFirst; + aPlayer.addChatMessage( + new ChatComponentTranslation( + "proghatches.decoy.reservefirst." + (reserveFirst ? "enabled" : "disabled"))); + + return; + } + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); +}@Override +public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable mode, BaseActionSource src) { + + long requested = request.getStackSize(); + long num = request.getStackSize(); + try { + AENetworkProxy proxy = getProxy(); + GridStorageCache st; + ArrayList ordered = new ArrayList(); + + + st = (GridStorageCache) proxy.getStorage(); + for (final ICellProvider cc : get(st)) { + ordered.addAll(cc.getCellArray(StorageChannel.FLUIDS)); + } + ordered.sort((IMEInventoryHandler a, IMEInventoryHandler b) -> a.getPriority() - b.getPriority()); + + boolean somethingChanged=true; + done: while (true) { + if(somethingChanged){ + somethingChanged=false; + }else{break done;} + if(num<=0){break done;} + ArrayList most = new ArrayList<>(); + long most_ = -1; + long sec_ = 0; + for (IMEInventoryHandler o : ordered) { + IAEStack ex = o.extractItems(request.copy().setStackSize(Long.MAX_VALUE), Actionable.SIMULATE, src); + if (ex != null) { + if (most_ == -1) { + most_ = ex.getStackSize(); + most.add(o); + } else if (most_ == ex.getStackSize()) { + most.add(o); + } else if (most_ < ex.getStackSize()) { + sec_ = most_; + most = new ArrayList<>();most.add(o); + most_ = ex.getStackSize(); + }else if(sec_==0)sec_=ex.getStackSize(); + } + } + if (most_ == -1) + break done; + + + most.sort((a,b)->a.getPriority()-b.getPriority()); + { + long eachmax = most_ - sec_; + int nums = most.size(); + + if (num >= eachmax * nums) { + + for (IMEInventoryHandler s : most) { + IAEStack ret = s.extractItems(request.copy().setStackSize(eachmax), Actionable.MODULATE, + src); + if (ret != null){somethingChanged=true; + num -= ret.getStackSize();} + } + } else if (num > nums) { + for (IMEInventoryHandler s : most) { + IAEStack ret = s.extractItems(request.copy().setStackSize(num / nums), Actionable.MODULATE, + src); + if (ret != null){somethingChanged=true; + num -= ret.getStackSize();} + } + } else { + for (IMEInventoryHandler s : most) { + IAEStack ret = s.extractItems(request.copy().setStackSize(1), Actionable.MODULATE, src); + if (ret != null) { + num -= ret.getStackSize(); + if (num <= 0){somethingChanged=true; + break done;} + } + } + + } + + } + + } + + } catch (GridAccessException e) { + + } + if(requested==num)return null; + return request.copy().setStackSize(requested-num); +} +} diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java index 68360ba..0a3e7dd 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java @@ -14,6 +14,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.ListIterator; import java.util.NoSuchElementException; @@ -1286,7 +1287,7 @@ public int fill(FluidStack aFluid, boolean doFill) { if(fluidLimit==0){int oldamount=aFluid.amount; aFluid=aFluid.copy(); for(ListeningFluidTank tk:this.mStoredFluid){ - if(tk.getFluidAmount()==0)tk.setFluid(null); + if(tk.getFluidAmount()==0)tk.setFluidDirect(null); if((aFluid.amount-=tk.fill(aFluid, doFill))<=0){ break; }; @@ -1324,19 +1325,24 @@ public int fill(FluidStack aFluid, boolean doFill) { int oldamount=aFluid.amount; aFluid=aFluid.copy(); + LinkedList tks=new LinkedList<>(); for(ListeningFluidTank tk:this.mStoredFluid){ if(tk.getFluidAmount()==0){ - tk.setFluid(null); - if((aFluid.amount-=tk.fill(aFluid, doFill))<=0){ + tk.setFluidDirect(null); + tks.add(tk); + if((aFluid.amount-=tk.fillDirect(aFluid, doFill))<=0){ break; }; } } for(ListeningFluidTank tk:this.mStoredFluid){ - if((aFluid.amount-=tk.fill(aFluid, doFill))<=0){ + tks.add(tk); + if((aFluid.amount-=tk.fillDirect(aFluid, doFill))<=0){ break; }; } + tks.forEach(s->s.onChange()); + return oldamount-aFluid.amount; } return 0; diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/util/IMEHatchOverrided.java b/src/main/java/reobf/proghatches/gt/metatileentity/util/IMEHatchOverrided.java new file mode 100644 index 0000000..6897936 --- /dev/null +++ b/src/main/java/reobf/proghatches/gt/metatileentity/util/IMEHatchOverrided.java @@ -0,0 +1,12 @@ +package reobf.proghatches.gt.metatileentity.util; + +import appeng.api.config.Actionable; +import appeng.api.networking.security.BaseActionSource; +import appeng.api.storage.IMEMonitor; +import appeng.api.storage.data.IAEStack; + +public interface IMEHatchOverrided { +public void overridedBehoviour(int minPull); + +public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable mode, BaseActionSource src); +} diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/util/ListeningFluidTank.java b/src/main/java/reobf/proghatches/gt/metatileentity/util/ListeningFluidTank.java index b5843ae..a4d57fd 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/util/ListeningFluidTank.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/util/ListeningFluidTank.java @@ -36,14 +36,16 @@ public ListeningFluidTank addListener(Runnable c) { @Override public int fill(FluidStack resource, boolean doFill) { - + int filled = 0; try { - return super.fill(resource, doFill); + return filled=super.fill(resource, doFill); } finally { - callback.ifPresent(Runnable::run); + if(filled>0)callback.ifPresent(Runnable::run); } } - +public void onChange(){ + callback.ifPresent(Runnable::run); +} @Override public void setFluid(FluidStack fluid) { diff --git a/src/main/java/reobf/proghatches/main/MyMod.java b/src/main/java/reobf/proghatches/main/MyMod.java index 186d5b1..d89bc75 100644 --- a/src/main/java/reobf/proghatches/main/MyMod.java +++ b/src/main/java/reobf/proghatches/main/MyMod.java @@ -128,6 +128,7 @@ import gregtech.api.util.shutdown.SimpleShutDownReason; import gregtech.common.blocks.GT_Block_Machines; import gregtech.common.covers.CoverInfo; +import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_InputBus_ME; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_HeatExchanger; import gregtech.crossmod.waila.GregtechWailaDataProvider; import li.cil.oc.api.Driver; @@ -177,7 +178,7 @@ public class MyMod { public static final Logger LOG = LogManager.getLogger(MODID); public static MyMod instance; { - //GT_MetaTileEntity_MultiBlockBase.class.getDeclaredFields(); + GT_MetaTileEntity_Hatch_InputBus_ME.class.getDeclaredFields(); instance = this; } diff --git a/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java b/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java index e5ad90c..03afbe7 100644 --- a/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java +++ b/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java @@ -199,6 +199,7 @@ public List getMixins() { retLate.add("part2.MixinRecursiveSlotClickProtection"); retLate.add("part2.MixinMultiPattern"); retLate.add("part2.MixinSplitDetect"); + retLate.add("part2.MixinMEBusOverride"); if (FMLLaunchHandler.side().isClient()) { if (!"true".equals(pp.get("noAEItemSortMixins"))) if(ff)retLate.add("MixinAEItemStackCompare"); diff --git a/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinMEBusOverride.java b/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinMEBusOverride.java new file mode 100644 index 0000000..0ec60be --- /dev/null +++ b/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinMEBusOverride.java @@ -0,0 +1,80 @@ +package reobf.proghatches.main.mixin.mixins.part2; + +import java.lang.reflect.Field; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import appeng.api.config.Actionable; +import appeng.api.networking.security.BaseActionSource; +import appeng.api.storage.IMEMonitor; +import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IAEStack; +import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_InputBus_ME; +import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_Input_ME; +import reobf.proghatches.gt.metatileentity.util.IMEHatchOverrided; + +@Mixin(remap=false,value={GT_MetaTileEntity_Hatch_InputBus_ME.class, + GT_MetaTileEntity_Hatch_Input_ME.class, + +}) +public class MixinMEBusOverride { + private static Field minAutoPullStackSize; + private static Field minAutoPullAmount; + static { + + try { + minAutoPullStackSize= GT_MetaTileEntity_Hatch_InputBus_ME.class.getDeclaredField("minAutoPullStackSize"); + minAutoPullAmount= GT_MetaTileEntity_Hatch_Input_ME.class.getDeclaredField("minAutoPullAmount"); + + minAutoPullAmount.setAccessible(true); + minAutoPullStackSize.setAccessible(true); + } catch (Exception e) { + e.printStackTrace(); + + } + + } + + @Inject(method={"refreshItemList" + ,"refreshFluidList" + },cancellable=true,at = { @At("HEAD") }) + private void refreshItemList(CallbackInfo ci) { + if(this instanceof IMEHatchOverrided){ + try { + ((IMEHatchOverrided)this).overridedBehoviour( + ( (Object)this instanceof GT_MetaTileEntity_Hatch_InputBus_ME? + minAutoPullStackSize:minAutoPullAmount) + + .getInt(this)); + } catch (Exception e) { + e.printStackTrace(); + } + ci.cancel(); + } + + } + + @Redirect(method="endRecipeProcessing" + , + + at = @At(value="INVOKE", + target = "extractItems", + remap = false + )) + private IAEStack r(IMEMonitor thiz,IAEStack request, Actionable mode, BaseActionSource src) { + if(this instanceof IMEHatchOverrided){ + return ((IMEHatchOverrided)this).overridedExtract(thiz,request,mode,src); + + } + + return (IAEStack) thiz.extractItems(request, mode, src); + + + } + +} diff --git a/src/main/java/reobf/proghatches/main/registration/PHRecipes.java b/src/main/java/reobf/proghatches/main/registration/PHRecipes.java index 1506f62..bf182f4 100644 --- a/src/main/java/reobf/proghatches/main/registration/PHRecipes.java +++ b/src/main/java/reobf/proghatches/main/registration/PHRecipes.java @@ -98,1214 +98,7 @@ public class PHRecipes implements Runnable { { Cosmic/*Transcendent*/ }}; - ItemList[] multi = { null, null, null, null, Hatch_Input_Multi_2x2_EV, Hatch_Input_Multi_2x2_IV, - Hatch_Input_Multi_2x2_LuV, Hatch_Input_Multi_2x2_ZPM, Hatch_Input_Multi_2x2_UV, Hatch_Input_Multi_2x2_UHV, - Hatch_Input_Multi_2x2_UEV, - - Hatch_Input_Multi_2x2_UIV, Hatch_Input_Multi_2x2_UMV, Hatch_Input_Multi_2x2_UXV, - Hatch_Input_Multi_2x2_Humongous }; - @Override - public void run() { - - -if(Config.skipRecipeAdding)return; - -if( -GameRegistry.findItem("dreamcraft","item.PolychromePikoCircuit")!=null -){ - MyMod.LOG.info("Found new dreamcraft Nano-Piko-Quantum circuit, use oredict: Exotic-Cosmic-Transcendent."); - mat=matNewVersion;} -else{ - mat=metget.get(); - MyMod.LOG.info("Good ol' version."); - -} -//You just like breaking changes, isn't that true, GTNH dev? - - -IRecipe rec = new ShapedOreRecipe(new ItemStack(MyMod.plunger),"CRR","TSR","Q F", - 'R',"plateAnyRubber", - 'C',"craftingToolWireCutter", - 'F',"craftingToolFile", - 'Q',"stickCertusQuartz", - 'S', - new ItemStack( - GameRegistry.findItem("appliedenergistics2","item.ToolChargedStaff"),1, - OreDictionary.WILDCARD_VALUE - ) - - //Api.INSTANCE.definitions().items().chargedStaff().maybeStack(1).get() - //ApiItems.chargedStaff() returns memoryCard, not chargedStaff - //What are you doing GTNH dev? - - , - 'T', - - new ItemStack( - GameRegistry.findItem("appliedenergistics2","item.ToolWirelessTerminal"),1, - OreDictionary.WILDCARD_VALUE - ) - - ); -CraftingManager.getInstance().getRecipeList().add(rec); - - - - - - - - ArrayList pc0 = new ArrayList<>(); - HashMapproductivity */> pc = new HashMap<>();// List> - - no: { - Item im = GameRegistry.findItem("bartworks", "gt.BWCircuitProgrammer"); - if (im == null) { - MyMod.LOG.fatal("BW Programmer not found! Did you install GTNH properly?"); - break no; - } - pc0.add(new ItemStack(im, 0)); - pc.put(new ItemStack(im, 1), 4); - - } - no: { - Item im = GameRegistry.findItem("miscutils", "blockCircuitProgrammer"); - if (im == null) { - MyMod.LOG.fatal("GT++ Programmer not found! Did you install GTNH properly?"); - break no; - } - - pc0.add(new ItemStack(im, 0)); - pc.put(new ItemStack(im, 1), 1); - } - // in dev env, use bedrock to replace programmer to debug - Optional.of(pc0) - .filter(List::isEmpty) - .ifPresent(s -> s.add(new ItemStack(Blocks.bedrock, 0))); - Optional.of(pc) - .filter(Map::isEmpty) - .ifPresent((s) -> s.put(new ItemStack(Blocks.bedrock, 1), 1)); - - pc.forEach((s, i) -> { - - GT_Values.RA.stdBuilder() - .itemInputs(s, Materials.Titanium.getPlates(1)) - .fluidInputs(Materials.TungstenSteel.getMolten(144*20L)) - .itemOutputs(new ItemStack(MyMod.cover, 4 * i, 0)) - .duration(1 * SECONDS) - .eut(480) - .addTo(RecipeMaps.mixerRecipes); - GT_Values.RA.stdBuilder() - .itemInputs(s, Materials.Titanium.getPlates(1)) - .fluidInputs(Materials.StainlessSteel.getMolten(144*20L)) - .itemOutputs(new ItemStack(MyMod.cover, 2 * i, 0)) - .duration(1 * SECONDS) - .eut(480) - .addTo(RecipeMaps.mixerRecipes); - - }); - pc0.forEach(s -> { - GregTech_API.getConfigurationCircuitList(100) - .stream() - .forEach(ss -> { - GT_Values.RA.stdBuilder() - .itemInputs(s, GT_Utility.copyAmount(0, ss)) - - .itemOutputs(ItemProgrammingCircuit.wrap(ss)) - .duration(1 * SECONDS) - .eut(120) - .addTo(RecipeMaps.hammerRecipes); - - });; - - }); - - ArrayList is = Arrays.stream(HATCHES_INPUT) - .map(s -> s.get(1)) - .collect(ArrayList::new, ArrayList::add, ArrayList::addAll); - for (int i = 12097; i <= 12102; i++) { - is.add(new ItemStack(GregTech_API.sBlockMachines, 1, i)); - } // stuff from gtnhcoremod - ItemStack[] single_fluid = is.toArray(new ItemStack[0]); - is = Arrays.stream(HATCHES_INPUT_BUS) - .map(s -> s.get(1)) - .collect(ArrayList::new, ArrayList::add, ArrayList::addAll); - - is.add(new ItemStack(GregTech_API.sBlockMachines, 1, 30030));// gt++ superbus - is.add(new ItemStack(GregTech_API.sBlockMachines, 1, 30030)); - is.add(new ItemStack(GregTech_API.sBlockMachines, 1, 30030)); - is.add(new ItemStack(GregTech_API.sBlockMachines, 1, 30030)); - is.add(new ItemStack(GregTech_API.sBlockMachines, 1, 30030)); - ItemStack[] single_item = is.toArray(new ItemStack[0]); - - for (int i = 4; i < GT_Values.VN.length - 1; i++) { - - GT_Values.RA.stdBuilder() - .itemInputs(multi[i].get(1), single_item[i], new ItemStack(MyMod.cover, 1, 0)) - .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) - .itemOutputs( - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.QuadDualInputHatchOffset + i)) - .duration(20 * SECONDS) - .eut(GT_Values.VP[i]) - .addTo(RecipeMaps.mixerRecipes); - } - - for (int i = 0; i < GT_Values.VN.length - 1; i++) { - - GT_Values.RA.stdBuilder() - .itemInputs(single_fluid[i], single_item[i], new ItemStack(MyMod.cover, 1, 0)) - .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) - .itemOutputs( - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.DualInputHatchOffset + i)) - .duration(20 * SECONDS) - .eut(GT_Values.VP[i]) - .addTo(RecipeMaps.mixerRecipes); - } - - for (int i = 0; i < GT_Values.VN.length - 1; i++) { - Object circuit = OrePrefixes.circuit.get(mat[i][0]); - Object circuitP = OrePrefixes.circuit.get(mat[Math.min(i + 1, mat.length - 2)][0]); - if (circuit == null || GT_OreDictUnificator.get(circuit, 1) == null) { - MyMod.LOG.fatal("Circuit not found for " + GT_Values.VN[i] + "!"); - continue; - } - - /* - * //GT OreDict handling is too magic for me to understand - * GT_Values.RA.stdBuilder() - * .itemInputs( - * new - * ItemStack(GregTech_API.sBlockMachines,1,Config.metaTileEntityOffset+Registration.DualInputHatchOffset+i) - * , new Object[] {circuit,2} - * ,new ItemStack(MyMod.smartarm,1,i) - * ) - * .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) - * .itemOutputs( - * new ItemStack(GregTech_API.sBlockMachines,1,Config.metaTileEntityOffset+Registration. - * BufferedDualInputHatchOffset+i) - * ) - * .duration(20 * SECONDS) - * .eut(GT_Values.VP[i]) - * .addTo(RecipeMaps.assemblerRecipes); - */ - - RecipeMaps.assemblerRecipes.add( - new GT_Recipe/*.GT_Recipe_WithAlt*/( - false, - new ItemStack[] { GT_OreDictUnificator.get((circuit), 2), single_item[i], - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.DualInputHatchOffset + i) - - , new ItemStack(MyMod.smartarm, 1, i) }// II - , - new ItemStack[] { new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.BufferedDualInputHatchOffset + i) } - // IO - , - null// SP - , - null// CHANCE - , - new FluidStack[] { Materials.AdvancedGlue.getFluid(4000) }// FI - , - null// FO - , - 20 * SECONDS, - (int) GT_Values.VP[i], - 0/*, - new ItemStack[][] { - - Arrays.stream(mat[i]) - .map(s -> GT_OreDictUnificator.getOres(OrePrefixes.circuit, s)) - .flatMap(ArrayList::stream) - .map(s -> GT_Utility.copyAmount(2, s)) - .toArray(ItemStack[]::new) } */// ALT - )); - RecipeMaps.assemblerRecipes.add( - new GT_Recipe( - false, - new ItemStack[] { GT_OreDictUnificator.get((circuit), 2), single_item[i], - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.QuadDualInputHatchOffset + i) - - , new ItemStack(MyMod.smartarm, 1, i) }// II - , - new ItemStack[] { new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.BufferedQuadDualInputHatchOffset + i) } - // IO - , - null// SP - , - null// CHANCE - , - new FluidStack[] { Materials.Osmiridium.getMolten(144*20) }// FI - , - null// FO - , - 20 * SECONDS, - (int) GT_Values.VP[i], - 0/*, - new ItemStack[][] { - - Arrays.stream(mat[i]) - .map(s -> GT_OreDictUnificator.getOres(OrePrefixes.circuit, s)) - .flatMap(ArrayList::stream) - .map(s -> GT_Utility.copyAmount(2, s)) - .toArray(ItemStack[]::new) } */// ALT - )); - RecipeMaps.assemblerRecipes.add( - new GT_Recipe( - false, - new ItemStack[] { GT_OreDictUnificator.get(circuitP, 2), - GT_Utility.copyAmount(5, single_item[i]), - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.BufferedQuadDualInputHatchOffset + i), - new ItemStack(MyMod.smartarm, 5, i) }// II - , - new ItemStack[] { new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.BufferedQuadDualInputHatchMKIIOffset + i) } - // IO - , - null// SP - , - null// CHANCE - , - new FluidStack[] { Materials.Neutronium.getMolten(144*60) }// FI - , - null// FO - , - 20 * SECONDS, - (int) GT_Values.VP[i], - 0/*, - new ItemStack[][] { - - Arrays.stream(mat[Math.min(i + 1, mat.length - 1)]) - .map(s -> GT_OreDictUnificator.getOres(OrePrefixes.circuit, s)) - .flatMap(ArrayList::stream) - .map(s -> GT_Utility.copyAmount(2, s)) - .toArray(ItemStack[]::new) } */// ALT - )); - } - - pc.forEach((s, i) -> { - GT_Values.RA.stdBuilder() - .itemInputs( - s, - new ItemStack(ItemAndBlockHolder.INTERFACE), - new ItemStack(MyMod.toolkit, 0, OreDictionary.WILDCARD_VALUE), - ( - Api.INSTANCE.definitions() - .blocks() - .craftingStorage256k() - .maybeStack(1) - .get()), - ( - Api.INSTANCE.definitions() - .blocks() - .craftingAccelerator4x() - .maybeStack(1) - .get()), - new ItemStack( - Api.INSTANCE.definitions() - .blocks() - .molecularAssembler() - .maybeItem() - .get()) - - - ) - .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) - .itemOutputs( - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.CircuitProviderOffset)) - .duration(20 * SECONDS) - .eut(GT_Values.VP[5]) - .addTo(RecipeMaps.assemblerRecipes); -//T0 - GT_Values.RA.stdBuilder() - .itemInputs( - s, - Api.INSTANCE.definitions().blocks().iface().maybeStack(1).get(), - new ItemStack(MyMod.toolkit, 0, OreDictionary.WILDCARD_VALUE), - ( - Api.INSTANCE.definitions() - .blocks() - .craftingStorage1k() - .maybeStack(1) - .get()), - ( - Api.INSTANCE.definitions() - .blocks() - .craftingAccelerator() - .maybeStack(1) - .get()), - - Machine_HV_Assembler.get(1) - - - ) - .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) - .itemOutputs( - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.CircuitProviderOffsetT0)) - .duration(20 * SECONDS) - .eut(GT_Values.VP[3]) - .addTo(RecipeMaps.assemblerRecipes); - }); - - pc0.forEach((s) -> { - GT_Values.RA.stdBuilder() - .itemInputs( - s, - Hatch_CraftingInput_Bus_Slave.get(1), - - GT_Utility.getIntegratedCircuit(13)) - .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) - .itemOutputs( - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.SlaveOffset)) - .duration(20 * SECONDS) - .eut(GT_Values.VP[7]) - .addTo(RecipeMaps.assemblerRecipes); - - }); - - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack(GameRegistry.findItem("RIO", "tile.remote_interface")), - new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 0), - single_item[6]) - .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) - .itemOutputs( - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.RemoteInputBusOffset)) - .duration(20 * SECONDS) - .eut(GT_Values.VP[5]) - .addTo(RecipeMaps.assemblerRecipes); - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack(GameRegistry.findItem("RIO", "tile.remote_interface")), - new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 1), - single_fluid[6] - - ) - .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) - .itemOutputs( - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.RemoteInputHatchOffset)) - .duration(20 * SECONDS) - .eut(GT_Values.VP[5]) - .addTo(RecipeMaps.assemblerRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs( - - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.BufferedQuadDualInputHatchOffset + 8), - Quantum_Tank_LV.get(24), - Electric_Pump_UV.get(24), - Cover_Shutter.get(24)) - .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) - .itemOutputs( - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.SuperFluidHatch)) - .duration(20 * SECONDS) - .eut(GT_Values.VP[8]) - .addTo(RecipeMaps.assemblerRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs( - Hatch_CraftingInput_Bus_ME.get(1), - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.BufferedQuadDualInputHatchMKIIOffset + 8)) - .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) - .itemOutputs( - new ItemStack(GregTech_API.sBlockMachines, 1, Config.metaTileEntityOffset + Registration.PatternOffset)) - .duration(20 * SECONDS) - .eut(GT_Values.VP[9]) - .addTo(RecipeMaps.assemblerRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs( - Hatch_CraftingInput_Bus_ME_ItemOnly.get(1), - new ItemStack( - MyMod.smartarm,4,6)) - .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) - .itemOutputs( - new ItemStack(GregTech_API.sBlockMachines, 1, Config.metaTileEntityOffset + Registration.PatternOffsetBus)) - .duration(20 * SECONDS) - .eut(GT_Values.VP[6]) - .addTo(RecipeMaps.assemblerRecipes); - - - for (int i = 0; i < 4; i++) { - GT_Values.RA.stdBuilder() - .itemInputs(single_item[i], new ItemStack(GameRegistry.findItem("Automagy", "blockTenaciousChest")) - - ) - .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) - .itemOutputs( - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.TenaciousOffset + i)) - .duration(20 * SECONDS) - .eut(GT_Values.VP[i]) - .addTo(RecipeMaps.assemblerRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack(GameRegistry.findItem("Automagy", "glyph"), 1, 3), - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.TenaciousOffset + i) - - ) - .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) - .itemOutputs( - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.FilterOffset + i) - - ) - .duration(20 * SECONDS) - .eut(GT_Values.VP[i]) - .addTo(RecipeMaps.assemblerRecipes); - - } - - GT_Values.RA.stdBuilder() - .itemInputs(Cover_Controller.get(1), Cover_AdvancedRedstoneReceiverInternal.get(1) - - ) - .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) - .itemOutputs(new ItemStack(MyMod.cover, 1, 1) - - ) - .duration(20 * SECONDS) - .eut(GT_Values.VP[2]) - .addTo(RecipeMaps.mixerRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1, 33), - GT_Utility.getIntegratedCircuit(14), - Machine_HV_Scanner.get(1), - new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 2, 25), - new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 2, 78)) - .fluidInputs(Materials.SolderingAlloy.getMolten(144*20)) - .itemOutputs(new ItemStack(MyMod.oc_api, 1) - - ) - .duration(20 * SECONDS) - .eut(GT_Values.VP[2]) - .addTo(RecipeMaps.circuitAssemblerRecipes); - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1, 33), - GT_Utility.getIntegratedCircuit(15), - Cover_AdvancedRedstoneReceiverInternal.get(1), - Cover_AdvancedRedstoneTransmitterInternal.get(1)) - .fluidInputs(Materials.SolderingAlloy.getMolten(144*20)) - .itemOutputs(new ItemStack(MyMod.oc_redstone, 1) - - ) - .duration(20 * SECONDS) - .eut(GT_Values.VP[2]) - .addTo(RecipeMaps.circuitAssemblerRecipes); - pc.forEach((s, i) -> { - GT_Values.RA.stdBuilder() - .itemInputs( - s, - ItemList.Tool_Scanner.get(1), - new ItemStack( - Api.INSTANCE.definitions() - .items() - .networkTool() - .maybeItem() - .get())) - - .itemOutputs(new ItemStack(MyMod.toolkit, 1) - - ) - .duration(20 * SECONDS) - .eut(GT_Values.VP[3]) - .addTo(RecipeMaps.assemblerRecipes); - }); - - pc0.forEach((s) -> { - GT_Values.RA.stdBuilder() - .itemInputs(new ItemStack(Items.book), s) - .fluidInputs(Materials.SolderingAlloy.getMolten(144)) - .itemOutputs(MyMod.tutorial() - - ) - .duration(20 * SECONDS) - .eut(GT_Values.VP[2]) - .addTo(RecipeMaps.assemblerRecipes); - }); - - GT_Values.RA.stdBuilder() - .itemInputs(new ItemStack(Items.book), new ItemStack(GameRegistry.findItem("IC2","itemBatREDischarged"),0,OreDictionary.WILDCARD_VALUE)) - .fluidInputs(Materials.BatteryAlloy.getMolten(144)) - .itemOutputs(MyMod.tutorial("programmable_hatches.eucreafting.tutorial") - - ) - .duration(20 * SECONDS) - .eut(GT_Values.VP[2]) - .addTo(RecipeMaps.assemblerRecipes); - GT_Values.RA.stdBuilder() - .itemInputs(new ItemStack(Items.book), new ItemStack(GameRegistry.findItem("IC2","itemBatRE"),0,OreDictionary.WILDCARD_VALUE)) - .fluidInputs(Materials.BatteryAlloy.getMolten(144)) - .itemOutputs(MyMod.tutorial("programmable_hatches.eucreafting.tutorial") - - ) - .duration(20 * SECONDS) - .eut(GT_Values.VP[2]) - .addTo(RecipeMaps.assemblerRecipes); - ////////////// - - - - ///////// - smartArm(); - Item oc=GameRegistry.findItem("OpenComputers", "item"); - Item ocae=GameRegistry.findItem("OpenComputers", "item.ae"); - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack(oc,2,53),//inv - new ItemStack(oc,1,61),//inv upgrade - new ItemStack(oc,2,76),//tank - new ItemStack(oc,1,77),//tank upgrade - new ItemStack(GameRegistry.findItem("OpenComputers", "transposer")) - ,new ItemStack[]{ - new ItemStack(ocae,1,0), - new ItemStack(ocae,1,1), - new ItemStack(ocae,1,2)//any tier - }, - new ItemStack(GameRegistry.findItem("ae2fc", "fluid_interface"),1,77) - ) - .itemOutputs(new ItemStack(MyMod.iohub, 1, 0)) - .duration(1 * SECONDS) - .eut(480) - .addTo(RecipeMaps.mixerRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1, 33), - new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1, 51), - new ItemStack(GameRegistry.findItem("OpenComputers", "cable"), 4, 0), - Emitter_EV.get(1), - GT_Utility.getIntegratedCircuit(16) - -) - .fluidInputs(Materials.Enderium.getMolten(144*16)) - .itemOutputs(new ItemStack(MyMod.pitem, 1) - - ) .duration(40 * SECONDS) - .eut(480) - .addTo(RecipeMaps.assemblerRecipes);; - - GT_Values.RA.stdBuilder() - .itemInputs( - Casing_EV.get(1), - Sensor_EV.get(1), - new ItemStack(GameRegistry.findItem("OpenComputers", "cable"), 32, 0), - new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1, 51), - new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1, 33), - GT_Utility.getIntegratedCircuit(17) - -) - .fluidInputs(Materials.Enderium.getMolten(144*16)) - .itemOutputs(new ItemStack(MyMod.pstation, 1) - - ) .duration(40 * SECONDS) - .eut(480) - .addTo(RecipeMaps.assemblerRecipes);; - - - - - - for(ItemStack[] io:new ItemStack[][]{ - {Api.INSTANCE.definitions().parts().iface().maybeStack(1).get(),new ItemStack(MyMod.cover, 1,32)}, - {new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE),new ItemStack(MyMod.cover, 1,33)}, - {Api.INSTANCE.definitions().parts().p2PTunnelMEInterface().maybeStack(1).get(),new ItemStack(MyMod.cover, 1,34)}, - {new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE_P2P),new ItemStack(MyMod.cover, 1,35)} - - - }) - GT_Values.RA.stdBuilder() - .itemInputs( - io[0] , - new ItemStack(MyMod.cover, 1,37), - GT_Utility.getIntegratedCircuit(18) - -) - - .itemOutputs(io[1]) - - .duration(40 * SECONDS) - .eut(480) - .addTo(RecipeMaps.formingPressRecipes);; - - - GT_Values.RA.stdBuilder() - .itemInputs( - GT_Utility.getIntegratedCircuit(19), - Api.INSTANCE.definitions().blocks().fluix().maybeStack(1).get() -) - - .itemOutputs( new ItemStack(MyMod.cover, 4,37)) - - .duration(256 * SECONDS) - .eut(480) - .addTo(RecipeMaps.cutterRecipes);; - - GT_Values.RA.stdBuilder() - .itemInputs( - GT_Utility.getIntegratedCircuit(19), - Materials.Iron.getPlates(1), - new ItemStack(Items.comparator), - Emitter_MV.get(1) -) - .fluidInputs(Iron.getMolten(144*2)) - .itemOutputs( new ItemStack(MyMod.cover, 1,3)) - - .duration(40 * SECONDS) - .eut(480) - .addTo(RecipeMaps.assemblerRecipes);; - - - GT_Values.RA.stdBuilder() - .itemInputs( -new ItemStack(ItemAndBlockHolder.BUFFER), - Conveyor_Module_HV.get(1), - Electric_Pump_HV.get(1), - Casing_HV.get(1) -) - - .itemOutputs( new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.IngBufferOffset)) - - .duration(10 * SECONDS) - .eut(480) - .addTo(RecipeMaps.assemblerRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs( -new ItemStack(ItemAndBlockHolder.LARGE_BUFFER), - Conveyor_Module_IV.get(1), - Electric_Pump_IV.get(1), - Casing_IV.get(1) -) - - .itemOutputs( new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.IngBufferOffset+1)) - - .duration(10 * SECONDS) - .eut(480*4*4) - .addTo(RecipeMaps.assemblerRecipes); - - - - GT_Values.RA.stdBuilder() - .itemInputs( -new ItemStack(ItemAndBlockHolder.LEVEL_MAINTAINER), -//Casing_EV.get(1), -Casing_CleanStainlessSteel.get(1), -new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.CircuitProviderOffset) - -) - - .itemOutputs( new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.LargeProviderOffset)) - - .duration(600 * SECONDS) - .eut(480*4*4) - .addTo(RecipeMaps.assemblerRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs( -new ItemStack(ItemAndBlockHolder.LEVEL_MAINTAINER), -Casing_EV.get(1), -Api.INSTANCE.definitions() -.blocks() -.craftingStorage64k() -.maybeStack(4) -.get(), -Api.INSTANCE.definitions() -.blocks() -.craftingAccelerator() -.maybeStack(4) -.get() -) - - .itemOutputs( new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.ChainerOffset)) - - .duration(60 * SECONDS) - .eut(480*4*4) - .addTo(RecipeMaps.assemblerRecipes); - - - GT_Values.RA.stdBuilder() - .itemInputs( - GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Terbium, 4) - ,new ItemStack(MyMod.smartarm,32,4) - , Materials.TungstenSteel.getPlates(16) - - -) - - .itemOutputs( new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.IngredientDistributorOffset)) - - .duration(60 * SECONDS) - .eut(480*4*4) - .addTo(RecipeMaps.assemblerRecipes); - - - - for(int i=1;i<=10;i++){ - - ItemList [][] list={ - { - - Super_Tank_LV, - Super_Tank_MV, - Super_Tank_HV, - Super_Tank_EV, - Super_Tank_IV, - Quantum_Tank_LV, - Quantum_Tank_MV, - Quantum_Tank_HV, - Quantum_Tank_EV, - Quantum_Tank_IV, },{ - Super_Chest_LV, - Super_Chest_MV, - Super_Chest_HV, - Super_Chest_EV, - Super_Chest_IV, - Quantum_Chest_LV, - Quantum_Chest_MV, - Quantum_Chest_HV, - Quantum_Chest_EV, - Quantum_Chest_IV, - } - - }; - - - GT_Values.RA.stdBuilder() - .itemInputs( - list[1][i-1].get(1), - Api.INSTANCE.definitions().parts().storageBus().maybeStack(1).get() - - ) - - .itemOutputs( new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset+Registration.MEChest + i-1) ) - - .duration(10 * SECONDS) - .eut((int) (30*Math.pow(4, i-1))) - .addTo(RecipeMaps.formingPressRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs( - list[0][i-1].get(1), - ItemAndBlockHolder.FLUID_STORAGE_BUS.stack(1) - - ) - - .itemOutputs( new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset+Registration.METank + i-1) ) - - .duration(10 * SECONDS) - .eut((int) (30*Math.pow(4, i-1))) - .addTo(RecipeMaps.formingPressRecipes); - - } - - - - prefab(); - - GT_Values.RA.stdBuilder() - .itemInputs( new ItemStack(MyMod.cover, 1, 0)) - .fluidInputs(Materials.Enderium.getMolten(144*10)) - .itemOutputs( - new ItemStack(MyMod.cover, 1, 4)) - .duration(20 * SECONDS) - .eut(GT_Values.VP[3]) - .addTo(RecipeMaps.assemblerRecipes); - - - GT_Values.RA.stdBuilder() - .itemInputs( - Hatch_Input_Bus_ME_Advanced.get(1), - Hatch_DataAccess_UV.get(1), - com.github.technus.tectech.thing. CustomItemList.Machine_Multi_DataBank.get(1), - com.github.technus.tectech.thing. CustomItemList.dataInAss_Hatch.get(1), - com.github.technus.tectech.thing. CustomItemList.dataOutAss_Hatch.get(1), - com.github.technus.tectech.thing. CustomItemList.LASERpipe.get(4) - ) - //.fluidInputs(Materials.Enderium.getMolten(144*10)) - .itemOutputs( - new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset+Registration.DataHatchMEOffset)) - .duration(20 * SECONDS) - .eut(GT_Values.VP[8]) - .addTo(RecipeMaps.assemblerRecipes); - - - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack( - ConfigItems.itemGolemCore,1,8), - ItemList.Duct_Tape.get(64) - ) - .fluidInputs(Materials.AdvancedGlue.getFluid(8000)) - .itemOutputs( - new ItemStack( - ConfigItems.itemGolemCore,1,120)) - .duration(20 * SECONDS) - .eut(GT_Values.VP[3]) - .addTo(RecipeMaps.assemblerRecipes); - - - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack(GameRegistry.findItem("IC2","blockReactorChamber")), - Sensor_LuV.get(1), - ItemList.Circuit_Chip_NOR.get(20) - ) - - .itemOutputs( - new ItemStack( - MyMod.reactorsyncer)) - .duration(20 * SECONDS) - .eut(GT_Values.VP[3]) - .addTo(RecipeMaps.assemblerRecipes); - - - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack(GameRegistry.findItem("IC2NuclearControl","blockNuclearControlMain"),1,9), - Sensor_LuV.get(1), - new ItemStack(GameRegistry.findItem("OpenComputers","adapter")) - ) - .itemOutputs(new ItemStack(MyMod.reader)) - .duration(20 * SECONDS).eut(GT_Values.VP[3]).addTo(RecipeMaps.assemblerRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs( - Api.INSTANCE.definitions().parts().storageBus().maybeStack(1).get(), - new ItemStack(ItemAndBlockHolder.FLUID_STORAGE_BUS), - new ItemStack(ItemAndBlockHolder.LEVEL_MAINTAINER) - ).fluidInputs( Materials.Grade4PurifiedWater.getFluid(1000)) - .itemOutputs(new ItemStack(MyMod.amountmaintainer)) - .duration(20 * SECONDS).eut(GT_Values.VP[3]).addTo(RecipeMaps.assemblerRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack(ItemAndBlockHolder.LEVEL_MAINTAINER) - ).fluidInputs( Materials.Grade8PurifiedWater.getFluid(16000)) - .itemOutputs(new ItemStack(MyMod.submitter)) - .duration(20 * SECONDS).eut(GT_Values.VP[3]).addTo(RecipeMaps.fluidSolidifierRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack(GregTech_API.sBlockMachines,0,Config.metaTileEntityOffset+Registration.SlaveOffset), - new ItemStack(GameRegistry.findItem("RIO", "tile.remote_interface")), - new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 0), - new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 1) - - ) - .fluidInputs(new FluidStack(TinkerSmeltery.moltenEnderFluid,1000)) - .itemOutputs(new ItemStack( GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset+Registration.MappingSlaveOffset)) - .duration(20 * SECONDS).eut(GT_Values.VP[3]).addTo(RecipeMaps.assemblerRecipes); - - - - GT_Values.RA.stdBuilder() - .metadata(RESEARCH_ITEM, new ItemStack( GregTech_API.sBlockMachines, - 1,Config.metaTileEntityOffset+Registration.MappingSlaveOffset)) - .metadata(RESEARCH_TIME, 1 * HOURS) - .itemInputs( - new ItemStack( GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset+Registration.MappingSlaveOffset), - new ItemStack( ItemAndBlockHolder.INTERFACE), - new ItemStack( ItemAndBlockHolder.INTERFACE), - new ItemStack( ItemAndBlockHolder.INTERFACE), - new ItemStack(GameRegistry.findItem("RIO", "tile.remote_interface")), - new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 0), - new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 1) - ) - .fluidInputs( - new FluidStack(TinkerSmeltery.moltenEnderFluid,1000), - Enderium.getMolten(1000), - HeeEndium.getMolten(1000), - FluidRegistry.getFluid("endergoo")==null?Water.getFluid(1): new FluidStack(FluidRegistry.getFluid("endergoo"),1000) - ) - .itemOutputs(new ItemStack( GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset+Registration.PatternMappingSlaveOffset)) - .duration(2000000 * SECONDS).eut(GT_Values.VP[1]).addTo(GT_RecipeConstants.AssemblyLine); - - - GT_Values.RA.stdBuilder() - .itemInputs( - - new ItemStack( GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset+Registration.QuadDualInputHatchOffset+10), - new ItemStack(MyMod.iohub) - ) - .itemOutputs(new ItemStack( GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset+Registration.DualInputHatchOCOffset)) - .duration(20 * SECONDS).eut(GT_Values.VP[10]).addTo(RecipeMaps.assemblerRecipes); - - - - - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack( - MyMod.toolkit,0,OreDictionary.WILDCARD_VALUE) , - new ItemStack(Items.diamond) - , GT_Utility.getIntegratedCircuit(7) - -) - - .itemOutputs( new ItemStack( MyMod.fixer) ) - - .duration(10 * SECONDS) - .eut(480) - .addTo(RecipeMaps.assemblerRecipes); - - - - - - if(flag){ - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack( - GameRegistry.findItem("computronics","computronics.chatBox")), - Api.INSTANCE.definitions().blocks().spatialPylon().maybeStack(1).get(), - new ItemStack(Items.ender_pearl,16) - ) - .fluidInputs(Materials.Enderium.getMolten(144)) - .itemOutputs( new ItemStack( MyMod.alert) ) - - .duration(100 * SECONDS) - .eut(480) - .addTo(RecipeMaps.assemblerRecipes); - - - GT_Values.RA.stdBuilder() - .itemInputs(Hatch_Input_Bus_ME.get(1), - Materials.Steel.getPlates(1) - ) - .itemOutputs( new ItemStack( MyMod.upgrades,1,1) ) - .duration(100 * SECONDS) - .eut(480*4*4) - .addTo(RecipeMaps.formingPressRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs(Hatch_Input_ME.get(1), - Materials.Steel.getPlates(1) - ) - .itemOutputs( new ItemStack( MyMod.upgrades,1,2) ) - .duration(100 * SECONDS) - .eut(480*4*4) - .addTo(RecipeMaps.formingPressRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs(Hatch_Input_Bus_ULV.get(16), - Materials.Steel.getPlates(1) - ) - .itemOutputs( new ItemStack( MyMod.upgrades,1,0) ) - .duration(100 * SECONDS) - .eut(480*4*4) - .addTo(RecipeMaps.formingPressRecipes); - - - - for(int i=0;i<4;i++) - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack( MyMod.upgrades,3,0), - HATCHES_INPUT_BUS[i].get(1) - - ) - .itemOutputs( new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.MultiCircuitBusOffset + i)) - - .duration(15 * SECONDS) - .eut(GT_Values.VP[i]) - .addTo(RecipeMaps.assemblerRecipes); - - } - /* - GT_Values.RA.stdBuilder() - .itemInputs( - - gregtech.api.enums.ItemList.Shape_Mold_Block.get(0) - -).fluidInputs( Materials.Grade8PurifiedWater.getFluid(256000)) -.itemOutputs( new ItemStack( - MyMod.submitter)) - - .duration(150 * SECONDS) - .eut(GT_Values.VP[8]) - .addTo(RecipeMaps.fluidSolidifierRecipes); - - - GT_Values.RA.stdBuilder() - .itemInputs( - - gregtech.api.enums.ItemList.Shape_Mold_Plate.get(0) - -).fluidInputs( Materials.Grade4PurifiedWater.getFluid(64000)) -.itemOutputs( new ItemStack( - MyMod.amountmaintainer)) - - .duration(150 * SECONDS) - .eut(GT_Values.VP[7]) - .addTo(RecipeMaps.fluidSolidifierRecipes); - */ - - GT_Values.RA.stdBuilder() - .itemInputs( - Hatch_Input_Bus_ME - .get(1) , new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1,29) -) - - .itemOutputs(new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.RestrictedBusME) ) - - .duration(100 * SECONDS) - .eut(480) - .addTo(RecipeMaps.assemblerRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs( - Hatch_Input_ME - .get(1) , new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1,29) -) - - .itemOutputs(new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.RestrictedHatchME) ) - - .duration(100 * SECONDS) - .eut(480) - .addTo(RecipeMaps.assemblerRecipes); - - - - - for(ItemList i:new ItemList[]{ItemList.ItemFilter_Export,ItemList.ItemFilter_Import}) - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack(GregTech_API.sBlockMachines,1,Config.metaTileEntityOffset + Registration.SlaveOffset) ,CertusQuartz.getPlates(4),i.get(1) -) - - .itemOutputs(new ItemStack( - GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset + Registration.SlaveBusOffset) ) - - .duration(100 * SECONDS) - .eut(480) - .addTo(RecipeMaps.assemblerRecipes); - - - - - - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack(GregTech_API.sBlockMachines,1,Config.metaTileEntityOffset + Registration.SlaveOffset) - , Lapis.getPlates(4),ItemList.FluidFilter.get(1) -) - -.itemOutputs(new ItemStack(GregTech_API.sBlockMachines,1,Config.metaTileEntityOffset + Registration.SlaveHatchOffset) ) -.duration(100 * SECONDS) -.eut(480) -.addTo(RecipeMaps.assemblerRecipes); - - - - } - - /////////////////////////////////// + /////////////////////////////////// public void prefab(){ GT_Values.RA.stdBuilder() .itemInputs( @@ -1370,7 +163,6 @@ public void prefab(){ - } @@ -1506,6 +298,1266 @@ public void smartArm(){ ); } } + + + + ItemList[] multi = { null, null, null, null, Hatch_Input_Multi_2x2_EV, Hatch_Input_Multi_2x2_IV, + Hatch_Input_Multi_2x2_LuV, Hatch_Input_Multi_2x2_ZPM, Hatch_Input_Multi_2x2_UV, Hatch_Input_Multi_2x2_UHV, + Hatch_Input_Multi_2x2_UEV, + + Hatch_Input_Multi_2x2_UIV, Hatch_Input_Multi_2x2_UMV, Hatch_Input_Multi_2x2_UXV, + Hatch_Input_Multi_2x2_Humongous }; + + + @Override + public void run() { + + + if(Config.skipRecipeAdding)return; + + if( + GameRegistry.findItem("dreamcraft","item.PolychromePikoCircuit")!=null + ){ + MyMod.LOG.info("Found new dreamcraft Nano-Piko-Quantum circuit, use oredict: Exotic-Cosmic-Transcendent."); + mat=matNewVersion;} + else{ + mat=metget.get(); + MyMod.LOG.info("Good ol' version."); + + } + //You just like breaking changes, isn't that true, GTNH dev? + + + IRecipe rec = new ShapedOreRecipe(new ItemStack(MyMod.plunger),"CRR","TSR","Q F", + 'R',"plateAnyRubber", + 'C',"craftingToolWireCutter", + 'F',"craftingToolFile", + 'Q',"stickCertusQuartz", + 'S', + new ItemStack( + GameRegistry.findItem("appliedenergistics2","item.ToolChargedStaff"),1, + OreDictionary.WILDCARD_VALUE + ) + + //Api.INSTANCE.definitions().items().chargedStaff().maybeStack(1).get() + //ApiItems.chargedStaff() returns memoryCard, not chargedStaff + + + , + 'T', + + new ItemStack( + GameRegistry.findItem("appliedenergistics2","item.ToolWirelessTerminal"),1, + OreDictionary.WILDCARD_VALUE + ) + + ); + CraftingManager.getInstance().getRecipeList().add(rec); + + + + + + + + ArrayList pc0 = new ArrayList<>(); + HashMapproductivity */> pc = new HashMap<>();// List> + + no: { + Item im = GameRegistry.findItem("bartworks", "gt.BWCircuitProgrammer"); + if (im == null) { + MyMod.LOG.fatal("BW Programmer not found! Did you install GTNH properly?"); + break no; + } + pc0.add(new ItemStack(im, 0)); + pc.put(new ItemStack(im, 1), 4); + + } + no: { + Item im = GameRegistry.findItem("miscutils", "blockCircuitProgrammer"); + if (im == null) { + MyMod.LOG.fatal("GT++ Programmer not found! Did you install GTNH properly?"); + break no; + } + + pc0.add(new ItemStack(im, 0)); + pc.put(new ItemStack(im, 1), 1); + } + // in dev env, use bedrock to replace programmer to debug + Optional.of(pc0) + .filter(List::isEmpty) + .ifPresent(s -> s.add(new ItemStack(Blocks.bedrock, 0))); + Optional.of(pc) + .filter(Map::isEmpty) + .ifPresent((s) -> s.put(new ItemStack(Blocks.bedrock, 1), 1)); + + pc.forEach((s, i) -> { + + GT_Values.RA.stdBuilder() + .itemInputs(s, Materials.Titanium.getPlates(1)) + .fluidInputs(Materials.TungstenSteel.getMolten(144*20L)) + .itemOutputs(new ItemStack(MyMod.cover, 4 * i, 0)) + .duration(1 * SECONDS) + .eut(480) + .addTo(RecipeMaps.mixerRecipes); + GT_Values.RA.stdBuilder() + .itemInputs(s, Materials.Titanium.getPlates(1)) + .fluidInputs(Materials.StainlessSteel.getMolten(144*20L)) + .itemOutputs(new ItemStack(MyMod.cover, 2 * i, 0)) + .duration(1 * SECONDS) + .eut(480) + .addTo(RecipeMaps.mixerRecipes); + + }); + pc0.forEach(s -> { + GregTech_API.getConfigurationCircuitList(100) + .stream() + .forEach(ss -> { + GT_Values.RA.stdBuilder() + .itemInputs(s, GT_Utility.copyAmount(0, ss)) + + .itemOutputs(ItemProgrammingCircuit.wrap(ss)) + .duration(1 * SECONDS) + .eut(120) + .addTo(RecipeMaps.hammerRecipes); + + });; + + }); + + ArrayList is = Arrays.stream(HATCHES_INPUT) + .map(s -> s.get(1)) + .collect(ArrayList::new, ArrayList::add, ArrayList::addAll); + for (int i = 12097; i <= 12102; i++) { + is.add(new ItemStack(GregTech_API.sBlockMachines, 1, i)); + } // stuff from gtnhcoremod + ItemStack[] single_fluid = is.toArray(new ItemStack[0]); + is = Arrays.stream(HATCHES_INPUT_BUS) + .map(s -> s.get(1)) + .collect(ArrayList::new, ArrayList::add, ArrayList::addAll); + + is.add(new ItemStack(GregTech_API.sBlockMachines, 1, 30030));// gt++ superbus + is.add(new ItemStack(GregTech_API.sBlockMachines, 1, 30030)); + is.add(new ItemStack(GregTech_API.sBlockMachines, 1, 30030)); + is.add(new ItemStack(GregTech_API.sBlockMachines, 1, 30030)); + is.add(new ItemStack(GregTech_API.sBlockMachines, 1, 30030)); + ItemStack[] single_item = is.toArray(new ItemStack[0]); + + for (int i = 4; i < GT_Values.VN.length - 1; i++) { + + GT_Values.RA.stdBuilder() + .itemInputs(multi[i].get(1), single_item[i], new ItemStack(MyMod.cover, 1, 0)) + .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) + .itemOutputs( + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.QuadDualInputHatchOffset + i)) + .duration(20 * SECONDS) + .eut(GT_Values.VP[i]) + .addTo(RecipeMaps.mixerRecipes); + } + + for (int i = 0; i < GT_Values.VN.length - 1; i++) { + + GT_Values.RA.stdBuilder() + .itemInputs(single_fluid[i], single_item[i], new ItemStack(MyMod.cover, 1, 0)) + .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) + .itemOutputs( + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.DualInputHatchOffset + i)) + .duration(20 * SECONDS) + .eut(GT_Values.VP[i]) + .addTo(RecipeMaps.mixerRecipes); + } + + for (int i = 0; i < GT_Values.VN.length - 1; i++) { + Object circuit = OrePrefixes.circuit.get(mat[i][0]); + Object circuitP = OrePrefixes.circuit.get(mat[Math.min(i + 1, mat.length - 2)][0]); + if (circuit == null || GT_OreDictUnificator.get(circuit, 1) == null) { + MyMod.LOG.fatal("Circuit not found for " + GT_Values.VN[i] + "!"); + continue; + } + + /* + * //GT OreDict handling is too magic for me to understand + * GT_Values.RA.stdBuilder() + * .itemInputs( + * new + * ItemStack(GregTech_API.sBlockMachines,1,Config.metaTileEntityOffset+Registration.DualInputHatchOffset+i) + * , new Object[] {circuit,2} + * ,new ItemStack(MyMod.smartarm,1,i) + * ) + * .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) + * .itemOutputs( + * new ItemStack(GregTech_API.sBlockMachines,1,Config.metaTileEntityOffset+Registration. + * BufferedDualInputHatchOffset+i) + * ) + * .duration(20 * SECONDS) + * .eut(GT_Values.VP[i]) + * .addTo(RecipeMaps.assemblerRecipes); + */ + + RecipeMaps.assemblerRecipes.add( + new GT_Recipe/*.GT_Recipe_WithAlt*/( + false, + new ItemStack[] { GT_OreDictUnificator.get((circuit), 2), single_item[i], + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.DualInputHatchOffset + i) + + , new ItemStack(MyMod.smartarm, 1, i) }// II + , + new ItemStack[] { new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.BufferedDualInputHatchOffset + i) } + // IO + , + null// SP + , + null// CHANCE + , + new FluidStack[] { Materials.AdvancedGlue.getFluid(4000) }// FI + , + null// FO + , + 20 * SECONDS, + (int) GT_Values.VP[i], + 0/*, + new ItemStack[][] { + + Arrays.stream(mat[i]) + .map(s -> GT_OreDictUnificator.getOres(OrePrefixes.circuit, s)) + .flatMap(ArrayList::stream) + .map(s -> GT_Utility.copyAmount(2, s)) + .toArray(ItemStack[]::new) } */// ALT + )); + RecipeMaps.assemblerRecipes.add( + new GT_Recipe( + false, + new ItemStack[] { GT_OreDictUnificator.get((circuit), 2), single_item[i], + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.QuadDualInputHatchOffset + i) + + , new ItemStack(MyMod.smartarm, 1, i) }// II + , + new ItemStack[] { new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.BufferedQuadDualInputHatchOffset + i) } + // IO + , + null// SP + , + null// CHANCE + , + new FluidStack[] { Materials.Osmiridium.getMolten(144*20) }// FI + , + null// FO + , + 20 * SECONDS, + (int) GT_Values.VP[i], + 0/*, + new ItemStack[][] { + + Arrays.stream(mat[i]) + .map(s -> GT_OreDictUnificator.getOres(OrePrefixes.circuit, s)) + .flatMap(ArrayList::stream) + .map(s -> GT_Utility.copyAmount(2, s)) + .toArray(ItemStack[]::new) } */// ALT + )); + RecipeMaps.assemblerRecipes.add( + new GT_Recipe( + false, + new ItemStack[] { GT_OreDictUnificator.get(circuitP, 2), + GT_Utility.copyAmount(5, single_item[i]), + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.BufferedQuadDualInputHatchOffset + i), + new ItemStack(MyMod.smartarm, 5, i) }// II + , + new ItemStack[] { new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.BufferedQuadDualInputHatchMKIIOffset + i) } + // IO + , + null// SP + , + null// CHANCE + , + new FluidStack[] { Materials.Neutronium.getMolten(144*60) }// FI + , + null// FO + , + 20 * SECONDS, + (int) GT_Values.VP[i], + 0/*, + new ItemStack[][] { + + Arrays.stream(mat[Math.min(i + 1, mat.length - 1)]) + .map(s -> GT_OreDictUnificator.getOres(OrePrefixes.circuit, s)) + .flatMap(ArrayList::stream) + .map(s -> GT_Utility.copyAmount(2, s)) + .toArray(ItemStack[]::new) } */// ALT + )); + } + + pc.forEach((s, i) -> { + GT_Values.RA.stdBuilder() + .itemInputs( + s, + new ItemStack(ItemAndBlockHolder.INTERFACE), + new ItemStack(MyMod.toolkit, 0, OreDictionary.WILDCARD_VALUE), + ( + Api.INSTANCE.definitions() + .blocks() + .craftingStorage256k() + .maybeStack(1) + .get()), + ( + Api.INSTANCE.definitions() + .blocks() + .craftingAccelerator4x() + .maybeStack(1) + .get()), + new ItemStack( + Api.INSTANCE.definitions() + .blocks() + .molecularAssembler() + .maybeItem() + .get()) + + + ) + .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) + .itemOutputs( + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.CircuitProviderOffset)) + .duration(20 * SECONDS) + .eut(GT_Values.VP[5]) + .addTo(RecipeMaps.assemblerRecipes); + //T0 + GT_Values.RA.stdBuilder() + .itemInputs( + s, + Api.INSTANCE.definitions().blocks().iface().maybeStack(1).get(), + new ItemStack(MyMod.toolkit, 0, OreDictionary.WILDCARD_VALUE), + ( + Api.INSTANCE.definitions() + .blocks() + .craftingStorage1k() + .maybeStack(1) + .get()), + ( + Api.INSTANCE.definitions() + .blocks() + .craftingAccelerator() + .maybeStack(1) + .get()), + + Machine_HV_Assembler.get(1) + + + ) + .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) + .itemOutputs( + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.CircuitProviderOffsetT0)) + .duration(20 * SECONDS) + .eut(GT_Values.VP[3]) + .addTo(RecipeMaps.assemblerRecipes); + }); + + pc0.forEach((s) -> { + GT_Values.RA.stdBuilder() + .itemInputs( + s, + Hatch_CraftingInput_Bus_Slave.get(1), + + GT_Utility.getIntegratedCircuit(13)) + .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) + .itemOutputs( + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.SlaveOffset)) + .duration(20 * SECONDS) + .eut(GT_Values.VP[7]) + .addTo(RecipeMaps.assemblerRecipes); + + }); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GameRegistry.findItem("RIO", "tile.remote_interface")), + new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 0), + single_item[6]) + .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) + .itemOutputs( + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.RemoteInputBusOffset)) + .duration(20 * SECONDS) + .eut(GT_Values.VP[5]) + .addTo(RecipeMaps.assemblerRecipes); + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GameRegistry.findItem("RIO", "tile.remote_interface")), + new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 1), + single_fluid[6] + + ) + .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) + .itemOutputs( + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.RemoteInputHatchOffset)) + .duration(20 * SECONDS) + .eut(GT_Values.VP[5]) + .addTo(RecipeMaps.assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.BufferedQuadDualInputHatchOffset + 8), + Quantum_Tank_LV.get(24), + Electric_Pump_UV.get(24), + Cover_Shutter.get(24)) + .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) + .itemOutputs( + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.SuperFluidHatch)) + .duration(20 * SECONDS) + .eut(GT_Values.VP[8]) + .addTo(RecipeMaps.assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + Hatch_CraftingInput_Bus_ME.get(1), + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.BufferedQuadDualInputHatchMKIIOffset + 8)) + .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) + .itemOutputs( + new ItemStack(GregTech_API.sBlockMachines, 1, Config.metaTileEntityOffset + Registration.PatternOffset)) + .duration(20 * SECONDS) + .eut(GT_Values.VP[9]) + .addTo(RecipeMaps.assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + Hatch_CraftingInput_Bus_ME_ItemOnly.get(1), + new ItemStack( + MyMod.smartarm,4,6)) + .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) + .itemOutputs( + new ItemStack(GregTech_API.sBlockMachines, 1, Config.metaTileEntityOffset + Registration.PatternOffsetBus)) + .duration(20 * SECONDS) + .eut(GT_Values.VP[6]) + .addTo(RecipeMaps.assemblerRecipes); + + + for (int i = 0; i < 4; i++) { + GT_Values.RA.stdBuilder() + .itemInputs(single_item[i], new ItemStack(GameRegistry.findItem("Automagy", "blockTenaciousChest")) + + ) + .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) + .itemOutputs( + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.TenaciousOffset + i)) + .duration(20 * SECONDS) + .eut(GT_Values.VP[i]) + .addTo(RecipeMaps.assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GameRegistry.findItem("Automagy", "glyph"), 1, 3), + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.TenaciousOffset + i) + + ) + .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) + .itemOutputs( + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.FilterOffset + i) + + ) + .duration(20 * SECONDS) + .eut(GT_Values.VP[i]) + .addTo(RecipeMaps.assemblerRecipes); + + } + + GT_Values.RA.stdBuilder() + .itemInputs(Cover_Controller.get(1), Cover_AdvancedRedstoneReceiverInternal.get(1) + + ) + .fluidInputs(Materials.AdvancedGlue.getFluid(4000)) + .itemOutputs(new ItemStack(MyMod.cover, 1, 1) + + ) + .duration(20 * SECONDS) + .eut(GT_Values.VP[2]) + .addTo(RecipeMaps.mixerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1, 33), + GT_Utility.getIntegratedCircuit(14), + Machine_HV_Scanner.get(1), + new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 2, 25), + new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 2, 78)) + .fluidInputs(Materials.SolderingAlloy.getMolten(144*20)) + .itemOutputs(new ItemStack(MyMod.oc_api, 1) + + ) + .duration(20 * SECONDS) + .eut(GT_Values.VP[2]) + .addTo(RecipeMaps.circuitAssemblerRecipes); + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1, 33), + GT_Utility.getIntegratedCircuit(15), + Cover_AdvancedRedstoneReceiverInternal.get(1), + Cover_AdvancedRedstoneTransmitterInternal.get(1)) + .fluidInputs(Materials.SolderingAlloy.getMolten(144*20)) + .itemOutputs(new ItemStack(MyMod.oc_redstone, 1) + + ) + .duration(20 * SECONDS) + .eut(GT_Values.VP[2]) + .addTo(RecipeMaps.circuitAssemblerRecipes); + pc.forEach((s, i) -> { + GT_Values.RA.stdBuilder() + .itemInputs( + s, + ItemList.Tool_Scanner.get(1), + new ItemStack( + Api.INSTANCE.definitions() + .items() + .networkTool() + .maybeItem() + .get())) + + .itemOutputs(new ItemStack(MyMod.toolkit, 1) + + ) + .duration(20 * SECONDS) + .eut(GT_Values.VP[3]) + .addTo(RecipeMaps.assemblerRecipes); + }); + + pc0.forEach((s) -> { + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(Items.book), s) + .fluidInputs(Materials.SolderingAlloy.getMolten(144)) + .itemOutputs(MyMod.tutorial() + + ) + .duration(20 * SECONDS) + .eut(GT_Values.VP[2]) + .addTo(RecipeMaps.assemblerRecipes); + }); + + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(Items.book), new ItemStack(GameRegistry.findItem("IC2","itemBatREDischarged"),0,OreDictionary.WILDCARD_VALUE)) + .fluidInputs(Materials.BatteryAlloy.getMolten(144)) + .itemOutputs(MyMod.tutorial("programmable_hatches.eucreafting.tutorial") + + ) + .duration(20 * SECONDS) + .eut(GT_Values.VP[2]) + .addTo(RecipeMaps.assemblerRecipes); + GT_Values.RA.stdBuilder() + .itemInputs(new ItemStack(Items.book), new ItemStack(GameRegistry.findItem("IC2","itemBatRE"),0,OreDictionary.WILDCARD_VALUE)) + .fluidInputs(Materials.BatteryAlloy.getMolten(144)) + .itemOutputs(MyMod.tutorial("programmable_hatches.eucreafting.tutorial") + + ) + .duration(20 * SECONDS) + .eut(GT_Values.VP[2]) + .addTo(RecipeMaps.assemblerRecipes); + ////////////// + + + + ///////// + smartArm(); + Item oc=GameRegistry.findItem("OpenComputers", "item"); + Item ocae=GameRegistry.findItem("OpenComputers", "item.ae"); + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(oc,2,53),//inv + new ItemStack(oc,1,61),//inv upgrade + new ItemStack(oc,2,76),//tank + new ItemStack(oc,1,77),//tank upgrade + new ItemStack(GameRegistry.findItem("OpenComputers", "transposer")) + ,new ItemStack[]{ + new ItemStack(ocae,1,0), + new ItemStack(ocae,1,1), + new ItemStack(ocae,1,2)//any tier + }, + new ItemStack(GameRegistry.findItem("ae2fc", "fluid_interface"),1,77) + ) + .itemOutputs(new ItemStack(MyMod.iohub, 1, 0)) + .duration(1 * SECONDS) + .eut(480) + .addTo(RecipeMaps.mixerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1, 33), + new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1, 51), + new ItemStack(GameRegistry.findItem("OpenComputers", "cable"), 4, 0), + Emitter_EV.get(1), + GT_Utility.getIntegratedCircuit(16) + + ) + .fluidInputs(Materials.Enderium.getMolten(144*16)) + .itemOutputs(new ItemStack(MyMod.pitem, 1) + + ) .duration(40 * SECONDS) + .eut(480) + .addTo(RecipeMaps.assemblerRecipes);; + + GT_Values.RA.stdBuilder() + .itemInputs( + Casing_EV.get(1), + Sensor_EV.get(1), + new ItemStack(GameRegistry.findItem("OpenComputers", "cable"), 32, 0), + new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1, 51), + new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1, 33), + GT_Utility.getIntegratedCircuit(17) + + ) + .fluidInputs(Materials.Enderium.getMolten(144*16)) + .itemOutputs(new ItemStack(MyMod.pstation, 1) + + ) .duration(40 * SECONDS) + .eut(480) + .addTo(RecipeMaps.assemblerRecipes);; + + + + + + for(ItemStack[] io:new ItemStack[][]{ + {Api.INSTANCE.definitions().parts().iface().maybeStack(1).get(),new ItemStack(MyMod.cover, 1,32)}, + {new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE),new ItemStack(MyMod.cover, 1,33)}, + {Api.INSTANCE.definitions().parts().p2PTunnelMEInterface().maybeStack(1).get(),new ItemStack(MyMod.cover, 1,34)}, + {new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE_P2P),new ItemStack(MyMod.cover, 1,35)} + + + }) + GT_Values.RA.stdBuilder() + .itemInputs( + io[0] , + new ItemStack(MyMod.cover, 1,37), + GT_Utility.getIntegratedCircuit(18) + + ) + + .itemOutputs(io[1]) + + .duration(40 * SECONDS) + .eut(480) + .addTo(RecipeMaps.formingPressRecipes);; + + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_Utility.getIntegratedCircuit(19), + Api.INSTANCE.definitions().blocks().fluix().maybeStack(1).get() + ) + + .itemOutputs( new ItemStack(MyMod.cover, 4,37)) + + .duration(256 * SECONDS) + .eut(480) + .addTo(RecipeMaps.cutterRecipes);; + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_Utility.getIntegratedCircuit(19), + Materials.Iron.getPlates(1), + new ItemStack(Items.comparator), + Emitter_MV.get(1) + ) + .fluidInputs(Iron.getMolten(144*2)) + .itemOutputs( new ItemStack(MyMod.cover, 1,3)) + + .duration(40 * SECONDS) + .eut(480) + .addTo(RecipeMaps.assemblerRecipes);; + + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(ItemAndBlockHolder.BUFFER), + Conveyor_Module_HV.get(1), + Electric_Pump_HV.get(1), + Casing_HV.get(1) + ) + + .itemOutputs( new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.IngBufferOffset)) + + .duration(10 * SECONDS) + .eut(480) + .addTo(RecipeMaps.assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(ItemAndBlockHolder.LARGE_BUFFER), + Conveyor_Module_IV.get(1), + Electric_Pump_IV.get(1), + Casing_IV.get(1) + ) + + .itemOutputs( new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.IngBufferOffset+1)) + + .duration(10 * SECONDS) + .eut(480*4*4) + .addTo(RecipeMaps.assemblerRecipes); + + + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(ItemAndBlockHolder.LEVEL_MAINTAINER), + //Casing_EV.get(1), + Casing_CleanStainlessSteel.get(1), + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.CircuitProviderOffset) + + ) + + .itemOutputs( new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.LargeProviderOffset)) + + .duration(600 * SECONDS) + .eut(480*4*4) + .addTo(RecipeMaps.assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(ItemAndBlockHolder.LEVEL_MAINTAINER), + Casing_EV.get(1), + Api.INSTANCE.definitions() + .blocks() + .craftingStorage64k() + .maybeStack(4) + .get(), + Api.INSTANCE.definitions() + .blocks() + .craftingAccelerator() + .maybeStack(4) + .get() + ) + + .itemOutputs( new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.ChainerOffset)) + + .duration(60 * SECONDS) + .eut(480*4*4) + .addTo(RecipeMaps.assemblerRecipes); + + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Terbium, 4) + ,new ItemStack(MyMod.smartarm,32,4) + , Materials.TungstenSteel.getPlates(16) + + + ) + + .itemOutputs( new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.IngredientDistributorOffset)) + + .duration(60 * SECONDS) + .eut(480*4*4) + .addTo(RecipeMaps.assemblerRecipes); + + + + for(int i=1;i<=10;i++){ + + ItemList [][] list={ + { + + Super_Tank_LV, + Super_Tank_MV, + Super_Tank_HV, + Super_Tank_EV, + Super_Tank_IV, + Quantum_Tank_LV, + Quantum_Tank_MV, + Quantum_Tank_HV, + Quantum_Tank_EV, + Quantum_Tank_IV, },{ + Super_Chest_LV, + Super_Chest_MV, + Super_Chest_HV, + Super_Chest_EV, + Super_Chest_IV, + Quantum_Chest_LV, + Quantum_Chest_MV, + Quantum_Chest_HV, + Quantum_Chest_EV, + Quantum_Chest_IV, + } + + }; + + + GT_Values.RA.stdBuilder() + .itemInputs( + list[1][i-1].get(1), + Api.INSTANCE.definitions().parts().storageBus().maybeStack(1).get() + + ) + + .itemOutputs( new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset+Registration.MEChest + i-1) ) + + .duration(10 * SECONDS) + .eut((int) (30*Math.pow(4, i-1))) + .addTo(RecipeMaps.formingPressRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + list[0][i-1].get(1), + ItemAndBlockHolder.FLUID_STORAGE_BUS.stack(1) + + ) + + .itemOutputs( new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset+Registration.METank + i-1) ) + + .duration(10 * SECONDS) + .eut((int) (30*Math.pow(4, i-1))) + .addTo(RecipeMaps.formingPressRecipes); + + } + + + + prefab(); + + GT_Values.RA.stdBuilder() + .itemInputs( new ItemStack(MyMod.cover, 1, 0)) + .fluidInputs(Materials.Enderium.getMolten(144*10)) + .itemOutputs( + new ItemStack(MyMod.cover, 1, 4)) + .duration(20 * SECONDS) + .eut(GT_Values.VP[3]) + .addTo(RecipeMaps.assemblerRecipes); + + + GT_Values.RA.stdBuilder() + .itemInputs( + Hatch_Input_Bus_ME_Advanced.get(1), + Hatch_DataAccess_UV.get(1), + com.github.technus.tectech.thing. CustomItemList.Machine_Multi_DataBank.get(1), + com.github.technus.tectech.thing. CustomItemList.dataInAss_Hatch.get(1), + com.github.technus.tectech.thing. CustomItemList.dataOutAss_Hatch.get(1), + com.github.technus.tectech.thing. CustomItemList.LASERpipe.get(4) + ) + //.fluidInputs(Materials.Enderium.getMolten(144*10)) + .itemOutputs( + new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset+Registration.DataHatchMEOffset)) + .duration(20 * SECONDS) + .eut(GT_Values.VP[8]) + .addTo(RecipeMaps.assemblerRecipes); + + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack( + ConfigItems.itemGolemCore,1,8), + ItemList.Duct_Tape.get(64) + ) + .fluidInputs(Materials.AdvancedGlue.getFluid(8000)) + .itemOutputs( + new ItemStack( + ConfigItems.itemGolemCore,1,120)) + .duration(20 * SECONDS) + .eut(GT_Values.VP[3]) + .addTo(RecipeMaps.assemblerRecipes); + + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GameRegistry.findItem("IC2","blockReactorChamber")), + Sensor_LuV.get(1), + ItemList.Circuit_Chip_NOR.get(20) + ) + + .itemOutputs( + new ItemStack( + MyMod.reactorsyncer)) + .duration(20 * SECONDS) + .eut(GT_Values.VP[3]) + .addTo(RecipeMaps.assemblerRecipes); + + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GameRegistry.findItem("IC2NuclearControl","blockNuclearControlMain"),1,9), + Sensor_LuV.get(1), + new ItemStack(GameRegistry.findItem("OpenComputers","adapter")) + ) + .itemOutputs(new ItemStack(MyMod.reader)) + .duration(20 * SECONDS).eut(GT_Values.VP[3]).addTo(RecipeMaps.assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + Api.INSTANCE.definitions().parts().storageBus().maybeStack(1).get(), + new ItemStack(ItemAndBlockHolder.FLUID_STORAGE_BUS), + new ItemStack(ItemAndBlockHolder.LEVEL_MAINTAINER) + ).fluidInputs( Materials.Grade4PurifiedWater.getFluid(1000)) + .itemOutputs(new ItemStack(MyMod.amountmaintainer)) + .duration(20 * SECONDS).eut(GT_Values.VP[3]).addTo(RecipeMaps.assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(ItemAndBlockHolder.LEVEL_MAINTAINER) + ).fluidInputs( Materials.Grade8PurifiedWater.getFluid(16000)) + .itemOutputs(new ItemStack(MyMod.submitter)) + .duration(20 * SECONDS).eut(GT_Values.VP[3]).addTo(RecipeMaps.fluidSolidifierRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GregTech_API.sBlockMachines,0,Config.metaTileEntityOffset+Registration.SlaveOffset), + new ItemStack(GameRegistry.findItem("RIO", "tile.remote_interface")), + new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 0), + new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 1) + + ) + .fluidInputs(new FluidStack(TinkerSmeltery.moltenEnderFluid,1000)) + .itemOutputs(new ItemStack( GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset+Registration.MappingSlaveOffset)) + .duration(20 * SECONDS).eut(GT_Values.VP[3]).addTo(RecipeMaps.assemblerRecipes); + + + + GT_Values.RA.stdBuilder() + .metadata(RESEARCH_ITEM, new ItemStack( GregTech_API.sBlockMachines, + 1,Config.metaTileEntityOffset+Registration.MappingSlaveOffset)) + .metadata(RESEARCH_TIME, 1 * HOURS) + .itemInputs( + new ItemStack( GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset+Registration.MappingSlaveOffset), + new ItemStack( ItemAndBlockHolder.INTERFACE), + new ItemStack( ItemAndBlockHolder.INTERFACE), + new ItemStack( ItemAndBlockHolder.INTERFACE), + new ItemStack(GameRegistry.findItem("RIO", "tile.remote_interface")), + new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 0), + new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 1) + ) + .fluidInputs( + new FluidStack(TinkerSmeltery.moltenEnderFluid,1000), + Enderium.getMolten(1000), + HeeEndium.getMolten(1000), + FluidRegistry.getFluid("endergoo")==null?Water.getFluid(1): new FluidStack(FluidRegistry.getFluid("endergoo"),1000) + ) + .itemOutputs(new ItemStack( GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset+Registration.PatternMappingSlaveOffset)) + .duration(2000000 * SECONDS).eut(GT_Values.VP[1]).addTo(GT_RecipeConstants.AssemblyLine); + + /*GT_Values.RA.stdBuilder() + .metadata(RESEARCH_ITEM, new ItemStack(Items.apple)) + .metadata(RESEARCH_TIME, 100 ) + .itemInputs( + new ItemStack(Items.book), + new ItemStack(Items.beef), + new ItemStack(Items.beef), + new ItemStack(Items.beef) + ) + .fluidInputs( + new FluidStack(FluidRegistry.WATER,1000), + new FluidStack(FluidRegistry.WATER,1000), + new FluidStack(FluidRegistry.WATER,1000), + new FluidStack(FluidRegistry.WATER,1000) + ) + .itemOutputs( + + new ItemStack(Items.bed) + + ) + .duration(100 * SECONDS).eut(GT_Values.VP[1]).addTo(GT_RecipeConstants.AssemblyLine); + */ + + + GT_Values.RA.stdBuilder() + .itemInputs( + + new ItemStack( GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset+Registration.QuadDualInputHatchOffset+10), + new ItemStack(MyMod.iohub) + ) + .itemOutputs(new ItemStack( GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset+Registration.DualInputHatchOCOffset)) + .duration(20 * SECONDS).eut(GT_Values.VP[10]).addTo(RecipeMaps.assemblerRecipes); + + + + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack( + MyMod.toolkit,0,OreDictionary.WILDCARD_VALUE) , + new ItemStack(Items.diamond) + , GT_Utility.getIntegratedCircuit(7) + + ) + + .itemOutputs( new ItemStack( MyMod.fixer) ) + + .duration(10 * SECONDS) + .eut(480) + .addTo(RecipeMaps.assemblerRecipes); + + + + + + if(flag){ + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack( + GameRegistry.findItem("computronics","computronics.chatBox")), + Api.INSTANCE.definitions().blocks().spatialPylon().maybeStack(1).get(), + new ItemStack(Items.ender_pearl,16) + ) + .fluidInputs(Materials.Enderium.getMolten(144)) + .itemOutputs( new ItemStack( MyMod.alert) ) + + .duration(100 * SECONDS) + .eut(480) + .addTo(RecipeMaps.assemblerRecipes); + + + GT_Values.RA.stdBuilder() + .itemInputs(Hatch_Input_Bus_ME.get(1), + Materials.Steel.getPlates(1) + ) + .itemOutputs( new ItemStack( MyMod.upgrades,1,1) ) + .duration(100 * SECONDS) + .eut(480*4*4) + .addTo(RecipeMaps.formingPressRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(Hatch_Input_ME.get(1), + Materials.Steel.getPlates(1) + ) + .itemOutputs( new ItemStack( MyMod.upgrades,1,2) ) + .duration(100 * SECONDS) + .eut(480*4*4) + .addTo(RecipeMaps.formingPressRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(Hatch_Input_Bus_ULV.get(16), + Materials.Steel.getPlates(1) + ) + .itemOutputs( new ItemStack( MyMod.upgrades,1,0) ) + .duration(100 * SECONDS) + .eut(480*4*4) + .addTo(RecipeMaps.formingPressRecipes); + + + + for(int i=0;i<4;i++) + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack( MyMod.upgrades,3,0), + HATCHES_INPUT_BUS[i].get(1) + + ) + .itemOutputs( new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.MultiCircuitBusOffset + i)) + + .duration(15 * SECONDS) + .eut(GT_Values.VP[i]) + .addTo(RecipeMaps.assemblerRecipes); + + } + /* + GT_Values.RA.stdBuilder() + .itemInputs( + + gregtech.api.enums.ItemList.Shape_Mold_Block.get(0) + + ).fluidInputs( Materials.Grade8PurifiedWater.getFluid(256000)) + .itemOutputs( new ItemStack( + MyMod.submitter)) + + .duration(150 * SECONDS) + .eut(GT_Values.VP[8]) + .addTo(RecipeMaps.fluidSolidifierRecipes); + + + GT_Values.RA.stdBuilder() + .itemInputs( + + gregtech.api.enums.ItemList.Shape_Mold_Plate.get(0) + + ).fluidInputs( Materials.Grade4PurifiedWater.getFluid(64000)) + .itemOutputs( new ItemStack( + MyMod.amountmaintainer)) + + .duration(150 * SECONDS) + .eut(GT_Values.VP[7]) + .addTo(RecipeMaps.fluidSolidifierRecipes); + */ + + GT_Values.RA.stdBuilder() + .itemInputs( + Hatch_Input_Bus_ME + .get(1) , new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1,29) + ) + + .itemOutputs(new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.RestrictedBusME) ) + + .duration(100 * SECONDS) + .eut(480) + .addTo(RecipeMaps.assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + Hatch_Input_ME + .get(1) , new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1,29) + ) + + .itemOutputs(new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.RestrictedHatchME) ) + + .duration(100 * SECONDS) + .eut(480) + .addTo(RecipeMaps.assemblerRecipes); + + + + + for(ItemList i:new ItemList[]{ItemList.ItemFilter_Export,ItemList.ItemFilter_Import}) + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GregTech_API.sBlockMachines,1,Config.metaTileEntityOffset + Registration.SlaveOffset) ,CertusQuartz.getPlates(4),i.get(1) + ) + + .itemOutputs(new ItemStack( + GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset + Registration.SlaveBusOffset) ) + + .duration(100 * SECONDS) + .eut(480) + .addTo(RecipeMaps.assemblerRecipes); + + + + + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(GregTech_API.sBlockMachines,1,Config.metaTileEntityOffset + Registration.SlaveOffset) + , Lapis.getPlates(4),ItemList.FluidFilter.get(1) + ) + + .itemOutputs(new ItemStack(GregTech_API.sBlockMachines,1,Config.metaTileEntityOffset + Registration.SlaveHatchOffset) ) + .duration(100 * SECONDS) + .eut(480) + .addTo(RecipeMaps.assemblerRecipes); + + + + GT_Values.RA.stdBuilder() + .itemInputs( + ItemList.Hatch_Input_Bus_ME_Advanced.get(1) + , ItemList.Machine_Multi_Assemblyline.get(0) + , new ItemStack(Items.fishing_rod) + ) + + .itemOutputs(new ItemStack(GregTech_API.sBlockMachines,1,Config.metaTileEntityOffset + Registration.DecoyBusME) ) + .duration(100 * SECONDS) + .eut(480) + .addTo(RecipeMaps.assemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + ItemList.Hatch_Input_ME_Advanced.get(1) + , ItemList.Machine_Multi_Assemblyline.get(0) + , new ItemStack(Items.fishing_rod) + ) + + .itemOutputs(new ItemStack(GregTech_API.sBlockMachines,1,Config.metaTileEntityOffset + Registration.DecoyHatchME) ) + .duration(100 * SECONDS) + .eut(480) + .addTo(RecipeMaps.assemblerRecipes); + + + + } } diff --git a/src/main/java/reobf/proghatches/main/registration/Registration.java b/src/main/java/reobf/proghatches/main/registration/Registration.java index d3eaf99..e341a6c 100644 --- a/src/main/java/reobf/proghatches/main/registration/Registration.java +++ b/src/main/java/reobf/proghatches/main/registration/Registration.java @@ -33,6 +33,8 @@ import reobf.proghatches.gt.metatileentity.BufferedDualInputHatch; import reobf.proghatches.gt.metatileentity.CommunicationPortHatch; import reobf.proghatches.gt.metatileentity.DataHatchME; +import reobf.proghatches.gt.metatileentity.DecoyInputBusME; +import reobf.proghatches.gt.metatileentity.DecoyInputHatchME; import reobf.proghatches.gt.metatileentity.DualInputHachOC; import reobf.proghatches.gt.metatileentity.DualInputHatch; import reobf.proghatches.gt.metatileentity.DualInputHatchInventoryMappingSlave; @@ -101,6 +103,8 @@ public class Registration implements Runnable { public static final int SlaveBusOffset = 168; public static final int SlaveHatchOffset = 169; public static final int CommunicationPortHatchOffset= 170; + public static final int DecoyBusME= 171; + public static final int DecoyHatchME= 172; @SuppressWarnings("deprecation") @Override public void run() { @@ -445,6 +449,19 @@ public void run() { LangManager.translateToLocalFormatted("hatch.commport.name"), 4 ); + new DecoyInputBusME( + Config.metaTileEntityOffset + DecoyBusME, + "fluid.input.bus.me.decoy", + LangManager.translateToLocalFormatted("fluid.input.bus.me.decoy.name") + + ); + new DecoyInputHatchME( + Config.metaTileEntityOffset + DecoyHatchME, + "fluid.input.me.decoy", + LangManager.translateToLocalFormatted("fluid.input.me.decoy.name") + + ); + /*for (int i = 0; i < 4; i++) { new DualInputHatch( diff --git a/src/main/resources/assets/proghatches/lang/en_US.lang b/src/main/resources/assets/proghatches/lang/en_US.lang index 6671e3d..15ee782 100644 --- a/src/main/resources/assets/proghatches/lang/en_US.lang +++ b/src/main/resources/assets/proghatches/lang/en_US.lang @@ -587,3 +587,7 @@ programmable_hatches.gt.fluidlimit.neo=Fluid filling policy programmable_hatches.gt.fluidlimit.neo.0=Normal: Fill fluid slots of lower index, then higher. programmable_hatches.gt.fluidlimit.neo.1=Limiting: Only fill slot of same fluid, if no same fluid present then fill the first empty slot. programmable_hatches.gt.fluidlimit.neo.2=Empty first: Fill empty fluid slots first, then try Nomal mode. +proghatches.decoy.reservefirst.enabled=Reserve the first slot for inventory of highest priority: true +proghatches.decoy.reservefirst.disabled=Reserve the first slot for inventory of highest priority: false +fluid.input.bus.me.decoy.name=Assline Decoy Stocking Input Bus (ME) +fluid.input.me.decoy.name=Assline Decoy Stocking Input Hatch (ME) diff --git a/src/main/resources/assets/proghatches/lang/en_US/DIBME.lang b/src/main/resources/assets/proghatches/lang/en_US/DIBME.lang new file mode 100644 index 0000000..31722a6 --- /dev/null +++ b/src/main/resources/assets/proghatches/lang/en_US/DIBME.lang @@ -0,0 +1,8 @@ +Item Input for Multiblocks +Basically an Advanced Stocking Input Bus (ME),but pull items from storage with higher priority first. +And try to consume items evenly from all storages then in reversed priority. +Can be used to trick Assembly Line into working, when recipe requires same items in different slots. +Use it as the last input bus of Assembly Line, and access other 15 buses' inventory via Storage Bus +and watch this bus do the trick. +Might carsh the machine and void materials if used improperly. +Shift+Screwdriver RMB to toggle reserve first slot if storage of highest priority is empty \ No newline at end of file diff --git a/src/main/resources/assets/proghatches/lang/en_US/DIHME.lang b/src/main/resources/assets/proghatches/lang/en_US/DIHME.lang new file mode 100644 index 0000000..c41ddf3 --- /dev/null +++ b/src/main/resources/assets/proghatches/lang/en_US/DIHME.lang @@ -0,0 +1,8 @@ +Fluid Input for Multiblocks +Basically an Advanced Stocking Input Hatch (ME),but pull fluid from storage with higher priority first. +And try to consume fluid evenly from all storages then in reversed priority. +Can be used to trick Assembly Line into working, when recipe requires same fluid in different slots. +Use it as the last input hatch of Assembly Line, and access other 15 buses' inventory via Storage Bus +and watch this bus do the trick. +Might carsh the machine and void materials if used improperly. +Shift+Screwdriver RMB to toggle reserve first slot if storage of highest priority is empty \ No newline at end of file diff --git a/src/main/resources/assets/proghatches/lang/zh_CN.lang b/src/main/resources/assets/proghatches/lang/zh_CN.lang index e34af8d..f09c197 100644 --- a/src/main/resources/assets/proghatches/lang/zh_CN.lang +++ b/src/main/resources/assets/proghatches/lang/zh_CN.lang @@ -585,3 +585,7 @@ programmable_hatches.gt.fluidlimit.neo=流体注入策略 programmable_hatches.gt.fluidlimit.neo.0=常规: 按照槽位序号从小到大依次注入 programmable_hatches.gt.fluidlimit.neo.1=限制: 仅注入含有相同流体的槽,如果没有则注入第一个空槽 programmable_hatches.gt.fluidlimit.neo.2=空优先: 总是先注入空流体槽,再尝试常规模式(结果高度依赖于物流设备的具体实现,请不要假设二合一接口以外的设备能符合期望) +proghatches.decoy.reservefirst.enabled=保留第一个槽给最高优先存储: true +proghatches.decoy.reservefirst.disabled=保留第一个槽给最高优先存储: false +fluid.input.bus.me.decoy.name=装配线诱骗存储输入总线(ME) +fluid.input.me.decoy.name=装配线诱骗存储输入仓(ME) diff --git a/src/main/resources/assets/proghatches/lang/zh_CN/DIBME.lang b/src/main/resources/assets/proghatches/lang/zh_CN/DIBME.lang new file mode 100644 index 0000000..08e456e --- /dev/null +++ b/src/main/resources/assets/proghatches/lang/zh_CN/DIBME.lang @@ -0,0 +1,16 @@ +多方块的物品输入 +基本上就是一个进阶存储输入总线(ME),但优先拉取高优先级存储的物品 +尽量保证均匀消耗网络内存储,其次按逆向优先级 +当装配线配方不同格有重复物品,可以诱骗装配线通过检测 +把它作为装配线最后一个输入总线,并用存储总线访问其余15个存储输入总线的存储 +并从低到高设置优先级,它就能搞定一切 +不当使用可能会使装配线崩溃并吞材料 +Shift+螺丝刀右键 在最高优先级存储为空时留空第一格 +-------------------------------------------------------------------------- +简单来说 装配线假设所有ME输入共用一个ME存储(事实并非如此)有重复物品时会漏统计导致不开机 +利用装配线会统计其余15个格子的物品,但不会从其余15格取物品的特性 +让这个总线统计所有16个子网的数量,作为最后一个总线覆盖掉装配线之前漏统计的数量 +从而同时保证装配线会从这个总线获取所有原料,而不是之前的15个输入总线 +正确设置优先级以确保 +1.装配线配方第16格有物品时拉取物品时能出现在第一个格子 +2.总是从低序号低的存储消耗物品(类似进阶装配线的消耗顺序) \ No newline at end of file diff --git a/src/main/resources/assets/proghatches/lang/zh_CN/DIHME.lang b/src/main/resources/assets/proghatches/lang/zh_CN/DIHME.lang new file mode 100644 index 0000000..ea72e07 --- /dev/null +++ b/src/main/resources/assets/proghatches/lang/zh_CN/DIHME.lang @@ -0,0 +1,11 @@ +多方块的流体输入 +基本上就是一个进阶存储输入仓(ME) +基本上就是一个进阶存储输入总线(ME),但优先拉取高优先级存储的物品 +尽量保证均匀消耗网络内存储,其次按逆向优先级 +把它作为装配线最后一个输入仓,并用存储总线访问其余15个存储输入总线的存储 +并从低到高设置优先级,它就能搞定一切 +不当使用可能会使装配线崩溃并吞材料 +Shift+螺丝刀右键 在最高优先级存储为空时留空第一格 +------------------------------------------------------------- +原理参考总线版本的tooltips +流体无法通过重命名压印的方法来区分 或许并没有太多选项... \ No newline at end of file