Fare un mod minecraft in java. Creazione e registrazione di un'istanza
Sto cercando di creare un lingotto di uranio che dia ai giocatori che lo tengono nel loro inventario un effetto avvizzito. Ho ricevuto alcuni suggerimenti dai forum di minecraft, mi hanno detto di fare per far sì che il mio oggetto mi dia l'effetto avvizzito.
Re: 1.10.2 Item has wither "Reply #2 on: Today at 02: 29: 58 am" Quotegrazie a creare una classe che estende Item e sovrascrive Articolo # onUpdate.
Nel tuo override, controlla se l'argomento entityIn è un'istanza di EntityLivingBase. Se lo è, lancialo per EntityLivingBase e chiamare EntityLivingBase # isPotionActive per verificare se ha i MobEffects.Effetto APPASSIRE attivo. In caso contrario, creare un PotionEffect e chiamare EntityLivingBase#addPotionEffect per aggiungerlo.
La mia domanda
Create and register an instance of this class instead of Item.
L'ultima riga è ciò che im confuso su.
Ecco la classe che ho fatto che mi ha detto di fare. Inoltre, per favore informami se non ho fatto qualcos'altro in questa classe
package item;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.MobEffects;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class UraniumIngotEffect extends Item{
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if(entityIn instanceof EntityLivingBase){
Object EntityLivingBase = ((EntityLivingBase) entityIn).isPotionActive(MobEffects.WITHER);
}else{
Object PotionEffect = new PotionEffect(MobEffects.WITHER);
}
super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
}
}
1 answers
È necessario rendere l'oggetto item nel mod tenere il metodo onUpdate.
Significa:
Avere una classe che estende l'elemento (il lingotto di uranio)
Registrare l'elemento nel caricatore dell'elemento
Item myurnanium = new UraniumIngot();
GameRegistry.register(myuranium);
E ovviamente crea i file json appropriati in modo che l'elemento venga visualizzato correttamente.
Ti suggerisco di leggere:
Http://bedrockminer.jimdo.com/modding-tutorials/basic-modding-1-8/first-item /