Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.14.4] Entity that implements IRendersAsItem crashes server during loading
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
sanman00

[1.14.4] Entity that implements IRendersAsItem crashes server during loading

By sanman00, February 20, 2020 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

sanman00    0

sanman00

sanman00    0

  • Tree Puncher
  • sanman00
  • Members
  • 0
  • 8 posts
Posted February 20, 2020 (edited)

I have an entity that implements IRendersAsItem so that it can be used with SpriteRenderer. However, when this entity is registered, it causes the server (but not the client) to crash with a NoClassDefFoundError saying that it cannot find this interface (which makes sense since it is annotated to indicate that it can only be loaded on the client).

 

I could remove the entity's implementation of IRendersAsItem and replace how it is currently rendered with an emulation of SpriteRenderer but I'm not sure if this would the correct way to solve this issue.

 

Current implementation of entity class:

public class EntityExplosivePotion extends ThrowableEntity implements IRendersAsItem {
    public EntityExplosivePotion(EntityType<? extends ThrowableEntity> type, World worldIn) {
        super(type, worldIn);
    }

    @Override
    public ItemStack getItem() {
        return new ItemStack(this.isSpicy() ? ModItems.SPICY_THROWABLE_EXPLOSIVE_POTION : ModItems.THROWABLE_EXPLOSIVE_POTION);
    }

    @Override
    public IPacket<?> createSpawnPacket() {
        return NetworkHooks.getEntitySpawningPacket(this);
    }
}

Registration of entity:

@EventBusSubscriber(modid = Main.MOD_ID, bus = EventBusSubscriber.Bus.MOD)
class ModSetup {
    @SubscribeEvent
    static void registerEntities(RegistryEvent.Register<EntityType<?>> event) {
        event.getRegistry().register(EntityType.Builder.<EntityExplosivePotion>create(EntityExplosivePotion::new, EntityClassification.MISC)
                .size(0.25f, 0.25f).setTrackingRange(2).setUpdateInterval(5).setShouldReceiveVelocityUpdates(true)
                .build(ModUtil.qualify(ModUtil.THROWABLE_EXPLOSIVE_POTION_NAME)).setRegistryName(ModUtil.qualify(ModUtil.THROWABLE_EXPLOSIVE_POTION_NAME)));
    }
}

Registration of entity renderer:

@EventBusSubscriber(modid = Main.MOD_ID, value = {Dist.CLIENT}, bus = EventBusSubscriber.Bus.MOD)
public class ClientProxy {
    @SubscribeEvent
    public static void init(FMLClientSetupEvent event) {
        RenderingRegistry.registerEntityRenderingHandler(EntityExplosivePotion.class, m -> new SpriteRenderer<>(m, Minecraft.getInstance().getItemRenderer()));
    }
}

 

Here is my latest.log file: https://pastebin.com/19uFbBQb

Edited February 20, 2020 by sanman00
  • Quote

My mod: Explosive Potions for 1.10.2

Share this post


Link to post
Share on other sites

diesieben07    7619

diesieben07

diesieben07    7619

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7619
  • 55249 posts
Posted February 20, 2020

Look at the @OnlyIn annotation on vanilla implementations of this interface.

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

sanman00    0

sanman00

sanman00    0

  • Tree Puncher
  • sanman00
  • Members
  • 0
  • 8 posts
Posted February 20, 2020

@diesieben07 Thanks, that helped.

 

It turns out that that annotation needed to be added to the entity class:

@OnlyIn(
   value = Dist.CLIENT,
   _interface = IRendersAsItem.class
)
public class EntityExplosivePotion extends ThrowableEntity implements IRendersAsItem {
  // ...
}

 

  • Quote

My mod: Explosive Potions for 1.10.2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Exced
      Minecraft Eternal Modpack Server won't start

      By Exced · Posted 11 minutes ago

      C:\Users\Exced\Desktop\Eternal (ServerPack 1.3.7)>java -Xms4G -Xmx6G -XX:PermSize=256m -Dfml.read.Timeout=560 -jar forge-1.12.2-14.23.5.2847-universal.jar nogui Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option PermSize; support was removed in 8.0 A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:70) at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34) Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap') at net.minecraft.launchwrapper.Launch.(Launch.java:34) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) ... 6 more C:\Users\Exced\Desktop\Eternal (ServerPack 1.3.7)>pause Premere un tasto per continuare . . . I read more post about this problem, but i saw forge server wont start with a java version above 8. But i already have java 8 64 bit. Also this is the code inside the bat file java -Xms8G -Xmx8G -XX:PermSize=256m -Dfml.read.Timeout=560 -jar forge-1.12.2-14.23.5.2847-universal.jar nogui pause Can anyone help? Also i tried with jarfix but doesnt work neither.
    • octa
      Disconnection From Server When Placing Modded Block

      By octa · Posted 13 minutes ago

      Woops. Fixed the item names. According to the docs, RegistryEvent.Register is a valid way of registering entries, so I'll stick with that since I know it better. The repo should build now, so back to my original question: Why when placing a Portal Base does the client get disconnected from the server?
    • diesieben07
      Valhelsia 3 server not starting

      By diesieben07 · Posted 45 minutes ago

      You can use https://gist.github.com/ for large text files.
    • diesieben07
      Disconnection From Server When Placing Modded Block

      By diesieben07 · Posted 46 minutes ago

      Your repository crashes for a different reason: You have two items with the same name. Additionally, you are not registering your registry entries properly. You need to either use @ObjectHolder or DeferredRegister.
    • squidlex
      Check if player wakes up in the Morning

      By squidlex · Posted 48 minutes ago

      This is perfect, thank you!
  • Topics

    • Exced
      0
      Minecraft Eternal Modpack Server won't start

      By Exced
      Started 11 minutes ago

    • octa
      4
      Disconnection From Server When Placing Modded Block

      By octa
      Started 3 hours ago

    • Purity
      7
      Valhelsia 3 server not starting

      By Purity
      Started 16 hours ago

    • squidlex
      2
      Check if player wakes up in the Morning

      By squidlex
      Started 1 hour ago

    • squidlex
      2
      How to create the regeneration effect on hearts for other HUD elements

      By squidlex
      Started 22 hours ago

  • Who's Online (See full list)

    • octa
    • F0RZera
    • Tieso2001
    • xX_deadbush_Xx
    • Mopaseo
    • kiou.23
    • apollos
    • Shlub
    • daniel gonzalez
    • SpeedDemon640
    • Yuqera
    • Exced
    • connorhorwood@outlook.com
    • Luis_ST
    • TheidenHD
    • UnderBlade
    • ChampionAsh5357
    • Bokkake_Monster
    • diesieben07
    • soul ein
    • zelenac83
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.14.4] Entity that implements IRendersAsItem crashes server during loading
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community