From 39fee963d7cf7b600fe493a04969e335ea4f4f6b Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Mon, 10 Jun 2024 15:22:09 +0800 Subject: [PATCH] update --- build.gradle | 2 +- .../BufferedDualInputHatch.java | 44 +- .../metatileentity/PatternDualInputHatch.java | 2 +- .../gt/metatileentity/RemoteInputBus.java | 50 +- .../gt/metatileentity/RemoteInputHatch.java | 103 ++- .../gt/metatileentity/SuperChestME.java | 18 +- .../gt/metatileentity/SuperTankME.java | 594 ++++++++++++++++++ .../util/RecursiveLinkExcpetion.java | 10 + .../mixin/mixins/MixinAEItemStackCompare.java | 17 +- .../main/registration/Registration.java | 9 +- .../assets/proghatches/lang/en_US.lang | 7 + .../assets/proghatches/lang/en_US/SCME.lang | 3 +- .../assets/proghatches/lang/en_US/STME.lang | 2 + .../assets/proghatches/lang/zh_CN.lang | 7 + .../assets/proghatches/lang/zh_CN/SCME.lang | 3 +- .../assets/proghatches/lang/zh_CN/STME.lang | 2 + 16 files changed, 821 insertions(+), 52 deletions(-) create mode 100644 src/main/java/reobf/proghatches/gt/metatileentity/SuperTankME.java create mode 100644 src/main/java/reobf/proghatches/gt/metatileentity/util/RecursiveLinkExcpetion.java create mode 100644 src/main/resources/assets/proghatches/lang/en_US/STME.lang create mode 100644 src/main/resources/assets/proghatches/lang/zh_CN/STME.lang diff --git a/build.gradle b/build.gradle index 691af07..6154356 100644 --- a/build.gradle +++ b/build.gradle @@ -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.15p4' +String versionOverride = '0.0.15p5' 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) { diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java index f3eb381..acdefd4 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java @@ -1180,7 +1180,23 @@ public boolean justUpdated() { justHadNewItems = false; return ret; } - + class PiorityBuffer implements Comparable{ + PiorityBuffer(DualInvBuffer buff){this.buff=buff; + this.piority=getPossibleCopies(buff); + } + DualInvBuffer buff; + int piority; + @Override + public String toString() { + return ""+piority; + } + @Override + public int compareTo(PiorityBuffer o) { + + return -piority+o.piority; + } + + } @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public Optional getFirstNonEmptyInventory() { @@ -1189,23 +1205,7 @@ public boolean justUpdated() { if(Config.experimentalOptimize){ - class PiorityBuffer implements Comparable{ - PiorityBuffer(DualInvBuffer buff){this.buff=buff; - this.piority=getPossibleCopies(buff); - } - DualInvBuffer buff; - int piority; - @Override - public String toString() { - return ""+piority; - } - @Override - public int compareTo(PiorityBuffer o) { - - return -piority+o.piority; - } - - } + return (Optional) inv0.stream().filter(DualInvBuffer::isAccessibleForMulti) .map(s->new PiorityBuffer(s)) @@ -1230,7 +1230,15 @@ private Predicate not(Predicate s) { public Iterator inventories() { markDirty(); dirty=true; + + if(Config.experimentalOptimize){ + return inv0.stream().filter(DualInvBuffer::isAccessibleForMulti) + .map(s->new PiorityBuffer(s)) + .sorted().map(s->{return s.buff;}).iterator(); + // return inv0.stream().filter(DualInvBuffer::isAccessibleForMulti).iterator(); + } return inv0.stream().filter(DualInvBuffer::isAccessibleForMulti).iterator(); + } @Override diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatch.java index 900f637..03589d6 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatch.java @@ -569,7 +569,7 @@ public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCraf } else { items++; - if (items > 4) { + if (items > 16) { clearInv(); return false; } diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/RemoteInputBus.java b/src/main/java/reobf/proghatches/gt/metatileentity/RemoteInputBus.java index 9da1229..45e8a9a 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/RemoteInputBus.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/RemoteInputBus.java @@ -43,6 +43,7 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Utility; import gregtech.common.tileentities.machines.IRecipeProcessingAwareHatch; +import reobf.proghatches.gt.metatileentity.util.RecursiveLinkExcpetion; import reobf.proghatches.lang.LangManager; import reobf.proghatches.main.MyMod; import reobf.proghatches.main.registration.Registration; @@ -102,7 +103,11 @@ public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aP this.x = x; this.y = y; this.z = z; - + if(this.getBaseMetaTileEntity().getWorld().getChunkProvider().chunkExists(x >> 4, z >> 4) == false){ + aPlayer.addChatMessage(new ChatComponentTranslation("programmable_hatches.remote.deferred")); + this.linked = true; + return; + } if (checkBlackList() // blacklist.contains(this.getBaseMetaTileEntity().getWorld().getBlock(x, // y, z).getUnlocalizedName()) @@ -179,6 +184,8 @@ public void addUIWidgets(Builder builder, UIBuildContext buildContext) { if (opt.isPresent() == false) return LangManager.translateToLocal("programmable_hatches.remote.nothing"); + else + checkBlackList(); if (opt.get() instanceof IInventory == false) { return LangManager.translateToLocal("programmable_hatches.remote.dummytarget"); @@ -315,6 +322,7 @@ public boolean checkDepth() { private int count; public boolean checkDepthLoose() { + if(2>1){return false;} if (count++ < 40) return false; count = 0; @@ -323,6 +331,8 @@ public boolean checkDepthLoose() { @Override public int getSizeInventory() { + try(AutoCloseable o=mark()){ + if (!processingRecipe) return 1; // justQueried=true; @@ -332,14 +342,21 @@ public int getSizeInventory() { } if (!linked) return 1; - if (checkDepthLoose()) { + /*if (checkDepthLoose()) { getBaseMetaTileEntity().getWorld().setBlockToAir(this.x, this.y, this.z); return 0; - } + }*/ return opt.filter(s -> s instanceof IInventory).map(s -> ((IInventory) s).getSizeInventory()).orElse(0) + 2; - + } + catch (RecursiveLinkExcpetion e) { + return 0; + } + catch (Exception e) { + e.printStackTrace(); + return 0; + } } @Override public int[] getAccessibleSlotsFromSide(int ordinalSide) { @@ -363,16 +380,16 @@ public void setInventorySlotContents(int aIndex, ItemStack aStack) { @Override @Nullable public ItemStack getStackInSlot(int aIndex) { - + try(AutoCloseable o=mark()){ // justQueried=true; Optional opt = getTile(); if (opt.isPresent() && checkBlackList(opt)) { this.linked = false; } - if (checkDepthLoose()) { + /*if (checkDepthLoose()) { getBaseMetaTileEntity().getWorld().setBlockToAir(this.x, this.y, this.z); return null; - } + }*/ if(aIndex == getCircuitSlot()){ return mInventory[0]; } @@ -408,7 +425,14 @@ public ItemStack getStackInSlot(int aIndex) { return arr.get(aIndex); // }catch(Exception e){e.printStackTrace();return null;} - + } + catch (RecursiveLinkExcpetion e) { + return null; + } + catch (Exception e) { + e.printStackTrace(); + return null; + } } @Override @@ -520,5 +544,13 @@ protected void validateSlotIndex(int slot) { }; } - +private static HashSet record=new HashSet<>(); +public AutoCloseable mark(){ + if(!record.add(this)){ + getBaseMetaTileEntity().getWorld().setBlockToAir(this.x, this.y, this.z); + throw new RecursiveLinkExcpetion(); + }; + + return ()->{record.remove(this);}; +} } diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/RemoteInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/RemoteInputHatch.java index 0744ed8..8a75f3b 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/RemoteInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/RemoteInputHatch.java @@ -2,6 +2,8 @@ import static gregtech.api.enums.Textures.BlockIcons.FLUID_IN_SIGN; +import java.io.Closeable; +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -16,12 +18,15 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import com.gtnewhorizons.modularui.common.widget.TextWidget; @@ -37,6 +42,7 @@ import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.render.TextureFactory; import gregtech.common.tileentities.machines.IRecipeProcessingAwareHatch; +import reobf.proghatches.gt.metatileentity.util.RecursiveLinkExcpetion; import reobf.proghatches.lang.LangManager; import reobf.proghatches.main.MyMod; import reobf.proghatches.main.registration.Registration; @@ -94,7 +100,11 @@ public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aP this.x = x; this.y = y; this.z = z; - + if(this.getBaseMetaTileEntity().getWorld().getChunkProvider().chunkExists(x >> 4, z >> 4) == false){ + aPlayer.addChatMessage(new ChatComponentTranslation("programmable_hatches.remote.deferred")); + this.linked = true; + return; + } if (checkBlackList() // blacklist.contains(this.getBaseMetaTileEntity().getWorld().getBlock(x, // y, z).getUnlocalizedName()) @@ -176,6 +186,8 @@ public void addUIWidgets(Builder builder, UIBuildContext buildContext) { if (opt.isPresent() == false) return LangManager.translateToLocal("programmable_hatches.remote.nothing"); + else + checkBlackList(); if (opt.get() instanceof IFluidHandler == false) { return LangManager.translateToLocal("programmable_hatches.remote.dummytarget"); @@ -215,8 +227,60 @@ public Optional getTile() { } return Optional.ofNullable(this.getBaseMetaTileEntity().getWorld().getTileEntity(x, y, z)); } + @Override + public FluidStack getFluid(int aSlot) { + try(AutoCloseable o=mark()){ + Optional opt = getTile(); + if (opt.isPresent() && checkBlackList(opt)) { + this.linked = false; + } + /*if (checkDepthLoose()) { + getBaseMetaTileEntity().getWorld().setBlockToAir(this.x, this.y, this.z); + return null; + }*/ + + return getTile().map(this::filterTakable) + .map(s->{ + if(aSlot<0||aSlot>=s.size())return null; + return s.get(aSlot); + }).orElse(null); + } + catch (RecursiveLinkExcpetion e) { + return null; + } + catch (Exception e) { + e.printStackTrace(); + return null; + } + } +@Override +public FluidStack getFillableStack() { + try(AutoCloseable o=mark()){ + Optional opt = getTile(); + if (opt.isPresent() && checkBlackList(opt)) { + this.linked = false; + } + /*if (checkDepthLoose()) { + getBaseMetaTileEntity().getWorld().setBlockToAir(this.x, this.y, this.z); + return null; + }*/ + + return getTile().map(this::filterTakable) + .filter(s->s.size()>=1) + .orElseGet(()->ImmutableList.of(null)).get(0); + } + catch (RecursiveLinkExcpetion e) { + return null; + } + catch (Exception e) { + e.printStackTrace(); + return null; + } + - public List filterTakable(TileEntity e) { +} + @SuppressWarnings("unchecked") + public List filterTakable(TileEntity e) { if (processingRecipe == false) return new ArrayList(); @@ -242,7 +306,7 @@ public List filterTakable(TileEntity e) { // } ArrayList arrm = new ArrayList<>(slots); tmp = arrm; - return arrm; + return (List)(Object)arrm; } return new ArrayList<>(); @@ -318,12 +382,26 @@ public boolean checkDepth() { private int count; public boolean checkDepthLoose() { + if(2>1)return false; + + if (count++ < 40) return false; count = 0; return checkDepth(); } - + + + private static HashSet record=new HashSet<>(); + + public AutoCloseable mark(){ + if(!record.add(this)){ + getBaseMetaTileEntity().getWorld().setBlockToAir(this.x, this.y, this.z); + throw new RecursiveLinkExcpetion(); + }; + + return ()->{record.remove(this);}; + } @Override public int getSizeInventory() { @@ -348,20 +426,29 @@ public void updateSlots() { @Override public FluidStack[] getStoredFluid() { - + try(AutoCloseable o=mark()){ Optional opt = getTile(); if (opt.isPresent() && checkBlackList(opt)) { this.linked = false; } - if (checkDepthLoose()) { + /*if (checkDepthLoose()) { getBaseMetaTileEntity().getWorld().setBlockToAir(this.x, this.y, this.z); return new FluidStack[0]; - } + }*/ return getTile().map(this::filterTakable).orElse(new ArrayList<>()).toArray(new FluidStack[0]); + } + catch (RecursiveLinkExcpetion e) { + return new FluidStack[0]; + } + catch (Exception e) { + e.printStackTrace(); + return new FluidStack[0]; + } + + } - protected boolean processingRecipe = false; @Override diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/SuperChestME.java b/src/main/java/reobf/proghatches/gt/metatileentity/SuperChestME.java index 8d5b33e..9a74e1c 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/SuperChestME.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/SuperChestME.java @@ -226,10 +226,10 @@ public ITexture[] getTexturesActive(ITexture aBaseTexture) { return new ITexture[]{aBaseTexture , new IIconTexture (ExtraBlockTextures.MEChest.getIcon(), - 0xffffff) + 0xD7BBEC) , new IIconTexture (ExtraBlockTextures.BlockMEChestItems_Light.getIcon(), - 0xD7BBEC) + 0xffffff) }; } @@ -238,10 +238,10 @@ public ITexture[] getTexturesInactive(ITexture aBaseTexture) { return new ITexture[]{aBaseTexture , new IIconTexture (ExtraBlockTextures.MEChest.getIcon(), - 0xffffff) - , new IIconTexture - (ExtraBlockTextures.BlockMEChestItems_Light.getIcon(), 0xD7BBEC) + /*, new IIconTexture + (ExtraBlockTextures.BlockMEChestItems_Light.getIcon(), + 0xffffff)*/ }; } @@ -423,6 +423,14 @@ protected void fillStacksIntoFirstSlots() { } @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if(!aBaseMetaTileEntity.getWorld().isRemote&&(aTick&16)!=0){ + this.getBaseMetaTileEntity().setActive( + this.getProxy().isPowered()&&this.getProxy().isActive() + ) + ; + + } + super.onPostTick(aBaseMetaTileEntity, aTick); boolean needToSort=false; for(int i=1;i getCellArray(StorageChannel channel) { + if(channel==StorageChannel.FLUIDS) + return ImmutableList.of(handler); + else + return ImmutableList.of(); + + } + + + @Override + public int getPriority() { + + return 0; + } + private ItemStack visualStack() { + return new ItemStack(GregTech_API.sBlockMachines,1, getBaseMetaTileEntity().getMetaTileID()); + } + AENetworkProxy gridProxy; + private void updateValidGridProxySides() { + /*if (disabled) { + getProxy().setValidSides(EnumSet.noneOf(ForgeDirection.class)); + return; + }*/ + getProxy().setValidSides(EnumSet.complementOf(EnumSet.of(getBaseMetaTileEntity().getFrontFacing()))); + + } + @Override + public AENetworkProxy getProxy() { + + if (gridProxy == null) { + gridProxy = new AENetworkProxy(this, "proxy", visualStack(), true); + gridProxy.setFlags(GridFlags.REQUIRE_CHANNEL); + updateValidGridProxySides(); + if (getBaseMetaTileEntity().getWorld() != null) + gridProxy.setOwner(getBaseMetaTileEntity().getWorld() + .getPlayerEntityByName(getBaseMetaTileEntity().getOwnerName())); + } + + return this.gridProxy; + } + @Override + public void saveChanges(IMEInventory cellInventory) { + + markDirty(); + } + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + + return new SuperTankME(mName, mTier, mInventory.length, mDescriptionArray, mTextures); + } + @Override + public void blinkCell(int slot) { + + post(); + } + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + + return new ITexture[]{aBaseTexture + , new IIconTexture + (ExtraBlockTextures.MEChest.getIcon(), + 0xD7BBEC) + , new IIconTexture + (FCPartsTexture.PartFluidTerminal_Bright.getIcon(), + 0xffffff) + + }; + } + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture + , new IIconTexture + (ExtraBlockTextures.MEChest.getIcon(), + 0xD7BBEC) + /*, new IIconTexture + (ExtraBlockTextures.BlockMEChestItems_Light.getIcon(), + 0xffffff)*/ + + }; + } + @Override + public DimensionalCoord getLocation() { + + return new DimensionalCoord((TileEntity)this.getBaseMetaTileEntity()); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + IMEInventoryHandler handler + =new MEInventoryHandler(new UnlimitedWrapper() + , StorageChannel .FLUIDS){ + public boolean getSticky() {return sticky;}; + public int getPriority() {return piority;}; + }; + boolean sticky; + int piority; + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + + super.onFirstTick(aBaseMetaTileEntity); + getProxy().onReady(); + onColorChangeServer(aBaseMetaTileEntity.getColorization()); + } + FluidTank content=new FluidTank(10000); + public class UnlimitedWrapper implements IMEInventory { + + + + public UnlimitedWrapper() { + + } + + @Override + public IAEFluidStack injectItems(IAEFluidStack input, Actionable type, BaseActionSource src) { + int acc=content.fill(input.getFluidStack(), type==Actionable.MODULATE); + IAEFluidStack ret = input.copy(); + ret.decStackSize(acc); + if(ret.getStackSize()==0)return null; + return ret; + } + + @Override + public IAEFluidStack extractItems(IAEFluidStack input, Actionable type, BaseActionSource src) { + if(content.getFluid()!=null&&content.getFluid().getFluid()!=input.getFluid() + ){return null;} + FluidStack suck= content.drain((int) Math.min(Integer.MAX_VALUE,input.getStackSize()), type==Actionable.MODULATE); + if(suck!=null&&suck.amount==0)return null; + return AEFluidStack.create(suck); + } + + @Override + public IItemList getAvailableItems(IItemList out) { + out.addStorage(AEFluidStack.create(content.getFluid())); + return out; + } + + @Override + public StorageChannel getChannel() { + + return StorageChannel.FLUIDS; + } + } + @Override + public boolean isValidSlot(int aIndex) { + + return true; + } + public int getMaxItemCount() { + + return super.getMaxItemCount(); + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + + return true; + } + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + + return true; + } + @Override + public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { + return(aStack.getItem() instanceof ItemFluidPacket); + } + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + + return true; + } + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + + return true; + + } + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + + return true; + } + + @Override + public boolean canTankBeFilled() { + + return true; + } + @Override + public boolean canTankBeEmptied() { + + return true; + } + @Override + public boolean canDrain(ForgeDirection side, Fluid aFluid) { + if(side!=this.getBaseMetaTileEntity().getFrontFacing())return false; + return super.canDrain(side, aFluid); + } + @Override + public boolean canFill(ForgeDirection side, Fluid aFluid) { + if(side!=this.getBaseMetaTileEntity().getFrontFacing())return false; + return super.canFill(side, aFluid); + } + @Override + public int fill(FluidStack aFluid, boolean doFill) { + + return content.fill(aFluid, doFill); + } + @Override + public int fill(ForgeDirection side, FluidStack aFluid, boolean doFill) { + + return content.fill(aFluid, doFill); + } + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if(!aBaseMetaTileEntity.getWorld().isRemote&&(aTick&16)!=0){ + this.getBaseMetaTileEntity().setActive( + this.getProxy().isPowered()&&this.getProxy().isActive() + ) + ; + + } + + super.onPostTick(aBaseMetaTileEntity, aTick); + boolean needToSort=false; + for(int i=0;i w.addTooltip(LangManager.translateToLocal( + "programmable_hatches.gt.metank.tooltip." + + s))); + + + builder.widget(createButton(() -> + sticky + , val -> { + sticky = val;post(); + //updateSlots(); + }, + new ItemDrawable(new ItemStack(Items.slime_ball)), + ImmutableList.of( + StatCollector.translateToLocal("programmable_hatches.gt.sticky") + + ) + + + , 0) + .setPos( 3,3+18*2)); + + builder.widget(new TextFieldWidget() + .setPattern(BaseTextFieldWidget.NATURAL_NUMS) + .setGetter(()->piority+"") + .setSetter(s-> + {try{piority=Integer.parseInt(s);}catch(Exception e){piority=0;};post();}) + .setSynced(true,true) + + .setFocusOnGuiOpen(true).setTextColor(Color.WHITE.dark(1)) + + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD.withOffset(-1, -1, 2, 2)) + .addTooltip(StatCollector.translateToLocal("programmable_hatches.gt.piority")) + .setPos(3+2,18*3+3+1).setSize(16*8,16)) + + ; + + + +} + private Widget createButton(Supplier getter, Consumer setter, IDrawable picture, + List tooltip, int offset) { + return new CycleButtonWidget().setToggle(getter, setter).setTextureGetter(__->picture) + .setVariableBackground(GT_UITextures.BUTTON_STANDARD_TOGGLE).setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(7 + offset * 18, 62).setSize(18, 18).addTooltips(tooltip); +} + @Override +public void loadNBTData(NBTTagCompound aNBT) { + getProxy().readFromNBT(aNBT); + super.loadNBTData(aNBT); + piority=aNBT.getInteger("piority"); + sticky= aNBT.getBoolean("sticky"); + content.readFromNBT(aNBT); +} + protected static int commonSizeCompute(int tier) { + switch (tier) { + case 1 : return 4000000; + case 2 : return 8000000; + case 3 : return 16000000; + case 4 : return 32000000; + case 5 : return 64000000; + case 6 : return 128000000; + case 7 : return 256000000; + case 8 : return 512000000; + case 9 : return 1024000000; + case 10 : return 2147483640; + default : return 0; + } + } +@Override +public void saveNBTData(NBTTagCompound aNBT) { + getProxy().writeToNBT(aNBT); + super.saveNBTData(aNBT); + + content.writeToNBT(aNBT); + aNBT.setInteger("piority", piority); + aNBT.setBoolean("sticky", sticky); +} +@Override +public void setItemNBT(NBTTagCompound aNBT) { + content.writeToNBT(aNBT); + if(piority!=0)aNBT.setInteger("piority", piority); + if(sticky)aNBT.setBoolean("sticky", sticky); +} +@Override +public boolean shouldDropItemAt(int index) { + + return true; +} + +public static String name(int t){ + + return StatCollector.translateToLocalFormatted("mesupertank.name."+(t>=5), suffix[t-1]); +} +public static String[] suffix={"I","II","III","IV","V","I","II","III","IV","V"}; +@Override +public void onColorChangeServer(byte aColor) { + + super.onColorChangeServer(aColor); + AEColor c; + if(aColor==-1){ + c=(AEColor.Transparent); + }else + c=(AEColor.values()[15-aColor]); + +try{ +getProxy().setColor(c); +getGridNode(null).updateState(); +}catch(Exception e){} + +} + +protected void fillStacksIntoFirstSlots() { + final int L = mInventory.length; + HashMap slots = new HashMap<>(L); + HashMap stacks = new HashMap<>(L); + List order = new ArrayList<>(L); + List validSlots = new ArrayList<>(L); + for (int i = 0; i < L; i++) { + if (!isValidSlot(i)) continue; + validSlots.add(i); + ItemStack s = mInventory[i]; + if (s == null) continue; + GT_Utility.ItemId sID = GT_Utility.ItemId.createNoCopy(s); + slots.merge(sID, s.stackSize, Integer::sum); + if (!stacks.containsKey(sID)) stacks.put(sID, s); + order.add(sID); + mInventory[i] = null; + } + int slotindex = 0; + for (GT_Utility.ItemId sID : order) { + int toSet = slots.get(sID); + if (toSet == 0) continue; + int slot = validSlots.get(slotindex); + slotindex++; + mInventory[slot] = stacks.get(sID) + .copy(); + toSet = Math.min(toSet, mInventory[slot].getMaxStackSize()); + mInventory[slot].stackSize = toSet; + slots.merge(sID, toSet, (a, b) -> a - b); + } +} + + +} diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/util/RecursiveLinkExcpetion.java b/src/main/java/reobf/proghatches/gt/metatileentity/util/RecursiveLinkExcpetion.java new file mode 100644 index 0000000..eb01991 --- /dev/null +++ b/src/main/java/reobf/proghatches/gt/metatileentity/util/RecursiveLinkExcpetion.java @@ -0,0 +1,10 @@ +package reobf.proghatches.gt.metatileentity.util; + + + +public class RecursiveLinkExcpetion extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1211161516l;} diff --git a/src/main/java/reobf/proghatches/main/mixin/mixins/MixinAEItemStackCompare.java b/src/main/java/reobf/proghatches/main/mixin/mixins/MixinAEItemStackCompare.java index 50b9ed6..99598f8 100644 --- a/src/main/java/reobf/proghatches/main/mixin/mixins/MixinAEItemStackCompare.java +++ b/src/main/java/reobf/proghatches/main/mixin/mixins/MixinAEItemStackCompare.java @@ -35,18 +35,21 @@ public void a(AEItemStack other,CallbackInfoReturnable r){ Optional a = ItemProgrammingCircuit.getCircuit(other.getItemStack()); Optional b = ItemProgrammingCircuit.getCircuit(this.getItemStack()); - boolean aa=ItemProgrammingCircuit.isNew(other.getItemStack()); - boolean bb=ItemProgrammingCircuit.isNew(this.getItemStack()); - if(aa!=bb){ - r.setReturnValue(aa?1:-1);return; - } + if(a.isPresent()&&b.isPresent()){ - r.setReturnValue(AEItemStack.create(b.get()).compareTo(AEItemStack.create(a.get()))); + int result=AEItemStack.create(b.get()).compareTo(AEItemStack.create(a.get())); + if(result!=0)r.setReturnValue(result); + return; } else if(!a.isPresent()&&b.isPresent()){r.setReturnValue(-1);} else if(a.isPresent()&&!b.isPresent()){r.setReturnValue(1);} else{ - r.setReturnValue(0); + boolean aa=ItemProgrammingCircuit.isNew(other.getItemStack()); + boolean bb=ItemProgrammingCircuit.isNew(this.getItemStack()); + if(aa!=bb){ + r.setReturnValue(aa?1:-1);return; + } + return;//r.setReturnValue(0); } }; diff --git a/src/main/java/reobf/proghatches/main/registration/Registration.java b/src/main/java/reobf/proghatches/main/registration/Registration.java index 24f746f..066e15a 100644 --- a/src/main/java/reobf/proghatches/main/registration/Registration.java +++ b/src/main/java/reobf/proghatches/main/registration/Registration.java @@ -40,6 +40,7 @@ import reobf.proghatches.gt.metatileentity.RemoteInputBus; import reobf.proghatches.gt.metatileentity.RemoteInputHatch; import reobf.proghatches.gt.metatileentity.SuperChestME; +import reobf.proghatches.gt.metatileentity.SuperTankME; import reobf.proghatches.gt.metatileentity.SuperfluidHatch; import reobf.proghatches.gt.metatileentity.multi.LargeProgrammingCircuitProvider; import reobf.proghatches.lang.LangManager; @@ -70,6 +71,7 @@ public class Registration implements Runnable { public final static int CircuitProviderOffsetT0 = 118; public final static int MEChest = 119;//-129 public final static int PatternOffsetBus = 130; + public final static int METank = 131;//-141 @SuppressWarnings("deprecation") @Override public void run() { @@ -329,7 +331,12 @@ public void run() { "mesuperchest."+i , SuperChestME.name(i),i,1+16 ); - + for(int i=1;i<=10;i++) + new SuperTankME( + Config.metaTileEntityOffset +METank+i-1 , + "mesupertank."+i , + SuperTankME.name(i),i,1+16 + ); } diff --git a/src/main/resources/assets/proghatches/lang/en_US.lang b/src/main/resources/assets/proghatches/lang/en_US.lang index 8791757..e2056bd 100644 --- a/src/main/resources/assets/proghatches/lang/en_US.lang +++ b/src/main/resources/assets/proghatches/lang/en_US.lang @@ -323,3 +323,10 @@ programmable_hatches.gt.mechest.tooltip.1=When storage slot(#0) is not empty, wi programmable_hatches.gt.mechest.tooltip.2=The first 2 non-empty input slots are displayed on the left side. programmable_hatches.gt.sticky=Sticky Mode programmable_hatches.gt.piority=Piority +mesupertank.name.false=ME Super Tank %s +mesupertank.name.true=ME Quantum Tank %s +programmable_hatches.gt.metank.tooltip=3 +programmable_hatches.gt.metank.tooltip.0=There are 16 input slots for AE2FC Fluid Packet(#0~#15). +programmable_hatches.gt.metank.tooltip.1=Fluid Packet will be decoded into fluid slot if possible. +programmable_hatches.gt.metank.tooltip.2=The first 2 non-empty input slots are displayed on the left side. +programmable_hatches.remote.deferred=Linked. Status is unknown because target chunk is not loaded. diff --git a/src/main/resources/assets/proghatches/lang/en_US/SCME.lang b/src/main/resources/assets/proghatches/lang/en_US/SCME.lang index 84e9294..fa0b7d1 100644 --- a/src/main/resources/assets/proghatches/lang/en_US/SCME.lang +++ b/src/main/resources/assets/proghatches/lang/en_US/SCME.lang @@ -1 +1,2 @@ -Hold {items} items at maximum \ No newline at end of file +Hold {items} items at maximum +When painted, it will only connect to cable with same or default color. \ No newline at end of file diff --git a/src/main/resources/assets/proghatches/lang/en_US/STME.lang b/src/main/resources/assets/proghatches/lang/en_US/STME.lang new file mode 100644 index 0000000..94ee6e6 --- /dev/null +++ b/src/main/resources/assets/proghatches/lang/en_US/STME.lang @@ -0,0 +1,2 @@ +Hold {fluid}L of fluid at maximum +When painted, it will only connect to cable with same or default color. \ No newline at end of file diff --git a/src/main/resources/assets/proghatches/lang/zh_CN.lang b/src/main/resources/assets/proghatches/lang/zh_CN.lang index 50f96cf..a530676 100644 --- a/src/main/resources/assets/proghatches/lang/zh_CN.lang +++ b/src/main/resources/assets/proghatches/lang/zh_CN.lang @@ -360,3 +360,10 @@ programmable_hatches.gt.mechest.tooltip.1=存储格(#0)未到上限时,输入格 programmable_hatches.gt.mechest.tooltip.2=左侧至多显示输入格中的前2个非空格 programmable_hatches.gt.sticky=黏性模式 programmable_hatches.gt.piority=优先级 +mesupertank.name.false=ME超级缸 %s +mesupertank.name.true=ME量子缸 %s +programmable_hatches.gt.metank.tooltip=3 +programmable_hatches.gt.metank.tooltip.0=一共有16个接收流体封包的输入格(#0~#15) +programmable_hatches.gt.metank.tooltip.1=流体封包会被尽量自动解码注入流体槽 +programmable_hatches.gt.metank.tooltip.2=左侧至多显示输入格中的前2个非空格 +programmable_hatches.remote.deferred=已连接 但目标区块未被加载,状态未知 diff --git a/src/main/resources/assets/proghatches/lang/zh_CN/SCME.lang b/src/main/resources/assets/proghatches/lang/zh_CN/SCME.lang index f5bb309..9510535 100644 --- a/src/main/resources/assets/proghatches/lang/zh_CN/SCME.lang +++ b/src/main/resources/assets/proghatches/lang/zh_CN/SCME.lang @@ -1 +1,2 @@ -最多存储{items}物品 \ No newline at end of file +最多存储{items}物品 +涂色后只能连接同色或默认色线缆 \ No newline at end of file diff --git a/src/main/resources/assets/proghatches/lang/zh_CN/STME.lang b/src/main/resources/assets/proghatches/lang/zh_CN/STME.lang new file mode 100644 index 0000000..6e68055 --- /dev/null +++ b/src/main/resources/assets/proghatches/lang/zh_CN/STME.lang @@ -0,0 +1,2 @@ +最多存储{fluid}L流体 +涂色后只能连接同色或默认色线缆 \ No newline at end of file