Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed Oct 5, 2024
1 parent 1ab834d commit 771dcf5
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
Expand All @@ -63,11 +64,13 @@
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.recipe.check.CheckRecipeResult;
import gregtech.api.util.GT_Config;
import gregtech.api.util.GT_Utility;
import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_InputBus_ME;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
Expand Down Expand Up @@ -133,9 +136,17 @@ public void overridedBehoviour(int minPull) {

try {
GridStorageCache st = (GridStorageCache) proxy.getStorage();

ArrayList<Object> order =new ArrayList();
TreeMultimap<Integer, IMEInventoryHandler<IAEItemStack>> orderMap = TreeMultimap.create((a, b) -> -a + b,
(a, b) -> a.hashCode() - b.hashCode());
(a, b) -> {
if(a==b)return 0;
int diff=a.hashCode() - b.hashCode();
if(diff!=0)return diff;
if(order.indexOf(a)==-1)order.add(a);
if(order.indexOf(b)==-1)order.add(b);
return order.indexOf(a)-order.indexOf(b);
}
);
for (final ICellProvider cc : get(st)) {

List<IMEInventoryHandler> list = cc
Expand Down Expand Up @@ -537,4 +548,16 @@ public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable m
return request.copy().setStackSize(requested-num);
}


@Override
public void saveNBTData(NBTTagCompound aNBT) {
aNBT.setBoolean("reserveFirst", reserveFirst);
super.saveNBTData(aNBT);
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
reserveFirst=aNBT.getBoolean("reserveFirst");
super.loadNBTData(aNBT);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_Input_ME;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
Expand Down Expand Up @@ -112,9 +113,17 @@ public void overridedBehoviour(int minPull) {

try {
GridStorageCache st = (GridStorageCache) proxy.getStorage();

ArrayList<Object> order =new ArrayList();
TreeMultimap<Integer, IMEInventoryHandler<IAEFluidStack>> orderMap = TreeMultimap.create((a, b) -> -a + b,
(a, b) -> a.hashCode() - b.hashCode());
(a, b) -> {
if(a==b)return 0;
int diff=a.hashCode() - b.hashCode();
if(diff!=0)return diff;
if(order.indexOf(a)==-1)order.add(a);
if(order.indexOf(b)==-1)order.add(b);
return order.indexOf(a)-order.indexOf(b);
}
);
for (final ICellProvider cc : get(st)) {

List<IMEInventoryHandler> list = cc
Expand Down Expand Up @@ -512,5 +521,15 @@ public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable m
}
if(requested==num)return null;
return request.copy().setStackSize(requested-num);
}
@Override
public void saveNBTData(NBTTagCompound aNBT) {
aNBT.setBoolean("reserveFirst", reserveFirst);
super.saveNBTData(aNBT);
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
reserveFirst=aNBT.getBoolean("reserveFirst");
super.loadNBTData(aNBT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {

super.onFirstTick(aBaseMetaTileEntity);
getProxy().onReady();
onColorChangeServer(aBaseMetaTileEntity.getColorization());
onColorChangeServer(aBaseMetaTileEntity.getColorization());
post();
}

public class UnlimitedWrapper implements IMEInventory<IAEItemStack> {
Expand All @@ -308,6 +309,7 @@ public UnlimitedWrapper() {

@Override
public IAEItemStack injectItems(IAEItemStack input, Actionable type, BaseActionSource src) {
try{
long l=input.getStackSize();
long compl=0;
if(l>Integer.MAX_VALUE){compl=l-Integer.MAX_VALUE;}
Expand Down Expand Up @@ -336,7 +338,15 @@ public IAEItemStack injectItems(IAEItemStack input, Actionable type, BaseActionS
}


return null;
return null;}finally{

if(voidOverflow&&(mInventory[0]!=null&&
ItemStack.areItemStackTagsEqual(mInventory[0],input.getItemStack())&&
mInventory[0].getItem()==input.getItem()&&
mInventory[0].getItemDamage()==input.getItemDamage()
)
){return null;}
}
}

@Override
Expand Down Expand Up @@ -451,13 +461,27 @@ protected void fillStacksIntoFirstSlots() {
boolean autoUnlock;
boolean suppressSticky;


boolean wasActive;

@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {



if(!aBaseMetaTileEntity.getWorld().isRemote){
if(wasActive!=this.getProxy().isActive()){
wasActive=this.getProxy().isActive();
post();
}
if (voidFull ) {
voidOverflow = false;
mInventory[0]=null;
}
if(mInventory[0]!=null){

if(mInventory[0]!=null)
mInventory[0].stackSize=Math.min
(commonSizeCompute(mTier),mInventory[0].stackSize);
}
}
if(!aBaseMetaTileEntity.getWorld().isRemote&&(aTick&16)!=0){
this.getBaseMetaTileEntity().setActive(
this.getProxy().isPowered()&&this.getProxy().isActive()
Expand Down Expand Up @@ -634,8 +658,46 @@ public void setStackInSlot(int slot, ItemStack stack) {
.addTooltip(StatCollector.translateToLocal("programmable_hatches.gt.piority"))
.setPos(3+2,18*3+3+1).setSize(16*8,16))

;
.widget(new CycleButtonWidget().setToggle(() -> voidFull, val -> {
voidFull = val;

if (!voidFull) {
GT_Utility.sendChatToPlayer(
buildContext.getPlayer(),
GT_Utility.trans("269", "Void Full Mode Disabled"));
} else {
GT_Utility.sendChatToPlayer(
buildContext.getPlayer(),
GT_Utility.trans("270", "Void Full Mode Enabled"));
}
})
.setVariableBackground(GT_UITextures.BUTTON_STANDARD_TOGGLE)
.setStaticTexture(GT_UITextures.OVERLAY_BUTTON_TANK_VOID_ALL)
.setGTTooltip(() -> mTooltipCache.getData("GT5U.machines.digitaltank.voidfull.tooltip"))
.setTooltipShowUpDelay(TOOLTIP_DELAY)
.setPos(3+18*3,3+18*2)
.setSize(18, 18))

.widget(new CycleButtonWidget().setToggle(() -> voidOverflow, val -> {
voidOverflow = val;

if (!voidOverflow) {
GT_Utility.sendChatToPlayer(
buildContext.getPlayer(),
GT_Utility.trans("267", "Overflow Voiding Mode Disabled"));
} else {
GT_Utility.sendChatToPlayer(
buildContext.getPlayer(),
GT_Utility.trans("268", "Overflow Voiding Mode Enabled"));
}
})
.setVariableBackground(GT_UITextures.BUTTON_STANDARD_TOGGLE)
.setStaticTexture(GT_UITextures.OVERLAY_BUTTON_TANK_VOID_EXCESS)
.setGTTooltip(() -> mTooltipCache.getData("GT5U.machines.digitaltank.voidoverflow.tooltip"))
.setTooltipShowUpDelay(TOOLTIP_DELAY)
.setPos(3+18*4,3+18*2)
.setSize(18, 18))
;


}
Expand All @@ -661,6 +723,8 @@ public void loadNBTData(NBTTagCompound aNBT) {
cachedFilter[0]=ItemStack.loadItemStackFromNBT(tag);
updateFilter(cachedFilter[0]);
}
voidFull=aNBT.getBoolean("voidFull" );
voidOverflow= aNBT.getBoolean("voidOverflow" );
}

@Override
Expand All @@ -685,6 +749,8 @@ public void saveNBTData(NBTTagCompound aNBT) {
cachedFilter[0].writeToNBT(tag);
aNBT.setTag("cahcedFilter", tag);
}
aNBT.setBoolean("voidFull", voidFull);
aNBT.setBoolean("voidOverflow", voidOverflow);

}@Override
public void onFacingChange() {
Expand All @@ -707,6 +773,8 @@ public void setItemNBT(NBTTagCompound aNBT) {
aNBT.setTag("Inventory", tItemList);
if(piority!=0)aNBT.setInteger("piority", piority);
if(sticky)aNBT.setBoolean("sticky", sticky);
if(voidFull)aNBT.setBoolean("voidFull", voidFull);
if(voidOverflow)aNBT.setBoolean("voidOverflow", voidOverflow);
}
@Override
public boolean shouldDropItemAt(int index) {
Expand Down Expand Up @@ -778,6 +846,7 @@ public ItemStack decrStackSize(int aIndex, int aAmount) {
post();}
}


boolean voidFull;
boolean voidOverflow;

}
Loading

0 comments on commit 771dcf5

Please sign in to comment.