public static Biome[] clean(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()]); }
/* * public Entity spawnEntity(int var1, World var2, double var3, double var5, * double var7) { if(var1==mobid) return new * mcreator_mobSlime.EntitymobSlime(var2); else return null; } */
public static class EntitymobSlime extends EntityMob { World world = null;
public EntitymobSlime(World var1) { super(var1); world = var1; experienceValue = 5; this.isImmuneToFire = false; addRandomArmor(); setNoAI(!false);
this.tasks.addTask(1, new EntityAIWander(this, 0.8D)); this.tasks.addTask(1, new EntityAIAttackMelee(this, 1.0D, false)); this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAILookIdle(this));
@Override public void onStruckByLightning(EntityLightningBolt entityLightningBolt) { super.onStruckByLightning(entityLightningBolt); int i = (int) this.posX; int j = (int) this.posY; int k = (int) this.posZ; Entity entity = this;
}
@Override public void fall(float l, float d) { super.fall(l, d); int i = (int) this.posX; int j = (int) this.posY; int k = (int) this.posZ; super.fall(l, d); Entity entity = this;
}
@Override public void onDeath(DamageSource source) { super.onDeath(source); int i = (int) this.posX; int j = (int) this.posY; int k = (int) this.posZ; Entity entity = this;
}
@Override public boolean processInteract(EntityPlayer entity, EnumHand hand, ItemStack stack) { super.processInteract(entity, hand, stack); int i = (int) this.posX; int j = (int) this.posY; int k = (int) this.posZ;
You use 1.9.x or 1.10.x , right? There were removed/renamed some AI tasks , but try add these: this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
Simply add custom AI (wander, look around and attack on collide)
It does't work ... when I spawn it , it only than one time turn and stays on the same place ..
@#2 try with priority: attacck on collide 10,wander 5 and lookaround 5
It doesn't work ..
when i hit it is falling slower
I don't know... Is itba flying mob? Or it's based on something?
mob typ :
monster
character :
mob
movement speed : i set 2
that is my code
[spoiler]
package mod.mcreator;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
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.util.math.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.EnumHand;
import net.minecraft.util.DamageSource;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.init.Items;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.Entity;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.Minecraft;
import java.util.Random;
import java.util.Iterator;
import java.util.ArrayList;
@SuppressWarnings("unchecked")
public class mcreator_mobSlime {
public int mobid = 0;
public static Object instance;
public void load(FMLInitializationEvent event) {
}
public void generateNether(World world, Random random, int chunkX, int chunkZ) {
}
public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
}
public int addFuel(ItemStack fuel) {
return 0;
}
@SideOnly(Side.CLIENT)
public void registerRenderers() {
RenderLiving customRender = new RenderLiving(Minecraft.getMinecraft().getRenderManager(), new mcreator_mobSlime.Modelmob(), 0) {
protected ResourceLocation getEntityTexture(Entity par1Entity) {
return new ResourceLocation("Normal_Creeper.png");
}
};
RenderingRegistry.registerEntityRenderingHandler(mcreator_mobSlime.EntitymobSlime.class, customRender);
}
public void serverLoad(FMLServerStartingEvent event) {
}
public void preInit(FMLPreInitializationEvent event) {
int entityID = MathHelper.getRandomUUID().hashCode();
mobid = entityID;
EntityRegistry.registerModEntity(mcreator_mobSlime.EntitymobSlime.class, "mobSlime", entityID, instance, 64, 1, true, (51 << 16) + (255 << 8)
+ 204, (0 << 16) + (255 << 8) + 102);
EntityRegistry.addSpawn(mcreator_mobSlime.EntitymobSlime.class, 20, 1, 10, EnumCreatureType.MONSTER, mcreator_biom.biome);
}
public static Biome[] clean(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()]);
}
/*
* public Entity spawnEntity(int var1, World var2, double var3, double var5,
* double var7) { if(var1==mobid) return new
* mcreator_mobSlime.EntitymobSlime(var2); else return null; }
*/
public static class EntitymobSlime extends EntityMob {
World world = null;
public EntitymobSlime(World var1) {
super(var1);
world = var1;
experienceValue = 5;
this.isImmuneToFire = false;
addRandomArmor();
setNoAI(!false);
this.tasks.addTask(1, new EntityAIWander(this, 0.8D));
this.tasks.addTask(1, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(1, new EntityAILookIdle(this));
}
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(2.0D);
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10D);
if (this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null)
this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(5D);
}
protected void addRandomArmor() {
}
@Override
protected Item getDropItem() {
return new ItemStack(Items.SLIME_BALL).getItem();
}
@Override
protected net.minecraft.util.SoundEvent getAmbientSound() {
return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(""));
}
@Override
protected net.minecraft.util.SoundEvent getHurtSound() {
return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("game.neutral.hurt"));
}
@Override
protected net.minecraft.util.SoundEvent getDeathSound() {
return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("game.neutral.die"));
}
@Override
public void onStruckByLightning(EntityLightningBolt entityLightningBolt) {
super.onStruckByLightning(entityLightningBolt);
int i = (int) this.posX;
int j = (int) this.posY;
int k = (int) this.posZ;
Entity entity = this;
}
@Override
public void fall(float l, float d) {
super.fall(l, d);
int i = (int) this.posX;
int j = (int) this.posY;
int k = (int) this.posZ;
super.fall(l, d);
Entity entity = this;
}
@Override
public void onDeath(DamageSource source) {
super.onDeath(source);
int i = (int) this.posX;
int j = (int) this.posY;
int k = (int) this.posZ;
Entity entity = this;
}
@Override
public boolean processInteract(EntityPlayer entity, EnumHand hand, ItemStack stack) {
super.processInteract(entity, hand, stack);
int i = (int) this.posX;
int j = (int) this.posY;
int k = (int) this.posZ;
return true;
}
@Override
protected float getSoundVolume() {
return 1.0F;
}
}
// Date: 30.10.2016 19:58:50
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX
public static class Modelmob extends ModelBase {
// fields
ModelRenderer head;
ModelRenderer body;
ModelRenderer leg3;
ModelRenderer leg4;
ModelRenderer leg1;
ModelRenderer leg2;
public Modelmob() {
textureWidth = 64;
textureHeight = 32;
head = new ModelRenderer(this, 0, 0);
head.addBox(-4F, -8F, -4F, 8, 8, 8);
head.setRotationPoint(0F, 6F, 0F);
head.setTextureSize(64, 32);
head.mirror = true;
setRotation(head, 0F, 0F, 0F);
body = new ModelRenderer(this, 16, 16);
body.addBox(-4F, 0F, -2F, 8, 12, 4);
body.setRotationPoint(0F, 6F, 0F);
body.setTextureSize(64, 32);
body.mirror = true;
setRotation(body, 0F, 0F, 0F);
leg3 = new ModelRenderer(this, 0, 16);
leg3.addBox(-2F, 0F, -2F, 4, 6, 4);
leg3.setRotationPoint(-2F, 18F, -4F);
leg3.setTextureSize(64, 32);
leg3.mirror = true;
setRotation(leg3, 0F, 0F, 0F);
leg4 = new ModelRenderer(this, 0, 16);
leg4.addBox(-2F, 0F, -2F, 4, 6, 4);
leg4.setRotationPoint(2F, 18F, -4F);
leg4.setTextureSize(64, 32);
leg4.mirror = true;
setRotation(leg4, 0F, 0F, 0F);
leg1 = new ModelRenderer(this, 0, 16);
leg1.addBox(0F, 0F, -2F, 4, 6, 4);
leg1.setRotationPoint(-4F, 18F, 4F);
leg1.setTextureSize(64, 32);
leg1.mirror = true;
setRotation(leg1, 0F, 0F, 0F);
leg2 = new ModelRenderer(this, 0, 16);
leg2.addBox(-2F, 0F, -2F, 4, 6, 4);
leg2.setRotationPoint(2F, 18F, 4F);
leg2.setTextureSize(64, 32);
leg2.mirror = true;
setRotation(leg2, 0F, 0F, 0F);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
super.render(entity, f, f1, f2, f3, f4, f5);
setRotationAngles(f, f1, f2, f3, f4, f5, entity);
head.render(f5);
body.render(f5);
leg3.render(f5);
leg4.render(f5);
leg1.render(f5);
leg2.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity e)
{
super.setRotationAngles(f, f1, f2, f3, f4, f5, e);
this.head.rotateAngleY = f3 / (180F / (float) Math.PI);
this.head.rotateAngleX = f4 / (180F / (float) Math.PI);
this.leg2.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
this.leg1.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
this.leg3.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * 2.0F * f1 * 0.5F;
this.leg4.rotateAngleX = MathHelper.cos(f * 0.6662F) * 2.0F * f1 * 0.5F;
}
}
}
[/spoiler]
@#5 try using the default moving speed
Because a time i used move speed 2 but it was slow and didn't attack. Now added 20 speed to the default and works fine. So don't use extreme speed
@#6 sorry but i can't code. Maybe can help you a moderator like klemen IR xx_mc_xx or qn user that knows how to code (like nuparo0)
:(
Change setNoAI(!false); to setNoAI(false); , or you can edit the element and in the AI part check the has AI tickbox.
Naparu00
I have it thx i forget set has AI
XD
but now i have problem it dousnt attack .. it runs and turn but id doesnt attack
and when I hitt it nothig happening.
tambêm estou passando pelo mesmo problema o meu mob esta setado como agressivo mas não ataca
You use 1.9.x or 1.10.x , right?
There were removed/renamed some AI tasks , but try add these:
this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));