Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hey, I've got this weird issue where my mob won't spawn outside in the world, and only near the player's entry point to the world.

 

Spawn/Entity code (located in init method)

EntityRegistry.registerModEntity(EntityMimic.class, "rpgMimic", ENTITY_MIMIC_ID, BrightRPG.instance, 80, 1, true);
	EntityRegistry.addSpawn(EntityMimic.class, 85, 3, 7, EnumCreatureType.CREATURE,
			BiomeGenBase.desert,  BiomeGenBase.beach, BiomeGenBase.birchForest, BiomeGenBase.birchForestHills, BiomeGenBase.desertHills, BiomeGenBase.extremeHills,
			BiomeGenBase.extremeHillsEdge, BiomeGenBase.extremeHillsPlus, BiomeGenBase.forest, BiomeGenBase.forestHills, BiomeGenBase.jungle, BiomeGenBase.jungleEdge,
			BiomeGenBase.jungleHills, BiomeGenBase.mesa, BiomeGenBase.mesaPlateau, BiomeGenBase.mesaPlateau_F, BiomeGenBase.plains,
			BiomeGenBase.river, BiomeGenBase.roofedForest, BiomeGenBase.savanna, BiomeGenBase.savannaPlateau);
	EntityList.addMapping(EntityMimic.class, "rpgMimic", 205, 113213, 3523523);

 

A few things:

 

1. Do NOT use '1' for the update frequency (the number after '80') - vanilla animals / mobs all use '3'

 

2. 205 is a magic number - use a counter or something of that nature

 

3. Entity spawning logic is mostly done in the actual Entity class getCanSpawnHere method - show us yours.

  • Author

Here it is:

@Override
public boolean getCanSpawnHere()
{
	return this.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL;
}

 

I changed the frequency to 3 and they still would only spawn near the world entrance. Also, why is 205 taken? When I changed it to a final int, I set it at 400, nothing spawned at all.

Vanilla global entity IDs only go up to 255, which is why it is HIGHLY recommended NOT to use them, and use only the registerModEntity. In 1.8, you don't need to manually add mappings like that anymore to get a spawn egg, you can use instead EntityRegister#registerEgg.

 

The frequency I mentioned is not related to spawn rate, just something I see all the time that is probably not very good to do.

 

Put some println statements in your mob's onInitialSpawn method and see if that is getting called. Also, you probably want to call super.getCanSpawnHere() - the super methods generally have useful checks, depending on what class your mob extends.

 

 

  • Author

So I changed the registry to this:

int id = 600;

	EntityRegistry.registerModEntity(EntityMimic.class, "rpgMimic", BrightRPG.ENTITY_MIMIC_ID, BrightRPG.instance, 80, 3, true);
	EntityRegistry.addSpawn(EntityMimic.class, 85, 3, 7, EnumCreatureType.CREATURE,
			BiomeGenBase.desert,  BiomeGenBase.beach, BiomeGenBase.birchForest, BiomeGenBase.birchForestHills, BiomeGenBase.desertHills, BiomeGenBase.extremeHills,
			BiomeGenBase.extremeHillsEdge, BiomeGenBase.extremeHillsPlus, BiomeGenBase.forest, BiomeGenBase.forestHills, BiomeGenBase.jungle, BiomeGenBase.jungleEdge,
			BiomeGenBase.jungleHills, BiomeGenBase.mesa, BiomeGenBase.mesaPlateau, BiomeGenBase.mesaPlateau_F, BiomeGenBase.plains,
			BiomeGenBase.river, BiomeGenBase.roofedForest, BiomeGenBase.savanna, BiomeGenBase.savannaPlateau);

	EntityList.idToClassMapping.put(id, EntityMimic.class);
	EntityList.entityEggs.put(id, new EntityEggInfo(id, 113213, 3523523));

	id++;

 

I did some more experimenting and it seems that they'll just despawn as soon as I look away. I also can't find the onInitialSpawn method in EntityMob, EntityCreature, EntityLiving or EntityLivingBase.

  • Author

I'll update MCP in a sec, here's the entity code. It's pretty barebones right now:

package twain.brightRPG.entity;

import java.util.UUID;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMoveThroughVillage;
import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
import twain.brightRPG.BrightRPG;

public class EntityMimic extends EntityMob
{
private UUID field_175459_bn;

public EntityMimic(World par1World)
{
	super(par1World);
	this.tasks.addTask(0, new EntityAISwimming(this));
	this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityPlayer.class, 0.6D, false));
	this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityVillager.class, 0.6D, true));
	this.tasks.addTask(3, new EntityAIMoveTowardsRestriction(this, 1.0D));
	this.tasks.addTask(4, new EntityAIMoveThroughVillage(this, 0.6D, true));
	this.tasks.addTask(5, new EntityAIWander(this, 0.6D));
	this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 7.0F));
	this.tasks.addTask(7, new EntityAILookIdle(this));
	this.targetTasks.addTask(0, new EntityAIHurtByTarget(this, true));

	this.setSize(0.6F, 1.8F);
}

@Override
protected void applyEntityAttributes()
{
	super.applyEntityAttributes();
	this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);;
	this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.6D);
	this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3.0D);
}

@Override
protected String getLivingSound()
{
	return null;
}

@Override
protected String getHurtSound()
{
	return "brightRPG:mimicHurt";
}

@Override
protected String getDeathSound()
{
	return "brightRPG:mimicDeath";
}

@Override
protected float getSoundVolume()
{
	return 0.4F;
}

@Override
public void setRevengeTarget(EntityLivingBase livingBase)
{
	super.setRevengeTarget(livingBase);

	if (livingBase != null)
	{
		this.field_175459_bn = livingBase.getUniqueID();
	}
}

@Override
public boolean getCanSpawnHere()
{
	return this.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL && super.getCanSpawnHere();
}
}

  • Author

All no...it's really perplexing. I've tried each difficulty setting and then just running around the world looking, but it's only near the spawn. I'm using forge 11.14.3.1450.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.