Jump to content

Recommended Posts

Posted

I am making an entity and it is almost an identical copy of a zombie that spawns in the nether (hell) and I am getting cascading World gen error when exploring in creative in the nether, even though I am adding over 10 entities in the overworld without any troubles. I tried un-registering the entity and the problem went away. I am not adding any extra mob gen and I do not even know how to add biomes or dimensions so I do not even know why this happens.
My zombie class:

public class EntityDoctorZombie extends EntityAnimatedZombie {

	private static final DataParameter<Byte> ACTIVE = EntityDataManager.<Byte>createKey(EntityDoctorZombie.class,
			DataSerializers.BYTE);

	static {
		EntityDoctorZombie.animHandler.addAnim(Reference.MOD_ID, "skeleton_walk", "zombie", true);
		EntityDoctorZombie.animHandler.addAnim(Reference.MOD_ID, "skeleton_walk_hands", "zombie", true);
		EntityDoctorZombie.animHandler.addAnim(Reference.MOD_ID, "doctor_throw", "zombie", false);
		EntityDoctorZombie.animHandler.addAnim(Reference.MOD_ID, "doctor_heal", "zombie", false);
		EntityDoctorZombie.animHandler.addAnim(Reference.MOD_ID, "lookat", new AnimationLookAt("Head"));
		EntityDoctorZombie.animHandler.addAnim(Reference.MOD_ID, "riding", new AnimationRiding());
	}

	public EntityDoctorZombie(World worldIn) {
		super(worldIn);
		this.setSize(0.7F, 2F);
	}

	@Override
	protected void initEntityAI() {
		this.tasks.addTask(0, new EntityAISwimming(this));
		this.tasks.addTask(1, new EntityAIDoctorHeal(this, 1.0D));
		this.tasks.addTask(2, new EntityAIAvoidEntity(this, EntityPlayer.class, 3, 1D, 1.4D));
		this.tasks.addTask(3, new EntityAIMoveTowardsRestriction(this, 1.0D));
		this.tasks.addTask(4, new EntityAIMoveThroughVillage(this, 1.0D, false));
		this.tasks.addTask(5, new EntityAIWanderAvoidWater(this, 1.0D));
		this.tasks.addTask(6, new EntityAILookIdle(this));
		this.targetTasks.addTask(1,
				new EntityAIDoctorTarget(this, false, EntityZombie.class, EntityZombieVillager.class,
						EntityKnightZombie.class, EntityWorkerZombie.class, EntityGoroZombie.class));

	}

	@Override
	protected void entityInit() {
		super.entityInit();
		this.dataManager.register(ACTIVE, Byte.valueOf((byte) 0));
	}

