3737import net .minecraftforge .fml .common .Optional ;
3838import org .spongepowered .asm .mixin .Final ;
3939import org .spongepowered .asm .mixin .Mixin ;
40+ import org .spongepowered .asm .mixin .Overwrite ;
4041import org .spongepowered .asm .mixin .Shadow ;
4142import org .spongepowered .asm .mixin .Unique ;
42- import org .spongepowered .asm .mixin .injection .At ;
43- import org .spongepowered .asm .mixin .injection .Inject ;
44- import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
45- import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
4643
47- import java .util .Objects ;
48-
49- @ Mixin (value = TileLevelMaintainer .class , remap = false )
44+ @ Mixin (value = TileLevelMaintainer .class , remap = false , priority = 999 )
5045public abstract class MixinTileLevelMaintainer extends TileNetworkDevice implements IStackWatcherHost , ICraftingRequester , AEIgnoredInputMachine {
5146
5247 @ Shadow
@@ -76,8 +71,8 @@ public abstract class MixinTileLevelMaintainer extends TileNetworkDevice impleme
7671 * @author circulation
7772 * @reason 删除多余的检测
7873 */
79- @ Inject ( method = "tick" , at = @ At ( "HEAD" ), cancellable = true )
80- protected void tick (CallbackInfo ci ) {
74+ @ Overwrite
75+ protected void tick () {
8176 if (!this .world .isRemote ) {
8277 this .aeGrid ().ifPresent ((grid ) -> {
8378 if (this .sleepTicks <= 0 ) {
@@ -122,53 +117,33 @@ protected void tick(CallbackInfo ci) {
122117
123118 });
124119 }
125- ci .cancel ();
126120 }
127121
128122 /**
129123 * @author circulation
130124 * @reason 修复插入物品逻辑,防止出现意外地吞物品
131125 */
132- @ Inject ( method = "injectCraftedItems" , at = @ At ( "HEAD" ), cancellable = true )
133- public void injectCraftedItems (ICraftingLink link , IAEItemStack stack , Actionable mode , CallbackInfoReturnable < IAEItemStack > cir ) {
126+ @ Overwrite
127+ public IAEItemStack injectCraftedItems (ICraftingLink link , IAEItemStack stack , Actionable mode ) {
134128 if (stack == null ) {
135- cir . setReturnValue ( null ) ;
129+ return null ;
136130 } else {
137131 int slot = this .crafter .getSlotForJob (link );
138132 if (slot == -1 ) {
139- cir .setReturnValue (stack );
140- } else if (mode == Actionable .SIMULATE ) {
141- if (this .aeGrid ().isPresent ()) {
142- var grid = this .aeGrid ().get ();
143- IEnergyGrid energyGrid = grid .getCache (IEnergyGrid .class );
144- var gridCache = ((IStorageGrid ) grid .getCache (IStorageGrid .class ));
145- IMEMonitor <IAEItemStack > storageGrid = gridCache .getInventory (AEApi .instance ().storage ().getStorageChannel (IItemStorageChannel .class ));
146- if (Loader .isModLoaded ("ae2fc" )) {
147- var i = ae2fc$work (grid , mode , gridCache , stack );
148- cir .setReturnValue (i );
149- return ;
150- } else {
151- cir .setReturnValue (Platform .poweredInsert (energyGrid , storageGrid , stack , this .actionSource , Actionable .MODULATE ));
152- }
153- return ;
154- }
155- cir .setReturnValue (null );
133+ return stack ;
156134 } else {
157135 if (this .aeGrid ().isPresent ()) {
158136 var grid = this .aeGrid ().get ();
159137 IEnergyGrid energyGrid = grid .getCache (IEnergyGrid .class );
160138 var gridCache = ((IStorageGrid ) grid .getCache (IStorageGrid .class ));
161139 IMEMonitor <IAEItemStack > storageGrid = gridCache .getInventory (AEApi .instance ().storage ().getStorageChannel (IItemStorageChannel .class ));
162140 if (Loader .isModLoaded ("ae2fc" )) {
163- var i = ae2fc$work (grid , mode , gridCache , stack );
164- cir .setReturnValue (i );
165- return ;
141+ return ae2fc$work (grid , mode , gridCache , stack );
166142 } else {
167- cir . setReturnValue ( Platform . poweredInsert ( energyGrid , storageGrid , stack , this .actionSource , Actionable . MODULATE ) );
143+ return storageGrid . injectItems ( stack , mode , this .actionSource );
168144 }
169- return ;
170145 }
171- cir . setReturnValue ( null ) ;
146+ return null ;
172147 }
173148 }
174149 }
@@ -181,13 +156,10 @@ public void injectCraftedItems(ICraftingLink link, IAEItemStack stack, Actionabl
181156
182157 ItemStack inputStack = stack .getCachedItemStack (stack .getStackSize ());
183158 FluidStack inputFluid = FakeItemRegister .getStack (inputStack );
184- IAEFluidStack remaining ;
185-
186- if (mode == appeng .api .config .Actionable .SIMULATE ) {
187- remaining = fluidGrid .injectItems (AEFluidStack .fromFluidStack (inputFluid ), Actionable .SIMULATE , this .actionSource );
159+ final IAEFluidStack remaining = fluidGrid .injectItems (AEFluidStack .fromFluidStack (inputFluid ), mode , this .actionSource );
160+ if (mode == Actionable .SIMULATE ) {
188161 stack .setCachedItemStack (inputStack );
189162 } else {
190- remaining = fluidGrid .injectItems (AEFluidStack .fromFluidStack (inputFluid ), Actionable .MODULATE , this .actionSource );
191163 if (remaining == null || remaining .getStackSize () <= 0L ) {
192164 ItemStack tmp = FakeFluids .packFluid2AEDrops (remaining ) != null ? FakeFluids .packFluid2AEDrops (remaining ).getDefinition () : null ;
193165 stack .setCachedItemStack (tmp );
@@ -215,13 +187,12 @@ public void injectCraftedItems(ICraftingLink link, IAEItemStack stack, Actionabl
215187
216188 ItemStack inputStack = stack .getCachedItemStack (stack .getStackSize ());
217189 GasStack inputGas = FakeItemRegister .getStack (inputStack );
218- IAEGasStack remaining ;
190+
191+ final IAEGasStack remaining = gasGrid .injectItems (AEGasStack .of (inputGas ), mode , this .actionSource );
219192
220193 if (mode == Actionable .SIMULATE ) {
221- remaining = gasGrid .injectItems (AEGasStack .of (inputGas ), Actionable .SIMULATE , this .actionSource );
222194 stack .setCachedItemStack (inputStack );
223195 } else {
224- remaining = gasGrid .injectItems (AEGasStack .of (inputGas ), Actionable .MODULATE , this .actionSource );
225196 if (remaining == null || remaining .getStackSize () <= 0L ) {
226197 ItemStack tmp = FakeGases .packGas2AEDrops (remaining ) != null ? FakeGases .packGas2AEDrops (remaining ).getDefinition () : null ;
227198 stack .setCachedItemStack (tmp );
@@ -235,13 +206,6 @@ public void injectCraftedItems(ICraftingLink link, IAEItemStack stack, Actionabl
235206 return FakeGases .packGas2AEDrops (remaining );
236207 }
237208
238- @ Unique
239- private IAEItemStack r$request (int index , long count ) {
240- AEItemStack stack = Objects .requireNonNull (AEItemStack .fromItemStack (((AccessorInventoryRequest ) this .requests ).getRequestStacks ()[index ]));
241- stack .setStackSize (count );
242- return stack ;
243- }
244-
245209 @ Unique
246210 private long r$computeDelta (int index , long existing ) {
247211 AccessorInventoryRequest t = ((AccessorInventoryRequest ) this .requests );
0 commit comments