Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed Jul 7, 2024
1 parent 736203c commit 879e754
Show file tree
Hide file tree
Showing 8 changed files with 313 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.17p5'
String versionOverride = '0.0.17p6'
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot;
import com.gtnewhorizons.modularui.common.widget.CycleButtonWidget;
import com.gtnewhorizons.modularui.common.widget.DrawableWidget;
import com.gtnewhorizons.modularui.common.widget.FluidSlotWidget;
import com.gtnewhorizons.modularui.common.widget.SlotWidget;
import com.gtnewhorizons.modularui.common.widget.textfield.BaseTextFieldWidget;
import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget;
Expand Down Expand Up @@ -63,8 +64,11 @@
import appeng.me.storage.MEInventoryHandler;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import appeng.util.item.AEItemStack;
import appeng.util.item.FluidList;
import appeng.util.item.ItemList;
import appeng.util.prioitylist.PrecisePriorityList;
import gregtech.api.GregTech_API;
import gregtech.api.gui.modularui.GT_UIInfos;
import gregtech.api.gui.modularui.GT_UITextures;
Expand All @@ -88,7 +92,9 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import reobf.proghatches.gt.metatileentity.util.BaseSlotPatched;
import reobf.proghatches.gt.metatileentity.util.MappingFluidTank;
import reobf.proghatches.lang.LangManager;
import reobf.proghatches.main.registration.Registration;
import reobf.proghatches.util.IIconTexture;
Expand Down Expand Up @@ -258,13 +264,28 @@ public DimensionalCoord getLocation() {

return new DimensionalCoord((TileEntity)this.getBaseMetaTileEntity());
}
public Consumer<IItemList> updateFilter;
ItemStack[] cachedFilter=new ItemStack[1];
public void updateFilter(ItemStack fs){
cachedFilter[0]=fs;
ItemList fl = new ItemList();
fl.add(AEItemStack.create(fs));
updateFilter.accept(fl);
post();
}



