Jump to content

[SOLVED] [1.16.4] Entity Attributes not Registering


UserMC123

Recommended Posts

Im trying to add my attributes but they are not Registering

 

Main Class:

@Mod(test.MOD_ID)
@Mod.EventBusSubscriber(modid = test.MOD_ID, bus = Bus.MOD)
public class test
{
    public static final Logger LOGGER = LogManager.getLogger();
    public static final String MOD_ID = "test";

    public test() {
        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientEvent);

        MinecraftForge.EVENT_BUS.register(modEventBus);
    }

    public void clientEvent(final FMLClientSetupEvent event){

    }



    public static void onRegisterEntities(final RegistryEvent.Register<EntityType<?>> event){
    }

    @SubscribeEvent
    public static void setup(final FMLCommonSetupEvent event) {
          DeferredWorkQueue.runLater(()->
         {
        GlobalEntityTypeAttributes.put(EntityInit.test_entity, TestEntity.setAttributes().create());
        });

    }
}

 

ModEntities:

@ObjectHolder(test.MOD_ID)
@Mod.EventBusSubscriber(modid = "test", bus = Mod.EventBusSubscriber.Bus.MOD)
public class EntityInit
{

  public static EntityType<TestEntity> test_entity = null;

  @SubscribeEvent
  public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) {
    event.getRegistry().register(EntityType.Builder.create(TestEntity::new, EntityClassification.CREATURE).size(1.0f, 2.f).build(new ResourceLocation(test.MOD_ID, "test_entity").toString()).setRegistryName("test_entity"));
  }
}

 

TestEntity:

public class TestEntity extends MobEntity {


    public TestEntity(EntityType<? extends MobEntity> p_i48576_1_, World p_i48576_2_) {
        super(p_i48576_1_, p_i48576_2_);

    }

    public static AttributeModifierMap.MutableAttribute setAttributes() {
        return MobEntity.func_233666_p_()
                .createMutableAttribute(Attributes.MAX_HEALTH, 100.0D)
                .createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.25D);
    }

    @Nullable @Override
    protected SoundEvent getDeathSound()
    {
        return SoundEvents.BLOCK_ANVIL_DESTROY;
    }

 

Renderer:

public class TestEntityRenderer extends MobRenderer<TestEntity, TestEntityModdel<TestEntity>>
{

    protected static final ResourceLocation TEXTURE = new ResourceLocation(test.MOD_ID,"textures/entity/test_entity.png");

    public TestEntityRender(EntityRendererManager renderManagerIn)
    {super(renderManagerIn, new TestEntityModel(), 1.0f);}

    @Override public ResourceLocation getEntityTexture(TestEntity entity){return TEXTURE;}
}

 

Edited by UserMC123
Link to comment
Share on other sites

I tried to use DeferredRegister And they work but when I package my mod in to a .jar file and launch the game with it installed I get this

 

Test Mod (test) encountered an error during the common_setup event phase

 

And in the crash report I see this.

 

---- Minecraft Crash Report ----
// There are four lights!

Time: 12/15/20 3:20 PM
Description: Mod loading error has occurred

java.lang.Exception: Mod Loading has failed
    at net.minecraftforge.fml.CrashReportExtender.dumpModLoadingCrashReport(CrashReportExtender.java:85) [?:?] {re:classloading}
    at net.minecraftforge.fml.client.ClientModLoader.completeModLoading(ClientModLoader.java:188) [?:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.lambda$null$1(Minecraft.java:508) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft$$Lambda$3860/1126454617.run(Unknown Source) [?:?] {}
    at net.minecraft.util.Util.func_215077_a(SourceFile:404) [?:?] {re:classloading}
    at net.minecraft.client.Minecraft.lambda$new$2(Minecraft.java:504) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft$$Lambda$3572/1610803524.accept(Unknown Source) [?:?] {}
    at net.minecraft.client.gui.ResourceLoadProgressGui.func_230430_a_(ResourceLoadProgressGui.java:113) [?:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.GameRenderer.func_195458_a(GameRenderer.java:480) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.func_195542_b(Minecraft.java:976) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:607) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.main.Main.main(Main.java:184) [?:?] {re:classloading,pl:runtimedistcleaner:A}
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51] {}
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51] {}
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51] {}
    at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51] {}
    at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:51) [forge-1.16.4-35.1.10.jar:35.1] {}
    at net.minecraftforge.fml.loading.FMLClientLaunchProvider$$Lambda$426/474933596.call(Unknown Source) [forge-1.16.4-35.1.10.jar:35.1] {}
    at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.6.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.6.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.6.jar:?] {}
    at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.6.jar:?] {}
    at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.6.jar:?] {}


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
    at java.util.Objects.requireNonNull(Objects.java:290) ~[?:1.8.0_51] {}
-- MOD test --
Details:
    Mod File: modid-1.0.jar
    Failure message: Test Mod (test) encountered an error during the common_setup event phase
        java.lang.NullPointerException: Registry Object not present: test:test_entity
    Mod Version: 1.0
    Mod Issue URL: http://my.issue.tracker/
    Exception message: java.lang.NullPointerException: Registry Object not present: test:test_entity
