diff --git a/gradle.properties b/gradle.properties index a9a6f9cf0..743ab6e97 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ author = masa mod_file_name = minihud-fabric # Current mod version -mod_version = 0.33.0-sakura.3 +mod_version = 0.33.0-sakura.4 # Required malilib version malilib_version = 0.22.0-sakura.3 diff --git a/src/main/java/fi/dy/masa/minihud/gui/InventoryOverlayScreen.java b/src/main/java/fi/dy/masa/minihud/gui/InventoryOverlayScreen.java index 123a3c7a8..93f95c96b 100644 --- a/src/main/java/fi/dy/masa/minihud/gui/InventoryOverlayScreen.java +++ b/src/main/java/fi/dy/masa/minihud/gui/InventoryOverlayScreen.java @@ -26,6 +26,7 @@ import fi.dy.masa.malilib.util.BlockUtils; import fi.dy.masa.malilib.util.GuiUtils; import fi.dy.masa.malilib.util.WorldUtils; +import fi.dy.masa.minihud.MiniHUD; import fi.dy.masa.minihud.config.Configs; import fi.dy.masa.minihud.data.EntitiesDataManager; import fi.dy.masa.minihud.event.RenderHandler; @@ -64,14 +65,20 @@ public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) List armourItems = new ArrayList<>(); if (previewData.entity() instanceof AbstractHorseEntity) { - armourItems.add(previewData.inv().getStack(0)); + if (previewData.inv() == null) + { + MiniHUD.logger.error("InventoryOverlayScreen(): Horse inv() = null"); + return; + } armourItems.add(previewData.entity().getEquippedStack(EquipmentSlot.BODY)); + armourItems.add(previewData.inv().getStack(0)); startSlot = 1; totalSlots = previewData.inv().size() - 1; } else if (previewData.entity() instanceof WolfEntity) { armourItems.add(previewData.entity().getEquippedStack(EquipmentSlot.BODY)); + //armourItems.add(ItemStack.EMPTY); } final InventoryOverlay.InventoryRenderType type = (previewData.entity() instanceof VillagerEntity) ? InventoryOverlay.InventoryRenderType.VILLAGER : InventoryOverlay.getBestInventoryType(previewData.inv(), previewData.nbt() != null ? previewData.nbt() : new NbtCompound(), previewData); diff --git a/src/main/java/fi/dy/masa/minihud/util/RayTraceUtils.java b/src/main/java/fi/dy/masa/minihud/util/RayTraceUtils.java index 5b5b62632..ee9ae5787 100644 --- a/src/main/java/fi/dy/masa/minihud/util/RayTraceUtils.java +++ b/src/main/java/fi/dy/masa/minihud/util/RayTraceUtils.java @@ -299,10 +299,11 @@ else if (entity instanceof PiglinEntity) //MiniHUD.logger.warn("getTargetInventoryFromEntity(): rawNbt: [{}]", nbt.toString()); // Fix for empty horse inv - if (inv != null && inv.size() == 1 && + if (inv != null && + //inv.size() == 1 && nbt.contains(NbtKeys.ITEMS) && - nbt.getList(NbtKeys.ITEMS, Constants.NBT.TAG_COMPOUND).size() > 1 && - !DataStorage.getInstance().hasIntegratedServer()) + nbt.getList(NbtKeys.ITEMS, Constants.NBT.TAG_COMPOUND).size() > 1) + //!DataStorage.getInstance().hasIntegratedServer()) { if (entity instanceof AbstractHorseEntity) { @@ -315,9 +316,10 @@ else if (entity instanceof PiglinEntity) inv = null; } // Fix for saddled horse, no inv - else if (inv != null && inv.size() == 1 && - nbt.contains(NbtKeys.SADDLE) && - !DataStorage.getInstance().hasIntegratedServer()) + else if (inv != null && + inv.size() == 1 && + nbt.contains(NbtKeys.SADDLE)) + //!DataStorage.getInstance().hasIntegratedServer()) { inv2 = InventoryUtils.getNbtInventoryHorseFix(nbt, -1, entity.getRegistryManager()); inv = null; @@ -325,8 +327,8 @@ else if (inv != null && inv.size() == 1 && // Fix for empty Villager/Piglin inv else if (inv != null && inv.size() == 8 && nbt.contains(NbtKeys.INVENTORY) && - !nbt.getList(NbtKeys.INVENTORY, Constants.NBT.TAG_COMPOUND).isEmpty() && - !DataStorage.getInstance().hasIntegratedServer()) + !nbt.getList(NbtKeys.INVENTORY, Constants.NBT.TAG_COMPOUND).isEmpty()) + //!DataStorage.getInstance().hasIntegratedServer()) { inv2 = InventoryUtils.getNbtInventory(nbt, 8, entity.getRegistryManager()); inv = null; @@ -334,7 +336,11 @@ else if (inv != null && inv.size() == 8 && else { inv2 = InventoryUtils.getNbtInventory(nbt, inv != null ? inv.size() : -1, entity.getRegistryManager()); - inv = null; + + if (inv2 != null) + { + inv = null; + } } //MiniHUD.logger.error("getTargetInventoryFromEntity(): inv.size [{}], inv2.size [{}]", inv != null ? inv.size() : "null", inv2 != null ? inv2.size() : "null"); @@ -350,14 +356,7 @@ else if (inv != null && inv.size() == 8 && return null; } - //return new InventoryPreviewData(inv, null, entityLivingBase); return new InventoryOverlay.Context(inv != null ? InventoryOverlay.getBestInventoryType(inv, nbt) : InventoryOverlay.getInventoryType(nbt), inv, null, entityLivingBase, nbt); } - - /* - public record InventoryPreviewData(Inventory inv, @Nullable BlockEntity te, @Nullable LivingEntity entity) - { - } - */ }