Posted April 21, 20196 yr My item class extends ItemAxe. It has a texture and behaves the same way as normal axes. When it's destroyed due to having 0 durability, the particles that appear are the purple missing texture image. I can't figure out why this happens. Here's the item class: public class ItemImprovisedAxe extends ItemAxe { public ItemImprovisedAxe() { super(ItemTier.WOOD, 7.0f, -3.0f, new Item.Properties().addToolType(ToolType.AXE, 1).defaultMaxDamage(33).group(ItemGroup.TOOLS)); this.setRegistryName(ModInfo.MODID, "improvised_axe"); } } Here's src/main/resources/assets/[modid]/models/item/improvised_axe.json: { "parent": "item/handheld", "textures": { "layer0": "modid:item/improvised_axe" } } The 16x16 texture is src/main/resources/assets/[modid]/textures.item/improvised_axe.png Edited April 22, 20196 yr by treebranch
April 22, 20196 yr Author I "fixed" this by overriding the hitEntity, onBlockDestroyed, and onItemUse methods to call my own copy/paste of ItemStack.damageItem, which passes a stack of Items.WOODEN_AXE to EntityLivingBase.renderBrokenItemStack instead of my axe's stack. It's extremely hard to look at, but it works. If anybody has a better solution please let me know still. public class ItemImprovisedAxe extends ItemAxe { public ItemImprovisedAxe() { super(ItemTier.WOOD, 7.0f, -3.0f, new Item.Properties().addToolType(ToolType.AXE, 1).defaultMaxDamage(33).group(ItemGroup.TOOLS)); this.setRegistryName(ModInfo.MODID, "improvised_axe"); } private final ItemStack WOODEN_AXE_STACK = new ItemStack(Items.WOODEN_AXE); // from ItemStack private void damageItem(ItemStack stack, int amount, EntityLivingBase entityIn) { if (!(entityIn instanceof EntityPlayer) || !((EntityPlayer)entityIn).abilities.isCreativeMode) { if (/*this*/stack.isDamageable()) { if (/*this*/stack.attemptDamageItem(amount, entityIn.getRNG(), entityIn instanceof EntityPlayerMP ? (EntityPlayerMP)entityIn : null)) { //entityIn.renderBrokenItemStack(/*this*/stack); entityIn.renderBrokenItemStack(WOODEN_AXE_STACK); Item item = /*this*/stack.getItem(); /*this*/stack.shrink(1); if (entityIn instanceof EntityPlayer) { ((EntityPlayer)entityIn).addStat(StatList.ITEM_BROKEN.get(item)); } /*this*/stack.setDamage(0); } } } } @Override public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { //stack.damageItem(2, attacker); damageItem(stack, 2, attacker); return true; } @Override public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) { if (!worldIn.isRemote && state.getBlockHardness(worldIn, pos) != 0.0F) { //stack.damageItem(1, entityLiving); damageItem(stack, 1, entityLiving); } return true; } @Override public EnumActionResult onItemUse(ItemUseContext p_195939_1_) { World world = p_195939_1_.getWorld(); BlockPos blockpos = p_195939_1_.getPos(); IBlockState iblockstate = world.getBlockState(blockpos); Block block = BLOCK_STRIPPING_MAP.get(iblockstate.getBlock()); if (block != null) { EntityPlayer entityplayer = p_195939_1_.getPlayer(); world.playSound(entityplayer, blockpos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F); if (!world.isRemote) { world.setBlockState(blockpos, block.getDefaultState().with(BlockRotatedPillar.AXIS, iblockstate.get(BlockRotatedPillar.AXIS)), 11); if (entityplayer != null) { //p_195939_1_.getItem().damageItem(1, entityplayer); damageItem(p_195939_1_.getItem(), 1, entityplayer); } } return EnumActionResult.SUCCESS; } else { return EnumActionResult.PASS; } } } Edited April 22, 20196 yr by treebranch
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.