Je n'arrive pas à faire tenir un item au mob
-
Bonjour j’ai fait un mob mais je n’arrive pas à le faire tenir un item.
J’y arrive en mettant dans le render “extends RenderBiped”
mais comme mon mob n’a pas les dimensions d’un mob Biped le model du mob est buguer. Je cherche donc comment faire pour pouvoir avoir un item sur un mob qui n’a pas une forme comme les autres.
( Je suis en 1.7.10 ).Mon mob "Goblin Guerrier"
Voici mes class :pour le render :
package com.elejin.elejinmod.renders; import com.elejin.elejinmod.Reference; import com.elejin.elejinmod.entity.EntityGoblinGuerrier; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; public class RenderGoblinGuerrier extends RenderLiving { private final ResourceLocation textureGoblinGuerrier = new ResourceLocation(Reference.MOD_ID+":textures/mobs/goblin_guerrier.png"); public RenderGoblinGuerrier(ModelBase par1ModelBase, float par2) { super(par1ModelBase, par2); } protected ResourceLocation getGoblinGuerrierTexture(EntityGoblinGuerrier goblinGuerrier) { return textureGoblinGuerrier; } @Override protected ResourceLocation getEntityTexture(Entity entity) { return this.getGoblinGuerrierTexture((EntityGoblinGuerrier)entity); } }
pour le l’entité:
package com.elejin.elejinmod.entity; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.*; import net.minecraft.entity.ai.*; import net.minecraft.entity.monster.*; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class EntityGoblinGuerrier extends EntityMob { private int attackTimer; public EntityGoblinGuerrier(World par1world) { super(par1world); this.setSize(1.0F, 1.2F); this.getNavigator().setBreakDoors(true); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityVillager.class, 5.0D, true)); this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false)); this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); this.tasks.addTask(8,new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8,new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); this.targetTasks.addTask(2,new EntityAINearestAttackableTarget(this, EntityVillager.class, 0, false)); } public void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.8D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(10.0D); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); } protected int decreaseAirSupply(int p_70682_1_) { return p_70682_1_; } protected void collideWithEntity(Entity p_82167_1_) { if (p_82167_1_ instanceof IMob && this.getRNG().nextInt(20) == 0) { this.setAttackTarget((EntityLivingBase)p_82167_1_); } super.collideWithEntity(p_82167_1_); } public void onLivingUpdate() { super.onLivingUpdate(); if (this.attackTimer > 0) { --this.attackTimer; } if (this.motionX * this.motionX + this.motionZ * this.motionZ > 2.500000277905201E-7D && this.rand.nextInt(5) == 0) { int i = MathHelper.floor_double(this.posX); int j = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double)this.yOffset); int k = MathHelper.floor_double(this.posZ); Block block = this.worldObj.getBlock(i, j, k); if (block.getMaterial() != Material.air) { this.worldObj.spawnParticle("blockcrack_" + Block.getIdFromBlock(block) + "_" + this.worldObj.getBlockMetadata(i, j, k), this.posX + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, this.boundingBox.minY + 0.1D, this.posZ + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, 4.0D * ((double)this.rand.nextFloat() - 0.5D), 0.5D, ((double)this.rand.nextFloat() - 0.5D) * 4.0D); } } } public boolean attackEntityAsMob(Entity p_70652_1_) { this.attackTimer = 10; this.worldObj.setEntityState(this, (byte)4); boolean flag = p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), (float)(15)); this.playSound("mob.irongolem.throw", 1.0F, 1.0F); return flag; } @SideOnly(Side.CLIENT) public void handleHealthUpdate(byte p_70103_1_) { if (p_70103_1_ == 4) { this.attackTimer = 10; this.playSound("mob.irongolem.throw", 1.0F, 1.0F); } else { super.handleHealthUpdate(p_70103_1_); } } @SideOnly(Side.CLIENT) public int getAttackTimer() { return this.attackTimer; } protected String getSwimSound() { return "game.hostile.swim"; } protected String getSplashSound() { return "game.hostile.swim.splash"; } @Override public boolean getCanSpawnHere() { return (this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox)); } @Override protected boolean isValidLightLevel(){ return true; } protected boolean canDespawn() { return false; } private final ItemStack defaultHeldItem = new ItemStack(Items.stone_sword, 1); public ItemStack getHeldItem() { return defaultHeldItem; } }
-
Bonjour,
Nous ne faisons plus de support pour la 1.7.10, cette version est ultra-obsolète.
-