Class SpoilHelper
java.lang.Object
com.mrbysco.spoiled.util.SpoilHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.world.item.crafting.RecipeHolder<SpoilRecipe> getSpoilRecipe(net.minecraft.world.level.Level level, net.minecraft.world.item.ItemStack stack) get the Spoil Recipe for the given stackstatic intgetSpoilTime(net.minecraft.world.item.ItemStack stack) Get the spoil time for a stackstatic booleanisSpoiled(net.minecraft.world.item.ItemStack stack) Check if a stack is spoiledstatic booleanisSpoiling(net.minecraft.world.item.ItemStack stack) Check if a stack is spoilingstatic voidsetSpoilTime(net.minecraft.world.item.ItemStack stack, int time) Set the spoil time for a stackstatic voidspoilItemForEntity(net.minecraft.world.Container container, net.minecraft.world.entity.Entity entity, net.minecraft.world.item.ItemStack stack, SpoilRecipe recipe) Spoil a stack for a containerstatic voidspoilItemForPlayer(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack, SpoilRecipe recipe) Spoil a stack for a playerstatic voidspoilSingleItemAndReplace(net.minecraft.server.level.ServerLevel level, net.minecraft.world.item.ItemStack stack, Consumer<net.minecraft.world.item.ItemStack> setCallback) Spoils a stack with a single item and replaces the instance in the associated location.static booleantotalUnderMax(net.minecraft.world.item.ItemStack stack1, net.minecraft.world.item.ItemStack stack2) Check if merging two stacks will have the total under the max stack sizestatic voidupdateSpoilingStack(net.minecraft.world.item.ItemStack stack, SpoilRecipe recipe) Update the spoil time for a stack
-
Constructor Details
-
SpoilHelper
public SpoilHelper()
-
-
Method Details
-
getSpoilRecipe
public static net.minecraft.world.item.crafting.RecipeHolder<SpoilRecipe> getSpoilRecipe(net.minecraft.world.level.Level level, net.minecraft.world.item.ItemStack stack) get the Spoil Recipe for the given stack- Parameters:
level- The world to get the recipe manager fromstack- The stack to check against- Returns:
- The Spoil Recipe matching the stack or null if none found
-
isSpoiling
public static boolean isSpoiling(net.minecraft.world.item.ItemStack stack) Check if a stack is spoiling- Parameters:
stack- The stack to check- Returns:
- true if the stack is spoiling
-
getSpoilTime
public static int getSpoilTime(net.minecraft.world.item.ItemStack stack) Get the spoil time for a stack- Parameters:
stack- The stack to check- Returns:
- The spoil time for the stack
-
setSpoilTime
public static void setSpoilTime(net.minecraft.world.item.ItemStack stack, int time) Set the spoil time for a stack- Parameters:
stack- The stack to set the spoil time fortime- The time to set
-
spoilItemForPlayer
public static void spoilItemForPlayer(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack, SpoilRecipe recipe) Spoil a stack for a player- Parameters:
player- The player to give the spoiled item tostack- The stack to spoilrecipe- The spoil recipe to use
-
spoilItemForEntity
public static void spoilItemForEntity(net.minecraft.world.Container container, net.minecraft.world.entity.Entity entity, net.minecraft.world.item.ItemStack stack, SpoilRecipe recipe) Spoil a stack for a container- Parameters:
container- The container to give the spoiled item toentity- The entity to get the world fromstack- The stack to spoilrecipe- The spoil recipe to use
-
spoilSingleItemAndReplace
public static void spoilSingleItemAndReplace(net.minecraft.server.level.ServerLevel level, net.minecraft.world.item.ItemStack stack, Consumer<net.minecraft.world.item.ItemStack> setCallback) Spoils a stack with a single item and replaces the instance in the associated location.- Parameters:
level- The level the stack is withinstack- The stack to spoilsetCallback- A callback to set the spoiled stack's location
-
updateSpoilingStack
public static void updateSpoilingStack(net.minecraft.world.item.ItemStack stack, SpoilRecipe recipe) Update the spoil time for a stack- Parameters:
stack- The stack to updaterecipe- The spoil recipe to use
-
isSpoiled
public static boolean isSpoiled(net.minecraft.world.item.ItemStack stack) Check if a stack is spoiled- Parameters:
stack- The stack to check- Returns:
- true if the stack is spoiled
-
totalUnderMax
public static boolean totalUnderMax(net.minecraft.world.item.ItemStack stack1, net.minecraft.world.item.ItemStack stack2) Check if merging two stacks will have the total under the max stack size- Parameters:
stack1- The first stackstack2- The second stack- Returns:
- true if the total will be under the max stack size
-