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 0000000..1a44d52 Binary files /dev/null and b/src/main/resources/assets/proghatches/textures/states.png differ