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.

(Solved)[1.10.2]Making a pickaxe change textures between night and day.

Featured Replies

Posted

I have a mod where a pickaxe changes its textures between night and day. It worked in 1.8 but I am converting it to 1.10. The old methods don't work and I currently am trying to find a way to do so.

 

This was the code responsible for doing this in 1.8.

@Override
public void onUpdate(ItemStack item, World world, Entity player, int num, boolean bool) {
if (world.getWorldTime() % 24000 < 12000) {
dayTime = true;
}
else {
dayTime = false;
}
}

@Override
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int usesLeft) {
if (dayTime)
  return new ModelResourceLocation(MyMod.MODID + "myPickaxe", "inventory");
else
  return new ModelResourceLocation(MyMod.MODID + "myPickaxe2", "inventory");
}

 

Here is my first try at it.

public CustomPickaxe() {
	super(MyMod.myToolMaterial);
	this.setCreativeTab(CreativeTabs.COMBAT);
	this.setUnlocalizedName("myPickaxe");

	this.addPropertyOverride(new ResourceLocation(MyMod.MODID,"dayTime"), new IItemPropertyGetter()
	{
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn)
        {
        	if(entityIn == null){
        		return 0.0F;
        	}
        	if(worldIn == null){
        		worldIn = entityIn.worldObj;
        	}
  
        	if (PickaxeHelper.isDayTime(worldIn)) {
        			return 0.0F;
        		}else {
        			return 1.0F;
        		}
        }
	});

}




}

And the model file is.

{
    "parent": "item/handheld",
    "textures": {
        "layer0": "fundamentals:items/myPickaxe"
    },
    "overrides": [
        {
            "predicate": {
                "dayTime": 0
            },
            "model": "fundamentals:item/myPickaxe"
        },
        {
            "predicate": {
                "dayTime": 1
            },
            "model": "fundamentals:item/myPickaxe2"
        }
    ]
}

 

 

 

 

  • Author

{
    "parent": "item/handheld",
    "textures": {
        "layer0": "fundamentals:items/myPickaxe"
    },
    "overrides": [
        {
            "predicate": {
                "fundamentals:dayTime": 0
            },
            "model": "fundamentals:item/myPickaxe"
        },
        {
            "predicate": {
                "fundamentals:dayTime": 1
            },
            "model": "fundamentals:item/myPickaxe2"
        }
    ]
}

Still getting a purple block.  Maybe I am not registering the textures right?

 

Located in Init() in MyMod.java

ModelBakery.registerItemVariants(myPickaxe, PickaxeHelper.getModel("myPickaxe"), PickaxeHelper.getModel("myPickaxe2"));

 

GetModel's declaration.

public static ModelResourceLocation getModel(String name) {
	return new ModelResourceLocation(MyMod.MODID + ":"+name, "inventory");
}

 

 

  • Author

Well, I ended up figuring it out.

 

Thank you for your help, especially with the predicate.

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.