Posted July 19, 20169 yr 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" } ] }
July 19, 20169 yr 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"); }
July 19, 20169 yr 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.