Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed Feb 18, 2025
1 parent 01bed9a commit ec54c20
Show file tree
Hide file tree
Showing 7 changed files with 482 additions and 102 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import mcp.mobius.waila.api.IWailaDataAccessor;
import reobf.proghatches.gt.metatileentity.BufferedDualInputHatch.DualInvBuffer;
import reobf.proghatches.gt.metatileentity.DualInputHatch.Net;
import reobf.proghatches.gt.metatileentity.bufferutil.ItemStackG;
import reobf.proghatches.gt.metatileentity.util.IMultiplePatternPushable;
import reobf.proghatches.gt.metatileentity.util.MappingItemHandler;
import reobf.proghatches.lang.LangManager;
Expand All @@ -89,6 +90,9 @@
public class PatternDualInputHatch extends BufferedDualInputHatch implements ICraftingProvider, IGridProxyable,
ICustomNameObject, IInterfaceViewable, IPowerChannelState, IActionHost, IMultiplePatternPushable {




public PatternDualInputHatch(String mName, byte mTier, String[] mDescriptionArray, ITexture[][][] mTextures,
boolean mMultiFluid, int bufferNum) {
super(mName, mTier, mDescriptionArray, mTextures, mMultiFluid, bufferNum);
Expand Down Expand Up @@ -356,7 +360,7 @@ abstract class Inv {

@Override
ItemStack[] geti() {
return s.mStoredItemInternal;
return flat(s.mStoredItemInternal);
}

@Override
Expand Down Expand Up @@ -658,9 +662,9 @@ public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCraf
*/

DualInvBuffer theBuffer = /* ((BufferedDualInputHatch) master). */classifyForce();
if(theBuffer!=null)
recordRecipe(theBuffer);

if(theBuffer!=null){
recordRecipe(theBuffer);theBuffer.onChange();
}
justHadNewItems = true;
return true;
}
Expand Down Expand Up @@ -940,14 +944,14 @@ public void onBlockDestroyed() {
}
}

public int fluidLimit() {
public long fluidLimit() {

return Integer.MAX_VALUE;
return Long.MAX_VALUE;
}

public int itemLimit() {
public long itemLimit() {

return Integer.MAX_VALUE;
return Long.MAX_VALUE;
}

boolean createInsertion() {
Expand Down Expand Up @@ -1083,11 +1087,11 @@ public int[] pushPatternMulti(ICraftingPatternDetails patternDetails, InventoryC
for (int ix = 0; ix < theBuffer.i; ix++) {
if (theBuffer.mStoredItemInternalSingle[ix] != null) {
if (theBuffer.mStoredItemInternal[ix] == null) {
theBuffer.mStoredItemInternal[ix] = theBuffer.mStoredItemInternalSingle[ix].copy();
theBuffer.mStoredItemInternal[ix].stackSize = 0;// circuit?
theBuffer.mStoredItemInternal[ix] = ItemStackG.neo(theBuffer.mStoredItemInternalSingle[ix].copy());
theBuffer.mStoredItemInternal[ix].stackSize(0);// circuit?
}
theBuffer.mStoredItemInternal[ix].stackSize += theBuffer.mStoredItemInternalSingle[ix].stackSize
* todo;
theBuffer.mStoredItemInternal[ix].stackSizeInc( theBuffer.mStoredItemInternalSingle[ix].stackSize
* todo);
}
}

Expand All @@ -1105,7 +1109,7 @@ public int[] pushPatternMulti(ICraftingPatternDetails patternDetails, InventoryC
}
suc += todo;
}

theBuffer.onChange();
}

saved += suc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import mcp.mobius.waila.api.IWailaDataAccessor;
import reobf.proghatches.block.BlockIOHub;
import reobf.proghatches.gt.metatileentity.BufferedDualInputHatch.DualInvBuffer;
import reobf.proghatches.gt.metatileentity.bufferutil.ItemStackG;
import reobf.proghatches.gt.metatileentity.util.IDataCopyablePlaceHolder;
import reobf.proghatches.gt.metatileentity.util.IMultiplePatternPushable;
import reobf.proghatches.gt.metatileentity.util.MappingItemHandler;
Expand Down Expand Up @@ -878,8 +879,8 @@ public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCraf
BufferedDualInputHatch m = (BufferedDualInputHatch) master;

DualInvBuffer theBuffer = ((BufferedDualInputHatch) master).classifyForce();
if(theBuffer!=null)
((BufferedDualInputHatch) master).recordRecipe(theBuffer);
if(theBuffer!=null){
((BufferedDualInputHatch) master).recordRecipe(theBuffer);theBuffer.onChange();}
// ((BufferedDualInputHatch) master).classifyForce();
}
return true;// hoo ray
Expand Down Expand Up @@ -1141,11 +1142,11 @@ public int[] pushPatternMulti(ICraftingPatternDetails patternDetails, InventoryC
for (int ix = 0; ix < theBuffer.i; ix++) {
if (theBuffer.mStoredItemInternalSingle[ix] != null) {
if (theBuffer.mStoredItemInternal[ix] == null) {
theBuffer.mStoredItemInternal[ix] = theBuffer.mStoredItemInternalSingle[ix].copy();
theBuffer.mStoredItemInternal[ix].stackSize = 0;// circuit?
theBuffer.mStoredItemInternal[ix] = ItemStackG.neo(theBuffer.mStoredItemInternalSingle[ix].copy());
theBuffer.mStoredItemInternal[ix].stackSize (0);// circuit?
}
theBuffer.mStoredItemInternal[ix].stackSize += theBuffer.mStoredItemInternalSingle[ix].stackSize
* todo;
theBuffer.mStoredItemInternal[ix].stackSizeInc( theBuffer.mStoredItemInternalSingle[ix].stackSize
* todo);
}
}

Expand All @@ -1165,7 +1166,7 @@ public int[] pushPatternMulti(ICraftingPatternDetails patternDetails, InventoryC

suc += todo;
}

theBuffer.onChange();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {

}

public int fluidLimit() {
public long fluidLimit() {
return 100_000_000;

}

public int itemLimit() {
public long itemLimit() {
return 64;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
package reobf.proghatches.gt.metatileentity.bufferutil;

import java.util.ArrayList;
import java.util.Iterator;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;

//G is for group
public class ItemStackG {
public ArrayList<ItemStack> arr = new ArrayList<>();


public static ItemStackG neo(ItemStack is) {
if (is == null)
return null;
return new ItemStackG(is);
}

private ItemStackG(ItemStack is) {
arr.add(is);
}
public ItemStack getZero(){
return arr.get(0);


}
public NBTTagCompound writeToNBT(NBTTagCompound p_77955_1_) {

arr.get(0).writeToNBT(p_77955_1_);
p_77955_1_.setInteger("ICount", arr.get(0).stackSize);

NBTTagList lst = new NBTTagList();
for (int i = 1; i < arr.size(); i++) {

NBTTagCompound t = new NBTTagCompound();
arr.get(i).writeToNBT(t);
t.setInteger("ICount", arr.get(i).stackSize);
lst.appendTag(t);

}

p_77955_1_.setTag("therest", lst);

return p_77955_1_;
}

public static ItemStackG readFromNBT(NBTTagCompound p_77963_1_) {

ItemStack is = ItemStack.loadItemStackFromNBT(p_77963_1_);
if (is == null)
return null;
is.stackSize = p_77963_1_.getInteger("ICount");
ItemStackG to = neo(is);
if (to != null) {

if (p_77963_1_.hasKey("therest")) {

NBTTagList lst = (NBTTagList) p_77963_1_.getTag("therest");
for (int ix = 0; ix < lst.tagCount(); ix++) {
NBTTagCompound TAG = lst.getCompoundTagAt(ix);

ItemStack isX = ItemStack.loadItemStackFromNBT(TAG);
if (isX != null) {
isX.stackSize = TAG.getInteger("ICount");
to.arr.add(isX);
}

}

}

}

return to;

}

public long stackSize() {
return arr.stream().mapToLong(s->s.stackSize).sum();
}

public Item getItem() {

return arr.get(0).getItem();
}

public ItemStack getStack() {
ItemStack ret=arr.get(0).copy();
ret.stackSize=(int) Math.min(stackSize(),Integer.MAX_VALUE);
return ret;
}

public void stackSizeInc(int todo) {

for(ItemStack is:arr){
int cando=Math.min(

Integer.MAX_VALUE
//64


-is.stackSize,todo);
todo-=cando;
is.stackSize+=cando;
if(todo<=0)return;
}
ItemStack i = arr.get(0).copy();
i.stackSize=todo;
arr.add(i);


}

public static ItemStackG loadItemStackFromNBT(NBTTagCompound tag) {

return readFromNBT(tag);
}

public ItemStack[] flat() {
adjust();
return arr.toArray(new ItemStack[arr.size()]);
}



public void stackSize(int i) {

if(arr.size()>1){arr.remove(1);}
arr.get(0).stackSize=i;
}

public static ItemStackG setZero(ItemStackG itemStackG, ItemStack copyStackWithSize) {


if(itemStackG==null){
return neo(copyStackWithSize);
}
if(copyStackWithSize==null)
itemStackG.arr.get(0).stackSize=0;

else
itemStackG.arr.get(0).stackSize=copyStackWithSize.stackSize;
itemStackG.adjust();
return itemStackG;
}

public void adjust(){boolean dirty=false;
for(int i=0;i<arr.size()-1;i++){
if(arr.get(i).stackSize<Integer.MAX_VALUE){
if(arr.get(i+1).stackSize>0){
int todo=Math.min(Integer.MAX_VALUE-arr.get(i).stackSize, arr.get(i+1).stackSize);
arr.get(i).stackSize+=todo;
arr.get(i+1).stackSize-=todo;dirty=true;

}
}

}

if(dirty){
Iterator<ItemStack> it = arr.iterator();it.next();
while(it.hasNext()){
if(it.next().stackSize<=0){it.remove();}

}

}
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package reobf.proghatches.gt.metatileentity.util;

import net.minecraft.item.ItemStack;
import reobf.proghatches.gt.metatileentity.bufferutil.ItemStackG;

import com.gtnewhorizons.modularui.api.forge.ItemHandlerHelper;

Expand All @@ -17,7 +18,9 @@ public MappingItemHandler(ItemStack[] is, int index, int num) {
this.num = num;
}

boolean phantom;


boolean phantom;

public MappingItemHandler phantom() {
phantom = true;
Expand Down
Loading

0 comments on commit ec54c20

Please sign in to comment.