diff --git a/CHANGELOG.md b/CHANGELOG.md index c9f28bf..60f1c35 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.20.4-3.2.1.6] - 2024-09-29 +### Fixed +- lava bucket did not serve as fuel in furnace (Fabric & Forge) (thanks to memoharos and AvaAsUsual for the report) #49 https://github.com/cech12/CeramicBucket/issues/83 + ## [1.20.4-3.2.1.5] - 2024-09-07 ### Fixed - buckets could not be stacked after holding fish or axolotl (thanks to Sinhika & Blazified for the report) #46 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 dc80bb0..8416b25 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 @@ -41,6 +41,7 @@ import net.minecraft.world.item.MobBucketItem; import net.minecraft.world.item.UseAnim; import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -169,6 +170,18 @@ public int getMaxStackSize(ItemStack stack) { return BucketLibUtil.isEmpty(stack) ? this.properties.maxStackSize : 1; } + //used by mixins + public int getBucketBurnTime(ItemStack stack, RecipeType recipeType) { + //entity buckets should not use the burn time of its fluid + if (stack.getItem() instanceof UniversalBucketItem && !BucketLibUtil.containsEntityType(stack)) { + Fluid fluid = Services.FLUID.getContainedFluid(stack); + if (fluid != Fluids.EMPTY) { + return Services.PLATFORM.getBurnTime(new ItemStack(fluid.getBucket()), recipeType); + } + } + return 0; //don't call Services.PLATFORM.getBurnTime() to avoid recursive calls + } + @Override public void inventoryTick(@Nonnull ItemStack itemStack, @Nonnull Level level, @Nonnull Entity entity, int position, boolean selected) { if (!level.isClientSide) { diff --git a/common/src/main/java/de/cech12/bucketlib/platform/services/IPlatformHelper.java b/common/src/main/java/de/cech12/bucketlib/platform/services/IPlatformHelper.java index 1e5667d..4c046c9 100644 --- a/common/src/main/java/de/cech12/bucketlib/platform/services/IPlatformHelper.java +++ b/common/src/main/java/de/cech12/bucketlib/platform/services/IPlatformHelper.java @@ -2,6 +2,8 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; /** @@ -61,4 +63,11 @@ default String getEnvironmentName() { */ String getMilkTranslationKey(); + /** + * Gets the burn time of an ItemStack. + * + * @return burn time of an ItemStack + */ + int getBurnTime(ItemStack stack, RecipeType recipeType); + } \ No newline at end of file diff --git a/fabric/src/main/java/de/cech12/bucketlib/mixin/AbstractFurnaceBlockEntityMixin.java b/fabric/src/main/java/de/cech12/bucketlib/mixin/AbstractFurnaceBlockEntityMixin.java new file mode 100644 index 0000000..0cc02ad --- /dev/null +++ b/fabric/src/main/java/de/cech12/bucketlib/mixin/AbstractFurnaceBlockEntityMixin.java @@ -0,0 +1,28 @@ +package de.cech12.bucketlib.mixin; + +import de.cech12.bucketlib.api.item.UniversalBucketItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; +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({AbstractFurnaceBlockEntity.class}) +public abstract class AbstractFurnaceBlockEntityMixin { + + @Inject(method = "getBurnDuration", at = @At("RETURN"), cancellable = true) + private void getBurnDurationProxy(ItemStack itemStack, CallbackInfoReturnable cir) { + if (cir.getReturnValue() <= 0 && itemStack.getItem() instanceof UniversalBucketItem universalBucketItem) { + cir.setReturnValue(universalBucketItem.getBucketBurnTime(itemStack, null)); + } + } + + @Inject(method = "isFuel", at = @At("RETURN"), cancellable = true) + private static void isFuelProxy(ItemStack itemStack, CallbackInfoReturnable cir) { + if (!cir.getReturnValue() && itemStack.getItem() instanceof UniversalBucketItem universalBucketItem) { + cir.setReturnValue(universalBucketItem.getBucketBurnTime(itemStack, null) > 0); + } + } + +} diff --git a/fabric/src/main/java/de/cech12/bucketlib/platform/FabricPlatformHelper.java b/fabric/src/main/java/de/cech12/bucketlib/platform/FabricPlatformHelper.java index 72c7ec7..003fce5 100644 --- a/fabric/src/main/java/de/cech12/bucketlib/platform/FabricPlatformHelper.java +++ b/fabric/src/main/java/de/cech12/bucketlib/platform/FabricPlatformHelper.java @@ -6,7 +6,10 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTabs; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; /** * The platform service implementation for Fabric. @@ -43,4 +46,9 @@ public String getMilkTranslationKey() { return "tag.fluid.c.milk"; } + @Override + public int getBurnTime(ItemStack stack, RecipeType recipeType) { + return AbstractFurnaceBlockEntity.getFuel().getOrDefault(stack.getItem(), 0); + } + } diff --git a/fabric/src/main/resources/bucketlib.fabric.mixins.json b/fabric/src/main/resources/bucketlib.fabric.mixins.json index b2ee806..a7b7268 100644 --- a/fabric/src/main/resources/bucketlib.fabric.mixins.json +++ b/fabric/src/main/resources/bucketlib.fabric.mixins.json @@ -7,6 +7,7 @@ "MobBucketItemAccessor" ], "client": [ + "AbstractFurnaceBlockEntityMixin", "BlockModelAccessor", "ItemModelGeneratorAccessor" ], diff --git a/forge/src/main/java/de/cech12/bucketlib/mixin/ForgeUniversalBucketItemMixin.java b/forge/src/main/java/de/cech12/bucketlib/mixin/ForgeUniversalBucketItemMixin.java index 2bec566..59fe44b 100644 --- a/forge/src/main/java/de/cech12/bucketlib/mixin/ForgeUniversalBucketItemMixin.java +++ b/forge/src/main/java/de/cech12/bucketlib/mixin/ForgeUniversalBucketItemMixin.java @@ -4,7 +4,6 @@ import de.cech12.bucketlib.api.item.UniversalBucketItem; import de.cech12.bucketlib.item.UniversalBucketFluidHandler; import de.cech12.bucketlib.platform.Services; -import de.cech12.bucketlib.util.BucketLibUtil; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -12,8 +11,6 @@ import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.Enchantments; -import net.minecraft.world.level.material.Fluid; -import net.minecraft.world.level.material.Fluids; import net.minecraftforge.common.capabilities.ICapabilityProvider; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; @@ -27,12 +24,8 @@ public ForgeUniversalBucketItemMixin(Properties properties) { @Override public int getBurnTime(ItemStack itemStack, @Nullable RecipeType recipeType) { - //entity buckets should not use the burn time of its fluid - if (!BucketLibUtil.containsEntityType(itemStack)) { - Fluid fluid = Services.FLUID.getContainedFluid(itemStack); - if (fluid != Fluids.EMPTY) { - return new ItemStack(fluid.getBucket()).getBurnTime(recipeType); - } + if (itemStack.getItem() instanceof UniversalBucketItem universalBucketItem) { + return universalBucketItem.getBucketBurnTime(itemStack, recipeType); } return super.getBurnTime(itemStack, recipeType); } diff --git a/forge/src/main/java/de/cech12/bucketlib/platform/ForgePlatformHelper.java b/forge/src/main/java/de/cech12/bucketlib/platform/ForgePlatformHelper.java index b187a42..496bc74 100644 --- a/forge/src/main/java/de/cech12/bucketlib/platform/ForgePlatformHelper.java +++ b/forge/src/main/java/de/cech12/bucketlib/platform/ForgePlatformHelper.java @@ -4,7 +4,10 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTabs; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; +import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.util.LogicalSidedProvider; import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.ModList; @@ -49,4 +52,9 @@ public String getMilkTranslationKey() { return "fluid_type.minecraft.milk"; } + @Override + public int getBurnTime(ItemStack stack, RecipeType recipeType) { + return ForgeHooks.getBurnTime(stack, recipeType); + } + } diff --git a/gradle.properties b/gradle.properties index d8f584c..e5388aa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ # Project group=de.cech12.bucketlib -mod_version=3.2.1.5 +mod_version=3.2.1.6 mod_id=bucketlib mod_name=BucketLib mod_author=Cech12 diff --git a/neoforge/src/main/java/de/cech12/bucketlib/mixin/NeoforgeUniversalBucketItemMixin.java b/neoforge/src/main/java/de/cech12/bucketlib/mixin/NeoforgeUniversalBucketItemMixin.java index 69f2b00..6e13c9f 100644 --- a/neoforge/src/main/java/de/cech12/bucketlib/mixin/NeoforgeUniversalBucketItemMixin.java +++ b/neoforge/src/main/java/de/cech12/bucketlib/mixin/NeoforgeUniversalBucketItemMixin.java @@ -3,15 +3,12 @@ import de.cech12.bucketlib.api.BucketLibTags; import de.cech12.bucketlib.api.item.UniversalBucketItem; import de.cech12.bucketlib.platform.Services; -import de.cech12.bucketlib.util.BucketLibUtil; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.Enchantments; -import net.minecraft.world.level.material.Fluid; -import net.minecraft.world.level.material.Fluids; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; @@ -25,12 +22,8 @@ public NeoforgeUniversalBucketItemMixin(Properties properties) { @Override public int getBurnTime(@NotNull ItemStack itemStack, @Nullable RecipeType recipeType) { - //entity buckets should not use the burn time of its fluid - if (!BucketLibUtil.containsEntityType(itemStack)) { - Fluid fluid = Services.FLUID.getContainedFluid(itemStack); - if (fluid != Fluids.EMPTY) { - return new ItemStack(fluid.getBucket()).getBurnTime(recipeType); - } + if (itemStack.getItem() instanceof UniversalBucketItem universalBucketItem) { + return universalBucketItem.getBucketBurnTime(itemStack, recipeType); } return super.getBurnTime(itemStack, recipeType); } diff --git a/neoforge/src/main/java/de/cech12/bucketlib/platform/NeoforgePlatformHelper.java b/neoforge/src/main/java/de/cech12/bucketlib/platform/NeoforgePlatformHelper.java index 8667969..16502ed 100644 --- a/neoforge/src/main/java/de/cech12/bucketlib/platform/NeoforgePlatformHelper.java +++ b/neoforge/src/main/java/de/cech12/bucketlib/platform/NeoforgePlatformHelper.java @@ -4,6 +4,8 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTabs; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; import net.neoforged.fml.LogicalSide; import net.neoforged.fml.ModList; @@ -49,4 +51,9 @@ public String getMilkTranslationKey() { return "fluid_type.minecraft.milk"; } + @Override + public int getBurnTime(ItemStack stack, RecipeType recipeType) { + return stack.getBurnTime(recipeType); + } + }