mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 04:09:51 +00:00
Cleanup some null checks and remove deprecated methods in Item and Block (#3429)
This commit is contained in:
1 parent
2823447b6e
commit
2bd8b95a3b
31 files changed
+175
-174
No files matched your search
@@ -156,7 +156,7 @@ public class ForgeHooks
|
||||
private static boolean toolInit = false;
|
||||
//static HashSet<List> toolEffectiveness = new HashSet<List>();
|
||||
|
||||
public static boolean canHarvestBlock(Block block, EntityPlayer player, IBlockAccess world, BlockPos pos)
|
||||
public static boolean canHarvestBlock(@Nonnull Block block, @Nonnull EntityPlayer player, @Nonnull IBlockAccess world, @Nonnull BlockPos pos)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
state = state.getBlock().getActualState(state, world, pos);
|
||||
@@ -165,7 +165,7 @@ public class ForgeHooks
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemStack stack = player.inventory.getCurrentItem();
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
String tool = block.getHarvestTool(state);
|
||||
if (stack.func_190926_b() || tool == null)
|
||||
{
|
||||
@@ -190,7 +190,7 @@ public class ForgeHooks
|
||||
return stack.getItem().getHarvestLevel(stack, tool, null, null) >= state.getBlock().getHarvestLevel(state);
|
||||
}
|
||||
|
||||
public static float blockStrength(IBlockState state, EntityPlayer player, World world, BlockPos pos)
|
||||
public static float blockStrength(@Nonnull IBlockState state, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos)
|
||||
{
|
||||
float hardness = state.getBlockHardness(world, pos);
|
||||
if (hardness < 0.0F)
|
||||
|
||||
@@ -45,25 +45,7 @@ public class ForgeInternalHandler
|
||||
if (entity.getClass().equals(EntityItem.class))
|
||||
{
|
||||
ItemStack stack = ((EntityItem)entity).getEntityItem();
|
||||
|
||||
if (stack == null)
|
||||
{
|
||||
//entity.setDead();
|
||||
//event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Item item = stack.getItem();
|
||||
if (item == null)
|
||||
{
|
||||
FMLLog.warning("Attempted to add a EntityItem to the world with a invalid item at " +
|
||||
"(%2.2f, %2.2f, %2.2f), this is most likely a config issue between you and the server. Please double check your configs",
|
||||
entity.posX, entity.posY, entity.posZ);
|
||||
entity.setDead();
|
||||
event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.hasCustomEntity(stack))
|
||||
{
|
||||
Entity newEntity = item.createEntity(event.getWorld(), entity, stack);
|
||||
|
||||
Reference in new issue
Block a user