-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c35289
commit eb4fab3
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/main/java/com/nomiceu/nomilabs/mixin/gregtech/OverlayedItemHandlerMixin.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.nomiceu.nomilabs.mixin.gregtech; | ||
|
||
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 org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import com.llamalad7.mixinextras.sugar.ref.LocalIntRef; | ||
|
||
import gregtech.api.util.OverlayedItemHandler; | ||
|
||
/** | ||
* Ensures items inputted into new slots take into account the stack's max stack size. | ||
*/ | ||
@Mixin(value = OverlayedItemHandler.class, remap = false) | ||
public class OverlayedItemHandlerMixin { | ||
|
||
@Inject(method = "insertStackedItemStack", | ||
at = @At(value = "INVOKE", | ||
target = "Lgregtech/api/util/OverlayedItemHandler$OverlayedItemHandlerSlot;setItemStack(Lnet/minecraft/item/ItemStack;)V", | ||
ordinal = 0), | ||
require = 1, | ||
locals = LocalCapture.CAPTURE_FAILEXCEPTION) | ||
private void changeCanInsert(ItemStack stack, int amountToInsert, CallbackInfoReturnable<Integer> cir, | ||
@Local(index = 7) LocalIntRef insertedAmount) { | ||
insertedAmount.set(Math.min(insertedAmount.get(), stack.getMaxStackSize())); | ||
} | ||
} |
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