From 9e10c412f96ddadd7f85eedd4d1aee083bdb0ff2 Mon Sep 17 00:00:00 2001 From: 2No2Name <2No2Name@web.de> Date: Fri, 21 Jul 2023 00:10:04 +0200 Subject: [PATCH] fix crash when transferring items into chest cart --- .../mixin/StorageMinecartEntityMixin_ItemCap.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/mendedminecarts/mixin/StorageMinecartEntityMixin_ItemCap.java b/src/main/java/mendedminecarts/mixin/StorageMinecartEntityMixin_ItemCap.java index 3141cc9..6a0a7ea 100644 --- a/src/main/java/mendedminecarts/mixin/StorageMinecartEntityMixin_ItemCap.java +++ b/src/main/java/mendedminecarts/mixin/StorageMinecartEntityMixin_ItemCap.java @@ -1,6 +1,7 @@ package mendedminecarts.mixin; import mendedminecarts.MendedMinecartsMod; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.vehicle.StorageMinecartEntity; import net.minecraft.entity.vehicle.VehicleInventory; import net.minecraft.item.ItemStack; @@ -18,7 +19,12 @@ public void setInventoryStack(int slot, ItemStack stack) { stack.setCount(this.getMaxCountPerStack()); } } else { - VehicleInventory.super.setInventoryStack(slot, stack); + //Copypaste from VehicleInventory + this.generateInventoryLoot(null); + this.getInventory().set(slot, stack); + if (!stack.isEmpty() && stack.getCount() > this.getMaxCountPerStack()) { + stack.setCount(this.getMaxCountPerStack()); + } } } }