Jump to content

Recommended Posts

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.

Posted (edited)
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.

Posted

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.

Posted

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

×   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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
    • Maybe you need to create file in assets/<modid>/items/<itemname>.json with content like this:   { "model": { "type": "minecraft:model", "model": "modname:item/itemname" } }  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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