Jump to content

rEDOx_

Members
  • Posts

    5
  • Joined

  • Last visited

rEDOx_'s Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hi, I want insert and render my own model of an armor, but simply Idk where to start.
  2. I already read the page on registries in doc. Think I understand where the problem is. Basically The initial code was correct for registries initialization. The problem was that I called the .get() method in a method of a class that extend ArmorItem, the Items are registered before the MobEffect.
  3. It works like this: public class CustomEffectsRegistry { public static void register(IEventBus eventBus) { MOB_EFFECTS.register(eventBus); } public static final DeferredRegister<MobEffect> MOB_EFFECTS=DeferredRegister.create(ForgeRegistries.MOB_EFFECTS, BetterArmor.MODID); public static final FlyingEffect flyingEffect=new FlyingEffect(MobEffectCategory.BENEFICIAL, 3124687); public static RegistryObject<MobEffect> FLY_REGISTERED_OBJECT=MOB_EFFECTS.register("fly", ()->flyingEffect); } I reference to the object "flyingEffect", is that the "correct way"? I'm still searching in forum for other posts and in the link you provided. You said that I have not to store MobEffect directly into the item, and I thought I wasn't doing that. I stored the output of .register method in RegistryObject and call it. Edit: I tried to call .get() on the "FLY_REGISTERED_OBJECT" in an event fired at runtime and it works. So basically the problem is that a static allocation that imply the call of .get() perform on a not yet created entry. Is this correct? The code up here(and it's consequent use) seemed i bit verbose.
  4. I read the doc on why DeferredRegister gives me null. But now I don't understand how to fix that. It says: When using DeferredRegisters with non-vanilla registries, the registry key or the registry name should be supplied to the create method. These include the custom Forge registries for entity data serializers, global loot modifier serializers, world presets, and biome modifier serializers. Calling Supplier#get on a Supplier<IForgeRegistry<?>> when making a DeferredRegister will return null because the registry does not exist yet. So I have to change the create with registry key or registry name, but I have not understand how, cause I've not completely understand what these two objects are for, and how I have to pass to the create method.
  5. Hi, I'm trying to register a custom MobEffect, but when the mod load it seams to not have the MobEffect to be registered. The forge version is the 40.2.1 "Main" class @Mod(MODID) public class BetterArmor { //region Constructor public BetterArmor() { // Register the setup method for modloading IEventBus eventBus=FMLJavaModLoadingContext.get().getModEventBus(); CustomEffectsRegistry.register(eventBus); BetterArmorRegistryItems.register(eventBus); eventBus.addListener(this::setup); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); } ... } Class that hold references and register the effect public class CustomEffectsRegistry { public static void register(IEventBus eventBus) { MOB_EFFECTS.register(eventBus); } public static final DeferredRegister<MobEffect> MOB_EFFECTS= DeferredRegister.create(ForgeRegistries.MOB_EFFECTS, BetterArmor.MODID); public static RegistryObject<MobEffect> FLY=MOB_EFFECTS.register("fly", ()->new FlyingEffect(MobEffectCategory.BENEFICIAL, 3124687)); } Effetcs class public class FlyingEffect extends MobEffect { public FlyingEffect(MobEffectCategory mobEffectCategory, int color) { super(mobEffectCategory, color); } @Override public void applyEffectTick(LivingEntity livingEntity, int amplifier) { ... } @Override public boolean isDurationEffectTick(int p_19455_, int p_19456_) { //return super.isDurationEffectTick(p_19455_, p_19456_); return true; } } There's a method where I use the effect and where it gives me an excpetion(seems that Items are registerd before MobEffects) private static ArrayList<MobEffectInstance> buildEffectsArray() { ArrayList<MobEffectInstance> effects=new ArrayList<>(); effects.add(new MobEffectInstance(MobEffects.NIGHT_VISION, BaseMultipliers.BASETIMER, 50)); effects.add(new MobEffectInstance(CustomEffectsRegistry.FLY.get(), 200, 5)); return effects; } There's the exception
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.