mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-26 09:42:06 -07:00
Add ItemType#getBurnDuration() (#12604)
This commit is contained in:
@@ -3021,9 +3021,18 @@ public interface ItemType extends Keyed, Translatable, net.kyori.adventure.trans
|
||||
* Checks if this item type can be used as fuel in a Furnace
|
||||
*
|
||||
* @return true if this item type can be used as fuel.
|
||||
* @see #getBurnDuration()
|
||||
*/
|
||||
boolean isFuel();
|
||||
|
||||
/**
|
||||
* Retrieve the item's burn duration in a Furnace
|
||||
*
|
||||
* @return the burn duration, in ticks or 0 if the item is not fuel
|
||||
* @see #isFuel()
|
||||
*/
|
||||
int getBurnDuration();
|
||||
|
||||
/**
|
||||
* Checks whether this item type is compostable (can be inserted into a
|
||||
* composter).
|
||||
|
@@ -15,6 +15,7 @@ import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.component.ItemAttributeModifiers;
|
||||
import net.minecraft.world.level.block.ComposterBlock;
|
||||
import net.minecraft.world.level.block.entity.FuelValues;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Registry;
|
||||
import org.bukkit.World;
|
||||
@@ -155,6 +156,18 @@ public class CraftItemType<M extends ItemMeta> extends HolderableBase<Item> impl
|
||||
return MinecraftServer.getServer().fuelValues().isFuel(new net.minecraft.world.item.ItemStack(this.getHandle()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBurnDuration() {
|
||||
FuelValues fuelValues = MinecraftServer.getServer().fuelValues();
|
||||
net.minecraft.world.item.ItemStack stack = new net.minecraft.world.item.ItemStack(this.getHandle());
|
||||
|
||||
if (!fuelValues.isFuel(stack)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return fuelValues.burnDuration(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompostable() {
|
||||
return ComposterBlock.COMPOSTABLES.containsKey(this.getHandle());
|
||||
|
Reference in New Issue
Block a user