From 06695eaa07f9b8a6f0e6905e8e9d351ab7576238 Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Tue, 31 Dec 2024 23:48:09 +0800 Subject: [PATCH] update --- .../gt/metatileentity/DecoyInputBusME.java | 88 ++++++++++++++++--- .../gt/metatileentity/DecoyInputHatchME.java | 5 +- .../PriorityFilterInputBusME.java | 12 +++ .../PriorityFilterInputHatchME.java | 9 ++ .../mixins/part2/MixinMEBusOverride.java | 2 +- .../main/registration/PHRecipes.java | 21 ++++- 6 files changed, 124 insertions(+), 13 deletions(-) diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputBusME.java b/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputBusME.java index 25c1fb4..896e6de 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputBusME.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputBusME.java @@ -14,8 +14,10 @@ import java.util.List; import java.util.NavigableMap; import java.util.NavigableSet; +import java.util.Objects; import java.util.Map.Entry; import java.util.concurrent.ConcurrentSkipListMap; +import java.util.function.Predicate; import java.util.function.Supplier; import javax.naming.OperationNotSupportedException; @@ -82,6 +84,7 @@ import reobf.proghatches.gt.metatileentity.util.IDataCopyablePlaceHolder; import reobf.proghatches.gt.metatileentity.util.IDataCopyablePlaceHolderSuper; import reobf.proghatches.gt.metatileentity.util.IMEHatchOverrided; +import reobf.proghatches.main.MyMod; import reobf.proghatches.main.registration.Registration; public class DecoyInputBusME extends MTEHatchInputBusME implements IMEHatchOverrided,IDataCopyablePlaceHolderSuper { @@ -135,7 +138,7 @@ private static Set get(GridStorageCache thiz) { } } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({ "unchecked", "rawtypes", "deprecation" }) @Override public void overridedBehoviour(int minPull) { AENetworkProxy proxy = getProxy(); @@ -174,7 +177,9 @@ public void overridedBehoviour(int minPull) { if(reserveFirst&&orderMap.isEmpty()==false) { if(orderMap.get(orderMap.keySet().first()).stream() - .filter(s->s.getAvailableItems(StorageChannel.ITEMS.createList()).getFirstItem()!=null) + .filter(s->s.getAvailableItems(StorageChannel.ITEMS.createList(), + appeng.util.IterationCounter.fetchNewId() + ).getFirstItem()!=null) .findAny().isPresent()==false ){ keepFirstEmpty=true; @@ -196,6 +201,7 @@ public void add(final IAEItemStack option) { final IAEItemStack st = this.records.get(option); if (st != null) { + if(st.getStackSize()==0){added.add(option.copy());} st.add(option); return; } @@ -232,7 +238,8 @@ public void addStorage(final IAEItemStack option) { if(option.getItem()instanceof ItemFluidDrop){return;} final IAEItemStack st = this.records.get(option); - if (st != null) { + if (st != null) { + if(st.getStackSize()==0){added.add(option.copy());} st.incStackSize(option.getStackSize()); return; } @@ -250,7 +257,7 @@ public void addStorage(final IAEItemStack option) { @Override public void addCrafting(final IAEItemStack option) { - if (option == null) { + return;/*if (option == null) { return; } @@ -265,12 +272,12 @@ public void addCrafting(final IAEItemStack option) { opt.setStackSize(0); opt.setCraftable(true); - this.putItemRecord(opt); + this.putItemRecord(opt);*/ } @Override public void addRequestable(final IAEItemStack option) { - if (option == null) { + return;/*if (option == null) { return; } @@ -289,7 +296,7 @@ public void addRequestable(final IAEItemStack option) { opt.setCountRequestable(option.getCountRequestable()); opt.setCountRequestableCrafts(option.getCountRequestableCrafts()); - this.putItemRecord(opt); + this.putItemRecord(opt);*/ } @Override @@ -333,7 +340,7 @@ private Collection findFuzzyDamage(final AEItemStack filter, final }; for (Entry> ent : orderMap.entries()) { - ent.getValue().getAvailableItems(all); + ent.getValue().getAvailableItems(all,appeng.util.IterationCounter.fetchNewId()); if (added.size() > 16) { break; } @@ -452,7 +459,7 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye ((IStorageGrid) this.getProxy().getNode().getGrid().getCache(IStorageGrid.class)).getItemInventory(), AEItemStack.create(new ItemStack(net.minecraft.init.Items.apple,10)),Actionable.MODULATE, - requestSource + new MachineSource((IActionHost)this.getBaseMetaTileEntity()) )); } catch (Exception e) { @@ -463,9 +470,20 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye } + /** + * @param thiz + * @param request + * @param mode + * @param src + * @return + */ @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable mode, BaseActionSource src) { + + if(mode==Actionable.SIMULATE) + return thiz.extractItems(request, mode, src); + long requested = request.getStackSize(); long num = request.getStackSize(); try { @@ -505,7 +523,11 @@ public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable m } } if (most_ == -1) - break done; + { + + + + break done;} most.sort((a,b)->a.getPriority()-b.getPriority()); @@ -544,9 +566,55 @@ public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable m } + if(num!=0)try{ + MyMod.LOG.fatal("[Decoy Bus]:Fail to extract!"); + MyMod.LOG.fatal("Expected:"+request.toString()); + MyMod.LOG.fatal("Left:"+num); + MyMod.LOG.fatal("Auto-pull"); + for(ItemStack item:mInventory){ + MyMod.LOG.fatal(Objects.toString(item)); + } + MyMod.LOG.fatal("shadowInventory"); + try { + Field f=MTEHatchInputBusME.class.getDeclaredField("shadowInventory"); + f.setAccessible(true); + ItemStack[] get=(ItemStack[]) f.get(this); + for(ItemStack item:get){ + MyMod.LOG.fatal(Objects.toString(item)); + } + } catch (Exception e) { + e.printStackTrace(); + } + MyMod.LOG.fatal("savedStackSizes"); + try { + Field f=MTEHatchInputBusME.class.getDeclaredField("savedStackSizes"); + f.setAccessible(true); + int[] get=(int[]) f.get(this); + for(int item:get){ + MyMod.LOG.fatal(Objects.toString(item)); + } + } catch (Exception e) { + e.printStackTrace(); + } + + + MyMod.LOG.fatal("But not found from:"); + for(IMEInventoryHandler xo:ordered){ + MyMod.LOG.fatal(xo+":"); + xo.getAvailableItems(StorageChannel.ITEMS.createList(), + appeng.util.IterationCounter.fetchNewId()).forEach((s)->{ + MyMod.LOG.fatal(s); + }); + } + }catch(Exception e){e.printStackTrace();} + + } catch (GridAccessException e) { + MyMod.LOG.fatal("[Decoy Bus]:GridAccessException"); + e.printStackTrace(); } + if(requested==num)return null; return request.copy().setStackSize(requested-num); } diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputHatchME.java b/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputHatchME.java index 593d5c7..66a3d2d 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputHatchME.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputHatchME.java @@ -171,7 +171,7 @@ public void add(final IAEFluidStack option) { final IAEFluidStack st = this.records.get(option); - if (st != null) { + if (st != null) {if(st.getStackSize()==0){added.add(option.copy());} st.add(option); return; } @@ -209,6 +209,7 @@ public void addStorage(final IAEFluidStack option) { final IAEFluidStack st = this.records.get(option); if (st != null) { + if(st.getStackSize()==0){added.add(option.copy());} st.incStackSize(option.getStackSize()); return; } @@ -442,6 +443,8 @@ public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, f super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); }@Override public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable mode, BaseActionSource src) { + if(mode==Actionable.SIMULATE) + return thiz.extractItems(request, mode, src); long requested = request.getStackSize(); long num = request.getStackSize(); diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/PriorityFilterInputBusME.java b/src/main/java/reobf/proghatches/gt/metatileentity/PriorityFilterInputBusME.java index ade92a6..e6edc89 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/PriorityFilterInputBusME.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/PriorityFilterInputBusME.java @@ -156,9 +156,21 @@ public void overridedBehoviour(int minPull) { } + + boolean onlyFromSameP=true; + @SuppressWarnings("unchecked") @Override public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable mode, BaseActionSource src) { + lab:if(mode==Actionable.SIMULATE){ + if(onlyFromSameP){ + + break lab; + } + return thiz.extractItems(request, mode, src); + } + + AENetworkProxy proxy = getProxy(); long size=request.getStackSize(); request=request.copy(); diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/PriorityFilterInputHatchME.java b/src/main/java/reobf/proghatches/gt/metatileentity/PriorityFilterInputHatchME.java index 39f3c97..99f3bde 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/PriorityFilterInputHatchME.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/PriorityFilterInputHatchME.java @@ -156,9 +156,18 @@ public void overridedBehoviour(int minPull) { } + boolean onlyFromSameP; @SuppressWarnings("unchecked") @Override public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable mode, BaseActionSource src) { + lab:if(mode==Actionable.SIMULATE){ + if(onlyFromSameP){ + + break lab; + } + return thiz.extractItems(request, mode, src); + } + AENetworkProxy proxy = getProxy(); long size=request.getStackSize(); request=request.copy(); diff --git a/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinMEBusOverride.java b/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinMEBusOverride.java index 6ca2b5a..2abe975 100644 --- a/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinMEBusOverride.java +++ b/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinMEBusOverride.java @@ -59,7 +59,7 @@ private void refreshItemList(CallbackInfo ci) { } - @Redirect( require = 1,method="endRecipeProcessing" + @Redirect( require = 1,method="/^\\w/"//"endRecipeProcessing" , at = @At(value="INVOKE", diff --git a/src/main/java/reobf/proghatches/main/registration/PHRecipes.java b/src/main/java/reobf/proghatches/main/registration/PHRecipes.java index def2fc8..5b82539 100644 --- a/src/main/java/reobf/proghatches/main/registration/PHRecipes.java +++ b/src/main/java/reobf/proghatches/main/registration/PHRecipes.java @@ -35,6 +35,7 @@ import com.glodblock.github.loader.ItemAndBlockHolder; import appeng.core.Api; +import appeng.integration.modules.Chisel; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.ironchest.IronChest; import crazypants.enderio.EnderIOTab; @@ -55,6 +56,7 @@ import reobf.proghatches.main.Config; import reobf.proghatches.main.MyMod; import tconstruct.smeltery.TinkerSmeltery; +import team.chisel.init.ChiselBlocks; import tectech.recipe.TTRecipeAdder; import thaumcraft.api.ThaumcraftApi; import thaumcraft.common.config.ConfigItems; @@ -1863,7 +1865,24 @@ bb,new ItemStack(MyMod.smartarm, 4,i+5) } - + /*GTRecipeBuilder.builder() + .metadata(RESEARCH_ITEM, new ItemStack(ChiselBlocks.present,1,16)) + .metadata(RESEARCH_TIME, 1 ) + .itemInputs( + new ItemStack(ChiselBlocks.present,1,0), + new ItemStack(ChiselBlocks.present,1,1), + new ItemStack(ChiselBlocks.present,1,2), + new ItemStack(ChiselBlocks.present,1,0) + + + ) + .fluidInputs(new FluidStack(FluidRegistry.WATER,1) + + ) + .itemOutputs( new ItemStack(ChiselBlocks.present,1,15)) + .eut(TierEU.RECIPE_LV) + .duration(10) + .addTo( GTRecipeConstants.AssemblyLine);*/ }