Jump to content

Codex79

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by Codex79

  1. Thank you so much! I added a bus = Mod.EventBusSubscriber.Bus.MOD in the parentheses and that fixed it.
  2. I have been reading the logs; however, they only tell me where the null pointer exception occurs in the forge referenced libraries and not in my actual code so I'm at a loss. It seems to have to do with the Minecraft.getInstance().getRenderingManager() but I'm not sure if that is null or just using an associated null object. I've been trying to debug my code to no avail. Here's the relevant crash report: ---- Minecraft Crash Report ---- // I blame Dinnerbone. Time: 11/26/20 4:38 PM Description: Unexpected error java.lang.NullPointerException: Unexpected error at net.minecraft.client.renderer.entity.EntityRendererManager.shouldRender(EntityRendererManager.java:238) ~[forge-1.16.1-32.0.108_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.WorldRenderer.updateCameraAndRender(WorldRenderer.java:983) ~[forge-1.16.1-32.0.108_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.renderWorld(GameRenderer.java:613) ~[forge-1.16.1-32.0.108_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.updateCameraAndRender(GameRenderer.java:434) ~[forge-1.16.1-32.0.108_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:988) ~[forge-1.16.1-32.0.108_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:587) ~[forge-1.16.1-32.0.108_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.1-32.0.108_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121] {} at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_121] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121] {} at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.16.1-32.0.108_mapped_snapshot_20200514-1.16-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-6.1.3.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-6.1.3.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-6.1.3.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-6.1.3.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-6.1.3.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.1-32.0.108_mapped_snapshot_20200514-1.16-recomp.jar:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace: at net.minecraft.client.renderer.entity.EntityRendererManager.shouldRender(EntityRendererManager.java:238) at net.minecraft.client.renderer.WorldRenderer.updateCameraAndRender(WorldRenderer.java:983) at net.minecraft.client.renderer.GameRenderer.renderWorld(GameRenderer.java:613) And here is my custom entity class: public class SilverEnderPearlEntity extends ProjectileItemEntity { /* -constructors- */ /** An initialization constructor that overrides a constructor in EnderPearlEntity. * @param worldIn The current world that is loaded. * @param throwerIn The entity doing the throwing, e.g., a player. */ public SilverEnderPearlEntity(World worldIn, LivingEntity throwerIn) { super(/*EntityType.ENDER_PEARL*/EntityCollection.SILVER_ENDER_PEARL_ENTITY.get(), throwerIn, worldIn);} /** Another initialization constructor that overrides a constructor in EnderPearlEntity. * @param entityType The type of entity throwing the ender pearl. * @param worldIn The current world that is loaded. */ public SilverEnderPearlEntity(EntityType<? extends ProjectileItemEntity> entityType, World worldIn) { super(entityType, worldIn);} /** Another initialization constructor that overrides a constructor in EnderPearlEntity. * @param worldIn The current world that is loaded. * @param x The x position that the entity (and player) will be sent to. * @param y The y position that the entity (and player) will be sent to. * @param z The z position that the entity (and player) will be sent to. */ @OnlyIn(Dist.CLIENT) public SilverEnderPearlEntity(World worldIn, double x, double y, double z) { super(/*EntityType.ENDER_PEARL*/EntityCollection.SILVER_ENDER_PEARL_ENTITY.get(), x, y, z, worldIn);} /* -entity rendering methods- */ /** A method that returns the spawn packet required to be overridden by custom entity classes. * @return A spawn packet used by throwable entities. */ public IPacket<?> createSpawnPacket() { return NetworkHooks.getEntitySpawningPacket(this);} /** A method that returns the default item that uses this entity, i.e., the silver ender pearl. * @return The default item that uses this entity. */ protected Item getDefaultItem() { return /*Items.ENDER_PEARL;*/EndTab.SILVER_ENDER_PEARL.get();} /* -important overridden methods- */ /** Called whenever the silver ender pearl hits only an entity. * @param result The path of the ray tracing result. */ protected void onEntityHit(EntityRayTraceResult result) { super.onEntityHit(result); result.getEntity().attackEntityFrom(DamageSource.causeThrownDamage(this, this.func_234616_v_()), 0.0F);} /** Called whenever the silver ender pearl hits an entity or block. * @param result The resulting path that is given by throwing the ender pearl. */ @SuppressWarnings("deprecation") protected void onImpact(RayTraceResult result) { // gets the entity that activated the silver ender pearl. super.onImpact(result); Entity entity = this.func_234616_v_(); // if the world is not remote and the ender pearl entity has not been removed yet. if(!this.world.isRemote && !this.removed) { // if the entity is a server player entity. if(entity instanceof ServerPlayerEntity) { ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) entity; if(serverPlayerEntity.connection.getNetworkManager().isChannelOpen() && serverPlayerEntity.world == this.world && !serverPlayerEntity.isSleeping()) { // creates the teleport event. EnderTeleportEvent event = new EnderTeleportEvent( serverPlayerEntity, this.getPosX(), this.getPosY(), this.getPosZ(), 2.5f); if(!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) { // spawns a random mob if the player is unlucky. if(this.rand.nextFloat() < 0.05F && this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING)) { EndermiteEntity endermiteEntity = EntityType.ENDERMITE.create(this.world); endermiteEntity.setSpawnedByPlayer(true); endermiteEntity.setLocationAndAngles(entity.getPosX(), entity.getPosY(), entity.getPosZ(), entity.rotationYaw, entity.rotationPitch); this.world.addEntity(endermiteEntity);} // if their is a passenger, the passenger will stop riding. if (entity.isPassenger()) entity.stopRiding(); // set the new position of the player. entity.setPositionAndUpdate(event.getTargetX(), event.getTargetY(), event.getTargetZ()); entity.fallDistance = 0.0F; entity.attackEntityFrom(DamageSource.FALL, event.getAttackDamage());}}} // if the entity is something other than a player. else if (entity != null) { entity.setPositionAndUpdate(this.getPosX(), this.getPosY(), this.getPosZ()); entity.fallDistance = 0.0F;} // remove this silver ender pearl entity. this.remove();}} /* -other overridden methods- */ /** Called to update properties of the entity. */ public void tick() { Entity entity = this.func_234616_v_(); if (entity instanceof PlayerEntity && !entity.isAlive()) this.remove(); else super.tick();} /** A method that changes the dimension if the ender pearl is thrown into an end gate way or * something to that effect. * @param serverWorldIn The current server world that is loaded in. * @param teleporter An object that handles positioning during a dimension change. * @return An entity in a differing dimension. */ public Entity changeDimension(ServerWorld serverWorldIn, net.minecraftforge.common.util.ITeleporter teleporter) { Entity entity = this.func_234616_v_(); if (entity != null && entity.world.func_234923_W_() != serverWorldIn.func_234923_W_()) this.setShooter((Entity)null); return super.changeDimension(serverWorldIn, teleporter);} } And where I initialize the entity type: public class EntityCollection { /* -entity registry objects- */ /** A registry object for our silver ender pearl entities. */ public static RegistryObject< EntityType<SilverEnderPearlEntity> > SILVER_ENDER_PEARL_ENTITY; /* -static method initialization- */ /** A method that acts like a constructor to initialize our static instance objects and add * them to the registry. */ public static void init() { SILVER_ENDER_PEARL_ENTITY = EntityRegistryHandler.ENTITIES.register("silver_ender_pearl", () -> EntityType.Builder.<SilverEnderPearlEntity>create( SilverEnderPearlEntity::new, EntityClassification.MISC) .size(0.25f, 0.25f).func_233606_a_(4).func_233608_b_(10) .build(new ResourceLocation(CottageCraft.MOD_ID, "silver_ender_pearl").toString()));} } Thank you. I'll keep that in mind since I had no idea and thought using EntityType.ENDER_PEARL would be appropriate if I or someone else didn't come up with a solution.
  3. Thank you both. Unfortunately, I keep getting a null pointer exception whenever I throw the ender pearl and cannot for the life of me figure out why. But I think I'm just going to use EntityType.ENDER_PEARL instead of the one I made. EDIT: Also I did check out the GitHub and I'm pretty sure I'm doing everything right for the registerEntityRenderingHandler. I think the exception exists in my EntityCollection where I build the entity type, but as I said before I think I'm going to forgo using a custom entity type.
  4. I am trying to develop a mod for 1.16.1, and I am having trouble rending a throwable item when it is in flight. My main problem is that most other tutorials or suggestions use RendererSnowball (or Snowball Renderer, I can't remember) which doesn't seem to exist for versions after 1.15. So is there an adequate subsuite that could help me? For reference this is my ClientEventBusSubscriber class: package com.codex.cottage_craft.util; import... @Mod.EventBusSubscriber(value=Dist.CLIENT,modid= CottageCraft.MOD_ID) public class ClientEventBusSubscriber { /* -main methods- */ /** A method that registers the models through a model registry event. * @param event The model registry event that registers the models of entities and blocks. */ @SubscribeEvent public static void onRegisterModelsEvent(ModelRegistryEvent event) { registerEntityRenderers(); } /* -helper methods- */ /** A helper method that targets rendering entity models specifically. */ private static void registerEntityRenderers() { // registers the silver pearl entity with the rendering factory that returns a sprite render. RenderingRegistry.registerEntityRenderingHandler( EntityCollection.SILVER_ENDER_PEARL_ENTITY.get(), new IRenderFactory<SilverEnderPearlEntity> () { public EntityRenderer<? super SilverEnderPearlEntity> createRenderFor(EntityRendererManager manager) { return new SpriteRenderer<SilverEnderPearlEntity> (manager, Minecraft.getInstance().getItemRenderer()); } } ); } } I was hoping to replace the "SpriteRenderer<SilverEnderPearlEntity>" with a SnowballRenderer or RendererSnowball. Any help would be appreciated, including the way Snowball and Ender Pearls are now rendered. Also, the error that is actually occurring for me is a Null Pointer error but even if I were to resolve it I don't think it would work.
×
×
  • Create New...

Important Information

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