Jump to content

[1.8] Switching textures on click event.


TinMan216

Recommended Posts

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 !

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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