mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Add a hook to allow continuously using items through stack changes (#4834)
This commit is contained in:
1 parent
1a7e05a3da
commit
817546e4c8
4 files changed
+167
-7
No files matched your search
@@ -183,6 +183,15 @@ public class ForgeHooks
|
||||
return entry.getStack(rand, fortune);
|
||||
}
|
||||
|
||||
public static boolean canContinueUsing(@Nonnull ItemStack from, @Nonnull ItemStack to)
|
||||
{
|
||||
if (!from.isEmpty() && !to.isEmpty())
|
||||
{
|
||||
return from.getItem().canContinueUsing(from, to);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canHarvestBlock(@Nonnull IBlockState state, @Nonnull EntityPlayer player, @Nonnull IBlockReader world, @Nonnull BlockPos pos)
|
||||
{
|
||||
//state = state.getActualState(world, pos);
|
||||
|
||||
@@ -647,6 +647,20 @@ public interface IForgeItem
|
||||
&& (newStack.isDamageable() || newStack.getDamage() == oldStack.getDamage()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called while an item is in 'active' use to determine if usage should
|
||||
* continue. Allows items to continue being used while sustaining damage, for
|
||||
* example.
|
||||
*
|
||||
* @param oldStack the previous 'active' stack
|
||||
* @param newStack the stack currently in the active hand
|
||||
* @return true to set the new stack to active and continue using it
|
||||
*/
|
||||
default boolean canContinueUsing(ItemStack oldStack, ItemStack newStack)
|
||||
{
|
||||
return oldStack.equals(newStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to get the Mod ID of the mod that *created* the ItemStack, instead of
|
||||
* the real Mod ID that *registered* it.
|
||||
|
||||
Reference in new issue
Block a user