	@Override
	protected void applyEntityAttributes() {
		super.applyEntityAttributes();
		this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(40.0D);
		this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D);
		this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.26D);
	}

	public boolean isThrowing() {
		return this.dataManager.get(ACTIVE).byteValue() == 1;
	}

	public boolean isHealing() {
		return this.dataManager.get(ACTIVE).byteValue() == 2;
	}

	public void setActive(byte b) {
		if (this.dataManager.get(ACTIVE).byteValue() != b) {
			this.dataManager.set(ACTIVE, Byte.valueOf(b));
			this.dataManager.setDirty(ACTIVE);
		}
	}

	@Override
	public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) {
		super.onInitialSpawn(difficulty, livingdata);
		if (this.isChild()) {
			this.setChild(false);
		}
		if (this.isLeftHanded()) {
			this.setLeftHanded(false);
		}
		this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, new ItemStack(ModItems.health));
		ItemStack potion = new ItemStack(Items.SPLASH_POTION, 1, 0);
		NBTTagCompound nbt = new NBTTagCompound();
		nbt.setString("Potion", "minecraft:water");
		potion.setTagCompound(nbt);
		this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, potion);
		this.setEnchantmentBasedOnDifficulty(difficulty);
		return livingdata;
	}

	@Override
	public void onLivingUpdate() {
		super.onLivingUpdate();
		if (!this.isWorldRemote()) {
			this.setMoving(Boolean.valueOf(this.isMoving(this)));
		}
		if (this.isWorldRemote()) {
			if (this.getAnimationHandler().isAnimationActive(Reference.MOD_ID, "skeleton_walk", this)
					&& !this.getMoving()) {
				this.getAnimationHandler().stopAnimation(Reference.MOD_ID, "skeleton_walk", this);
				if (!this.isThrowing() && !this.isHealing()) {
					this.getAnimationHandler().stopAnimation(Reference.MOD_ID, "skeleton_walk_hands", this);
				}
			}
			if (this.isThrowing()
					&& !this.getAnimationHandler().isAnimationActive(Reference.MOD_ID, "doctor_throw", this)
					&& this.deathTime < 1) {
				this.getAnimationHandler().stopAnimation(Reference.MOD_ID, "skeleton_walk_hands", this);
				this.getAnimationHandler().startAnimation(Reference.MOD_ID, "doctor_throw", 0, this);
			}

			if (this.isHealing() && !this.getAnimationHandler().isAnimationActive(Reference.MOD_ID, "doctor_heal", this)
					&& this.deathTime < 1) {
				this.getAnimationHandler().stopAnimation(Reference.MOD_ID, "skeleton_walk_hands", this);
				this.getAnimationHandler().startAnimation(Reference.MOD_ID, "doctor_heal", 0, this);
			}

			if (!this.getAnimationHandler().isAnimationActive(Reference.MOD_ID, "skeleton_walk", this)
					&& this.getMoving() && this.deathTime < 1 && !this.isRiding()) {
				this.getAnimationHandler().startAnimation(Reference.MOD_ID, "skeleton_walk", 0, this);
			}

			if (!this.getAnimationHandler().isAnimationActive(Reference.MOD_ID, "skeleton_walk_hands", this)
					&& !this.isThrowing() && !this.isHealing()
					&& this.getAnimationHandler().isAnimationActive(Reference.MOD_ID, "skeleton_walk", this)) {
				this.getAnimationHandler().stopAnimation(Reference.MOD_ID, "doctor_throw", this);
				this.getAnimationHandler().stopAnimation(Reference.MOD_ID, "doctor_heal", this);
				this.getAnimationHandler().startAnimation(Reference.MOD_ID, "skeleton_walk_hands", 0, this);
			}

			if (!this.getAnimationHandler().isAnimationActive(Reference.MOD_ID, "lookat", this) && this.deathTime < 1) {
				this.getAnimationHandler().startAnimation(Reference.MOD_ID, "lookat", this);
			}
			if (!this.getAnimationHandler().isAnimationActive(Reference.MOD_ID, "riding", this) && this.isRiding()) {
				this.getAnimationHandler().stopAnimation(Reference.MOD_ID, "skeleton_walk", this);
				this.getAnimationHandler().startAnimation(Reference.MOD_ID, "riding", this);
			}
		}

	}

}

My Events class (that I stopped for testing and I still got the message):
 

//@Mod.EventBusSubscriber
public class CommonEvent {
	@SubscribeEvent
	public static void onLivingDeath(LivingDeathEvent e) {
		EntityLivingBase entity = e.getEntityLiving();
		if (entity.getEntityData().getBoolean("is")) {
			if (entity.getRNG().nextInt(2) == 0) {
				e.setCanceled(true);
				entity.setHealth(entity.getMaxHealth());
				entity.playSound(SoundEvents.ITEM_TOTEM_USE, 1f, 1f);
			}
			entity.getEntityData().setBoolean("is", false);
		}
		if (MobsConfig.zombies.magma.alwaysLava && e.getSource().getTrueSource() instanceof EntityPlayerMP) {
			EntityPlayerMP player = (EntityPlayerMP) e.getSource().getTrueSource();
			if (player.getHeldItemMainhand().getItem() == ModItems.fireSword) {
				player.getHeldItemMainhand().damageItem(25, player);
				if (player.world.isAirBlock(entity.getPosition())
						&& entity.world.isSideSolid(entity.getPosition().add(0, -1, 0), EnumFacing.UP)) {
					player.world.setBlockState(entity.getPosition(), Blocks.FLOWING_LAVA.getDefaultState(), 3);
				}
			}
		}
	}
	
