Add ItemType#getBurnDuration() (#12604)
This commit is contained in:
parent
3750927a06
commit
d61a51e81e
2 changed files with 22 additions and 0 deletions
|
@ -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
|
* Checks if this item type can be used as fuel in a Furnace
|
||||||
*
|
*
|
||||||
* @return true if this item type can be used as fuel.
|
* @return true if this item type can be used as fuel.
|
||||||
|
* @see #getBurnDuration()
|
||||||
*/
|
*/
|
||||||
boolean isFuel();
|
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
|
* Checks whether this item type is compostable (can be inserted into a
|
||||||
* composter).
|
* composter).
|
||||||
|
|
|
@ -15,6 +15,7 @@ import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.component.ItemAttributeModifiers;
|
import net.minecraft.world.item.component.ItemAttributeModifiers;
|
||||||
import net.minecraft.world.level.block.ComposterBlock;
|
import net.minecraft.world.level.block.ComposterBlock;
|
||||||
|
import net.minecraft.world.level.block.entity.FuelValues;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Registry;
|
import org.bukkit.Registry;
|
||||||
import org.bukkit.World;
|
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()));
|
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
|
@Override
|
||||||
public boolean isCompostable() {
|
public boolean isCompostable() {
|
||||||
return ComposterBlock.COMPOSTABLES.containsKey(this.getHandle());
|
return ComposterBlock.COMPOSTABLES.containsKey(this.getHandle());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue