Skip to content

Commit

Permalink
- moved new burn time methods to FilledCeramicBucketItem. #20
Browse files Browse the repository at this point in the history
  • Loading branch information
cech12 committed Sep 8, 2020
1 parent d25471d commit 0e53fcc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
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 @@ -23,7 +22,6 @@
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 @@ -220,32 +218,4 @@ 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 @@ -15,6 +15,7 @@
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack;
Expand Down Expand Up @@ -90,4 +91,32 @@ public ITextComponent getDisplayName(@Nonnull ItemStack 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;
}

}

0 comments on commit 0e53fcc

Please sign in to comment.