Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Evening guys.

 

Ive been following multiple series online ; Pahimar's Lets mod and VsweGoesMinecraft's summer lecture courses for minecraft modding. While many practices in these series have not changed, some have for instance, changing an items texture, both series use the icon register however with the new introduction of 1.8 it now needs JSON files to accompany the texture and a renderer.

 

My problem is, is that the second texture for the item is not getting changed when the code is called. However it happily changes it back to the original texture when instructed to do so.

 

Ive checked the both JSON files and are identical (copied one from another and renamed the texture its looking for) and in the same directory.

 

Wand Class


public class ItemWand extends CustomItem {

    public ItemWand() {
        super("wand", CreativeTabs.tabCombat, 1, 10);

        this.RegisterRenderer("wand");

    }


//TODO: change icon based on if it is charged or not. for this use the renderer but it acts odd.

    @Override
    public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target) {
        if (!target.worldObj.isRemote) {
            target.motionY = 2;

            if (isCharged(stack.getItemDamage())) {

               this.RegisterRenderer("wand2");  //will not change to second texture.

                target.motionX = (target.posX - playerIn.posX)*2;
                target.motionZ = (target.posZ - playerIn.posZ)*2;

            } else {
                stack.setItemDamage(stack.getItemDamage() + 1);

            }
            stack.damageItem(1, target);

        }
        return false;
    }

    public boolean isCharged(int dmgVal) {

        return dmgVal >= 3;
    }

 

Register renderer method call

  public void RegisterRenderer(String name) {
        System.out.println("Initialising Renderer For : " + name);
        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(this, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + name, "inventory"));

    }

 

JSON file (i'll provide one since the only difference between the two is names 'stevesexample:items/wand' and 'stevesexample:items/wand2')

 

{
"parent": "builtin/generated",
"textures": {
	"layer0": "stevesexample:items/wand"
},
"display": {
	"thirdperson": {
		"rotation": [-90, 0, 0],
		"translation": [0, 1, -3],
		"scale": [0.55, 0.55, 0.55 ]
	},
	"firstperson": {
		"rotation": [0, -135, 25 ],
		"translation": [0, 4, 2 ],
		"scale": [1.7, 1.7, 1.7]
	}
}
}

what am I missing here or is it not that simple any more?

 

Thanks

C# Web Developer who dabbles with many languages. Having fun with modding !

Don't dynamically register models..

Just use metadata for that.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

  • Author

Ah thanks, ill give that a try tonight and update with any code.

C# Web Developer who dabbles with many languages. Having fun with modding !

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.