Add IRecipeType parameter to burn time hooks (#7771)

This commit is contained in:
Take Weiland authored and GitHub committed 2021-07-16 17:37:41 -07:00
1 parent df53db351e
commit f9b894ecbf
7 files changed
+77 -8

No files matched your search

@@ -63,6 +63,7 @@ import net.minecraft.entity.ai.attributes.AttributeModifierMap;
import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes;
import net.minecraft.fluid.*;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.LootTableManager;
@@ -1244,10 +1245,16 @@ public class ForgeHooks
private static final Map<IRegistryDelegate<Item>, Integer> VANILLA_BURNS = new HashMap<>();
@Deprecated // use variant with IRecipeType
public static int getBurnTime(ItemStack stack)
{
return getBurnTime(stack, null);
}
/**
* Gets the burn time of this itemstack.
*/
public static int getBurnTime(ItemStack stack)
public static int getBurnTime(ItemStack stack, @Nullable IRecipeType<?> recipeType)
{
if (stack.isEmpty())
{
@@ -1256,8 +1263,8 @@ public class ForgeHooks
else
{
Item item = stack.getItem();
int ret = stack.getBurnTime();
return ForgeEventFactory.getItemBurnTime(stack, ret == -1 ? VANILLA_BURNS.getOrDefault(item.delegate, 0) : ret);
int ret = stack.getBurnTime(recipeType);
return ForgeEventFactory.getItemBurnTime(stack, ret == -1 ? VANILLA_BURNS.getOrDefault(item.delegate, 0) : ret, recipeType);
}
}
@@ -48,6 +48,7 @@ import net.minecraft.item.AxeItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.ResourceLocation;
@@ -759,7 +760,13 @@ public interface IForgeItem
* it not act as a fuel. Return -1 to let the default vanilla logic
* decide.
*/
default int getBurnTime(ItemStack itemStack)
default int getBurnTime(ItemStack itemStack, @Nullable IRecipeType<?> recipeType)
{
return getBurnTime(itemStack);
}
@Deprecated // use variant with IRecipeType
default int getBurnTime(ItemStack stack)
{
return -1;
}
@@ -24,6 +24,7 @@ import java.util.Set;
import javax.annotation.Nullable;
import net.minecraft.entity.monster.EndermanEntity;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.util.CachedBlockInfo;
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.Enchantment;
@@ -83,9 +84,15 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundNBT>
* it not act as a fuel. Return -1 to let the default vanilla logic
* decide.
*/
default int getBurnTime(@Nullable IRecipeType<?> recipeType)
{
return getStack().getItem().getBurnTime(getStack(), recipeType);
}
@Deprecated // use variant with IRecipeType
default int getBurnTime()
{
return getStack().getItem().getBurnTime(getStack());
return getBurnTime(null);
}
/**