	@SubscribeEvent
	public static void onInteract(PlayerInteractEvent.RightClickBlock e) {
		TileEntity tile = e.getWorld().getTileEntity(e.getPos());
		if (tile != null && tile instanceof TileEntityChest) {
			TileEntityLockableLoot chest = (TileEntityLockableLoot) tile;
			if (chest.getLootTable() != null && chest.getLootTable().equals(LootTableList.CHESTS_DESERT_PYRAMID)
					&& e.getEntityPlayer().getRNG().nextFloat() < 0.02f) {
				BlockPos pos = findPos(e.getPos().getAllInBox(e.getPos().add(-1, 0, -1), e.getPos().add(1, 1, 1)),
						e.getWorld());
				if (pos != null && MobsConfig.skeletons.corrupted.spawnFromLootChests) {
					EntityCorruptedSkeleton entity = new EntityCorruptedSkeleton(e.getWorld());
					entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.BONE));
					entity.setLocationAndAngles(pos.getX(), pos.getY(), pos.getZ(), 0, 0);
					entity.setAttackTarget(e.getEntityPlayer());
					if (entity.getCanSpawnHere()) {
						e.getWorld().spawnEntity(entity);
					}
				}
			}
		}
	}
	
	private static BlockPos findPos(Iterable<BlockPos> blocks, World world){
		for(BlockPos pos : blocks){
			if(world.isAirBlock(pos) && world.isAirBlock(pos.add(0, 1, 0))){
				return pos;
			}
		}
		return null;
	}

	@SubscribeEvent
	public static void onLivingUpdate(LivingUpdateEvent e) {
		// for testing.
		// if(e.getEntityLiving() instanceof EntityPlayer){
		// EntityPlayer player = (EntityPlayer) e.getEntityLiving();
		// System.out.println(player.getHeldItemMainhand() + " " +
		// player.getHeldItemMainhand().getTagCompound());
		// }
		System.out.println("hi");
		if (e.getEntityLiving() != null && !e.getEntityLiving().isDead) {
			if (e.getEntityLiving() instanceof EntityPlayer) {
				if (!e.getEntityLiving().isPotionActive(ModPotions.potionJokerness)) {
					ModPotions.potionJokerness.isReady = false;
				}
			}
		}
	}

	@SubscribeEvent
	public static void onAttack(AttackEntityEvent e) {
		if (!e.getEntityPlayer().getHeldItemMainhand().isEmpty()) {
			if (e.getEntityPlayer().getCooldownTracker()
					.hasCooldown(e.getEntityPlayer().getHeldItemMainhand().getItem())) {
				e.setCanceled(true);
			}
		}

	}
	
	@SubscribeEvent
	public static void onJoin(EntityJoinWorldEvent e){
		if (e.getEntity() instanceof EntityZombie) {
			EntityZombie zombie = (EntityZombie) e.getEntity();
			EntityAIMoveToNearestDoctor task = new EntityAIMoveToNearestDoctor(zombie, 1.2D, 16D);
			if (!zombie.tasks.taskEntries.contains(task)) {
				zombie.tasks.addTask(1, task);
			}
		}
		if(e.getEntity() instanceof EntitySpider && e.getWorld().rand.nextInt(100) == 76){
			EntitySpider spider = (EntitySpider) e.getEntity();
			EntityMiniSpider mini = new EntityMiniSpider(spider.world);
			mini.setLocationAndAngles(spider.posX, spider.posY, spider.posZ, spider.rotationYaw, 0.0F);
            spider.world.spawnEntity(mini);
            mini.startRiding(spider);
		}
	}

	@SubscribeEvent
	public static void onImpact(ProjectileImpactEvent.Throwable e) {
		if (e.getThrowable() instanceof EntityPotion) {
			EntityPotion potion = (EntityPotion) e.getThrowable();
			if (!potion.world.isRemote) {
				ItemStack itemstack = potion.getPotion();
				PotionType potiontype = PotionUtils.getPotionFromItem(itemstack);
				List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemstack);
				if (potiontype == PotionTypes.WATER && list.isEmpty()) {
					if (e.getRayTraceResult().entityHit != null) {
						e.getRayTraceResult().entityHit.extinguish();
					}
				}
			}
		}
	}

	@SubscribeEvent
	public static void onConfigChanged(final ConfigChangedEvent.OnConfigChangedEvent event) {
		if (event.getModID().equals(Reference.MOD_ID)) {
			ConfigManager.sync(Reference.MOD_ID, Config.Type.INSTANCE);
		}
	}

	//@SubscribeEvent
	public static void spawnMiniSpider(ChunkEvent.Load e) {

//		if (!e.isSpawner() && e.getResult() == Result.ALLOW) {
//			if (e.getEntityLiving() instanceof EntityAnimatedSpider || e.getEntityLiving() instanceof EntitySpider) {
//				if (e.getEntityLiving().getRNG().nextFloat() < 0.01f) {
//					EntityMiniSpider mini = new EntityMiniSpider(e.getWorld());
//					mini.setLocationAndAngles(e.getX() + e.getEntityLiving().getRNG().nextGaussian(), e.getY(),
//							e.getZ() + e.getEntityLiving().getRNG().nextGaussian(), 0, 0);
//					e.getWorld().spawnEntity(mini);
//				}
//			}
//		}
//		if (!e.isSpawner() && e.getResult() == Result.ALLOW) {
//			if (e.getEntityLiving() instanceof EntityAnimatedZombie || e.getEntityLiving() instanceof EntityZombie) {
//				if (e.getEntityLiving().getRNG().nextFloat() < 0.1f) {
//					EntityDoctorZombie doctor = new EntityDoctorZombie(e.getWorld());
//					doctor.setLocationAndAngles(e.getX() + e.getEntityLiving().getRNG().nextGaussian(), e.getY(),
//							e.getZ() + e.getEntityLiving().getRNG().nextGaussian(), 0, 0);
//					e.getWorld().spawnEntity(doctor);
//				}
//			}
//		}
	}

}