@SuppressWarnings({ "unchecked", "rawtypes" })
IMEInventoryHandler<AEItemStack> handler
=new MEInventoryHandler(new UnlimitedWrapper()
, StorageChannel .ITEMS){
public boolean getSticky() {return sticky&&!suppressSticky;};
public int getPriority() {return piority;};
{
updateFilter=s->
this.setPartitionList(new PrecisePriorityList(s));
}
};
boolean sticky;
int piority;
Expand Down Expand Up @@ -562,6 +583,9 @@ public void addUIWidgets(Builder builder, UIBuildContext buildContext) {
builder.widget(createButton(() ->
autoUnlock
, val -> {

cachedFilter[0]=null;
updateFilter(cachedFilter[0]);
autoUnlock = val;post();
//updateSlots();
}, GT_UITextures.OVERLAY_BUTTON_RECIPE_UNLOCKED,
Expand All @@ -575,7 +599,20 @@ public void addUIWidgets(Builder builder, UIBuildContext buildContext) {

, 0)
.setPos( 3+18,3+18*2));

builder.widget(SlotWidget.phantom(

new ItemStackHandler(cachedFilter){
public void setStackInSlot(int slot, ItemStack stack) {
super.setStackInSlot(slot, stack);
updateFilter(cachedFilter[0]);
autoUnlock=false;
post();
};
}, 0

).setPos( 3+18*2,3+18*2).addTooltip(StatCollector.translateToLocal("programmable_hatches.gt.phantom.filter"))

);



Expand Down Expand Up @@ -614,6 +651,11 @@ public void loadNBTData(NBTTagCompound aNBT) {
sticky= aNBT.getBoolean("sticky");
autoUnlock=aNBT.getBoolean("autoUnlock");
suppressSticky=aNBT.getBoolean("suppressSticky");
NBTTagCompound tag=(NBTTagCompound) aNBT.getTag("cahcedFilter");
if(tag!=null){
cachedFilter[0]=ItemStack.loadItemStackFromNBT(tag);
updateFilter(cachedFilter[0]);
}
}

@Override
Expand All @@ -633,6 +675,11 @@ public void saveNBTData(NBTTagCompound aNBT) {
aNBT.setBoolean("sticky", sticky);
aNBT.setBoolean("autoUnlock",autoUnlock);
aNBT.setBoolean("suppressSticky",suppressSticky);
if(cachedFilter[0]!=null){
NBTTagCompound tag=new NBTTagCompound();
cachedFilter[0].writeToNBT(tag);
aNBT.setTag("cahcedFilter", tag);
}

}@Override
public void onFacingChange() {
Expand Down
61 changes: 59 additions & 2 deletions src/main/java/reobf/proghatches/gt/metatileentity/SuperTankME.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget;
import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder;

import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.implementations.tiles.IColorableTile;
Expand Down Expand Up @@ -67,7 +68,10 @@
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import appeng.util.item.AEItemStack;
import appeng.util.item.FluidList;
import appeng.util.item.ItemList;
import appeng.util.prioitylist.IPartitionList;
import appeng.util.prioitylist.PrecisePriorityList;
import gregtech.api.GregTech_API;
import gregtech.api.gui.modularui.GT_UIInfos;
import gregtech.api.gui.modularui.GT_UITextures;
Expand All @@ -92,9 +96,13 @@
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidEvent;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidTank;
import reobf.proghatches.gt.metatileentity.util.BaseSlotPatched;
import reobf.proghatches.gt.metatileentity.util.MappingFluidTank;
import reobf.proghatches.lang.LangManager;
import reobf.proghatches.main.registration.Registration;
import reobf.proghatches.util.IIconTexture;
Expand Down Expand Up @@ -247,13 +255,33 @@ public DimensionalCoord getLocation() {
return new DimensionalCoord((TileEntity)this.getBaseMetaTileEntity());
}


//final FluidList filterList=new FluidList();//new FluidStack(FluidRegistry.WATER,1);
public Consumer<IItemList> updateFilter;
FluidStack cachedFilter;
public void updateFilter(FluidStack fs){
cachedFilter=fs;
FluidList fl = new FluidList();
fl.add(AEFluidStack.create(fs));
updateFilter.accept(fl);
post();
}

@SuppressWarnings({ "unchecked", "rawtypes" })
IMEInventoryHandler<AEFluidStack> handler
=new MEInventoryHandler(new UnlimitedWrapper()
, StorageChannel .FLUIDS){
public boolean getSticky() {return sticky&&!suppressSticky;};
public int getPriority() {return piority;};
};
{
updateFilter=s->
this.setPartitionList(new PrecisePriorityList(s));
}
};




boolean sticky;
int piority;
@Override
Expand Down Expand Up @@ -525,7 +553,9 @@ public void addUIWidgets(Builder builder, UIBuildContext buildContext) {
builder.widget(createButton(() ->
autoUnlock
, val -> {
autoUnlock = val;post();
autoUnlock = val;
cachedFilter=null;
updateFilter(cachedFilter);post();
//updateSlots();
}, GT_UITextures.OVERLAY_BUTTON_RECIPE_UNLOCKED,

Expand All @@ -538,6 +568,16 @@ public void addUIWidgets(Builder builder, UIBuildContext buildContext) {

, 0)
.setPos( 3+18,3+18*2));


builder.widget(FluidSlotWidget.phantom(new MappingFluidTank(s->{cachedFilter=s==null?null:s.copy();if(s!=null){autoUnlock=false;}updateFilter(cachedFilter);}, ()->cachedFilter),
false
).setPos( 3+18*2,3+18*2).addTooltip(StatCollector.translateToLocal("programmable_hatches.gt.phantom.filter"))

);



builder.widget(new TextFieldWidget()
.setPattern(BaseTextFieldWidget.NATURAL_NUMS)
.setGetter(()->piority+"")
Expand Down Expand Up @@ -575,6 +615,14 @@ public void loadNBTData(NBTTagCompound aNBT) {
autoUnlock=aNBT.getBoolean("autoUnlock");
suppressSticky=aNBT.getBoolean("suppressSticky");
content.readFromNBT(aNBT);

NBTTagCompound tag=(NBTTagCompound) aNBT.getTag("cahcedFilter");
if(tag!=null){
cachedFilter=FluidStack.loadFluidStackFromNBT(tag);
updateFilter(cachedFilter);
}


}
protected static int commonSizeCompute(int tier) {
switch (tier) {
Expand All @@ -601,6 +649,15 @@ public void saveNBTData(NBTTagCompound aNBT) {
aNBT.setBoolean("sticky", sticky);
aNBT.setBoolean("autoUnlock",autoUnlock);
aNBT.setBoolean("suppressSticky",suppressSticky);
if(cachedFilter!=null){
NBTTagCompound tag=new NBTTagCompound();
cachedFilter.writeToNBT(tag);
aNBT.setTag("cahcedFilter", tag);
}




}
@Override
public void setItemNBT(NBTTagCompound aNBT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_StructureUtility;
import gregtech.api.util.GT_Utility;
import gregtech.api.util.IGT_HatchAdder;
import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_OutputBus_ME;
import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_Output_ME;
Expand Down Expand Up @@ -439,6 +440,7 @@ private boolean distribute() {
}
if(possibleSource==null&&mInputHatches.size()==1){
ArrayList<FluidStack> fluid = getStoredFluids();
fluid.removeIf(s->s==null||s.amount<=0);
if(fluid.size()>0){
possibleSource=ImmutableList.of(
new IDualInputInventory(){
Expand All @@ -461,6 +463,7 @@ public FluidStack[] getFluidInputs() {

if(possibleSource==null&&mInputBusses.size()==1){
ArrayList<ItemStack> items =getStoredInputs();
items.removeIf(s->s==null||s.stackSize<=0);
if(items.size()>0){
possibleSource=ImmutableList.of(
new IDualInputInventory(){
Expand Down Expand Up @@ -498,7 +501,7 @@ public FluidStack[] getFluidInputs() {
return false;
}
while(itr.hasNext()){
if(moveToOutpus(itr.next())){
if(moveToOutpus(itr.next(),true)){
return true;
};

Expand Down Expand Up @@ -643,12 +646,14 @@ private static boolean sameType(IAEFluidStack a,FluidStack b){
}


private boolean moveToOutpus(IDualInputInventory opt) {
private boolean moveToOutpus(IDualInputInventory opt,boolean checkSpace) {
ItemStack[] i = opt.getItemInputs();
FluidStack[] f = opt.getFluidInputs();

boolean anyDiff=false;
if(i.length>mOutputBusses.size())return false;
if(f.length>mOutputHatches.size())return false;

if(checkSpace){
for(int index=0;index<i.length;++index){
if(mOutputBusses.get(index) instanceof GT_MetaTileEntity_Hatch_OutputBus_ME){continue;}
GT_MetaTileEntity_Hatch_OutputBus bus = mOutputBusses.get(index);
Expand All @@ -667,33 +672,78 @@ private boolean moveToOutpus(IDualInputInventory opt) {
acc+=space(f[index],hatch);
if(acc<f[index].amount){return false;}
}
}


for(int index=0;index<i.length;++index){
if(mOutputBusses.get(index) instanceof GT_MetaTileEntity_Hatch_OutputBus_ME){
int before=i[index].stackSize;
i[index].stackSize=((GT_MetaTileEntity_Hatch_OutputBus_ME)mOutputBusses.get(index)).store(i[index]);
continue;
if(i[index].stackSize!=before)anyDiff=true;

continue;
}
GT_MetaTileEntity_Hatch_OutputBus bus = mOutputBusses.get(index);
bus.storeAll(i[index].copy());
i[index].stackSize=0;
int diff=storeAll(bus,i[index].copy());
if(diff>0)anyDiff=true;
i[index].stackSize-=diff;
}

for(int index=0;index<f.length;++index){
if(mOutputHatches.get(index) instanceof GT_MetaTileEntity_Hatch_Output_ME){
int before=f[index].amount;
f[index].amount-=((GT_MetaTileEntity_Hatch_Output_ME)mOutputHatches.get(index)).tryFillAE(f[index]);
continue;
if(f[index].amount!=before)anyDiff=true;

continue;
}
GT_MetaTileEntity_Hatch_Output hatch = mOutputHatches.get(index);
f[index].amount-=hatch.fill(f[index], true);
int diff=hatch.fill(f[index], true);
if(diff>0)anyDiff=true;
f[index].amount-=diff;

}
mInputBusses.forEach(s->s.updateSlots());
mInputHatches.forEach(s->s.updateSlots());


return true;
return anyDiff;
}
private static int storeAll(GT_MetaTileEntity_Hatch_OutputBus bus,ItemStack aStack) {
bus.markDirty();
int consumed=0;
for (int i = 0, mInventoryLength = bus.mInventory.length; i < mInventoryLength && aStack.stackSize > 0; i++) {
ItemStack tSlot = bus.mInventory[i];
if (GT_Utility.isStackInvalid(tSlot)) {
int tRealStackLimit = Math.min(bus.getInventoryStackLimit(), aStack.getMaxStackSize());
if (aStack.stackSize <= tRealStackLimit) {
bus.mInventory[i] = aStack;
consumed+=aStack.stackSize;
return consumed;
}
bus.mInventory[i] = aStack.splitStack(tRealStackLimit);
consumed+=tRealStackLimit;
} else {
int tRealStackLimit = Math.min(bus.getInventoryStackLimit(), tSlot.getMaxStackSize());
if (tSlot.stackSize < tRealStackLimit && tSlot.isItemEqual(aStack)
&& ItemStack.areItemStackTagsEqual(tSlot, aStack)) {
if (aStack.stackSize + tSlot.stackSize <= tRealStackLimit) {
bus.mInventory[i].stackSize += aStack.stackSize;
consumed+=aStack.stackSize;
return consumed;
} else {
// more to serve
consumed+=tRealStackLimit - tSlot.stackSize;
aStack.stackSize -= tRealStackLimit - tSlot.stackSize;
bus.mInventory[i].stackSize = tRealStackLimit;

}
}
}
}
return consumed;
}

private static int space(FluidStack in,IFluidStore store){
return store.fill(in, false);

Expand Down
Loading

0 comments on commit 879e754

Please sign in to comment.