Posted January 6, 20205 yr How would I go about rendering my projectile entity with a 2D texture similar to a snowball? I've done some poking around the SpriteRenderer and EntityRendererManager classes but I have no idea on how to proceed, since most of my attempts at filling in the ItemRenderer field result in errors or crashes. The rendering code in my ClientProxy is as follows: RenderingRegistry.registerEntityRenderingHandler(BulletEntity.class, renderManager -> new SpriteRenderer<BulletEntity>(renderManager, Minecraft.getInstance().getItemRenderer())); and whenever the projectile entity is created in game it will end in a NullPointerException: [Server thread/ERROR]: An Entity type net.minecraft.entity.EntityType@8bde368 has thrown an exception trying to write state. It will not persist. Report this to the mod author Secondly, is there a way to control what texture the projectile uses with this method? I took a quick look through Mojang's code and didn't notice anything that might let me do this, so it would be great if someone could point me in the right direction. Thanks in advance. Edited January 6, 20205 yr by CrackedScreen Issue solved.
January 6, 20205 yr Author Stacktrace: [Server thread/ERROR]: An Entity type net.minecraft.entity.EntityType@8bde368 has thrown an exception trying to write state. It will not persist. Report this to the mod author net.minecraft.crash.ReportedException: Saving entity NBT at net.minecraft.entity.Entity.func_189511_e(Entity.java:1423) ~[?:?] at net.minecraft.entity.Entity.func_184198_c(Entity.java:1341) ~[?:?] at net.minecraft.entity.Entity.func_70039_c(Entity.java:1349) ~[?:?] at net.minecraft.world.chunk.storage.ChunkSerializer.func_222645_a(ChunkSerializer.java:319) [?:?] at net.minecraft.world.server.ChunkManager.func_219229_a(ChunkManager.java:674) [?:?] at net.minecraft.world.server.ChunkManager$$Lambda$3698/582496320.test(Unknown Source) [?:?] at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174) [?:1.8.0_51] at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) [?:1.8.0_51] at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) [?:1.8.0_51] at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374) [?:1.8.0_51] at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512) [?:1.8.0_51] at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502) [?:1.8.0_51] at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) [?:1.8.0_51] at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) [?:1.8.0_51] at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) [?:1.8.0_51] at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) [?:1.8.0_51] at net.minecraft.world.server.ChunkManager.func_219177_a(ChunkManager.java:333) [?:?] at net.minecraft.world.server.ServerChunkProvider.func_217210_a(SourceFile:319) [?:?] at net.minecraft.world.server.ServerWorld.func_217445_a(ServerWorld.java:746) [?:?] at net.minecraft.server.MinecraftServer.func_213211_a(MinecraftServer.java:513) [?:?] at net.minecraft.server.MinecraftServer.func_71260_j(MinecraftServer.java:553) [?:?] at net.minecraft.server.integrated.IntegratedServer.func_71260_j(IntegratedServer.java:210) [?:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:661) [?:?] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51] Caused by: java.lang.NullPointerException at net.minecraft.network.datasync.EntityDataManager.func_187225_a(EntityDataManager.java:118) ~[?:?] at net.minecraft.entity.projectile.ProjectileItemEntity.func_213882_k(SourceFile:38) ~[?:?] at net.minecraft.entity.projectile.ProjectileItemEntity.func_213281_b(SourceFile:55) ~[?:?] at net.minecraft.entity.Entity.func_189511_e(Entity.java:1402) ~[?:?] ... 23 more [00:10:47] [Server thread/INFO]: ThreadedAnvilChunkStorage (Test): All chunks are saved [00:10:47] [Server thread/INFO]: ThreadedAnvilChunkStorage (Test): All chunks are saved [00:10:48] [Client thread/FATAL]: Reported exception thrown! net.minecraft.crash.ReportedException: Rendering entity in world at net.minecraft.client.renderer.entity.EntityRendererManager.func_188391_a(EntityRendererManager.java:401) ~[?:?] at net.minecraft.client.renderer.entity.EntityRendererManager.func_188388_a(EntityRendererManager.java:359) ~[?:?] at net.minecraft.client.renderer.WorldRenderer.func_215326_a(WorldRenderer.java:543) ~[?:?] at net.minecraft.client.renderer.GameRenderer.func_181560_a(GameRenderer.java:713) ~[?:?] at net.minecraft.client.renderer.GameRenderer.func_78471_a(GameRenderer.java:640) ~[?:?] at net.minecraft.client.renderer.GameRenderer.func_195458_a(GameRenderer.java:494) ~[?:?] at net.minecraft.client.Minecraft.func_195542_b(Minecraft.java:890) ~[?:?] at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:384) [?:?] at net.minecraft.client.main.Main.main(SourceFile:155) [?:?] 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:56) [forge-1.14.4-28.1.111.jar:28.1] at net.minecraftforge.fml.loading.FMLClientLaunchProvider$$Lambda$392/26357357.call(Unknown Source) [forge-1.14.4-28.1.111.jar:28.1] at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-4.1.0.jar:?] at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-4.1.0.jar:?] at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-4.1.0.jar:?] at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-4.1.0.jar:?] at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-4.1.0.jar:?] Caused by: java.lang.NullPointerException at net.minecraft.network.datasync.EntityDataManager.func_187225_a(EntityDataManager.java:118) ~[?:?] at net.minecraft.entity.projectile.ProjectileItemEntity.func_213882_k(SourceFile:38) ~[?:?] at net.minecraft.entity.projectile.ProjectileItemEntity.func_184543_l(SourceFile:43) ~[?:?] at net.minecraft.client.renderer.entity.SpriteRenderer.func_76986_a(SourceFile:41) ~[?:?] at net.minecraft.client.renderer.entity.EntityRendererManager.func_188391_a(EntityRendererManager.java:370) ~[?:?] ... 19 more ClientProxy class: public class ClientProxy implements IProxy { @Override public void init() { RenderingRegistry.registerEntityRenderingHandler(BulletEntity.class, renderManager -> new SpriteRenderer<BulletEntity>(renderManager, Minecraft.getInstance().getItemRenderer())); } public World getClientWorld() { return Minecraft.getInstance().world; } } BulletEntity class: public class BulletEntity extends ProjectileItemEntity { public BulletEntity(EntityType<? extends BulletEntity> type, World worldIn) { super(type, worldIn); } public BulletEntity(World worldIn, LivingEntity shooter) { super(ModEntities.BULLET, shooter, worldIn); } public BulletEntity(double x, double y, double z, World worldIn) { super(ModEntities.BULLET, x, y, z, worldIn); } @Override protected void registerData() { // TODO Auto-generated method stub } @Override public Item func_213885_i() { return ModItems.bullet; } @Override public IPacket<?> createSpawnPacket() { return NetworkHooks.getEntitySpawningPacket(this); } } I'm not entirely sure about the func_213885 method, is this related to the getItem method you mentioned? I did some digging on another related thread that had to do with projectile entities and mirrored what they did. Edited January 6, 20205 yr by CrackedScreen
January 6, 20205 yr Author Yep, removing that override fixed my issue. Didn't think my screw-up would be that dumb. Also answered the other question myself, the method that is the jumble of numbers and letters does indeed control the appearance. Thanks for helping, will close this thread.
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.