Skip to content

Commit

Permalink
buff DualHatch capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed May 23, 2024
1 parent 97e92d0 commit cc0d54c
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.Queue;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
Expand Down Expand Up @@ -87,7 +91,7 @@
import reobf.proghatches.util.ProghatchesUtil;

public class BufferedDualInputHatch extends DualInputHatch implements IRecipeProcessingAwareDualHatch {

public Deque<Long> scheduled=new LinkedList<>();//no randomaccess, LinkedList will work fine
public Widget circuitSlot(IItemHandlerModifiable inventory, int slot) {

List<String> tooltip = Arrays.asList(
Expand Down Expand Up @@ -174,6 +178,15 @@ public int itemLimit() {
return (int) (64 * Math.pow(2, Math.max(mTier - 3, 0)));
}

private static int fluidLimit(int mTier,boolean mMultiFluid) {

return (int) ((int) (8000 * Math.pow(2, mTier) / (mMultiFluid ? 4 : 1)));
}

private static int itemLimit(int mTier) {

return (int) (64 * Math.pow(2, Math.max(mTier - 3, 0)));
}
public BufferedDualInputHatch(int id, String name, String nameRegional, int tier, boolean mMultiFluid,
int bufferNum, String... optional) {
this(id, name, nameRegional, tier, getSlots(tier) + 1, mMultiFluid, bufferNum, optional);
Expand Down Expand Up @@ -213,10 +226,9 @@ public BufferedDualInputHatch(int id, String name, String nameRegional, int tier
.get("BDH",
ImmutableMap
.of("bufferNum", bufferNum, "cap",
format.format((int) (4000 * Math.pow(4, tier)
/ (mMultiFluid ? 4 : 1))),
format.format(fluidLimit(tier,mMultiFluid )),
"mMultiFluid", mMultiFluid, "slots",
Math.min(16, (1 + tier) * (tier + 1)), "stacksize",
itemLimit(tier), "stacksize",
(int) (64 * Math.pow(2, Math.max(tier - 3, 0)))))

))/* ) */;
Expand Down Expand Up @@ -282,20 +294,22 @@ public class DualInvBuffer implements IDualInputInventory {
// public boolean lock;
public boolean full() {

for (int index=0;index<mStoredItemInternal.length;index++) {
for (int index=0;index<mStoredItemInternalSingle.length;index++) {
ItemStack i =mStoredItemInternal[index];
ItemStack si =mStoredItemInternalSingle[index];
if(i!=null){
if (si!=null&&Integer.MAX_VALUE - i.stackSize <si.stackSize) {
return true;//over flow! count as full
}

if (i != null && i.stackSize >= itemLimit()) {
if (i.stackSize >= itemLimit()) {
return true;
}
}
}


for (int index=0;index<mStoredItemInternal.length;index++) {
for (int index=0;index<mStoredFluidInternalSingle.length;index++) {
FluidTank i =mStoredFluidInternal[index];
FluidTank si =mStoredFluidInternalSingle[index];
if (si!=null&&Integer.MAX_VALUE - i.getFluidAmount() <si.getFluidAmount()) {
Expand Down Expand Up @@ -476,7 +490,10 @@ public void firstClassify(ListeningFluidTank[] fin, ItemStack[] iin) {
mStoredItemInternal[ix] = Optional.ofNullable(iin[ix]).map(ItemStack::copy).orElse(null);
iin[ix] = null;
}
justHadNewItems = true;
Long tick=tickFirstClassify+5+1;
if(!tick.equals(scheduled.peekFirst()))
scheduled.push(tick);
//justHadNewItems = true;
onClassify();
programLocal();
}
Expand Down Expand Up @@ -677,7 +694,12 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
super.onPostTick(aBaseMetaTileEntity, aTick);
if (aBaseMetaTileEntity.getWorld().isRemote)
return;

Optional.ofNullable(scheduled.peekLast()).filter(s->s==aTick).ifPresent(s->{
scheduled.removeLast();
justHadNewItems=true;
inv0.forEach(st->System.out.println(st.isAccessibleForMulti()));
});

dirty = dirty || updateEveryTick();
if (dirty) {
updateSlots();
Expand Down Expand Up @@ -825,7 +847,7 @@ public void detectAndSendChanges(boolean init) {

}

private Widget createButtonBuffer(int id) {
private Widget createButtonBuffer(int id,int xoffset,int yoffset) {
// for(int i=0;i<bufferNum;i++)
return new ButtonWidget().setOnClick((clickData, widget) -> {
if (clickData.mouseButton == 0) {
Expand All @@ -835,7 +857,7 @@ private Widget createButtonBuffer(int id) {
}).setPlayClickSound(true).setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE)
.addTooltips(ImmutableList
.of(LangManager.translateToLocalFormatted("programmable_hatches.gt.buffer", "" + id)))
.setSize(16, 16).setPos(3 + 16 * (id % 3), 3 + 16 * (id / 3));
.setSize(16, 16).setPos(xoffset + 16 * (id % 3), yoffset + 16 * (id / 3));

/*
* return new ButtonWidget().setOnClick((clickData, widget) -> { if
Expand Down Expand Up @@ -1010,14 +1032,14 @@ ButtonWidget createPowerSwitchButton(IWidgetBuilder<?> builder) {

@Override
public void addUIWidgets(Builder builder, UIBuildContext buildContext) {

Scrollable sc = new Scrollable().setVerticalScroll();
for (int i = 0; i < bufferNum; i++) {
final int ii = i;
buildContext.addSyncedWindow(BUFFER_0 + i, (s) -> createWindow(s, ii));

builder.widget(createButtonBuffer(i));
sc.widget(createButtonBuffer(i,0,0));
}

builder.widget(sc.setSize(16*3,16*2).setPos(3,3));

builder.widget(createPowerSwitchButton(builder));
builder.widget(new SyncedWidget() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public PatternDualInputHatch(int id, String name, String nameRegional, int tier,
: reobf.proghatches.main.Config
.get("PDIH",
ImmutableMap
.of(/*"bufferNum", bufferNum, "cap",
.of("bufferNum", bufferNum,/* "cap",
format.format((int) (4000 * Math.pow(4, tier)
/ (mMultiFluid ? 4 : 1))),*/
"mMultiFluid", mMultiFluid, "slots",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,8 @@ private boolean checkBlackList(Optional<TileEntity> opt) {// World
}

public RemoteInputBus(int id, String name, String nameRegional, int tier) {
super(id, name, nameRegional, 0, 0, reobf.proghatches.main.Config.get("RIB", ImmutableMap.of())
/*
* defaultObj(
*
* ArrayExt.of(
* "Item Input for Multiblocks, wirelessly linked to a container, just like RemoteIO interface."
* , "LMB click this block with a tricorder with target coord to link.",
* "Items not extractable by pipes will not be accessible, with an exception of virtual circuits."
* ,
* "Cannot work across dimension. Will not load target chunk. Will not work if target chunk is unloaded."
* ,LangManager.translateToLocal("programmable_hatches.addedby") ),
* ArrayExt.of( "像RemoteIO一样远程访问某个容器中的物品 作为多方块机器的输入",
* "三录仪记录目标坐标后,左键此方块设定坐标", "无法被管道抽出的物品(除了虚拟电路板,如果目标有)也不能被访问",
* "不能跨维度链接 不会触发目标区块加载,且目标区块未加载时不工作"
* ,LangManager.translateToLocal("programmable_hatches.addedby") ))
*/);
super(id, name, nameRegional, tier, 0, reobf.proghatches.main.Config.get("RIB", ImmutableMap.of())
);
Registration.items.add(new ItemStack(GregTech_API.sBlockMachines, 1, id));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,8 @@ private boolean checkBlackList(Optional<TileEntity> opt) {// World
}

public RemoteInputHatch(int id, String name, String nameRegional, int tier) {
super(id, 0, name, nameRegional, 0, reobf.proghatches.main.Config.get("RIH", ImmutableMap.of())
/*
* defaultObj(
*
* ArrayExt.of(
* "Fluid Input for Multiblocks, wirelessly linked to a tank, just like RemoteIO interface."
* , "LMB click this block with a tricorder with target coord to link.",
* "Fluid not extractable by pipes will not be accessible.",
* "Cannot work across dimension. Will not load target chunk. Will not work if target chunk is unloaded."
* ,LangManager.translateToLocal("programmable_hatches.addedby") ),
* ArrayExt.of( "像RemoteIO一样远程访问某个容器中的流体 作为多方块机器的输入",
* "三录仪记录目标坐标后,左键此方块设定坐标", "无法被管道抽出的流体也不能被访问",
* "不能跨维度链接 不会触发目标区块加载,且目标区块未加载时不工作"
* ,LangManager.translateToLocal("programmable_hatches.addedby") ))
*/
super(id, 0, name, nameRegional, tier, reobf.proghatches.main.Config.get("RIH", ImmutableMap.of())


);
Registration.items.add(new ItemStack(GregTech_API.sBlockMachines, 1, id));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void run() {
String.format(LangManager.translateToLocal("hatch.input.buffered.dual.quad.tier.mkii.name"), GT_Values.VN[i]),
i,
true,
6);
6+Math.max(i-4, 0)*2);

}

Expand Down Expand Up @@ -239,12 +239,12 @@ public void run() {
Config.metaTileEntityOffset + RemoteInputBusOffset,
"hatch.input.item.remote",
LangManager.translateToLocal("hatch.input.item.remote.name"),
1);
6);
new RemoteInputHatch(
Config.metaTileEntityOffset + RemoteInputHatchOffset,
"hatch.input.fluid.remote",
LangManager.translateToLocal("hatch.input.fluid.remote.name"),
1);
6);
}
//int tier = 8;
new SuperfluidHatch(
Expand All @@ -262,7 +262,7 @@ public void run() {
LangManager.translateToLocal("hatch.input.buffered.me.name"),
10,
true,
6,
24,
true);

for (int i = 0; i < 4; i++) new FilterOutputBus(
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/proghatches/lang/en_US/PDIH.lang
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Blocking mode is always on
If all pattern inputs cannot be push in one single try, it won't be pushed at all.
Buffer: {bufferNum}
For each buffer:
Capacity: {2^31-1}L{mMultiFluid?} x4 types of fluid{mMultiFluid:}{mMultiFluid!}
Slot maximum stacksize:{2^31-1}
Capacity: 2^31-1 L{mMultiFluid?} x4 types of fluid{mMultiFluid:}{mMultiFluid!}
Slot maximum stacksize:2^31-1
4 changes: 2 additions & 2 deletions src/main/resources/assets/proghatches/lang/zh_CN/PDIH.lang
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
阻挡模式不可关闭
样板所有原料无法单次全部输入时,将拒绝此样板的输入
缓冲数量: {bufferNum}
缓冲容量: {2^31-1}L{mMultiFluid?} x4种流体{mMultiFluid:}{mMultiFluid!}
缓冲容量: 2^31-1 L{mMultiFluid?} x4种流体{mMultiFluid:}{mMultiFluid!}
{slots}格
每格堆叠限制:{2^31-1}
每格堆叠限制:2^31-1

0 comments on commit cc0d54c

Please sign in to comment.