Jump to content

[1.7.1] Reduce vanilla entity spawnrate? / Unexpected crash


Cybranfoehammer

Recommended Posts

Hi guys, I know you don't like handholding people, but I've been working on a mod for a long time that features more dynamic AI "factions" and seeks to increase the difficulty of the game. One of the simplest methods it does so is by dramatically increasing the aggro range of mobs, which is tons of fun when it comes to zombies but may create frustration when it comes to skeletons due to their firerate and knockback.

 

I attempted to reduce their knockback and firing rate to no avail whatsoever, unable to find code that lets me do so. After this, I attempted to reduce their spawnrate but couldn't find an "official" way to do that either, so I made my own makeshift event handler function to do something similar:

 

	 @SubscribeEvent
 public void onEntitySpawn(EntityJoinWorldEvent event)
 {


  if (event.entity instanceof EntityZombie) updateZombieAI((EntityZombie) event.entity, event);
  if (event.entity instanceof EntityGhast) updateGhastAI((EntityGhast) event.entity, event);
  if (event.entity instanceof EntitySkeleton){
		 Random rand = new Random();
		 int  n = rand.nextInt(4) + 1;
	  World world = DimensionManager.getWorld(0);
	  if (n != 1  && (world.getClosestPlayer((double)event.entity.posX + 0.5D, (double)event.entity.posY + 0.5D, (double)event.entity.posZ + 0.5D, 60) == null)){
		 	event.setResult(Result.DENY);
		}
	  else {
	  updateSkeleAI((EntitySkeleton) event.entity, event);
	  }
  }

 

Unfortunately, while this bootleg works perfectly on clientside and singleplayer testing, I discovered that it causes players to crash when they join a dedicated server. This is the error received in the client console.

 

This segment:

 

java.lang.NullPointerException: Ticking screen
    at ladyremilia.arcl.EventHandlerCommon.onEntitySpawn(EventHandlerCommon.java:140)

 

Refers to this particular line of code in my eventhandler:

 

		  if (n != 1  && (world.getClosestPlayer((double)event.entity.posX + 0.5D, (double)event.entity.posY + 0.5D, (double)event.entity.posZ + 0.5D, 60) == null)){

 

Is there any way I can fix this, or better yet, override BiomeGenBase's vanilla entity spawn rates?

 

I apologise if this is a question with a stupidly easy answer.

 

Edit: Forgot to mention. The server doesn't really report anything, just that the connection was "forcibly closed by the remote host".

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

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