From dac5ea017313cbdacdec126e8b4f0ef2026cd633 Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Wed, 24 Jul 2024 00:44:50 +0800 Subject: [PATCH] update --- build.gradle | 2 +- .../reobf/proghatches/eucrafting/AECover.java | 4 + .../proghatches/eucrafting/BridgingData.java | 2 + .../proghatches/eucrafting/InterfaceData.java | 3 + .../eucrafting/InterfaceP2PData.java | 2 +- .../eucrafting/InterfaceP2PEUData.java | 2 +- .../eucrafting/InterfaceP2PNoFluidData.java | 2 +- .../proghatches/eucrafting/PartEUSource.java | 1 + .../BufferedDualInputHatch.java | 13 +- .../gt/metatileentity/DualInputHatch.java | 365 +++++++++++++++++- .../metatileentity/PatternDualInputHatch.java | 14 +- .../ProgrammingCircuitProvider.java | 196 +++++++++- ...ogrammingCircuitProviderPrefabricated.java | 7 + .../LargeProgrammingCircuitProvider.java | 209 +++++++++- .../reobf/proghatches/item/ItemFixer.java | 9 +- .../reobf/proghatches/item/ItemUpgrades.java | 4 +- .../assets/proghatches/lang/en_US.lang | 13 + .../assets/proghatches/lang/zh_CN.lang | 13 + .../proghatches/textures/items/upgrade1.png | Bin 0 -> 314 bytes 19 files changed, 793 insertions(+), 68 deletions(-) create mode 100644 src/main/resources/assets/proghatches/textures/items/upgrade1.png diff --git a/build.gradle b/build.gradle index b8e7318..dc4a6bb 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.17p12' +String versionOverride = '0.0.17p13' 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/eucrafting/AECover.java b/src/main/java/reobf/proghatches/eucrafting/AECover.java index ac79eba..7d8bfb0 100644 --- a/src/main/java/reobf/proghatches/eucrafting/AECover.java +++ b/src/main/java/reobf/proghatches/eucrafting/AECover.java @@ -19,10 +19,12 @@ import appeng.api.networking.IGridConnection; import appeng.api.networking.IGridHost; import appeng.api.networking.IGridNode; +import appeng.api.networking.security.IActionHost; import appeng.api.networking.ticking.ITickManager; import appeng.api.util.AECableType; import appeng.api.util.DimensionalCoord; import appeng.api.util.IReadOnlyCollection; +import appeng.helpers.IInterfaceHost; import appeng.me.GridAccessException; import appeng.me.GridConnection; import appeng.me.GridNode; @@ -77,6 +79,7 @@ public AECover(Class c) { Class clazz; public static class DummyData implements Data { + public IInterfaceHost getInterfaceOrNull(){return null;}; public void setTag(NBTTagCompound tagCompound) { } @@ -205,6 +208,7 @@ public TileEntity fakeTile() { } public static interface Data extends ISerializableObject, IGridProxyable { + IInterfaceHost getInterfaceOrNull(); default boolean hasModularGUI(){return false;} default String tagName(){ NBTTagCompound tag = getTag(); diff --git a/src/main/java/reobf/proghatches/eucrafting/BridgingData.java b/src/main/java/reobf/proghatches/eucrafting/BridgingData.java index 2032c6b..1bdc819 100644 --- a/src/main/java/reobf/proghatches/eucrafting/BridgingData.java +++ b/src/main/java/reobf/proghatches/eucrafting/BridgingData.java @@ -8,6 +8,7 @@ import appeng.api.util.DimensionalCoord; import appeng.api.util.IReadOnlyCollection; import appeng.api.util.WorldCoord; +import appeng.helpers.IInterfaceHost; import appeng.me.GridConnection; import appeng.me.helpers.AENetworkProxy; import gregtech.api.interfaces.tileentity.ICoverable; @@ -19,6 +20,7 @@ import reobf.proghatches.main.MyMod; public class BridgingData implements Data { + public IInterfaceHost getInterfaceOrNull(){return null;}; public interface TriConsumer { public void accept(a aa, b bb, c cc); diff --git a/src/main/java/reobf/proghatches/eucrafting/InterfaceData.java b/src/main/java/reobf/proghatches/eucrafting/InterfaceData.java index 10203b4..722557f 100644 --- a/src/main/java/reobf/proghatches/eucrafting/InterfaceData.java +++ b/src/main/java/reobf/proghatches/eucrafting/InterfaceData.java @@ -29,6 +29,7 @@ import appeng.api.util.DimensionalCoord; import appeng.api.util.IConfigManager; import appeng.api.util.IConfigurableObject; +import appeng.api.util.IInterfaceViewable; import appeng.helpers.DualityInterface; import appeng.helpers.ICustomNameObject; import appeng.helpers.IInterfaceHost; @@ -62,6 +63,8 @@ public class InterfaceData implements Data, IInterfaceHost, IGridTickable, IUpgr IConfigurableObject, IPriorityHost, IActualSideProvider { + + public IInterfaceHost getInterfaceOrNull(){return this;}; public void setTag(NBTTagCompound tagCompound) { tag = tagCompound; diff --git a/src/main/java/reobf/proghatches/eucrafting/InterfaceP2PData.java b/src/main/java/reobf/proghatches/eucrafting/InterfaceP2PData.java index 41d807a..5c9e70b 100644 --- a/src/main/java/reobf/proghatches/eucrafting/InterfaceP2PData.java +++ b/src/main/java/reobf/proghatches/eucrafting/InterfaceP2PData.java @@ -76,7 +76,7 @@ public class InterfaceP2PData implements AECover.IMemoryCardSensitive, Data, IIn public void setTag(NBTTagCompound tagCompound) { tag = tagCompound; } - + public IInterfaceHost getInterfaceOrNull(){return duality;}; public NBTTagCompound getTag() { return tag; } diff --git a/src/main/java/reobf/proghatches/eucrafting/InterfaceP2PEUData.java b/src/main/java/reobf/proghatches/eucrafting/InterfaceP2PEUData.java index 31f80a4..3505b0a 100644 --- a/src/main/java/reobf/proghatches/eucrafting/InterfaceP2PEUData.java +++ b/src/main/java/reobf/proghatches/eucrafting/InterfaceP2PEUData.java @@ -88,7 +88,7 @@ public class InterfaceP2PEUData implements AECover.IMemoryCardSensitive, Data, I public void setTag(NBTTagCompound tagCompound) { tag = tagCompound; } - + public IInterfaceHost getInterfaceOrNull(){return duality;}; public NBTTagCompound getTag() { return tag; } diff --git a/src/main/java/reobf/proghatches/eucrafting/InterfaceP2PNoFluidData.java b/src/main/java/reobf/proghatches/eucrafting/InterfaceP2PNoFluidData.java index 3467012..37df4c4 100644 --- a/src/main/java/reobf/proghatches/eucrafting/InterfaceP2PNoFluidData.java +++ b/src/main/java/reobf/proghatches/eucrafting/InterfaceP2PNoFluidData.java @@ -72,7 +72,7 @@ public class InterfaceP2PNoFluidData implements AECover.IMemoryCardSensitive, Da public void setTag(NBTTagCompound tagCompound) { tag = tagCompound; } - + public IInterfaceHost getInterfaceOrNull(){return duality;}; public NBTTagCompound getTag() { return tag; } diff --git a/src/main/java/reobf/proghatches/eucrafting/PartEUSource.java b/src/main/java/reobf/proghatches/eucrafting/PartEUSource.java index 5df80fb..ec20f93 100644 --- a/src/main/java/reobf/proghatches/eucrafting/PartEUSource.java +++ b/src/main/java/reobf/proghatches/eucrafting/PartEUSource.java @@ -984,4 +984,5 @@ public ForgeDirection getLazerDir() { public List getLazerP2POuts() { return null; } + } diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java index 3f47697..7bb37ac 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java @@ -560,8 +560,8 @@ public boolean recordRecipeOrClassify(ListeningFluidTank[] fin, ItemStack[] iin) @Override public ItemStack[] getItemInputs() { - ItemStack[] condensed = filterStack.apply(mStoredItemInternal); - //System.out.print(Arrays.toString(condensed)); + /*ItemStack[] condensed = filterStack.apply(mStoredItemInternal); + ItemStack additional = getStackInSlot(getCircuitSlot()); if (additional == null) return condensed; @@ -571,12 +571,19 @@ public ItemStack[] getItemInputs() { bruh[before_size] = additional; System.arraycopy(condensed, 0, bruh, 0, before_size); return bruh; + */ + + ItemStack[] condensed = filterStack.apply(mStoredItemInternal,shared.getItems()); + + return condensed; + + } @Override public FluidStack[] getFluidInputs() { - return asFluidStack.apply(mStoredFluidInternal); + return asFluidStack.apply(mStoredFluidInternal,shared.getFluid()); } } diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java index 5d0a96f..70b552c 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java @@ -37,11 +37,13 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import net.minecraft.util.Tuple; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidTank; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -50,6 +52,7 @@ import com.gtnewhorizons.modularui.api.ModularUITextures; import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.drawable.Text; import com.gtnewhorizons.modularui.api.drawable.UITexture; import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; @@ -57,8 +60,10 @@ import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.Interactable; import com.gtnewhorizons.modularui.api.widget.Widget; import com.gtnewhorizons.modularui.api.widget.Widget.ClickData; +import com.gtnewhorizons.modularui.common.fluid.FluidStackTank; import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; import com.gtnewhorizons.modularui.common.internal.wrapper.ModularUIContainer; import com.gtnewhorizons.modularui.common.widget.ButtonWidget; @@ -72,7 +77,9 @@ import appeng.api.AEApi; import appeng.api.IAppEngApi; +import appeng.api.config.Actionable; import appeng.api.networking.IGrid; +import appeng.api.networking.IGridCache; import appeng.api.networking.IGridHost; import appeng.api.networking.IGridNode; import appeng.api.networking.security.BaseActionSource; @@ -83,10 +90,15 @@ import appeng.api.storage.IExternalStorageHandler; import appeng.api.storage.IMEInventory; import appeng.api.storage.StorageChannel; +import appeng.api.storage.data.IAEFluidStack; +import appeng.api.storage.data.IAEItemStack; import appeng.api.util.AECableType; import appeng.core.Api; import appeng.helpers.IInterfaceHost; import appeng.me.helpers.IGridProxyable; +import appeng.util.item.AEFluidStack; +import appeng.util.item.AEItemStack; +import appeng.util.item.AEStack; import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.SoundResource; @@ -108,6 +120,7 @@ import gregtech.api.util.GT_TooltipDataCache.TooltipData; import gregtech.common.tileentities.machines.IDualInputHatch; import gregtech.common.tileentities.machines.IDualInputInventory; +import reobf.proghatches.eucrafting.AECover; import reobf.proghatches.gt.metatileentity.util.BaseSlotPatched; import reobf.proghatches.gt.metatileentity.util.IMultiCircuitSupport; import reobf.proghatches.gt.metatileentity.util.IProgrammingCoverBlacklisted; @@ -609,7 +622,7 @@ private ModularWindow createSharedItemWindow(UIBuildContext buildContext) { - ModularWindow.Builder builder = ModularWindow.builder(32, 32+16*4); + ModularWindow.Builder builder = ModularWindow.builder(36+18*3, 36+18*4); builder.setBackground(GT_UITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); builder.setGuiTint(getGUIColorization()); builder.setDraggable(true); @@ -620,6 +633,138 @@ private ModularWindow createSharedItemWindow(UIBuildContext buildContext) { builder.widget(catalystSlot(new ItemStackHandler(shared.circuitInv), i).setPos(8-1, 8-1+18+18*i)); + int posoffset=0; + for(int i=0;i tooltip) { + FluidStack fluid = getContent(); + if (fluid != null) { + addFluidNameInfo(tooltip, fluid); + tooltip.add(Text.localised("modularui.fluid.phantom.amount", fluid.amount)); + addAdditionalFluidInfo(tooltip, fluid); + if (!Interactable.hasShiftDown()) { + tooltip.add(Text.EMPTY); + tooltip.add(Text.localised("modularui.tooltip.shift")); + } + } else { + tooltip.add( + Text.localised("modularui.fluid.empty") + .format(EnumChatFormatting.WHITE)); + } + } + @Override + protected void tryClickPhantom(ClickData clickData, ItemStack cursorStack) {} + + @Override + protected void tryScrollPhantom(int direction) {} + + public void detectAndSendChanges(boolean init) { + + if(cd--<0) + {cd=10; + FluidStack is=null; + Net net = getNetwork(); + if(net!=null){ + IStorageGrid cahce = net.g.getCache(IStorageGrid.class); + if(cahce!=null){ + IAEFluidStack aeis = cahce.getFluidInventory().getStorageList().findPrecise(AEFluidStack.create(shared.markedFluid.get(fi))); + if(aeis!=null)is=aeis.getFluidStack(); + } + } + ft.setFluid(is); + //todo + //this.setfl + + } + + + super.detectAndSendChanges(init); + }; + + } + + .setPos(8-1+18*3+4, 8-1+18*posoffset)); + posoffset++; + } + + + + return builder.build(); } @@ -685,7 +830,7 @@ private ItemStack[] dualItem() { } private FluidStack[] dualFluid() { - return asFluidStack.apply(mStoredFluid); + return asFluidStack.apply(mStoredFluid,shared.getFluid()); } public DualInv theInv = new DualInv(); @@ -710,8 +855,9 @@ public boolean isEmpty() { @Override public ItemStack[] getItemInputs() { - - return dualItem(); + ItemStack[] is=dualItem(); + //System.out.println(Arrays.toString(is)); + return is; } @Override @@ -723,7 +869,10 @@ public FluidStack[] getFluidInputs() { public interface VargsFunction { R apply(T... t); } - VargsFunction asFluidStack = (s) -> Arrays.stream(s).flatMap( Arrays::stream).map(FluidTank::getFluid) + VargsFunction asFluidStack = (s) -> Arrays.stream(s).flatMap( Arrays::stream).map(f->{ + if(f instanceof FluidTank){return ((FluidTank) f).getFluid();} + else if(f instanceof FluidStack){return (FluidStack)f;}else{throw new RuntimeException();} + }) .filter(a -> a != null && a.amount > 0).toArray(FluidStack[]::new); VargsFunction filterStack = (s) -> Arrays.stream(s).flatMap( Arrays::stream).filter(a -> a != null) .toArray(ItemStack[]::new); @@ -1628,28 +1777,131 @@ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex public OptioanlSharedContents shared=new OptioanlSharedContents(); public class OptioanlSharedContents{ + + ArrayList shadowItems=new ArrayList<>(); + ArrayList shadowFluid=new ArrayList<>(); + ArrayList cachedItems=new ArrayList<>(); + ArrayList cachedFluid=new ArrayList<>(); + ArrayList markedItems=new ArrayList<>(); + ArrayList markedFluid=new ArrayList<>(); + public void reinit(){ while(circuitInv.size() markedFluid.get(slotIndex), (stack) -> { + + + markedFluid.set(slotIndex, stack); + }, capacity); + } public boolean endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase controller) { + if(isDummy())return true; + boolean storageMissing=false; + Net net = getNetwork(); + IStorageGrid cahce=null; + if(net==null)storageMissing=true; + else{ + cahce=net.g.getCache(IStorageGrid.class); + if(cahce==null)storageMissing=true; + } + + for(int i=0;is.stackSize).orElse(0); + if(consumed>0&&storageMissing)return false; + ItemStack extract=sis.copy(); + extract.stackSize=consumed; + + IAEItemStack whatweget=cahce.getItemInventory().extractItems(AEItemStack.create(extract), Actionable.MODULATE, new MachineSource( net.h)); + int numweget=0; + if(whatweget!=null)numweget=(int) whatweget.getStackSize(); + if(numweget!=consumed){return false;} + } + } + for(int i=0;is.amount).orElse(0); + if(consumed>0&&storageMissing)return false; + FluidStack extract=sis.copy(); + extract.amount=consumed; + + IAEFluidStack whatweget=cahce.getFluidInventory().extractItems(AEFluidStack.create(extract), Actionable.MODULATE, new MachineSource( net.h)); + int numweget=0; + if(whatweget!=null)numweget=(int) whatweget.getStackSize(); + if(numweget!=consumed){return false;} + } + } + + + return true; } public void startRecipeProcessing() { + if(isDummy())return; + IGrid net = getNetwork().g; + IStorageGrid cahce=null; + if(net!=null) + cahce=net.getCache(IStorageGrid.class); + shadowItems.clear(); + shadowFluid.clear(); + cachedItems.clear(); + cachedFluid.clear(); + for(int i=0;i0) - - - te.getWorld().spawnEntityInWorld( new EntityItem(te.getWorld(),te.getXCoord(),te.getYCoord(),te.getZCoord(), new ItemStack(MyMod.upgrades,circuitUpgrades,0)) ); - - + if(itemMEUpgrades>0) + te.getWorld().spawnEntityInWorld( + new EntityItem(te.getWorld(),te.getXCoord(),te.getYCoord(),te.getZCoord(), new ItemStack(MyMod.upgrades,itemMEUpgrades,1)) + ); + if(fluidMEUpgrades>0) + te.getWorld().spawnEntityInWorld( + new EntityItem(te.getWorld(),te.getXCoord(),te.getYCoord(),te.getZCoord(), new ItemStack(MyMod.upgrades,fluidMEUpgrades,2)) + ); } public NBTTagCompound serList(ArrayList ls){ NBTTagCompound tag=new NBTTagCompound(); @@ -1660,6 +1912,15 @@ public NBTTagCompound serList(ArrayList ls){ } return tag; } + public NBTTagCompound serListF(ArrayList ls){ + NBTTagCompound tag=new NBTTagCompound(); + tag.setInteger("len", ls.size()); + for(int i=0;i deserList(NBTTagCompound tag){ ArrayList ls=new ArrayList(); int len=tag.getInteger("len"); @@ -1668,17 +1929,29 @@ public ArrayList deserList(NBTTagCompound tag){ } return ls; } - + public ArrayList deserListF(NBTTagCompound tag){ + ArrayList ls=new ArrayList(); + int len=tag.getInteger("len"); + for(int i=0;i all=new ArrayList<>(); all.addAll(circuitInv); + all.addAll(cachedItems); + return all.toArray(new ItemStack[0]); } - public FluidStack[] getFluid(){return new FluidStack[0];} + public FluidStack[] getFluid(){ + ArrayList all=new ArrayList<>(); + all.addAll(cachedFluid); + return all.toArray(new FluidStack[0]);} public boolean isDummy(){return circuitUpgrades+itemMEUpgrades+fluidMEUpgrades==0;} @@ -1705,6 +1978,8 @@ public NBTTagCompound ser(){ tag.setInteger("itemMEUpgrades", itemMEUpgrades); tag.setInteger("fluidMEUpgrades", fluidMEUpgrades); tag.setTag("circuitInv", serList(circuitInv)); + tag.setTag("markedItems", serList(markedItems)); + tag.setTag("markedFluid", serListF(markedFluid)); return tag;} public void deser(NBTTagCompound tag){ @@ -1712,8 +1987,15 @@ public void deser(NBTTagCompound tag){ itemMEUpgrades=tag.getInteger("itemMEUpgrades"); fluidMEUpgrades=tag.getInteger("fluidMEUpgrades"); circuitInv=deserList(tag.getCompoundTag("circuitInv")); + markedItems=deserList(tag.getCompoundTag("markedItems")); + markedFluid=deserListF(tag.getCompoundTag("markedFluid")); while(circuitInv.size()>circuitUpgrades)circuitInv.remove(circuitInv.size()-1); while(circuitInv.size()itemMEUpgrades)markedItems.remove(markedItems.size()-1); + while(markedItems.size()fluidMEUpgrades)markedFluid.remove(markedFluid.size()-1); + while(markedFluid.size() toReturn = new ArrayList<>(); - + //ArrayList toReturn = new ArrayList<>(); + private appeng.util.item.ItemList ret = new appeng.util.item.ItemList(); @Override public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table) { // this.getProxy().getEnergy().extractAEPower(amt, mode, @@ -134,8 +142,8 @@ public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCraf } ItemStack circuitItem = (patternDetails.getOutput(table, this.getBaseMetaTileEntity().getWorld())); - toReturn.add((circuitItem)); - + + ret.add(AEItemStack.create(circuitItem)); return true; } @@ -181,11 +189,10 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { } public void returnItems() { - toReturn.replaceAll(s -> Optional - .ofNullable(getStorageGrid().getItemInventory().injectItems(AEItemStack.create(s), Actionable.MODULATE, - new MachineSource((IActionHost) getBaseMetaTileEntity()))) - .filter(ss -> ss.getStackSize() <= 0).map(ss -> ss.getItemStack()).orElse(null)); - toReturn.removeIf(Objects::isNull); + ret.forEach(s-> + getStorageGrid().getItemInventory().injectItems(s, Actionable.MODULATE, new MachineSource((IActionHost) getBaseMetaTileEntity()) + )); + ret.clear(); } boolean legacy; @@ -381,7 +388,7 @@ public CircuitProviderPatternDetial(@Nonnull ItemStack o) { public ItemStack getPattern() { return Optional.of(new ItemStack(MyMod.fakepattern)).map(s -> { - s.stackTagCompound = out.writeToNBT(new NBTTagCompound()); + s.stackTagCompound = (NBTTagCompound) out.writeToNBT(new NBTTagCompound()).copy(); return s; }).get(); @@ -435,7 +442,7 @@ public boolean canSubstitute() { @Override public ItemStack getOutput(InventoryCrafting craftingInv, World world) { - return out; + return out.copy(); } @Override @@ -525,14 +532,47 @@ public void addUIWidgets(Builder builder, UIBuildContext buildContext) { builder.widget(SlotGroup.ofItemHandler(inventoryHandler, 4).startFromSlot(0).endAtSlot(mInventory.length-1) .background(new IDrawable[] { getGUITextureSet().getItemSlot() }).build().setPos(3, 3)); } + private NBTTagCompound writeItem(final IAEItemStack finalOutput2) { + final NBTTagCompound out = new NBTTagCompound(); + + if (finalOutput2 != null) { + finalOutput2.writeToNBT(out); + } + + return out; + } + private appeng.util.item.ItemList readList(final NBTTagList tag) { + final appeng.util.item.ItemList out = new appeng.util.item.ItemList(); + + if (tag == null) { + return out; + } + + for (int x = 0; x < tag.tagCount(); x++) { + final IAEItemStack ais = AEItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(x)); + if (ais != null) { + out.add(ais); + } + } + return out; + } + private NBTTagList writeList(final IItemList myList) { + final NBTTagList out = new NBTTagList(); + + for (final IAEItemStack ais : myList) { + out.appendTag(this.writeItem(ais)); + } + + return out; + } @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); int[] count = new int[1]; - toReturn.forEach(s -> aNBT.setTag("toReturn" + (count[0]++), s.writeToNBT(new NBTTagCompound()))); + aNBT.setTag("ret", this.writeList(this.ret)); getProxy().writeToNBT(aNBT); Optional.ofNullable(customName).ifPresent(s -> aNBT.setString("customName", s)); //aNBT.setString("customName",customName); @@ -545,12 +585,10 @@ public void saveNBTData(NBTTagCompound aNBT) { public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - toReturn.clear(); + this.ret = this.readList((NBTTagList) aNBT.getTag("ret")); int[] count = new int[1]; NBTTagCompound c; - while ((c = (NBTTagCompound) aNBT.getTag("toReturn" + (count[0]++))) != null) { - toReturn.add(ItemStack.loadItemStackFromNBT(c)); - } + getProxy().readFromNBT(aNBT); ; customName=aNBT.getString("customName"); @@ -634,7 +672,7 @@ public Collection getCircuit() { @Override public void complete() { - returnItems(); + //returnItems(); } @@ -675,7 +713,127 @@ public boolean isValidSlot(int aIndex) { } @Override public ItemStack getStackInSlot(int aIndex) {onBlockDestroyed(); - // TODO Auto-generated method stub + + + + return super.getStackInSlot(aIndex); } +//public Object getTile(){return this.getBaseMetaTileEntity();} + + + +@Override +public int rows() { + + return 0; +} + +@Override +public int rowSize() { + + return 0; +} + + +static IInventory EMPTY=new IInventory(){ + + @Override + public int getSizeInventory() { + + return 0; + } + + @Override + public ItemStack getStackInSlot(int slotIn) { + + return null; + } + + @Override + public ItemStack decrStackSize(int index, int count) { + + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int index) { + + return null; + } + + @Override + public void setInventorySlotContents(int index, ItemStack stack) { + + + } + + @Override + public String getInventoryName() { + + return "N/A"; + } + + @Override + public boolean hasCustomInventoryName() { + + return false; + } + + @Override + public int getInventoryStackLimit() { + + return 0; + } + + @Override + public void markDirty() { + + + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + + return false; + } + + @Override + public void openInventory() { + + + } + + @Override + public void closeInventory() { + + + } + + @Override + public boolean isItemValidForSlot(int index, ItemStack stack) { + + return false; + }};; +@Override +public IInventory getPatterns() { + + return EMPTY; +} +@Override +public String getName() { + + return "N/A"; +} +@Override +public TileEntity getTileEntity() { + + return (TileEntity) this.getBaseMetaTileEntity(); +} + +@Override +public boolean shouldDisplay() { + + return false; +} } diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/ProgrammingCircuitProviderPrefabricated.java b/src/main/java/reobf/proghatches/gt/metatileentity/ProgrammingCircuitProviderPrefabricated.java index 05f0c95..2b415ec 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/ProgrammingCircuitProviderPrefabricated.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/ProgrammingCircuitProviderPrefabricated.java @@ -113,6 +113,7 @@ public boolean patternDirty() { static void init(){ if(init==true)return; init=true; + System.out.println("init!!!!"); reg(0,GregTech_API.getConfigurationCircuitList(100)); ItemList[][] all = new ItemList[][]{{ Shape_Mold_Bottle, @@ -225,6 +226,12 @@ static void init(){ reg(5,is); } + prefab.values().forEach(s->s.removeIf(isy->{ + if(isy==null)System.out.println("Null:"+s); + return isy==null;})); + + + } static private void reg(int a,Collection raw){ diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/multi/LargeProgrammingCircuitProvider.java b/src/main/java/reobf/proghatches/gt/metatileentity/multi/LargeProgrammingCircuitProvider.java index 81c5760..e7fbfa1 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/multi/LargeProgrammingCircuitProvider.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/multi/LargeProgrammingCircuitProvider.java @@ -52,6 +52,7 @@ import com.gtnewhorizons.modularui.common.widget.TextWidget; import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; +import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.config.PowerMultiplier; import appeng.api.implementations.IPowerChannelState; @@ -69,8 +70,11 @@ import appeng.api.networking.security.IActionHost; import appeng.api.networking.security.MachineSource; import appeng.api.networking.storage.IStorageGrid; +import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IItemList; import appeng.api.util.AECableType; import appeng.api.util.DimensionalCoord; +import appeng.api.util.IInterfaceViewable; import appeng.block.crafting.BlockAdvancedCraftingUnit; import appeng.block.crafting.BlockCraftingUnit; import appeng.core.Api; @@ -103,9 +107,12 @@ import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import reobf.proghatches.block.BlockIOHub; @@ -124,7 +131,7 @@ public class LargeProgrammingCircuitProvider extends GT_MetaTileEntity_EnhancedMultiBlockBase implements ISurvivalConstructable, IGridProxyable, ICraftingProvider, IInstantCompletable, ICircuitProvider, - + IInterfaceViewable, IPowerChannelState { @@ -141,6 +148,7 @@ public LargeProgrammingCircuitProvider(int aID, String aName, String aNameRegion @Override public void onFacingChange() { + updateValidGridProxySides(); super.onFacingChange(); } @@ -565,24 +573,61 @@ public void saveNBTData(NBTTagCompound aNBT) { aNBT.setInteger("multiply", multiply); getProxy().writeToNBT(aNBT); int[] count = new int[1]; - toReturn.forEach(s -> aNBT.setTag("toReturn" + (count[0]++), s.writeToNBT(new NBTTagCompound()))); + //toReturn.forEach(s -> aNBT.setTag("toReturn" + (count[0]++), s.writeToNBT(new NBTTagCompound()))); + aNBT.setTag("ret", this.writeList(this.ret)); aNBT.setInteger("cacheState", cacheState.ordinal()); count[0]=0; patternCache.forEach(s -> aNBT.setTag("patternCache" + (count[0]++), s.writeToNBT(new NBTTagCompound()))); super.saveNBTData(aNBT); - } + } + private NBTTagCompound writeItem(final IAEItemStack finalOutput2) { + final NBTTagCompound out = new NBTTagCompound(); + + if (finalOutput2 != null) { + finalOutput2.writeToNBT(out); + } + + return out; + } + private appeng.util.item.ItemList readList(final NBTTagList tag) { + final appeng.util.item.ItemList out = new appeng.util.item.ItemList(); + + if (tag == null) { + return out; + } + for (int x = 0; x < tag.tagCount(); x++) { + final IAEItemStack ais = AEItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(x)); + if (ais != null) { + out.add(ais); + } + } + + return out; + } + private NBTTagList writeList(final IItemList myList) { + final NBTTagList out = new NBTTagList(); + + for (final IAEItemStack ais : myList) { + out.appendTag(this.writeItem(ais)); + } + + return out; + } + @Override public void loadNBTData(NBTTagCompound aNBT) { multiply=aNBT.getInteger("multiply"); getProxy().readFromNBT(aNBT); - toReturn.clear(); + + this.ret = this.readList((NBTTagList) aNBT.getTag("ret")); + //toReturn.clear(); patternCache.clear(); int[] count = new int[1]; NBTTagCompound c; - while ((c = (NBTTagCompound) aNBT.getTag("toReturn" + (count[0]++))) != null) { + /*while ((c = (NBTTagCompound) aNBT.getTag("toReturn" + (count[0]++))) != null) { toReturn.add(ItemStack.loadItemStackFromNBT(c)); - } + }*/ count[0]=0; while ((c = (NBTTagCompound) aNBT.getTag("patternCache" + (count[0]++))) != null) { patternCache.add(ItemStack.loadItemStackFromNBT(c)); @@ -592,12 +637,13 @@ public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); } - ArrayList toReturn = new ArrayList<>(); - + //ArrayList toReturn = new ArrayList<>(); + private appeng.util.item.ItemList ret = new appeng.util.item.ItemList(); + @SuppressWarnings({ "deprecation", "unchecked" }) public static void shut(GT_MetaTileEntity_MultiBlockBase thiz,String reason){ if(shut==null){ - + try { Class.forName("gregtech.api.util.shutdown.ShutDownReason"); //2.6.0+ @@ -652,7 +698,8 @@ public void accept(GT_MetaTileEntity_MultiBlockBase a,String reason) { public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table) { if(!getBaseMetaTileEntity().isActive())return false; try { - if (ItemProgrammingCircuit.getCircuit(patternDetails.getOutputs()[0].getItemStack()).map(ItemStack::getItem) + if(!(patternDetails instanceof ProgrammingCircuitProvider.CircuitProviderPatternDetial)){return false;} + if (ItemProgrammingCircuit.getCircuit(((CircuitProviderPatternDetial)patternDetails).out).map(ItemStack::getItem) .orElse(null) == MyMod.progcircuit) { shut(this,null); return false; @@ -666,9 +713,11 @@ public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCraf } catch (GridAccessException e) { } + + ItemStack circuitItem = (patternDetails.getOutput(table, this.getBaseMetaTileEntity().getWorld())); - toReturn.add((circuitItem)); - + //toReturn.add((circuitItem)); + ret.add(AEItemStack.create(circuitItem)); return true; } @@ -730,11 +779,15 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { } public void returnItems() { - toReturn.replaceAll(s -> Optional + ret.forEach(s-> + getStorageGrid().getItemInventory().injectItems(s, Actionable.MODULATE, new MachineSource((IActionHost) getBaseMetaTileEntity()) + )); + ret.clear(); + /*toReturn.replaceAll(s -> Optional .ofNullable(getStorageGrid().getItemInventory().injectItems(AEItemStack.create(s), Actionable.MODULATE, - new MachineSource((IActionHost) getBaseMetaTileEntity()))) + ))) .filter(ss -> ss.getStackSize() <= 0).map(ss -> ss.getItemStack()).orElse(null)); - toReturn.removeIf(Objects::isNull); + toReturn.removeIf(Objects::isNull);*/ } @@ -778,20 +831,23 @@ public void updateCache() { } private ItemStack mul( ItemStack s){ s=s.copy(); - s.stackSize=multiply; + s.stackSize=Math.max(multiply,1); return s; } @MENetworkEventSubscribe public void powerChange(MENetworkPowerStatusChange w){ + //System.out.println("xxxxxxxxxxx1"); cacheState = CacheState.DIRTY; } @MENetworkEventSubscribe public void powerChange(MENetworkChannelChanged w){ + //System.out.println("xxxxxxxxxxx2"); cacheState = CacheState.DIRTY; } @MENetworkEventSubscribe public void powerChange(MENetworkChannelsChanged w){ + //System.out.println("xxxxxxxxxxx3"); cacheState = CacheState.DIRTY; } @Override @@ -803,7 +859,7 @@ public void provideCrafting(ICraftingProviderHelper craftingTracker) { if (cacheState == CacheState.FRESHLY_UPDATED || cacheState == CacheState.UPDATED) if(isActive()) patternCache.forEach(s -> craftingTracker.addCraftingOption(this, - multiply==1? + multiply<=1? new CircuitProviderPatternDetial(s) : new CircuitProviderPatternDetial(mul(s)) @@ -824,7 +880,7 @@ public boolean checkLoop(HashSet blacklist) { @Override public void complete() { - returnItems(); + //returnItems(); } @@ -994,4 +1050,121 @@ public boolean isActive() { return getProxy() != null && getProxy().isActive(); } + +static IInventory EMPTY=new IInventory(){ + + @Override + public int getSizeInventory() { + + return 0; + } + + @Override + public ItemStack getStackInSlot(int slotIn) { + + return null; + } + + @Override + public ItemStack decrStackSize(int index, int count) { + + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int index) { + + return null; + } + + @Override + public void setInventorySlotContents(int index, ItemStack stack) { + + + } + + @Override + public String getInventoryName() { + + return "N/A"; + } + + @Override + public boolean hasCustomInventoryName() { + + return false; + } + + @Override + public int getInventoryStackLimit() { + + return 0; + } + + @Override + public void markDirty() { + + + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + + return false; + } + + @Override + public void openInventory() { + + + } + + @Override + public void closeInventory() { + + + } + + @Override + public boolean isItemValidForSlot(int index, ItemStack stack) { + + return false; + }};; + +public IInventory getPatterns() { + + return EMPTY; +} + +public String getName() { + + return "N/A"; +} + +public TileEntity getTileEntity() { + + return (TileEntity) this.getBaseMetaTileEntity(); +} + + +public boolean shouldDisplay() { + + return false; +} + + + + +public int rows() { + + return 0; +} + + +public int rowSize() { + + return 0; +} + + } diff --git a/src/main/java/reobf/proghatches/item/ItemFixer.java b/src/main/java/reobf/proghatches/item/ItemFixer.java index 42823ba..478124a 100644 --- a/src/main/java/reobf/proghatches/item/ItemFixer.java +++ b/src/main/java/reobf/proghatches/item/ItemFixer.java @@ -14,6 +14,7 @@ import appeng.api.networking.IGridNode; import appeng.api.parts.IPartHost; import appeng.api.storage.data.IAEItemStack; +import appeng.api.util.IInterfaceViewable; import appeng.core.localization.GuiText; import appeng.helpers.IInterfaceHost; import appeng.helpers.PatternHelper; @@ -108,8 +109,10 @@ public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World w, //System.out.println(host); //System.out.println(host instanceof IInterfaceHost); - if(host instanceof IInterfaceHost) - fix((IInterfaceHost) host,()->cnt[0]++); + if(host instanceof IInterfaceViewable){ + //System.out.println("fix:"+host); + + fix((IInterfaceViewable) host,()->cnt[0]++);} }); System.out.println("Player tried to use fixer to fix patterns, if this info spams in log and server gets laggy, blame 'em."); @@ -178,7 +181,7 @@ public ItemStack fix(ItemStack is,Runnable succ){ return is.copy(); } -public void fix(IInterfaceHost iface,Runnable succ){ +public void fix(IInterfaceViewable iface,Runnable succ){ iface.getTileEntity().markDirty(); IInventory inv = iface.getPatterns(); for(int i=0;i!lvI6;>1s;*b3=DjSL74G){)!Z!;CW9M$B+p3x6{t@HYo74UYu*QW1{lTiR|r{ zrUW#1uSsmA?dZCuhjD~!o!`NFpQtP={vzWWEv6*FE~-=w#I zTSF*eqtK*kOO=lAb^kv&zN~Bz6<8&=`Ea`kcX#F-Yet0wHRp<#HSGg>jlt8^&t;uc GLK6Ud1atoY literal 0 HcmV?d00001