Skip to content

Commit

Permalink
- a ceramic bucket filled with lava can now be used as fuel in furnac…
Browse files Browse the repository at this point in the history
…es. #20

- it also works for other fluids that have a burn time for their buckets
  • Loading branch information
cech12 committed Sep 8, 2020
1 parent af41740 commit d25471d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

mod_version=2.0.2
mod_version=2.0.3
minecraft_version=1.16.2+

forge_version=1.16.2-33.0.21
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cech12.ceramicbucket.item;

import cech12.ceramicbucket.api.item.CeramicBucketItems;
import cech12.ceramicbucket.util.CeramicBucketUtils;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.block.BlockState;
Expand All @@ -14,7 +15,6 @@
import net.minecraft.item.BucketItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.stats.Stats;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.*;
Expand All @@ -23,6 +23,7 @@
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
Expand Down Expand Up @@ -219,5 +220,32 @@ public ItemStack drain(ItemStack stack, int drainAmount) {
return stack;
}

@Override
public int getBurnTime(ItemStack itemStack) {
//get burn time of normal bucket
Fluid fluid = this.getFluid(itemStack);
if (fluid != Fluids.EMPTY) {
//all fluids have their burn time in their bucket item.
//get the burn time via ForgeHooks.getBurnTime to let other mods change burn times of buckets of vanilla and other fluids.
return ForgeHooks.getBurnTime(new ItemStack(fluid.getFilledBucket()));
}
return super.getBurnTime(itemStack);
}

@Override
public boolean hasContainerItem(ItemStack stack) {
//for using a filled bucket as fuel or in crafting recipes, an empty bucket should remain
Fluid fluid = this.getFluid(stack);
return fluid != Fluids.EMPTY && !CeramicBucketUtils.isFluidTooHotForCeramicBucket(fluid);
}

@Override
public ItemStack getContainerItem(ItemStack itemStack) {
//for using a filled bucket as fuel or in crafting recipes, an empty bucket should remain
if (this.hasContainerItem(itemStack)) {
return new ItemStack(CeramicBucketItems.CERAMIC_BUCKET);
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,11 @@ public ITextComponent getDisplayName(@Nonnull ItemStack stack) {
return new TranslationTextComponent("item.ceramicbucket.ceramic_milk_bucket");
}

@Override
public boolean hasContainerItem(ItemStack stack) {
//super method checks if a fluid is inside. Milk does not have to be a fluid.
Fluid fluid = this.getFluid(stack);
return fluid == Fluids.EMPTY || !CeramicBucketUtils.isFluidTooHotForCeramicBucket(fluid);
}

}

0 comments on commit d25471d

Please sign in to comment.