Jump to content

[1.10.2] IItemPropertyGetter and OBJ-model


MCRaichu

Recommended Posts

Hi,

I have an item using an obj-model (works fine). Now I tried to add a PropertyGetter to switch between two models and it seems it doesn't execute the 'apply' function (currently the function consists of a System.out and a return so no problem there). Any ideas are appreciated.

 

Thanks in adavance,

MCRaichu

 

PS: the idea is an item with an inventory that looks different while the gui is open. if there are examples with something similar out there, would be nice to know.

It doesn't work, I don't know why.

It works, I don't know why.

Link to comment
Share on other sites

4 hours ago, diesieben07 said:

Show your code.

okay.

my json file (location: assets.gunny.blockstates)

{
  "forge_marker": 1,
  "defaults": {
    "model": "gunny:b95_item.obj"
  },
  "variants": {
    "inventory": [
      {
        "transform": {
          "thirdperson_lefthand": {
            "rotation": [ { "x": 0 }, { "y": 0 }, { "z": 0 } ],
            "translation": [ 0.1, -0.1, 0.5 ],
            "scale": 0.15
          },
          "thirdperson_righthand": {
            "rotation": [ { "x": 0 }, { "y": 270 }, { "z": 0 } ],
            "translation": [ 0.1, 0.05, 0.2 ],
            "scale": 0.25
          },
          "gui": {
            "rotation": [ { "x": 45 }, { "y": 45 }, { "z": -45 } ],
            "translation": [ 0.2, -0.15, 0 ],
            "scale": 0.15
          },
          "firstperson_righthand": {
            "rotation": [ { "x": 0 }, { "y": 250 }, { "z": 0 } ],
            "translation": [ 0.0, 0.15, 0.0 ],
            "scale": 0.5
          },
          "firstperson_lefthand": {
            "rotation": [ { "x": 180 }, { "y": 180 }, { "z": 170 } ],
            "translation": [ 0, -0.1, 0 ],
            "scale": 0.5
          },
          "ground": {
            "rotation": [ { "x": 45 }, { "y": 0 }, { "z": 0 } ],
            "scale": 0.2
          }
        }
      }
    ]
  },
    "overrides": [
        {
            "predicate": {
                "loading": 1
            },
            "model": "gunny:b95_open.obj"
        }
    ]
}

 

Item:

public class B95 extends ItemInternalStorage
{
	
	final int gun_cooldown = 20;
	
    public B95(String name) 
    {
    	super(name, 1);
		this.setHasSubtypes(true);
        this.setMaxDamage(0);
        this.setCreativeTab(Gunny.tabGunny);
        
        this.addPropertyOverride(new ResourceLocation("loading"), new IItemPropertyGetter()
        {
            @SideOnly(Side.CLIENT)
            public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn)
            {
            	System.out.println("loading");
            	return 0.0F;
            }
        });
        
    }
...
}

 

Registration (domain is already added):

ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(Gunny.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory"));

 

 

Anything else needed, just let me know.

Edited by MCRaichu

It doesn't work, I don't know why.

It works, I don't know why.

Link to comment
Share on other sites

Thanks for the quick answer. Since I only have two states the first the solution with ItemMeshDefinition makes the most sence. I have seen the ICustomModelLoader in ImmersiveEngineering and I definitly won't do that:D. Do you have a good example for ItemMeshDefinition ?

It doesn't work, I don't know why.

It works, I don't know why.

Link to comment
Share on other sites

That actually brings up another question. Since I want to change the model while the player is using the inventory/gui should I set a NBT flag to differentiate between both states? or is there a better soplution? I ask because of

8 minutes ago, diesieben07 said:

You just return the model you want for the ItemStack you get passed in

so the itemstack needs to know if gui ist open, right?

It doesn't work, I don't know why.

It works, I don't know why.

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.