-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: patch several dupes in eu2 (#438)
- Loading branch information
1 parent
d2c0230
commit 2defc58
Showing
4 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
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
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
57 changes: 57 additions & 0 deletions
57
...ava/com/mitchej123/hodgepodge/mixins/late/extrautilities/MixinContainerFilingCabinet.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,57 @@ | ||
package com.mitchej123.hodgepodge.mixins.late.extrautilities; | ||
|
||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.inventory.Slot; | ||
import net.minecraft.item.ItemStack; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import com.rwtema.extrautils.gui.ContainerFilingCabinet; | ||
|
||
@Mixin(value = ContainerFilingCabinet.class) | ||
public abstract class MixinContainerFilingCabinet { | ||
|
||
@Unique | ||
private ItemStack hodgepodge$buffer; | ||
|
||
@Inject( | ||
method = "slotClick", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/inventory/Container;slotClick(IIILnet/minecraft/entity/player/EntityPlayer;)Lnet/minecraft/item/ItemStack;", | ||
ordinal = 1)) | ||
private void hodgepodge$patchFilingCabinetDupe(int slotId, int clickedButton, int mode, EntityPlayer player, | ||
CallbackInfoReturnable<ItemStack> cir) { | ||
if (mode != 2) { | ||
return; | ||
} | ||
ContainerFilingCabinet cabinet = (ContainerFilingCabinet) (Object) this; | ||
ItemStack stack = cabinet.getInventory().get(slotId); | ||
if (stack != null && stack.getMaxStackSize() < stack.stackSize) { | ||
int newSize = stack.stackSize - stack.getMaxStackSize(); | ||
hodgepodge$buffer = stack.copy(); | ||
hodgepodge$buffer.stackSize = newSize; | ||
stack.stackSize = stack.getMaxStackSize(); | ||
} | ||
} | ||
|
||
@Inject(method = "slotClick", at = @At(value = "TAIL")) | ||
private void hodgepodge$restoreItemStackSize(int slotId, int clickedButton, int mode, EntityPlayer player, | ||
CallbackInfoReturnable<ItemStack> cir) { | ||
if (mode != 2) { | ||
return; | ||
} | ||
ContainerFilingCabinet cabinet = (ContainerFilingCabinet) (Object) this; | ||
if (hodgepodge$buffer != null && slotId >= 0 && slotId < cabinet.getSlots().size()) { | ||
Slot slot = cabinet.inventorySlots.get(slotId); | ||
if (slot.getStack() == null) { | ||
slot.putStack(hodgepodge$buffer.copy()); | ||
hodgepodge$buffer = null; | ||
} | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/mitchej123/hodgepodge/mixins/late/extrautilities/MixinContainerFilter.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,32 @@ | ||
package com.mitchej123.hodgepodge.mixins.late.extrautilities; | ||
|
||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.ItemStack; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import com.rwtema.extrautils.gui.ContainerFilter; | ||
|
||
@Mixin(ContainerFilter.class) | ||
public class MixinContainerFilter { | ||
|
||
@Inject( | ||
method = "slotClick", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/inventory/Container;slotClick(IIILnet/minecraft/entity/player/EntityPlayer;)Lnet/minecraft/item/ItemStack;"), | ||
cancellable = true) | ||
private void hodgepodge$patchFilterDupe(int slotId, int clickedButton, int mode, EntityPlayer player, | ||
CallbackInfoReturnable<ItemStack> cir) { | ||
if (mode != 2) { | ||
return; | ||
} | ||
if (clickedButton == player.inventory.currentItem) { | ||
cir.setReturnValue(null); | ||
cir.cancel(); | ||
} | ||
} | ||
} |