Jump to content

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


Recommended Posts

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"
        }
    ]
}

 

 

 

 

Posted

{
    "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");
}

 

 

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.