From 025aefb166c43f8ac107332d7b4359c67456bbe2 Mon Sep 17 00:00:00 2001 From: cech12 Date: Thu, 29 Aug 2024 17:50:34 +0200 Subject: [PATCH] workaround to avoid game crash caused by "noBucket()" fluids of Registrate mod #45 --- CHANGELOG.md | 4 ++++ .../cech12/bucketlib/api/item/UniversalBucketItem.java | 10 +++++++++- gradle.properties | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff7ec6f..d64c7bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Forge Recommended Versioning](https://mcforge.readthedocs.io/en/latest/conventions/versioning/). +## [1.21-4.1.0.1] - 2024-08-29 +### Fixed +- workaround to avoid game crash caused by "noBucket()" fluids of Registrate mod (thanks to PhilTheGreatLOL for the report) #45 + ## [1.21-4.1.0.0] - 2024-07-14 ### Changed - updated NeoForge to 21.0.94-beta diff --git a/common/src/main/java/de/cech12/bucketlib/api/item/UniversalBucketItem.java b/common/src/main/java/de/cech12/bucketlib/api/item/UniversalBucketItem.java index 3f65cbc..575d83b 100644 --- a/common/src/main/java/de/cech12/bucketlib/api/item/UniversalBucketItem.java +++ b/common/src/main/java/de/cech12/bucketlib/api/item/UniversalBucketItem.java @@ -1,5 +1,6 @@ package de.cech12.bucketlib.api.item; +import de.cech12.bucketlib.api.BucketLib; import de.cech12.bucketlib.platform.Services; import de.cech12.bucketlib.util.BucketLibUtil; import de.cech12.bucketlib.util.ItemStackUtil; @@ -107,7 +108,14 @@ public boolean canHoldFluid(Fluid fluid) { if (fluid == Fluids.EMPTY) { return true; } - Item bucket = fluid.getBucket(); + Item bucket; + try { + bucket = fluid.getBucket(); + } catch (IllegalArgumentException ex) { + //workaround to avoid game crash caused by getBucket() method of "noBucket" fluids of Registrate (tterrag1098) mod: https://github.com/tterrag1098/Registrate/issues/69 + BucketLib.LOG.error("IllegalArgumentException occurred while trying to get the bucket item of fluid '" + Services.FLUID.getFluidDescription(fluid) + "' [fluid.getBucket()]. BucketLib is not compatible with this fluid. Please contact the mod developer of the mod which adds this fluid!", ex); + return false; + } if (bucket instanceof MilkBucketItem && fluid != Services.FLUID.getMilkFluid()) { return false; } diff --git a/gradle.properties b/gradle.properties index 6a9f6f2..4753cd7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ # Project group=de.cech12.bucketlib -mod_version=4.1.0.0 +mod_version=4.1.0.1 mod_id=bucketlib mod_name=BucketLib mod_author=Cech12