mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 19:15:32 +00:00
Expand getHarvestLevel to include player and blockstate (#3192)
This commit is contained in:
1 parent
7f40d90b75
commit
8dbfe1baad
4 files changed
+42
-12
No files matched your search
@@ -1,8 +1,11 @@
|
||||
package net.minecraftforge.debug;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -17,6 +20,8 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Mod(modid = ItemLayerModelDebug.MODID, name = "ForgeDebugItemLayerModel", version = ItemLayerModelDebug.VERSION)
|
||||
public class ItemLayerModelDebug
|
||||
{
|
||||
@@ -86,5 +91,19 @@ public class ItemLayerModelDebug
|
||||
newStack.setTagCompound(null);
|
||||
return !ItemStack.areItemStacksEqual(oldStack, newStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(ItemStack stack, String toolClass, @Nullable EntityPlayer player, @Nullable IBlockState blockState) {
|
||||
// This tool is a super pickaxe if the player is wearing a helment
|
||||
if("pickaxe".equals(toolClass) && player != null && player.getItemStackFromSlot(EntityEquipmentSlot.HEAD) != null) {
|
||||
return 5;
|
||||
}
|
||||
return super.getHarvestLevel(stack, toolClass, player, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStrVsBlock(ItemStack stack, IBlockState state) {
|
||||
return 10f;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user