From 2c27469bd6b0cc03c928a76eb795d488d17be5d4 Mon Sep 17 00:00:00 2001 From: MattiDragon Date: Tue, 16 May 2023 16:33:05 +0300 Subject: [PATCH] Fix shulker boxes (#57) --- changelog/1.4.0+1.19.4.md | 3 ++- .../mixin/ShulkerBoxBlockEntityMixin.java | 20 +++++++++++++++++++ .../resources/extended_drawers.mixins.json | 3 ++- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/main/java/io/github/mattidragon/extendeddrawers/mixin/ShulkerBoxBlockEntityMixin.java diff --git a/changelog/1.4.0+1.19.4.md b/changelog/1.4.0+1.19.4.md index b019e18..369da26 100644 --- a/changelog/1.4.0+1.19.4.md +++ b/changelog/1.4.0+1.19.4.md @@ -1,2 +1,3 @@ * Add compacting drawer -* Add option to control whether drawer retain contents when broken \ No newline at end of file +* Add option to control whether drawer retain contents when broken +* Fix shulker box weirdness \ No newline at end of file diff --git a/src/main/java/io/github/mattidragon/extendeddrawers/mixin/ShulkerBoxBlockEntityMixin.java b/src/main/java/io/github/mattidragon/extendeddrawers/mixin/ShulkerBoxBlockEntityMixin.java new file mode 100644 index 0000000..4d0092c --- /dev/null +++ b/src/main/java/io/github/mattidragon/extendeddrawers/mixin/ShulkerBoxBlockEntityMixin.java @@ -0,0 +1,20 @@ +package io.github.mattidragon.extendeddrawers.mixin; + +import io.github.mattidragon.extendeddrawers.item.DrawerItem; +import net.minecraft.block.entity.ShulkerBoxBlockEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.Direction; +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; + +@Mixin(ShulkerBoxBlockEntity.class) +public class ShulkerBoxBlockEntityMixin { + @Inject(method = "canInsert", at = @At("HEAD"), cancellable = true) + private void extended_drawers$fixShulkerBoxInsertion(int slot, ItemStack stack, Direction dir, CallbackInfoReturnable cir) { + if (stack.getItem() instanceof DrawerItem item && !item.canBeNested()) { + cir.setReturnValue(false); + } + } +} diff --git a/src/main/resources/extended_drawers.mixins.json b/src/main/resources/extended_drawers.mixins.json index fe98dd3..0a55e6d 100644 --- a/src/main/resources/extended_drawers.mixins.json +++ b/src/main/resources/extended_drawers.mixins.json @@ -7,7 +7,8 @@ "DataPackContentsMixin", "ItemStackMixin", "RecipeManagerMixin", - "ServerPlayerInteractionManagerMixin" + "ServerPlayerInteractionManagerMixin", + "ShulkerBoxBlockEntityMixin" ], "client": [ "ClientPlayerInteractionManagerMixin"