Stacktrace:
    at java.util.Objects.requireNonNull(Objects.java:290) ~[?:1.8.0_51] {}
    at net.minecraftforge.fml.RegistryObject.get(RegistryObject.java:120) ~[?:?] {re:classloading}
    at com.test.testMod.util.ForgeEvents.EntityRenderer.registerEntityRenders(EntityRenderer.java:76) ~[?:1.0] 

 

Link to comment
Share on other sites

Fixed it. the problem was I had the wrong version of forge.

 

I needed to have:

[[dependencies.test]]
    modId="forge"
    mandatory=true
    versionRange="[35,)"
    ordering="NONE"
    side="BOTH"
[[dependencies.test]]
    modId="minecraft"
    mandatory=true
    versionRange="[1.16.4,1.17)"
    ordering="NONE"
    side="BOTH"

I had:

 

[[dependencies.test]]
    modId="forge"
    mandatory=true
    versionRange="[35,)"
    ordering="NONE"
    side="BOTH"
[[dependencies.test]]
    modId="minecraft"
    mandatory=true
    versionRange="[1.16.4,1.17)"
    ordering="NONE"
    side="BOTH"
Link to comment
Share on other sites

  • UserMC123 changed the title to [SOLVED] [1.16.4] Entity Attributes not Registering

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hey. I created shield mod like kaupenjoe did on his course but blocking animation doesn't work. Forge 1.20.1. Here's some information: Mod structure image and code: https://ibb.co/z5Y1G26 https://www.online-java.com/crhUHmPoJt
    • i was playing forge modded singleplayer server then i added optifine to mods but it crashed with optifine is there anything to do without deleting optifine  crash report: https://paste.ee/p/Z13LO
    • package com.projectmushroom.lavapotions.item; import java.util.List;   import com.projectmushroom.lavapotions.LavaPotions;   import net.minecraft.core.BlockPos; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.stats.Stats; import net.minecraft.tags.FluidTags; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.AreaEffectCloud; import net.minecraft.world.entity.boss.enderdragon.EnderDragon; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemUtils; import net.minecraft.world.item.Items; import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.world.item.alchemy.Potions; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult;   public class ReinforcedBottle extends Item { public ReinforcedBottle(Item.Properties p_40648_) { super(p_40648_); }   public InteractionResultHolder<ItemStack> use(Level p_40656_, Player p_40657_, InteractionHand p_40658_) { List<AreaEffectCloud> list = p_40656_.getEntitiesOfClass(AreaEffectCloud.class, p_40657_.getBoundingBox().inflate(2.0D), (p_40650_) -> { return p_40650_ != null && p_40650_.isAlive() && p_40650_.getOwner() instanceof EnderDragon; }); ItemStack itemstack = p_40657_.getItemInHand(p_40658_); if (!list.isEmpty()) { AreaEffectCloud areaeffectcloud = list.get(0); areaeffectcloud.setRadius(areaeffectcloud.getRadius() - 0.5F); p_40656_.playSound((Player)null, p_40657_.getX(), p_40657_.getY(), p_40657_.getZ(), SoundEvents.BOTTLE_FILL_DRAGONBREATH, SoundSource.NEUTRAL, 1.0F, 1.0F); p_40656_.gameEvent(p_40657_, GameEvent.FLUID_PICKUP, p_40657_.blockPosition()); return InteractionResultHolder.sidedSuccess(this.turnBottleIntoItem(itemstack, p_40657_, new ItemStack(Items.DRAGON_BREATH)), p_40656_.isClientSide()); } else { HitResult hitresult = getPlayerPOVHitResult(p_40656_, p_40657_, ClipContext.Fluid.SOURCE_ONLY); if (hitresult.getType() == HitResult.Type.MISS) { return InteractionResultHolder.pass(itemstack); } else { if (hitresult.getType() == HitResult.Type.BLOCK) { BlockPos blockpos = ((BlockHitResult)hitresult).getBlockPos(); if (!p_40656_.mayInteract(p_40657_, blockpos)) { return InteractionResultHolder.pass(itemstack); }   if (p_40656_.getFluidState(blockpos).is(FluidTags.LAVA)) { p_40656_.playSound(p_40657_, p_40657_.getX(), p_40657_.getY(), p_40657_.getZ(), SoundEvents.BOTTLE_FILL, SoundSource.NEUTRAL, 1.0F, 1.0F); p_40656_.gameEvent(p_40657_, GameEvent.FLUID_PICKUP, blockpos); return InteractionResultHolder.sidedSuccess(this.turnBottleIntoItem(itemstack, p_40657_,(new ItemStack(LavaPotions.REINFORCED_BOTTLE), .LAVA)), p_40656_.isClientSide()); } } return InteractionResultHolder.pass(itemstack); } } }   protected ItemStack turnBottleIntoItem(ItemStack p_40652_, Player p_40653_, ItemStack p_40654_) { p_40653_.awardStat(Stats.ITEM_USED.get(this)); return ItemUtils.createFilledResult(p_40652_, p_40653_, p_40654_); } }   This is what I have so far, it's pretty much just the waterbottle code but I'm just trying to figure out how to get it to pick up lava rather than water
    • I never started my own server manually but I follow every single step i saw in a youtube video.
  • Topics

×
×
  • Create New...

Important Information

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