Jump to content

Faffreux

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by Faffreux

  1. Hello I've been making a mob that is supposed to raise his arm when he is close to a target here is my code (I'm using Mcreator) : 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.projectile.EntityTippedArrow; 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.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAILookIdle; 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.EntityLivingBase; import net.minecraft.entity.Entity; import net.minecraft.client.renderer.entity.RenderSnowball; 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_hammerBro { 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_hammerBro.ModelHammerBro(), 0) { protected ResourceLocation getEntityTexture(Entity par1Entity) { return new ResourceLocation("hammer.png"); } }; RenderingRegistry.registerEntityRenderingHandler(mcreator_hammerBro.EntityhammerBro.class, customRender); RenderingRegistry.registerEntityRenderingHandler(EntityArrowCustom.class, new RenderSnowball(Minecraft.getMinecraft().getRenderManager(), new ItemStack(Items.IRON_AXE).getItem(), Minecraft.getMinecraft().getRenderItem())); } public void serverLoad(FMLServerStartingEvent event) { } public void preInit(FMLPreInitializationEvent event) { int entityID = MathHelper.getRandomUUID().hashCode(); mobid = entityID; EntityRegistry.registerModEntity(new ResourceLocation("testenvironmentmod:hammerBro"), mcreator_hammerBro.EntityhammerBro.class, "hammerBro", entityID, instance, 64, 1, true, (51 << 16) + (153 << 8) + 0, (0 << 16) + (0 << 8) + 0); EntityRegistry.addSpawn(mcreator_hammerBro.EntityhammerBro.class, 0, 3, 30, EnumCreatureType.MONSTER, clean(Biome.REGISTRY)); int entityID2 = MathHelper.getRandomUUID().hashCode(); EntityRegistry.registerModEntity(new ResourceLocation("testenvironmentmod:entitybullethammerbro"), EntityArrowCustom.class, "entitybullethammerbro", entityID2, instance, 64, 1, true); } 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 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); } } public static class EntityhammerBro extends EntityMob implements IRangedAttackMob { World world = null; private int attacking = 0; public EntityhammerBro(World var1) { super(var1); world = var1; experienceValue = 5; this.isImmuneToFire = false; addRandomArmor(); setNoAI(!true); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(6, new EntityAIWander(this, 1.0D)); this.tasks.addTask(8, new EntityAILookIdle(this)); this.targetTasks.addTask(1, (new EntityAINearestAttackableTarget(this, EntityPlayer.class, true)).setUnseenMemoryTicks(300)); this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false)); this.tasks.addTask(1, new EntityAIAttackRanged(this, 1.25D, 20, 10.0F)); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10D); if (this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3D); } protected void addRandomArmor() { } public void onUpdate() { super.onUpdate(); } 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.setThrowableHeading(d1, d2 + (double) f, d3, 1.6F, 12.0F); this.world.spawnEntity(entityarrow); } @Override protected Item getDropItem() { return null; } @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) { super.processInteract(entity, hand); int i = (int) this.posX; int j = (int) this.posY; int k = (int) this.posZ; return true; } @Override protected float getSoundVolume() { return 1.0F; } public int attack() { return attacking; } public void setAttack(){ EntityLivingBase entitylivingbase = this.getAttackTarget(); if(this.getDistanceSqToEntity(entitylivingbase) < 9.0D) { attacking = 1; } else { attacking = 0; } } } /** * ModelGreenKoopa - Fawful Created using Tabula 5.0.0 */ public static class ModelHammerBro extends ModelBase { public ModelRenderer shoeD1; public ModelRenderer legD; public ModelRenderer shoeD2; public ModelRenderer shoeD3; public ModelRenderer shoeG3; public ModelRenderer shoeG1; public ModelRenderer shoeG2; public ModelRenderer legG; public ModelRenderer shell1; public ModelRenderer shell2; public ModelRenderer shell3; public ModelRenderer shell4; public ModelRenderer armD; public ModelRenderer fistD; public ModelRenderer armG; public ModelRenderer fistG; public ModelRenderer cou; public ModelRenderer queue; public ModelRenderer oeil1; public ModelRenderer bec1; public ModelRenderer bec2; public ModelRenderer bec3; public ModelRenderer bec4; public ModelRenderer bec5; public ModelRenderer bec6; public ModelRenderer casque2; public ModelRenderer oreillette1; public ModelRenderer lacet; public ModelRenderer casque3; public ModelRenderer casque1; public ModelRenderer oreillette2; public ModelRenderer head; public ModelRenderer oeil2; public ModelRenderer arriere; public ModelRenderer manche; public ModelRenderer tete; public ModelHammerBro() { this.textureWidth = 128; this.textureHeight = 128; this.shoeD3 = new ModelRenderer(this, 44, 8); this.shoeD3.setRotationPoint(-3.4F, 10.0F, 0.0F); this.shoeD3.addBox(-2.5F, 9.0F, -6.0F, 5, 5, 3, 0.0F); this.shell3 = new ModelRenderer(this, 42, 50); this.shell3.setRotationPoint(0.0F, 3.1F, 7.6F); this.shell3.addBox(-3.5F, -5.0F, -1.0F, 7, 10, 2, 1.0F); this.setRotateAngle(shell3, 0.27314402793711257F, 0.0F, 0.0F); this.oreillette1 = new ModelRenderer(this, 74, 20); this.oreillette1.setRotationPoint(0.0F, -9.0F, -4.2F); this.oreillette1.addBox(4.3F, -1.2F, 0.5F, 2, 3, 4, 0.0F); this.setRotateAngle(oreillette1, -0.7285004297824331F, 0.0F, 0.0F); this.casque1 = new ModelRenderer(this, 0, 100); this.casque1.setRotationPoint(0.0F, -9.0F, -4.2F); this.casque1.addBox(-6.0F, -3.2F, -6.5F, 12, 3, 14, 0.0F); this.setRotateAngle(casque1, -0.7285004297824331F, 0.0F, 0.0F); this.manche = new ModelRenderer(this, 0, 118); this.manche.setRotationPoint(-4.0F, 0.0F, -1.8F); this.manche.addBox(-1.0F, 11.0F, -5.0F, 2, 2, 8, 0.0F); this.setRotateAngle(manche, 0.0F, 0.0F, 0.5462880558742251F); this.armD = new ModelRenderer(this, 0, 0); this.armD.setRotationPoint(-4.0F, 0.0F, -1.8F); this.armD.addBox(-1.5F, 0.0F, -1.5F, 3, 10, 3, 0.1F); this.setRotateAngle(armD, 0.0F, 0.0F, 0.5462880558742251F); this.queue = new ModelRenderer(this, 0, 0); this.queue.setRotationPoint(0.0F, 14.0F, 3.0F); this.queue.addBox(-1.0F, -1.0F, -2.0F, 2, 2, 6, 0.0F); this.setRotateAngle(queue, -0.9105382707654417F, 0.0F, 0.0F); this.casque3 = new ModelRenderer(this, 0, 70); this.casque3.setRotationPoint(0.0F, -9.0F, -4.2F); this.casque3.addBox(-5.0F, -6.5F, -5.5F, 10, 4, 12, 0.0F); this.setRotateAngle(casque3, -0.7285004297824331F, 0.0F, 0.0F); this.oeil1 = new ModelRenderer(this, 90, 4); this.oeil1.setRotationPoint(0.0F, -9.0F, -4.2F); this.oeil1.addBox(0.5F, -2.8F, -3.8F, 3, 4, 1, 0.0F); this.bec5 = new ModelRenderer(this, 90, 40); this.bec5.setRotationPoint(0.0F, -9.0F, -4.2F); this.bec5.addBox(-3.0F, 1.0F, -6.6F, 6, 4, 5, 0.0F); this.setRotateAngle(bec5, -0.18203784098300857F, 0.0F, 0.0F); this.lacet = new ModelRenderer(this, 62, 50); this.lacet.setRotationPoint(0.0F, -9.0F, -4.2F); this.lacet.addBox(-5.5F, -1.70F, 1.5F, 11, 8, 2, 0.0F); this.setRotateAngle(lacet, -0.40980330836826856F, 0.0F, 0.0F); this.bec2 = new ModelRenderer(this, 90, 30); this.bec2.setRotationPoint(0.0F, -9.0F, -4.2F); this.bec2.addBox(-1.0F, 3.8F, -7.6F, 2, 1, 1, 0.0F); this.setRotateAngle(bec2, 0.091106186954104F, 0.0F, 0.0F); this.shell4 = new ModelRenderer(this, 42, 27); this.shell4.setRotationPoint(0.0F, 5.0F, 1.0F); this.shell4.addBox(-7.0F, -7.9F, 0.0F, 14, 17, 2, 1.0F); this.setRotateAngle(shell4, 0.27314402793711257F, 0.0F, 0.0F); this.fistD = new ModelRenderer(this, 0, 0); this.fistD.setRotationPoint(-4.0F, 0.0F, -1.8F); this.fistD.addBox(-2.0F, 10.0F, -2.0F, 4, 4, 4, 0.2F); this.setRotateAngle(fistD, 0.0F, 0.0F, 0.5462880558742251F); this.bec6 = new ModelRenderer(this, 90, 30); this.bec6.setRotationPoint(0.0F, -9.0F, -4.2F); this.bec6.addBox(-3.0F, 4.0F, -4.7F, 6, 2, 6, 0.0F); this.setRotateAngle(bec6, -0.136659280431156F, 0.0F, 0.0F); this.fistG = new ModelRenderer(this, 0, 0); this.fistG.setRotationPoint(4.0F, 0.0F, -1.8F); this.fistG.addBox(-2.0F, 10.0F, -2.0F, 4, 4, 4, 0.2F); this.setRotateAngle(fistG, 0.0F, 0.0F, -0.5462880558742251F); this.cou = new ModelRenderer(this, 70, 0); this.cou.setRotationPoint(0.0F, -4.0F, -2.0F); this.cou.addBox(-2.5F, -4.0F, -2.5F, 5, 6, 3, 0.0F); this.setRotateAngle(cou, 0.36425021489121656F, 0.0F, 0.0F); this.head = new ModelRenderer(this, 90, 0); this.head.setRotationPoint(0.0F, -9.0F, -4.2F); this.head.addBox(-4.5F, -3.5F, -3.5F, 9, 9, 9, 0.0F); this.casque2 = new ModelRenderer(this, 90, 50); this.casque2.setRotationPoint(0.0F, -9.0F, -4.2F); this.casque2.addBox(-4.0F, -8.2F, -4.5F, 8, 4, 10, 0.0F); this.setRotateAngle(casque2, -0.7285004297824331F, 0.0F, 0.0F); this.oreillette2 = new ModelRenderer(this, 74, 20); this.oreillette2.setRotationPoint(0.0F, -9.0F, -4.2F); this.oreillette2.addBox(-6.3F, -1.2F, 0.5F, 2, 3, 4, 0.0F); this.setRotateAngle(oreillette2, -0.7285004297824331F, 0.0F, 0.0F); this.legD = new ModelRenderer(this, 0, 0); this.legD.setRotationPoint(-3.4F, 10.0F, 0.0F); this.legD.addBox(-2.0F, 0.0F, -2.0F, 4, 10, 4, 0.0F); this.legG = new ModelRenderer(this, 0, 0); this.legG.setRotationPoint(3.4F, 10.0F, 0.0F); this.legG.addBox(-2.0F, 0.0F, -2.0F, 4, 10, 4, 0.0F); this.shell1 = new ModelRenderer(this, 0, 16); this.shell1.setRotationPoint(0.0F, 5.0F, 1.0F); this.shell1.addBox(-5.5F, -6.5F, -3.0F, 11, 14, 8, 1.0F); this.setRotateAngle(shell1, 0.27314402793711257F, 0.0F, 0.0F); this.shoeG2 = new ModelRenderer(this, 38, 0); this.shoeG2.setRotationPoint(3.4F, 10.0F, 0.0F); this.shoeG2.addBox(-2.5F, 8.0F, -2.5F, 5, 2, 5, 0.0F); this.bec4 = new ModelRenderer(this, 90, 30); this.bec4.setRotationPoint(0.0F, -9.0F, -4.2F); this.bec4.addBox(-2.0F, 2.8F, -7.6F, 4, 1, 2, 0.0F); this.setRotateAngle(bec4, 0.091106186954104F, 0.0F, 0.0F); this.shoeG3 = new ModelRenderer(this, 44, 8); this.shoeG3.setRotationPoint(3.4F, 10.0F, 0.0F); this.shoeG3.addBox(-2.5F, 9.0F, -6.0F, 5, 5, 3, 0.0F); this.bec3 = new ModelRenderer(this, 90, 30); this.bec3.setRotationPoint(0.0F, -9.0F, -4.2F); this.bec3.addBox(-2.5F, 4.6F, -3.8F, 5, 2, 4, 0.0F); this.setRotateAngle(bec3, -0.136659280431156F, 0.0F, 0.0F); this.shoeD2 = new ModelRenderer(this, 38, 0); this.shoeD2.setRotationPoint(-3.4F, 10.0F, 0.0F); this.shoeD2.addBox(-2.5F, 8.0F, -2.5F, 5, 2, 5, 0.0F); this.bec1 = new ModelRenderer(this, 90, 20); this.bec1.setRotationPoint(0.0F, -9.0F, -4.2F); this.bec1.addBox(-5.0F, 1.0F, -4.0F, 10, 4, 4, 0.0F); this.oeil2 = new ModelRenderer(this, 90, 0); this.oeil2.setRotationPoint(0.0F, -9.0F, -4.2F); this.oeil2.addBox(-3.5F, -2.8F, -3.8F, 3, 4, 1, 0.0F); this.arriere = new ModelRenderer(this, 37, 121); this.arriere.setRotationPoint(-4.0F, 0.0F, -1.8F); this.arriere.addBox(-1.5F, 8.0F, -5.0F, 3, 4, 3, 0.0F); this.setRotateAngle(arriere, -0.22759093446006054F, 0.0F, 0.5462880558742251F); this.shoeD1 = new ModelRenderer(this, 18, 0); this.shoeD1.setRotationPoint(-3.4F, 10.0F, 0.0F); this.shoeD1.addBox(-2.5F, 10.0F, -4.0F, 5, 4, 7, 0.0F); this.armG = new ModelRenderer(this, 0, 0); this.armG.setRotationPoint(4.0F, 0.0F, -1.8F); this.armG.addBox(-1.5F, 0.0F, -1.5F, 3, 10, 3, 0.2F); this.setRotateAngle(armG, 0.0F, 0.0F, -0.5462880558742251F); this.shoeG1 = new ModelRenderer(this, 18, 0); this.shoeG1.setRotationPoint(3.4F, 10.0F, 0.0F); this.shoeG1.addBox(-2.5F, 10.0F, -4.0F, 5, 4, 7, 0.0F); this.tete = new ModelRenderer(this, 21, 118); this.tete.setRotationPoint(-4.0F, 0.0F, -1.8F); this.tete.addBox(-2.0F, 9.0F, -8.0F, 4, 6, 4, 0.0F); this.setRotateAngle(tete, 0.0F, 0.0F, 0.5462880558742251F); this.shell2 = new ModelRenderer(this, 0, 39); this.shell2.setRotationPoint(0.0F, 5.0F, 2.0F); this.shell2.addBox(-4.5F, -6.0F, -5.5F, 9, 12, 11, 1.0F); this.setRotateAngle(shell2, 0.27314402793711257F, 0.007853981633974483F, 0.0F); } @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { this.shoeD3.render(f5); this.shell3.render(f5); this.oreillette1.render(f5); this.casque1.render(f5); this.manche.render(f5); this.armD.render(f5); this.queue.render(f5); this.casque3.render(f5); this.oeil1.render(f5); this.bec5.render(f5); this.lacet.render(f5); this.bec2.render(f5); this.shell4.render(f5); this.fistD.render(f5); this.bec6.render(f5); this.fistG.render(f5); this.cou.render(f5); this.head.render(f5); this.casque2.render(f5); this.oreillette2.render(f5); this.legD.render(f5); this.legG.render(f5); this.shell1.render(f5); this.shoeG2.render(f5); this.bec4.render(f5); this.shoeG3.render(f5); this.bec3.render(f5); this.shoeD2.render(f5); this.bec1.render(f5); this.oeil2.render(f5); this.arriere.render(f5); this.shoeD1.render(f5); this.armG.render(f5); this.shoeG1.render(f5); this.tete.render(f5); this.shell2.render(f5); } /** * This is a helper function from Tabula to set the rotation of model * parts */ public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.rotateAngleX = x; modelRenderer.rotateAngleY = y; modelRenderer.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity e) { this.shoeG3.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1; this.shoeG2.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1; this.shoeG1.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1; this.legG.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1; this.shoeD3.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1; this.shoeD2.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1; this.shoeD1.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1; this.legD.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1; this.armG.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1; this.fistG.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1; this.bec1.rotateAngleY = f3 / ( 180F / (float)Math.PI); this.bec1.rotateAngleX = f4 / ( 180F / (float)Math.PI); this.head.rotateAngleY = f3 / ( 180F / (float)Math.PI); this.head.rotateAngleX = f4 / ( 180F / (float)Math.PI); this.oeil1.rotateAngleY = f3 / ( 180F / (float)Math.PI); this.oeil1.rotateAngleX = f4 / ( 180F / (float)Math.PI); this.oeil2.rotateAngleY = f3 / ( 180F / (float)Math.PI); this.oeil2.rotateAngleX = f4 / ( 180F / (float)Math.PI); this.casque1.rotateAngleY = f3 / ( 180F / (float)Math.PI); this.casque1.rotateAngleX = f4 / ( 180F / (float)Math.PI) -0.7285004297824331F; this.casque2.rotateAngleY = f3 / ( 180F / (float)Math.PI); this.casque2.rotateAngleX = f4 / ( 180F / (float)Math.PI) -0.7285004297824331F; this.casque3.rotateAngleY = f3 / ( 180F / (float)Math.PI); this.casque3.rotateAngleX = f4 / ( 180F / (float)Math.PI) -0.7285004297824331F; this.bec2.rotateAngleY = f3 / ( 180F / (float)Math.PI); this.bec2.rotateAngleX = f4 / ( 180F / (float)Math.PI) +0.091106186954104F; this.bec4.rotateAngleY = f3 / ( 180F / (float)Math.PI); this.bec4.rotateAngleX = f4 / ( 180F / (float)Math.PI) +0.091106186954104F; this.bec5.rotateAngleY = f3 / ( 180F / (float)Math.PI); this.bec5.rotateAngleX = f4 / ( 180F / (float)Math.PI) - 0.18203784098300857F; this.bec3.rotateAngleY = f3 / ( 180F / (float)Math.PI); this.bec3.rotateAngleX = f4 / ( 180F / (float)Math.PI) -0.136659280431156F; this.bec6.rotateAngleY = f3 / ( 180F / (float)Math.PI); this.bec6.rotateAngleX = f4 / ( 180F / (float)Math.PI) -0.136659280431156F; this.oreillette1.rotateAngleY = f3 / ( 180F / (float)Math.PI); this.oreillette1.rotateAngleX = f4 / ( 180F / (float)Math.PI) - 0.18203784098300857F; this.oreillette2.rotateAngleY = f3 / ( 180F / (float)Math.PI); this.oreillette2.rotateAngleX = f4 / ( 180F / (float)Math.PI) -0.136659280431156F; this.lacet.rotateAngleY = f3 / ( 180F / (float)Math.PI); this.lacet.rotateAngleX = f4 / ( 180F / (float)Math.PI) -0.7285004297824331F; this.fistD.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1; this.armD.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1; this.manche.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1; this.tete.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1; this.arriere.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1 -0.22759093446006054F; EntityhammerBro entityhammerBro = (mcreator_hammerBro.EntityhammerBro)e; if(entityhammerBro.attack() == 1) { this.fistD.rotateAngleX = (MathHelper.cos(f * 1.0F) * -1.0F * f1) - 2.5F; this.armD.rotateAngleX = (MathHelper.cos(f * 1.0F) * -1.0F * f1) - 2.5F; this.manche.rotateAngleX = (MathHelper.cos(f * 1.0F) * -1.0F * f1) - 2.5F; this.tete.rotateAngleX = (MathHelper.cos(f * 1.0F) * -1.0F * f1) - 2.5F; this.arriere.rotateAngleX = (MathHelper.cos(f * 1.0F) * -1.0F * f1 -0.22759093446006054F) - 2.5F; this.fistD.rotateAngleY = 0.5F; this.armD.rotateAngleY = 0.5F; this.manche.rotateAngleY = 0.5F; this.tete.rotateAngleY = 0.5F; this.arriere.rotateAngleY = 0.5F; this.fistD.rotateAngleZ = -0.5F; this.armD.rotateAngleZ = -0.5F; this.manche.rotateAngleZ = -0.5F; this.tete.rotateAngleZ = -0.5F; this.arriere.rotateAngleZ = -0.5F; } } } } I made a void so when he is at 9 tiles from his target or less he should execute an action in his model part... what did I get wrong?
  2. I think you should lock the frame into #1 so the block doesn't move then you use the event on right click (look at EntityPlayer.java) and put the frame changer code in this event
  3. Hello guys, I'mp curious about how to make a mob that doesn't extend from a biped model hold an item? I tried many method however they are all obsolete or only work on biped models (so please don't ask me to go look at EntityZombie.java etc...) and how do you say where to put the item, if it's in left hand or right hand? thanks for replying
  4. In fact I changed the private method into a public one to see if it could work and no need to be salty. I'll do my best to find a solution and I'll post it here anyway thanks I guess
  5. Is there a way to modify the method onCollideWithPlayer to allow this method to work for every LivingBase Entity?
  6. sorry about that Lukas and diesieben07 that's a methode I took from EntityDragon.java so I assume this method is also called by Minecraft itself
  7. here is my entire code, I'm using Mcreator (please dont hit me) : 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 java.util.List; import net.minecraft.world.World; import net.minecraft.util.math.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumHand; import net.minecraft.util.DamageSource; import net.minecraft.item.ItemStack; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.Item; import net.minecraft.world.EnumDifficulty; import net.minecraft.util.math.RayTraceResult; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.EntityFlying; import net.minecraft.entity.ai.EntityMoveHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.Entity; import net.minecraft.util.math.AxisAlignedBB; 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_bulletBill { 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_bulletBill.BulletBill(), 0) { protected ResourceLocation getEntityTexture(Entity par1Entity) { return new ResourceLocation("bulletbill.png"); } }; RenderingRegistry.registerEntityRenderingHandler(mcreator_bulletBill.EntitybulletBill.class, customRender); } public void serverLoad(FMLServerStartingEvent event) { } public void preInit(FMLPreInitializationEvent event) { int entityID = MathHelper.getRandomUUID().hashCode(); mobid = entityID; EntityRegistry.registerModEntity(new ResourceLocation("testenvironmentmod:bulletBill"), mcreator_bulletBill.EntitybulletBill.class, "bulletBill", entityID, instance, 64, 1, true, (0 << 16) + (0 << + 0, (204 << 16) + (204 << + 204); EntityRegistry.addSpawn(mcreator_bulletBill.EntitybulletBill.class, 0, 3, 30, EnumCreatureType.MONSTER, clean(Biome.REGISTRY)); } 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 static class EntitybulletBill extends EntityFlying implements IMob { World world = null; public EntitybulletBill(World var1) { super(var1); world = var1; experienceValue = 5; this.isImmuneToFire = false; addRandomArmor(); setNoAI(!true); this.tasks.addTask(5, new EntitybulletBill.AIRandomFly(this)); this.moveHelper = new EntitybulletBill.bulletBillMoveHelper(this); this.tasks.addTask(7, new EntitybulletBill.AILookAround(this)); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.4D); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(1D); if (this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3D); } protected void addRandomArmor() { } public void onLivingUpdate() { super.onLivingUpdate(); World par1World = this.world; int par2 = (int) this.posX; int par3 = (int) this.posY; int par4 = (int) this.posZ; Random par5Random = this.rand; if (true) for (int la = 0; la < 4; ++la) { double d0 = (double) ((float) par2 + 0.5F) + (double) (par5Random.nextFloat() - 0.5F) * 0.0D; double d1 = (double) ((float) par3 + 0.5F) + (double) (par5Random.nextFloat() - 0.5F) * 0.0D; double d2 = (double) ((float) par4 + 0.5F) + (double) (par5Random.nextFloat() - 0.5F) * 0.0D; double d3 = 0.2199999988079071D; double d4 = 0.27000001072883606D; par1World.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); } } @Override protected Item getDropItem() { return null; } @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; } public void collideWithEntities(List<Entity> p_70970_1_) { int i = (int) this.posX; int j = (int) this.posY; int k = (int) this.posZ; world.createExplosion((Entity) null, i, j, k, 4F, true); } @Override public boolean processInteract(EntityPlayer entity, EnumHand hand) { super.processInteract(entity, hand); int i = (int) this.posX; int j = (int) this.posY; int k = (int) this.posZ; return true; } @Override protected float getSoundVolume() { return 1.0F; } static class AILookAround extends EntityAIBase { private final EntitybulletBill parentEntity; public AILookAround(EntitybulletBill bulletBill) { this.parentEntity = bulletBill; this.setMutexBits(2); } /** * Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { return true; } /** * Updates the task */ public void updateTask() { if (this.parentEntity.getAttackTarget() == null) { this.parentEntity.rotationYaw = -((float)MathHelper.atan2(this.parentEntity.motionX, this.parentEntity.motionZ)) * (180F / (float)Math.PI); this.parentEntity.renderYawOffset = this.parentEntity.rotationYaw; } else { EntityLivingBase entitylivingbase = this.parentEntity.getAttackTarget(); double d0 = 64.0D; if (entitylivingbase.getDistanceSqToEntity(this.parentEntity) < 4096.0D) { double d1 = entitylivingbase.posX - this.parentEntity.posX; double d2 = entitylivingbase.posZ - this.parentEntity.posZ; this.parentEntity.rotationYaw = -((float)MathHelper.atan2(d1, d2)) * (180F / (float)Math.PI); this.parentEntity.renderYawOffset = this.parentEntity.rotationYaw; } } } } static class AIRandomFly extends EntityAIBase { private final EntitybulletBill parentEntity; public AIRandomFly(EntitybulletBill bulletBill) { this.parentEntity = bulletBill; this.setMutexBits(1); } /** * Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { EntityMoveHelper entitymovehelper = this.parentEntity.getMoveHelper(); if (!entitymovehelper.isUpdating()) { return true; } else { double d0 = entitymovehelper.getX() - this.parentEntity.posX; double d1 = entitymovehelper.getY() - this.parentEntity.posY; double d2 = entitymovehelper.getZ() - this.parentEntity.posZ; double d3 = d0 * d0 + d1 * d1 + d2 * d2; return d3 < 1.0D || d3 > 3600.0D; } } /** * Returns whether an in-progress EntityAIBase should continue executing */ public boolean continueExecuting() { return false; } /** * Execute a one shot task or start executing a continuous task */ public void startExecuting() { Random random = this.parentEntity.getRNG(); double d0 = this.parentEntity.posX + (double)((random.nextFloat() * 2.0F - 1.0F) * 10.0F); double d1 = this.parentEntity.posY + (double)((random.nextFloat() * 2.0F - 1.0F) * 2.0F); double d2 = this.parentEntity.posZ + (double)((random.nextFloat() * 2.0F - 1.0F) * 10.0F); this.parentEntity.getMoveHelper().setMoveTo(d0, d1, d2, 1.0D); } } static class bulletBillMoveHelper extends EntityMoveHelper { private final EntitybulletBill parentEntity; private int courseChangeCooldown; public bulletBillMoveHelper(EntitybulletBill bulletBill) { super(bulletBill); this.parentEntity = bulletBill; } public void onUpdateMoveHelper() { double d0 = this.posX - this.parentEntity.posX; double d1 = this.posY - this.parentEntity.posY; double d2 = this.posZ - this.parentEntity.posZ; double d3 = d0 * d0 + d1 * d1 + d2 * d2; while(d0 == 0 || d2 == 0) { d0 = this.posX - this.parentEntity.posX; d1 = this.posY - this.parentEntity.posY; d2 = this.posZ - this.parentEntity.posZ; d3 = d0 * d0 + d1 * d1 + d2 * d2; } this.courseChangeCooldown += this.parentEntity.getRNG().nextInt(5) + 2; d3 = (double)MathHelper.sqrt(d3); this.parentEntity.motionX += d0 / d3 * 0.07D; this.parentEntity.motionY += d1 / d3 * 0.01D; this.parentEntity.motionZ += d2 / d3 * 0.07D; } } } /** * BulletBill - Faffreux Created using Tabula 5.0.0 */ public static class BulletBill extends ModelBase { public ModelRenderer turbo; public ModelRenderer jointure; public ModelRenderer body; public ModelRenderer head1; public ModelRenderer head2; public ModelRenderer head3; public ModelRenderer Lshoulder; public ModelRenderer Rshoulder; public ModelRenderer Larm; public ModelRenderer Lelbow; public ModelRenderer Lhand; public ModelRenderer Rarm; public ModelRenderer Relbow; public ModelRenderer Rhand; public BulletBill() { this.textureWidth = 128; this.textureHeight = 64; this.Rshoulder = new ModelRenderer(this, 50, 20); this.Rshoulder.setRotationPoint(-7.0F, 15.0F, 0.0F); this.Rshoulder.addBox(-1.0F, -2.0F, -2.0F, 1, 4, 4, 0.0F); this.jointure = new ModelRenderer(this, 0, 18); this.jointure.setRotationPoint(0.0F, 15.0F, 5.0F); this.jointure.addBox(-6.0F, -6.0F, 0.0F, 12, 12, 3, 0.0F); this.Lhand = new ModelRenderer(this, 50, 35); this.Lhand.setRotationPoint(7.0F, 14.5F, 0.0F); this.Lhand.addBox(2.0F, -0.5F, -7.0F, 3, 4, 3, 0.0F); this.Rarm = new ModelRenderer(this, 50, 35); this.Rarm.setRotationPoint(-7.0F, 14.5F, 0.0F); this.Rarm.addBox(-5.0F, -1.0F, -1.0F, 5, 2, 2, 0.0F); this.setRotateAngle(Rarm, 0.0F, 0.0F, -0.40980330836826856F); this.head3 = new ModelRenderer(this, 100, 0); this.head3.setRotationPoint(0.0F, 15.0F, -14.0F); this.head3.addBox(-4.0F, -4.0F, 0.0F, 8, 8, 2, 0.0F); this.Larm = new ModelRenderer(this, 50, 35); this.Larm.setRotationPoint(7.0F, 14.5F, 0.0F); this.Larm.addBox(0.0F, -1.0F, -1.0F, 5, 2, 2, 0.0F); this.setRotateAngle(Larm, 0.0F, 0.0F, 0.40980330836826856F); this.Relbow = new ModelRenderer(this, 50, 35); this.Relbow.setRotationPoint(-7.0F, 14.5F, 0.0F); this.Relbow.addBox(-5.0F, -1.0F, -5.0F, 2, 2, 5, 0.0F); this.setRotateAngle(Relbow, 0.0F, 0.0F, -0.40980330836826856F); this.body = new ModelRenderer(this, 0, 33); this.body.setRotationPoint(0.0F, 15.0F, -8.3F); this.body.addBox(-7.0F, -7.0F, 0.0F, 14, 14, 15, 0.0F); this.Lshoulder = new ModelRenderer(this, 50, 20); this.Lshoulder.setRotationPoint(7.0F, 15.0F, 0.0F); this.Lshoulder.addBox(0.0F, -2.0F, -2.0F, 1, 4, 4, 0.0F); this.head1 = new ModelRenderer(this, 38, 0); this.head1.setRotationPoint(0.0F, 15.0F, -11.0F); this.head1.addBox(-6.0F, -6.0F, 0.0F, 12, 12, 4, 0.0F); this.Lelbow = new ModelRenderer(this, 50, 35); this.Lelbow.setRotationPoint(7.0F, 14.5F, 0.0F); this.Lelbow.addBox(3.0F, -1.0F, -5.0F, 2, 2, 5, 0.0F); this.setRotateAngle(Lelbow, 0.0F, 0.0F, 0.40980330836826856F); this.turbo = new ModelRenderer(this, 0, 0); this.turbo.setRotationPoint(0.0F, 15.0F, 8.0F); this.turbo.addBox(-7.0F, -7.0F, 0.0F, 14, 14, 4, 0.0F); this.Rhand = new ModelRenderer(this, 50, 35); this.Rhand.setRotationPoint(-7.0F, 14.5F, 0.0F); this.Rhand.addBox(-5.0F, -0.5F, -7.0F, 3, 4, 3, 0.0F); this.head2 = new ModelRenderer(this, 73, 0); this.head2.setRotationPoint(0.0F, 15.0F, -13.0F); this.head2.addBox(-5.0F, -5.0F, 0.0F, 10, 10, 3, 0.0F); } @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { this.Rshoulder.render(f5); this.jointure.render(f5); this.Lhand.render(f5); this.Rarm.render(f5); this.head3.render(f5); this.Larm.render(f5); this.Relbow.render(f5); this.body.render(f5); this.Lshoulder.render(f5); this.head1.render(f5); this.Lelbow.render(f5); this.turbo.render(f5); this.Rhand.render(f5); this.head2.render(f5); } /** * This is a helper function from Tabula to set the rotation of model * parts */ public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.rotateAngleX = x; modelRenderer.rotateAngleY = y; modelRenderer.rotateAngleZ = z; } } } I used the method onCollideWithPlayer like that : public void onCollideWithPlayer(EntityPlayer entityplayer) { int i = (int) this.posX; int j = (int) this.posY; int k = (int) this.posZ; world.createExplosion((Entity) null, i, j, k, 4F, true); } and it worked perfectly fine so no need to call the method collideWithEntities right? and by the way thanks for replying
  8. Hello Forge community, I'm new here, I have an issue about a mob I'm creating, I want it to explode whenever it collides with a player, another entity or a block (it's a flying mob) I tried to take some codes from the enderdragon , the one that push away other mobs on collide and the one that destroy blocks on collides, here is the deal, it doesn't work here is a part of my code used for colliding with entities: private void collideWithEntities(List<Entity> p_70970_1_) { for (Entity entity : p_70970_1_) { if (entity instanceof EntityLivingBase) { int i = (int) this.posX; int j = (int) this.posY; int k = (int) this.posZ; world.createExplosion((Entity) null, i, j, k, 4F, true); } } } what did I get wrong?
×
×
  • Create New...

Important Information

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