Posted July 8, 20178 yr Hello, I have an item which needs to change texture based on a special property, like broken for elytra, but the texxture is never applied to the item and there are no errors relating to the item in the console, there are however errors for another item. I cant figure out why the texture isnt being displayed. Spoiler My Item Code: package net.drok.poverhaul.item; import javax.annotation.Nullable; import net.drok.poverhaul.ModBlocks; import net.drok.poverhaul.ModTabs; import net.drok.poverhaul.POHMod; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.IItemPropertyGetter; import net.minecraft.item.Item; import net.minecraft.item.ItemElytra; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ItemRock extends Item { private final int spacing = 25; public ItemRock() { this.setRegistryName(new ResourceLocation(POHMod.MODID, "rock")); this.setMaxDamage(110); this.setMaxStackSize(1); this.setCreativeTab(ModTabs.TABSTONEAGE); this.addPropertyOverride(new ResourceLocation("sharpness"), new IItemPropertyGetter() { @SideOnly(Side.CLIENT) public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) { System.out.println("sharpness: " + (int)Math.floor(stack.getMetadata() / spacing)); return (int)Math.floor(stack.getMetadata() / spacing); } }); } @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if(world.getBlockState(pos) == ModBlocks.basalt.getDefaultState()) { player.getHeldItemMainhand().damageItem(POHMod.RAND.nextInt(5) + 1, player); return EnumActionResult.SUCCESS; } return EnumActionResult.FAIL; } @Override public boolean showDurabilityBar(ItemStack stack) { return false; } @Override public String getUnlocalizedName(ItemStack stack) { return "item." + POHMod.getUnlocalizedNameBase(this.getRegistryName().getResourcePath()) + "_" + (int)Math.floor(stack.getMetadata() / spacing); } @SideOnly(Side.CLIENT) public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) { if (this.isInCreativeTab(tab)) { items.add(new ItemStack(this, 1, 0)); items.add(new ItemStack(this, 1, 25)); items.add(new ItemStack(this, 1, 50)); items.add(new ItemStack(this, 1, 75)); items.add(new ItemStack(this, 1, 100)); } } } My Main Item Json: { "parent": "item/generated", "textures": { "layer0": "poverhaul:items/rock_0" }, "overrides": [ { "predicate": { "sharpness": 1 }, "model": "poverhaul:item/rock_1" }, { "predicate": { "sharpness": 2 }, "model": "poverhaul:item/rock_2" }, { "predicate": { "sharpness": 3 }, "model": "poverhaul:item/rock_3" }, { "predicate": { "sharpness": 4 }, "model": "poverhaul:item/rock_4" } ] } My Sub Item Json: { "parent": "item/generated", "textures": { "layer0": "poverhaul:items/rock_1" } }
July 8, 20178 yr Author 7 hours ago, diesieben07 said: Show where you register your item models. What Minecraft version are you using? I am using 1.12 but what do you mean by where i register my models. I didnt know i had to register them unless you mean where i register my item?
July 8, 20178 yr If you didn't register models, you're not going to see models (so also no textures)... Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
July 8, 20178 yr You must register your models in the ModeRegistryEvent with ModelLoader.setCustomModelResourceLocation(). VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
July 8, 20178 yr Author 1 minute ago, Kokkie said: If you didn't register models, you're not going to see models (so also no textures)... Ok then what ddo i need to do to register them. EDIT: Ah ok thank you Animefan8888 Edited July 8, 20178 yr by drok0920
July 8, 20178 yr Just now, Animefan8888 said: You must register your models in the ModeRegistryEvent with ModelLoader.setCustomModelResourceLocation(). Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
July 8, 20178 yr Author Wait dont i only need to use ModelLoader if i plan on using variants rather lthan overrides? Unless im misunderstanding something.
July 8, 20178 yr You need to use ModelLoader for any model, yes.. Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
July 8, 20178 yr Author Ok then can you give me an example of what the parameters should be because i only know how to use that for variants.
July 8, 20178 yr Here's my model registration code. @SubscribeEvent public static void registerModels(ModelRegistryEvent event) { for (Block block : AMBlocks.BLOCKS) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory")); } for (Item item : AMItems.ITEMS) { ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); } } Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
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.