Fixes inventory behaviour with stackable empty shulker boxes. fixes #1048
This commit is contained in:
1 parent
7fb5e47da5
commit
16f3832d16
3 files changed
+35
-1
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.helpers.InventoryHelper;
|
||||
import net.minecraft.block.ShulkerBoxBlock;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(ScreenHandler.class)
|
||||
public class ScreenHandler_stackableSBoxesMixin
|
||||
{
|
||||
@Redirect(method = "internalOnSlotClick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/screen/slot/Slot;getMaxItemCount(Lnet/minecraft/item/ItemStack;)I"
|
||||
))
|
||||
private int getMaxCountForSboxesInScreenHander(Slot slot, ItemStack stack)
|
||||
{
|
||||
if (CarpetSettings.stackableShulkerBoxes &&
|
||||
stack.getItem() instanceof BlockItem &&
|
||||
((BlockItem)stack.getItem()).getBlock() instanceof ShulkerBoxBlock &&
|
||||
!InventoryHelper.shulkerBoxHasItems(stack)
|
||||
)
|
||||
{
|
||||
return CarpetSettings.SHULKER_STACK_SIZE;
|
||||
}
|
||||
return slot.getMaxItemCount(stack);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public class Slot_stackableSBoxesMixin {
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/screen/slot/Slot;getMaxItemCount(Lnet/minecraft/item/ItemStack;)I"
|
||||
))
|
||||
private int getMaxCountForSboxes(Slot slot, ItemStack stack)
|
||||
private int getMaxCountForSboxesInSlot(Slot slot, ItemStack stack)
|
||||
{
|
||||
if (CarpetSettings.stackableShulkerBoxes &&
|
||||
stack.getItem() instanceof BlockItem &&
|
||||
|
||||
@@ -136,6 +136,7 @@
|
||||
"CauldronBlock_stackableSBoxesMixin",
|
||||
"AbstractCauldronBlock_stackableSBoxesMixin",
|
||||
"Slot_stackableSBoxesMixin",
|
||||
"ScreenHandler_stackableSBoxesMixin",
|
||||
"ItemEntityMixin",
|
||||
"TntBlockMixin",
|
||||
"ExplosionMixin",
|
||||
|
||||
Reference in new issue
Block a user