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

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.

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

  • Author

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.

  • Author

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.

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.