thepillager Posted July 20, 2020 Posted July 20, 2020 Hi ! I'm New In Modding So I followed a tutorial about it , I watched TechoVision's Custom Food Tutorial ,Everything's Good But The ".effect" Is Strike Through ,If You Have A Solution That will be helpful :) !! *You Can Download it to see what's Happening NOTE : I use IntelliJ IDEA 2020.1 Minecraft Version : 1.15.2 package com.pillager.morefood.items; import com.pillager.morefood.MorefoodMod; import net.minecraft.item.Food; import net.minecraft.item.Item; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; public class Cheese extends Item { public Cheese() { super(new Item.Properties() .group(MorefoodMod.TAB) .food(new Food.Builder() .hunger(6) .saturation(16.2f) .effect(new EffectInstance(Effects.SATURATION,2400,1),1.0f) <-".effect" Is StrikeThrough .setAlwaysEdible() .fastToEat() .build() ) ); } } Cheese.java Quote
Ugdhar Posted July 20, 2020 Posted July 20, 2020 Look at the Food.Builder class, it tells you why it is deprecated right in the code. Quote
thepillager Posted July 20, 2020 Author Posted July 20, 2020 i don't have a class called Food.builder Quote
Ugdhar Posted July 20, 2020 Posted July 20, 2020 2 minutes ago, thepillager said: i don't have a class called Food.builder It has a capital B, open the Food class and find the nested Builder class. You should be able to right click on the method name in your own code and go to definition or something like that (I don't use IntelliJ so don't know what they call it, eclipse says "Open Declaration") Quote
thepillager Posted July 20, 2020 Author Posted July 20, 2020 Sorry ! I don't understand but here's a screenshot when i hover on ".effect": Quote
thepillager Posted July 20, 2020 Author Posted July 20, 2020 (edited) i found this : Did I need to do something Edited July 20, 2020 by thepillager Quote
Dzuchun Posted July 20, 2020 Posted July 20, 2020 (edited) If you want to apply an effect, use Item#onItemUseFinish, that works fine. But don't forget to check if you're on server - otherwise you'll get infinite ghost effect with zero duration left. I attach source of my pineapple item class, which has a stacking speed effect. (Whould be appreciate for any suggestions how to improve it as well) PineappleBlockItem.java P.S.: Now I don't use static fields as I do here. Edited July 21, 2020 by Dzuchun Quote Everything said above may be absolutely wrong. No rights reserved.
ChampionAsh5357 Posted July 20, 2020 Posted July 20, 2020 54 minutes ago, Dzuchun said: If you want to apply an effect, use Item#onItemUseFinish, that works fine. But don't forget to check if you're on server - otherwise you'll get infinite ghost effect with zero duration left. I attach source of my pineapple item class, which has a stacking speed effect. (Whould be appreciate for any suggestions how to improve it as well) PineappleBlockItem.java 3.28 kB · 1 download P.S.: Now I don't use static fields as I do here. No. Food specifically has a method for applying effects. Use the supplier version of the it. Do not override a method for an already implemented purpose. 1 Quote
Recommended Posts
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.