So, when MCreator used to open (I'll make another bug report about that or write it in the comments), I was experimenting with neutral mobs that can attack. After I made the first mob, I went on making a second one with the same skin. When I tested it, it showed a boss bar. Which was weird, since it was not meant to be a boss mob (it also was not set as one). How can I avoid this issue next time? Was it that I used the same skin? Please help!
Issue comments
package net.mcreator.byzantium_mod;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.World;
import net.minecraft.world.BossInfoServer;
import net.minecraft.world.BossInfo;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.DamageSource;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.init.Items;
import net.minecraft.entity.projectile.EntityTippedArrow;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAIAttackRanged;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.IRangedAttackMob;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.Entity;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.Minecraft;
import java.util.Iterator;
import java.util.ArrayList;
public class MCreatorByzantineArcher extends byzantium_mod.ModElement {
public static final int ENTITYID = 3;
public static final int ENTITYID_RANGED = 4;
public MCreatorByzantineArcher(byzantium_mod instance) {
super(instance);
instance.entities.add(() -> EntityEntryBuilder.create().entity(EntityCustom.class)
.id(new ResourceLocation("byzantium_mod", "byzantinearcher"), ENTITYID).name("byzantinearcher").tracker(64, 1, true)
.egg(-3407872, -3342439).build());
instance.entities.add(() -> EntityEntryBuilder.create().entity(EntityArrowCustom.class)
.id(new ResourceLocation("byzantium_mod", "entitybulletbyzantinearcher"), ENTITYID_RANGED).name("entitybulletbyzantinearcher")
.tracker(64, 1, true).build());
}
@Override
public void init(FMLInitializationEvent event) {
Biome[] spawnBiomes = allbiomes(Biome.REGISTRY);
EntityRegistry.addSpawn(EntityCustom.class, 20, 3, 10, EnumCreatureType.CREATURE, spawnBiomes);
}
private Biome[] allbiomes(net.minecraft.util.registry.RegistryNamespaced<ResourceLocation, Biome> in) {
Iterator<Biome> itr = in.iterator();
ArrayList<Biome> ls = new ArrayList<Biome>();
while (itr.hasNext())
ls.add(itr.next());
return ls.toArray(new Biome[ls.size()]);
}
@SideOnly(Side.CLIENT)
@Override
public void preInit(FMLPreInitializationEvent event) {
RenderingRegistry.registerEntityRenderingHandler(EntityCustom.class, renderManager -> {
RenderBiped customRender = new RenderBiped(renderManager, new ModelBiped(), 0.5f) {
protected ResourceLocation getEntityTexture(Entity entity) {
return new ResourceLocation("byzantium_mod:textures/byzantinecitizen.png");
}
};
customRender.addLayer(new net.minecraft.client.renderer.entity.layers.LayerHeldItem(customRender));
customRender.addLayer(new net.minecraft.client.renderer.entity.layers.LayerBipedArmor(customRender) {
protected void initArmor() {
this.modelLeggings = new ModelBiped();
this.modelArmor = new ModelBiped();
}
});
return customRender;
});
RenderingRegistry.registerEntityRenderingHandler(EntityArrowCustom.class, renderManager -> {
return new RenderSnowball<EntityArrowCustom>(renderManager, null, Minecraft.getMinecraft().getRenderItem()) {
public ItemStack getStackToRender(EntityArrowCustom entity) {
return new ItemStack(Items.ARROW, (int) (1));
}
};
});
}
public static class EntityCustom extends EntityMob implements IRangedAttackMob {
public EntityCustom(World world) {
super(world);
setSize(0.6f, 1.8f);
experienceValue = 5;
this.isImmuneToFire = false;
setNoAI(!true);
enablePersistence();
this.tasks.addTask(1, new EntityAIWander(this, 1));
this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false));
this.tasks.addTask(3, new EntityAISwimming(this));
this.tasks.addTask(1, new EntityAIAttackRanged(this, 1.25D, 20, 10.0F));
this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.BOW, (int) (1)));
this.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(Items.CHAINMAIL_HELMET, (int) (1)));
this.setItemStackToSlot(EntityEquipmentSlot.CHEST, new ItemStack(Items.CHAINMAIL_CHESTPLATE, (int) (1)));
this.setItemStackToSlot(EntityEquipmentSlot.LEGS, new ItemStack(Items.CHAINMAIL_LEGGINGS, (int) (1)));
this.setItemStackToSlot(EntityEquipmentSlot.FEET, new ItemStack(Items.CHAINMAIL_BOOTS, (int) (1)));
}
@Override
public EnumCreatureAttribute getCreatureAttribute() {
return EnumCreatureAttribute.UNDEFINED;
}
@Override
protected boolean canDespawn() {
return false;
}
@Override
protected Item getDropItem() {
return new ItemStack(Items.ARROW, (int) (1)).getItem();
}
@Override
public net.minecraft.util.SoundEvent getAmbientSound() {
return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(""));
}
@Override
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(""));
}
@Override
public net.minecraft.util.SoundEvent getDeathSound() {
return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(""));
}
@Override
protected float getSoundVolume() {
return 1.0F;
}
@Override
protected void applyEntityAttributes() {
super.applyEntityAttributes();
if (this.getEntityAttribute(SharedMonsterAttributes.ARMOR) != null)
this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(0.5D);
if (this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED) != null)
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3D);
if (this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH) != null)
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20D);
if (this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null)
this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(1D);
}
@Override
public void setSwingingArms(boolean swingingArms) {
}
public void attackEntityWithRangedAttack(EntityLivingBase target, float flval) {
EntityArrowCustom entityarrow = new EntityArrowCustom(this.world, this);
double d0 = target.posY + (double) target.getEyeHeight() - 1.1;
double d1 = target.posX - this.posX;
double d2 = d0 - entityarrow.posY;
double d3 = target.posZ - this.posZ;
float f = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F;
entityarrow.shoot(d1, d2 + (double) f, d3, 1.6F, 12.0F);
this.world.spawnEntity(entityarrow);
}
protected void dropRareDrop(int par1) {
this.dropItem(new ItemStack(Items.GOLD_INGOT, (int) (1)).getItem(), 1);
}
@Override
public boolean isNonBoss() {
return false;
}
private final BossInfoServer bossInfo = (BossInfoServer) (new BossInfoServer(this.getDisplayName(), BossInfo.Color.PINK,
BossInfo.Overlay.PROGRESS));
@Override
public void addTrackingPlayer(EntityPlayerMP player) {
super.addTrackingPlayer(player);
this.bossInfo.addPlayer(player);
}
@Override
public void removeTrackingPlayer(EntityPlayerMP player) {
super.removeTrackingPlayer(player);
this.bossInfo.removePlayer(player);
}
@Override
public void onUpdate() {
super.onUpdate();
this.bossInfo.setPercent(this.getHealth() / this.getMaxHealth());
}
}
public static class EntityArrowCustom extends EntityTippedArrow {
public EntityArrowCustom(World a) {
super(a);
}
public EntityArrowCustom(World worldIn, double x, double y, double z) {
super(worldIn, x, y, z);
}
public EntityArrowCustom(World worldIn, EntityLivingBase shooter) {
super(worldIn, shooter);
}
}
}
The wiki says something about the 1024 health limit:
https://minecraft.gamepedia.com/Health
(in the hearths section)
Are you sure you did not enable mob boss or had another boss mob around?
I was not able to replicate this bug.