Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed Oct 1, 2024
1 parent 4c3d50b commit ef93437
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

plugins {
id 'com.gtnewhorizons.gtnhconvention'
}

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -380,7 +386,14 @@ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {

return neo;
}

private CycleButtonWidget createButton(Supplier<Integer> getter, IntConsumer setter, Function<Integer, IDrawable> picture,
List<String> 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<Boolean> getter, Consumer<Boolean> setter, UITexture picture,
Supplier<GT_TooltipDataCache.TooltipData> tooltipDataSupplier, int offset) {
return new CycleButtonWidget().setToggle(getter, setter).setStaticTexture(picture)
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));


Expand Down Expand Up @@ -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);
Expand All @@ -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());
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/assets/proghatches/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 4 additions & 0 deletions src/main/resources/assets/proghatches/lang/zh_CN.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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=空优先: 总是先注入空流体槽,再尝试常规模式(结果高度依赖于物流设备的具体实现,请不要假设二合一接口以外的设备能符合期望)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ef93437

Please sign in to comment.