2015-06-23 01:23:05 +00:00
|
|
|
package net.minecraftforge.debug;
|
|
|
|
|
2016-08-19 22:54:37 +00:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2016-03-01 12:58:03 +00:00
|
|
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
2015-06-23 01:23:05 +00:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
2016-07-24 11:47:34 +00:00
|
|
|
import net.minecraft.entity.Entity;
|
2016-08-19 22:54:37 +00:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
2015-06-23 01:23:05 +00:00
|
|
|
import net.minecraft.item.Item;
|
2016-07-24 11:47:34 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2016-04-03 07:13:50 +00:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2016-07-24 11:47:34 +00:00
|
|
|
import net.minecraft.world.World;
|
2015-06-23 01:23:05 +00:00
|
|
|
import net.minecraftforge.client.model.ModelLoader;
|
|
|
|
import net.minecraftforge.fml.common.Mod;
|
|
|
|
import net.minecraftforge.fml.common.Mod.EventHandler;
|
|
|
|
import net.minecraftforge.fml.common.SidedProxy;
|
|
|
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
|
|
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
|
|
|
|
2016-07-24 11:47:34 +00:00
|
|
|
import java.util.Random;
|
|
|
|
|
2016-08-19 22:54:37 +00:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2016-11-22 20:12:13 +00:00
|
|
|
@Mod(modid = ItemLayerModelDebug.MODID, name = "ForgeDebugItemLayerModel", version = ItemLayerModelDebug.VERSION, acceptableRemoteVersions = "*")
|
2015-06-23 01:23:05 +00:00
|
|
|
public class ItemLayerModelDebug
|
|
|
|
{
|
2016-08-12 22:10:47 +00:00
|
|
|
public static final String MODID = "forgedebugitemlayermodel";
|
2015-06-23 01:23:05 +00:00
|
|
|
public static final String VERSION = "1.0";
|
|
|
|
|
2016-01-02 06:59:14 +00:00
|
|
|
@SidedProxy
|
2015-06-23 01:23:05 +00:00
|
|
|
public static CommonProxy proxy;
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); }
|
|
|
|
|
|
|
|
public static class CommonProxy
|
|
|
|
{
|
|
|
|
public void preInit(FMLPreInitializationEvent event)
|
|
|
|
{
|
2016-04-03 07:13:50 +00:00
|
|
|
GameRegistry.register(TestItem.instance);
|
2015-06-23 01:23:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-02 06:59:14 +00:00
|
|
|
public static class ServerProxy extends CommonProxy {}
|
|
|
|
|
2015-06-23 01:23:05 +00:00
|
|
|
public static class ClientProxy extends CommonProxy
|
|
|
|
{
|
|
|
|
private static ModelResourceLocation modelLocation = new ModelResourceLocation(MODID.toLowerCase() + ":" + TestItem.name, "inventory");
|
|
|
|
@Override
|
|
|
|
public void preInit(FMLPreInitializationEvent event)
|
|
|
|
{
|
|
|
|
super.preInit(event);
|
|
|
|
ModelLoader.setCustomModelResourceLocation(TestItem.instance, 0, modelLocation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final class TestItem extends Item
|
|
|
|
{
|
|
|
|
public static final TestItem instance = new TestItem();
|
2016-11-16 03:26:10 +00:00
|
|
|
public static final String name = "test_item";
|
2015-06-23 01:23:05 +00:00
|
|
|
|
|
|
|
private TestItem()
|
|
|
|
{
|
2016-05-18 12:11:56 +00:00
|
|
|
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
|
2015-06-23 01:23:05 +00:00
|
|
|
setUnlocalizedName(MODID + ":" + name);
|
2016-04-03 07:13:50 +00:00
|
|
|
setRegistryName(new ResourceLocation(MODID, name));
|
2015-06-23 01:23:05 +00:00
|
|
|
}
|
2016-07-24 11:47:34 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
|
|
|
|
{
|
|
|
|
NBTTagCompound tag = new NBTTagCompound();
|
|
|
|
tag.setInteger("foo", new Random().nextInt());
|
|
|
|
stack.setTagCompound(tag);
|
|
|
|
stack.setStackDisplayName(String.valueOf(new Random().nextInt()));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack)
|
|
|
|
{
|
|
|
|
return shouldCauseReequipAnimation(oldStack, newStack, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
|
|
|
|
{
|
|
|
|
oldStack = oldStack.copy();
|
|
|
|
oldStack.setTagCompound(null);
|
|
|
|
newStack = newStack.copy();
|
|
|
|
newStack.setTagCompound(null);
|
|
|
|
return !ItemStack.areItemStacksEqual(oldStack, newStack);
|
|
|
|
}
|
2016-08-19 22:54:37 +00:00
|
|
|
|
|
|
|
@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;
|
|
|
|
}
|
2015-06-23 01:23:05 +00:00
|
|
|
}
|
|
|
|
}
|