The AI classes are just slightly modified versions of the vanilla ones and do not add any new methods (it just allow multi mob class select instead of adding tasks for each one)

Posted

As usual, mysterious runtime behavior demands an investigation in the debugger. Set breakpoints that will stop execution when you reach the problem stage of the game. When you get there, then set more breakpoints in methods that you want to why they're even being called. When they hit, look at the call stack. Home in on your problem from there and do some stepping. If chunk gen is really running away, then the "why" should become obvious after an iteration or three.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

but I am just getting warnings and I do not where to set breakpoints but I tried setting breakpoints all over my code but nothing is related to my mob because my mob is extremely basic and I am not that expert with this call stack stuff 

Posted

(I honestly don't know much about entities and I never created one beefore, this is judt a general debugging suggestion...) 

Does it work if you only copy vanilla code? (If not it must have sth to do with registration...) If it does, try adding line for line until you find the problem and then try asking what's wrong with that... 

(I assume that you couldn't find the Problem whilst using ordinary debugging mechanisms) 

Another way would be to try to find the warning/error line in vanilla/forge code and then go back until you find the last call to your own code... (this way is probably more difficult... 

Posted

Cascading world gen basically means that while generating a chunk something requires a neighboring chunk that isn't already loaded to get loaded (and generated) and then that chunk spills into another and so on. For example, if a tree was at the edge of a chunk that would happen and if your mod made a lot of trees the probably would get high for cascading.

 

If your mod is only doing entities, I guess it may have to do with the spawning. For example, if you set the spawning funny maybe it is trying to spawn a lot of them and in large groups such that the group spawner needs to load a neighboring chunk to complete the group.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

I found the bug. It is because I adding the move through village AI task to the entities in the nether and that causes chunks to load. I will mark it as solved.
DO NOT ADD MOVE THROUGH VILLAGE AI TASK TO NETHER ENTITIES.

  • Like 1

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • UPDATE: This seems to be happening every time I leave the Beneath dimension (2 for 2). Not sure why those 2 dimensions specifically. I have no problems with the nether or Twilight Forest.
    • I was exploring my world that is hosted on a server and when I go to a certain place that is not yet loaded on the map I get disconnected and the server closes. Could you help me, since I don't know what is causing this? crashlog https://gist.github.com/Dwolfwoood/89438cd77dd8796a6dfa6783c20adaed   log server https://gist.github.com/Dwolfwoood/2aa08cc2c554098c7833b2a02f70e6e6
    • I can launch the game, but whenever I try to get in my server I get the error: java.lang.indexoutofboundsexception: readerIndex(5) + length(8) exceeds writerIndex(9): PooledUnsafeByteBuf(ridx: 5, widx: 9, cap: 9)    I don't really know what's going on. https://pastebin.com/ujr0sRDZ I put the whole log in the Pastebin link.
    • I recently built a mod pack ,RLMCC Insanity Unfolds, and Ive been playing it to make sure its stable and playable, these last few days the game has been running fine with the exception of a few player loading quirks here and there but nothing game breaking, fast forward to this morning attempting to load into my survival world results in the game crashing, I will reach 100% on world loading, the joining game prompt will appear, the loading terrain prompt will appear, I get a large lag spike, and then the game says Saving world and then crashes throwing an unknown error in the launcher when checking the logs I can see that right before the world gets shut down better combat throws a fatal error, I had assumed at first that maybe when the world got shutdown last that something got stuck in an invalid state so I removed the mod and played for a bit to hopefully un-stick whatever it was, no luck there. When I placed the mod back into the game the world continued to crash the game when loading in. I figured that maybe there was a bug introduced in the latest version so I downgraded a couple versions and worked my way back up. The original version of Better Combat the mod pack was using was better combat 1.8.6 - 1.20.1, I tried better combat 1.8.1 - 1.20.1 and worked my way up to version 1.8.5 - 1.20.1, still running into the problem. Removing Better combat solves the problem but removing the mod renders a major part of my mod pack broken as one of the major aspects of the pack was focused around better combat. As mentioned the mod pack was working and running stable prior to this morning with Better Combat 1.8.6 - 1.20.1, and there was no change in the mod list this morning I do not believe that this is a mod compatibility issue as I am still able to generate a new world perfectly fine and the mod pack was working fine these last few days. The loading issue seems to only occur with my original survival world that I made when I built the mod pack.   Here is the last section from my latest.log file https://pastebin.com/6Q9e9ZLf  
×
×
  • Create New...

Important Information

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