-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Duplication Glitch With ME Stocking Bus/Hatch
- Loading branch information
1 parent
2bd06e3
commit e86bb33
Showing
3 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
src/main/java/com/nomiceu/nomilabs/mixin/gregtech/MetaTileEntityMEStockingBusMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.nomiceu.nomilabs.mixin.gregtech; | ||
|
||
import net.minecraft.util.ResourceLocation; | ||
|
||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import gregtech.common.metatileentities.multi.multiblockpart.appeng.MetaTileEntityMEInputBus; | ||
import gregtech.common.metatileentities.multi.multiblockpart.appeng.MetaTileEntityMEStockingBus; | ||
|
||
/** | ||
* Fixes Duplication Glitch via Disconnecting from AE2. | ||
*/ | ||
@Mixin(value = MetaTileEntityMEStockingBus.class, remap = false) | ||
public abstract class MetaTileEntityMEStockingBusMixin extends MetaTileEntityMEInputBus { | ||
|
||
@Shadow | ||
@Final | ||
private static int CONFIG_SIZE; | ||
|
||
@Shadow | ||
private boolean autoPull; | ||
|
||
@Shadow | ||
protected abstract void clearInventory(int startIndex); | ||
|
||
/** | ||
* Default Ignored Constructor | ||
*/ | ||
public MetaTileEntityMEStockingBusMixin(ResourceLocation metaTileEntityId) { | ||
super(metaTileEntityId); | ||
} | ||
|
||
@Inject(method = "update", | ||
at = @At(value = "INVOKE", | ||
target = "Lgregtech/common/metatileentities/multi/multiblockpart/appeng/MetaTileEntityMEInputBus;update()V", | ||
shift = At.Shift.AFTER), | ||
require = 1, | ||
cancellable = true) | ||
private void checkAe2Disconnect(CallbackInfo ci) { | ||
if (!getWorld().isRemote && isWorkingEnabled() && !updateMEStatus()) { | ||
// If Disconnected from ME | ||
// Don't use Clear Inventory, Config Slots should not change | ||
// Unless is Auto Pull | ||
if (autoPull) clearInventory(0); | ||
else { | ||
for (int i = 0; i < CONFIG_SIZE; i++) { | ||
getAEItemHandler().getInventory()[i].setStack(null); | ||
} | ||
} | ||
ci.cancel(); | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/com/nomiceu/nomilabs/mixin/gregtech/MetaTileEntityMEStockingHatchMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.nomiceu.nomilabs.mixin.gregtech; | ||
|
||
import net.minecraft.util.ResourceLocation; | ||
|
||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import gregtech.common.metatileentities.multi.multiblockpart.appeng.MetaTileEntityMEInputHatch; | ||
import gregtech.common.metatileentities.multi.multiblockpart.appeng.MetaTileEntityMEStockingHatch; | ||
|
||
/** | ||
* Fixes Duplication Glitch via Disconnecting from AE2. | ||
*/ | ||
@Mixin(value = MetaTileEntityMEStockingHatch.class, remap = false) | ||
public abstract class MetaTileEntityMEStockingHatchMixin extends MetaTileEntityMEInputHatch { | ||
|
||
@Shadow | ||
@Final | ||
private static int CONFIG_SIZE; | ||
|
||
@Shadow | ||
private boolean autoPull; | ||
|
||
@Shadow | ||
protected abstract void clearInventory(int startIndex); | ||
|
||
/** | ||
* Default Ignored Constructor | ||
*/ | ||
public MetaTileEntityMEStockingHatchMixin(ResourceLocation metaTileEntityId) { | ||
super(metaTileEntityId); | ||
} | ||
|
||
@Inject(method = "update", | ||
at = @At(value = "INVOKE", | ||
target = "Lgregtech/common/metatileentities/multi/multiblockpart/appeng/MetaTileEntityMEInputHatch;update()V", | ||
shift = At.Shift.AFTER), | ||
require = 1, | ||
cancellable = true) | ||
private void checkAe2Disconnect(CallbackInfo ci) { | ||
if (!getWorld().isRemote && isWorkingEnabled() && !updateMEStatus()) { | ||
// If Disconnected from ME | ||
// Don't use Clear Inventory, Config Slots should not change | ||
// Unless is Auto Pull | ||
if (autoPull) clearInventory(0); | ||
else { | ||
for (int i = 0; i < CONFIG_SIZE; i++) { | ||
getAEFluidHandler().getInventory()[i].setStack(null); | ||
} | ||
} | ||
ci.cancel(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters