Une sorte de "familié"
-
Bon après plusieurs jour j’avais laissé tombé l’idée et supprimé la classe.

Mais ensuite après avoir quelque chose je me suis remotivé mais j’ai décidé de changé le familiar c’est à dire
[font=Ubuntu, sans-serifun familié que tu clique droit dessus avec une “paper” avec une list de joueur il ne l’attaquera pas ][font=Ubuntu, sans-serifque quand tu fait clique droit dessus avec un item spécial sa change c’est caractéristique mais avec des “lvl”]
[font=Ubuntu, sans-serifqu’il se tp à toi fait]
[font=Ubuntu, sans-serifquand tu fait clique sur ce mob il ne se tp plus et reste à l’endroit ou il est mais peux bougé et attaqué]
[font=Ubuntu, sans-serifquand tu fait clique droit avec un item spécial sa lui change son skin]
quand ton familiar est mort tu craft un item spécial et sa le fait respawn avec son skin spécial + ses lvl
quand pars exemple il est lvl 5 il gagne une capacité quand il attaque le mob sa donne c’est effet de potion ou quand il est lvl 10 il peut gagné la capacité quand il tape un joueur 3 fois sa lui donne un effet de potion.
Merci de votre aide

-
Salut alors j’ai un problème j’etait entrain de codé mais j’ai un problème c’est que comme mon entity à déjà était adopté avec mon entity je peut le re adopté avec un autre item une sorte d’amélioration
-
Pas compris, essaie de t’expliquer différemment. Poste ton code sa nous aidera aussi

-
3 problèmes se sont posé quand j’ai fais mon mini kirby

1 - Si une personne l’adopte au clique droit si tu ne lui donne pas un maitre tout le monde peux faire se qu’il veut avec
2 - Le chunk qui se décharge lors d’un /spawn ton piti chou ne va pas se tp =/
3 - Si tu stock pas le maitre quelque par si la personne déco ou leave il sera sans maitre jusqu’a se que quelqu’un le réadopte -
package ed.enderdeath.mod.entity; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ed.enderdeath.mod.Food.Baie; import ed.enderdeath.mod.common.enderdeath; import net.minecraft.block.Block; import net.minecraft.block.BlockColored; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIFollowOwner; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILeapAtTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMate; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget; import net.minecraft.entity.ai.EntityAIOwnerHurtTarget; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAITargetNonTamed; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.pathfinding.PathEntity; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class Familiar extends EntityTameable implements IMob { private boolean test; private int lvl; private boolean getActive; private float field_70926_e; private float field_70924_f; /** true is the wolf is wet else false */ private boolean isShaking; private boolean field_70928_h; /** * This time increases while wolf is shaking and emitting water particles. */ private float timeWolfIsShaking; private float prevTimeWolfIsShakin; public Familiar(World world) { super(world); this.setSize(1.0F, 1.0F); this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(2, this.aiSit); this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F)); this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true)); this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F)); this.tasks.addTask(6, new EntityAIMate(this, 1.0D)); this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(9, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true)); this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntityPlayer.class, 200, false)); this.targetTasks.addTask(10, new EntityAIAttackOnCollide(this, EntityPlayer.class, 5, true)); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D); if (this.isTamed()) { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D); } else { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); } } public boolean isAIEnabled() { return true; } protected void updateAITick() { this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth())); } protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, new Float(this.getHealth())); this.dataWatcher.addObject(19, new Byte((byte) 0)); this.dataWatcher.addObject(20, new Byte((byte) BlockColored.func_150032_b(1))); } public void onLivingUpdate() { super.onLivingUpdate(); if (!this.worldObj.isRemote && this.isShaking && !this.field_70928_h && !this.hasPath() && this.onGround) { this.field_70928_h = true; this.worldObj.setEntityState(this, (byte) 8); } } public void onUpdate() { super.onUpdate(); this.field_70924_f = this.field_70926_e; if (this.func_70922_bv()) { this.field_70926_e += (1.0F - this.field_70926_e) * 0.4F; } else { this.field_70926_e += (0.0F - this.field_70926_e) * 0.4F; } if (this.func_70922_bv()) { this.numTicksToChaseTarget = 10; } if (this.isWet()) { this.isShaking = true; this.field_70928_h = false; this.timeWolfIsShaking = 0.0F; } else if ((this.isShaking || this.field_70928_h) && this.field_70928_h) { if (this.timeWolfIsShaking == 0.0F) { this.playSound("mob.wolf.shake", this.getSoundVolume(), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); } this.timeWolfIsShaking += 0.05F; if (this.timeWolfIsShaking > 0.4F) { float f = (float) this.boundingBox.minY; int i = (int) (MathHelper.sin((this.timeWolfIsShaking - 0.4F) * (float) Math.PI) * 7.0F); for (int j = 0; j < i; ++j) { float f1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; float f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; this.worldObj.spawnParticle("splash", this.posX + (double) f1, (double) (f + 0.8F), this.posZ + (double) f2, this.motionX, this.motionY, this.motionZ); } } } } public int getVerticalFaceSpeed() { return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); } public boolean attackEntityAsMob(Entity p_70652_1_) { int i = this.isTamed() ? 4 : 2; return p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); } public void setTamed(boolean p_70903_1_) { super.setTamed(p_70903_1_); if (p_70903_1_) { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(700.0D); } else { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); } } public void setTameda(boolean p_70903_1_) { super.setTamed(p_70903_1_); if (p_70903_1_) { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D); } else { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); } } public boolean interact(EntityPlayer p_70085_1_) { ItemStack itemstack = p_70085_1_.inventory.getCurrentItem(); if (this.isTamed()) { if (itemstack != null) { if (itemstack.getItem() instanceof Baie) { ItemFood itemfood = (ItemFood) itemstack.getItem(); if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < 20.0F) { if (!p_70085_1_.capabilities.isCreativeMode) { –itemstack.stackSize; } this.heal((float) itemfood.func_150905_g(itemstack)); if (itemstack.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null); } return true; } } else if (itemstack.getItem() == null) { int i = BlockColored.func_150032_b(itemstack.getItemDamage()); if (!p_70085_1_.capabilities.isCreativeMode && --itemstack.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null); return true; } } } if (this.func_152114_e(p_70085_1_) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack)) { this.aiSit.setSitting(!this.isSitting()); this.isJumping = false; this.setPathToEntity((PathEntity) null); this.setTarget((Entity) null); this.setAttackTarget((EntityLivingBase) null); } } if (!p_70085_1_.capabilities.isCreativeMode) { --itemstack.stackSize; } if (itemstack.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null); } if (itemstack != null && itemstack.getItem() == enderdeath.GoldenCroquette) { if (!p_70085_1_.capabilities.isCreativeMode) { --itemstack.stackSize; } if (itemstack.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null); } if (!this.worldObj.isRemote) { if (this.rand.nextInt(3) == 0) { this.setTameda(true); this.setPathToEntity((PathEntity) null); this.setAttackTarget((EntityLivingBase) null); this.aiSit.setSitting(true); this.setHealth(100.0F); this.func_152115_b(p_70085_1_.getUniqueID().toString()); this.playTameEffect(true); this.lvl = 2; this.worldObj.setEntityState(this, (byte) 7); } else { this.playTameEffect(false); this.worldObj.setEntityState(this, (byte) 6); } } else if (itemstack != null && itemstack.getItem() == enderdeath.RubisCroquette && itemstack != null && this.lvl == 2) { if (!p_70085_1_.capabilities.isCreativeMode) { --itemstack.stackSize; } if (itemstack.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null); } if (!this.worldObj.isRemote) { if (this.rand.nextInt(3) == 0) { this.setTamed(true); this.setPathToEntity((PathEntity) null); this.setAttackTarget((EntityLivingBase) null); this.aiSit.setSitting(true); this.setHealth(5.0F); this.func_152115_b(p_70085_1_.getUniqueID().toString()); this.playTameEffect(true); this.lvl = 3; System.out.println("Test Lvl3"); this.worldObj.setEntityState(this, (byte) 7); } else { this.playTameEffect(false); this.worldObj.setEntityState(this, (byte) 6); } } } return true; } return super.interact(p_70085_1_); } public boolean isBreedingItem(ItemStack p_70877_1_) { return p_70877_1_ == null ? false : (!(p_70877_1_.getItem() instanceof Baie) ? false : ((Baie) p_70877_1_.getItem()).isWolfsFavoriteMeat()); } public Familiar createChild(EntityAgeable p_90011_1_) { Familiar entitywolf = new Familiar(this.worldObj); String s = this.func_152113_b(); if (s != null && s.trim().length() > 0) { entitywolf.func_152115_b(s); entitywolf.setTamed(true); } return entitywolf; } public void func_70918_i(boolean p_70918_1_) { if (p_70918_1_) { this.dataWatcher.updateObject(19, Byte.valueOf((byte) 1)); } else { this.dataWatcher.updateObject(19, Byte.valueOf((byte) 0)); } } public boolean canMateWith(EntityAnimal p_70878_1_) { if (p_70878_1_ == this) { return false; } else if (!this.isTamed()) { return false; } else if (!(p_70878_1_ instanceof Familiar)) { return false; } else { Familiar entitywolf = (Familiar) p_70878_1_; return !entitywolf.isTamed() ? false : (entitywolf.isSitting() ? false : this.isInLove() && entitywolf.isInLove()); } } public boolean func_70922_bv() { return this.dataWatcher.getWatchableObjectByte(19) == 1; } }Voici ma classe actuel je suis bloqué sur faire que l’entity attaque tout le sauf celui qui la adopté,sur de lui donné le lvl 3 je suis bloqué au lvl 2 comme pour mon entity quand je lui donne les croquette en or il est déjà adopté et donc je peut pas le re adoptée pour lui faire changé de stats.
aprés autre problème si tu lui donne un skin (avec l’item spécial n’importe qui peux donné un skin alors et il faut que sa soit juste le maite )
Ps:ma classe est un peu beaucoup en bazar

Merci de votre aide

-
Vas sur eclipse, appuies sur les touches ctrl + shift + f puis repostes ton code.
-
@‘robin4002’:
Vas sur eclipse, appuies sur les touches ctrl + shift + f puis repostes ton code.
Excuse j’y avais pas pensé x)
tien
package ed.enderdeath.mod.entity; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ed.enderdeath.mod.Food.Baie; import ed.enderdeath.mod.common.enderdeath; import net.minecraft.block.Block; import net.minecraft.block.BlockColored; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIFollowOwner; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILeapAtTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMate; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget; import net.minecraft.entity.ai.EntityAIOwnerHurtTarget; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAITargetNonTamed; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.pathfinding.PathEntity; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class Familiar extends EntityTameable implements IMob { private boolean test; private int lvl; private boolean getActive; private float field_70926_e; private float field_70924_f; /** true is the wolf is wet else false */ private boolean isShaking; private boolean field_70928_h; /** * This time increases while wolf is shaking and emitting water particles. */ private float timeWolfIsShaking; private float prevTimeWolfIsShakin; public Familiar(World world) { super(world); this.setSize(1.0F, 1.0F); this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(2, this.aiSit); this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F)); this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true)); this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F)); this.tasks.addTask(6, new EntityAIMate(this, 1.0D)); this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(9, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true)); this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntityPlayer.class, 200, false)); this.targetTasks.addTask(10, new EntityAIAttackOnCollide(this, EntityPlayer.class, 5, true)); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D); if(this.isTamed()) { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D); } else { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); } } public boolean isAIEnabled() { return true; } protected void updateAITick() { this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth())); } protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, new Float(this.getHealth())); this.dataWatcher.addObject(19, new Byte((byte)0)); this.dataWatcher.addObject(20, new Byte((byte)BlockColored.func_150032_b(1))); } public void onLivingUpdate() { super.onLivingUpdate(); if(!this.worldObj.isRemote && this.isShaking && !this.field_70928_h && !this.hasPath() && this.onGround) { this.field_70928_h = true; this.worldObj.setEntityState(this, (byte)8); } } public void onUpdate() { super.onUpdate(); this.field_70924_f = this.field_70926_e; if(this.func_70922_bv()) { this.field_70926_e += (1.0F - this.field_70926_e) * 0.4F; } else { this.field_70926_e += (0.0F - this.field_70926_e) * 0.4F; } if(this.func_70922_bv()) { this.numTicksToChaseTarget = 10; } if(this.isWet()) { this.isShaking = true; this.field_70928_h = false; this.timeWolfIsShaking = 0.0F; } else if((this.isShaking || this.field_70928_h) && this.field_70928_h) { if(this.timeWolfIsShaking == 0.0F) { this.playSound("mob.wolf.shake", this.getSoundVolume(), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); } this.timeWolfIsShaking += 0.05F; if(this.timeWolfIsShaking > 0.4F) { float f = (float)this.boundingBox.minY; int i = (int)(MathHelper.sin((this.timeWolfIsShaking - 0.4F) * (float)Math.PI) * 7.0F); for(int j = 0; j < i; ++j) { float f1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; float f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; this.worldObj.spawnParticle("splash", this.posX + (double)f1, (double)(f + 0.8F), this.posZ + (double)f2, this.motionX, this.motionY, this.motionZ); } } } } public int getVerticalFaceSpeed() { return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); } public boolean attackEntityAsMob(Entity p_70652_1_) { int i = this.isTamed() ? 4 : 2; return p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), (float)i); } public void setTamed(boolean p_70903_1_) { super.setTamed(p_70903_1_); if(p_70903_1_) { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(700.0D); } else { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); } } public void setTameda(boolean p_70903_1_) { super.setTamed(p_70903_1_); if(p_70903_1_) { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D); } else { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); } } public boolean interact(EntityPlayer p_70085_1_) { ItemStack itemstack = p_70085_1_.inventory.getCurrentItem(); if(this.isTamed()) { if(itemstack != null) { if(itemstack.getItem() instanceof Baie) { ItemFood itemfood = (ItemFood)itemstack.getItem(); if(itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < 20.0F) { if(!p_70085_1_.capabilities.isCreativeMode) { –itemstack.stackSize; } this.heal((float)itemfood.func_150905_g(itemstack)); if(itemstack.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack)null); } return true; } } else if(itemstack.getItem() == null) { int i = BlockColored.func_150032_b(itemstack.getItemDamage()); if(!p_70085_1_.capabilities.isCreativeMode && --itemstack.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack)null); return true; } } } if(this.func_152114_e(p_70085_1_) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack)) { this.aiSit.setSitting(!this.isSitting()); this.isJumping = false; this.setPathToEntity((PathEntity)null); this.setTarget((Entity)null); this.setAttackTarget((EntityLivingBase)null); } } if(!p_70085_1_.capabilities.isCreativeMode) { --itemstack.stackSize; } if(itemstack.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack)null); } if(itemstack != null && itemstack.getItem() == enderdeath.GoldenCroquette) { if(!p_70085_1_.capabilities.isCreativeMode) { --itemstack.stackSize; } if(!this.worldObj.isRemote) { if(this.rand.nextInt(3) == 0) { this.setTameda(true); this.setPathToEntity((PathEntity)null); this.setAttackTarget((EntityLivingBase)null); this.aiSit.setSitting(true); this.setHealth(100.0F); this.playTameEffect(true); this.lvl = 2; this.worldObj.setEntityState(this, (byte)7); } else { this.playTameEffect(false); this.worldObj.setEntityState(this, (byte)6); } } else if(itemstack != null && itemstack.getItem() == enderdeath.RubisCroquette && itemstack != null && this.lvl == 2) { if(!p_70085_1_.capabilities.isCreativeMode) { --itemstack.stackSize; } if(!this.worldObj.isRemote) { if(this.rand.nextInt(3) == 0) { this.setTamed(true); this.setPathToEntity((PathEntity)null); this.setAttackTarget((EntityLivingBase)null); this.aiSit.setSitting(true); this.setHealth(5.0F); this.func_152115_b(p_70085_1_.getUniqueID().toString()); this.playTameEffect(true); this.lvl = 3; System.out.println("Test Lvl3"); this.worldObj.setEntityState(this, (byte)7); } else { this.playTameEffect(false); this.worldObj.setEntityState(this, (byte)6); } } } return true; } return super.interact(p_70085_1_); } public boolean isBreedingItem(ItemStack p_70877_1_) { return p_70877_1_ == null ? false : (!(p_70877_1_.getItem() instanceof Baie) ? false : ((Baie)p_70877_1_.getItem()).isWolfsFavoriteMeat()); } public Familiar createChild(EntityAgeable p_90011_1_) { Familiar entitywolf = new Familiar(this.worldObj); String s = this.func_152113_b(); if(s != null && s.trim().length() > 0) { entitywolf.func_152115_b(s); entitywolf.setTamed(true); } return entitywolf; } public void func_70918_i(boolean p_70918_1_) { if(p_70918_1_) { this.dataWatcher.updateObject(19, Byte.valueOf((byte)1)); } else { this.dataWatcher.updateObject(19, Byte.valueOf((byte)0)); } } public boolean canMateWith(EntityAnimal p_70878_1_) { if(p_70878_1_ == this) { return false; } else if(!this.isTamed()) { return false; } else if(!(p_70878_1_ instanceof Familiar)) { return false; } else { Familiar entitywolf = (Familiar)p_70878_1_; return !entitywolf.isTamed() ? false : (entitywolf.isSitting() ? false : this.isInLove() && entitywolf.isInLove()); } } public boolean func_70922_bv() { return this.dataWatcher.getWatchableObjectByte(19) == 1; } } -
Ce n’est toujours pas formaté comme il faut …
J’ai édité ton message, c’est mieux comme ça.Ce que tu veux faire c’est qu’on puisse adopter une entité déjà adopté pour augmenter son niveau ?
-
@‘robin4002’:
Ce n’est toujours pas formaté comme il faut …
J’ai édité ton message, c’est mieux comme ça.Ce que tu veux faire c’est qu’on puisse adopter une entité déjà adopté pour augmenter son niveau ?
Excuse
Et c’est exact -
Du-coup au lieu d’avoir une variable tamed du type boolean il faudrait utiliser un int ou un short.
0 correspondrait à non adopté. 1 pour le premier niveau, etc …
Après c’est pas compliqué à mettre en place, il faut modifier la fonction interact et adapter en fonction de cette variable.
Et les fonctions qui demande un boolean il suffit de mettre this.tamed > 0 à la place. -
@‘robin4002’:
Du-coup au lieu d’avoir une variable tamed du type boolean il faudrait utiliser un int ou un short.
0 correspondrait à non adopté. 1 pour le premier niveau, etc …
Après c’est pas compliqué à mettre en place, il faut modifier la fonction interact et adapter en fonction de cette variable.
Et les fonctions qui demande un boolean il suffit de mettre this.tamed > 0 à la place.Bonjour robin merci de ta réponse rapide et précise
Mais pour moi sa devait être plus facile j’ai essayé des tas de manniére pour le faire mais n’y arrivant pas je poste ce message et je n’ai pas compris comment faire pour que la variable = adopté ou pas -
Poste ton code stp, avec tes nouvelles tentatives et dis nous là où ça coince.
-
package ed.enderdeath.mod.entity; import java.util.List; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ed.enderdeath.mod.Food.Baie; import ed.enderdeath.mod.common.enderdeath; import net.minecraft.block.Block; import net.minecraft.block.BlockColored; import net.minecraft.block.BlockEnchantmentTable; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIFollowOwner; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILeapAtTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMate; import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget; import net.minecraft.entity.ai.EntityAIOwnerHurtTarget; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAITargetNonTamed; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.boss.IBossDisplayData; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.monster.EntityGhast; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityChicken; import net.minecraft.entity.passive.EntityCow; import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.passive.EntityPig; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.pathfinding.PathEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class Familiar extends EntityTameable implements IMob, IBossDisplayData { private float field_70926_e; private float field_70924_f; /** true is the wolf is wet else false */ private boolean isShaking; private boolean field_70928_h; /** * This time increases while wolf is shaking and emitting water particles. */ private float timeWolfIsShaking; private float prevTimeWolfIsShaking; private int lvl; private static final String __OBFID = "CL_00001654"; private int Tamed = 1; private World world; private int x; private int y; private int z; private Random random; private int short1; private double d3; private double d4; private double d5; private int k; public Familiar(World p_i1696_1_) { super(p_i1696_1_); this.setSize(0.6F, 0.8F); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(2, this.aiSit); this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F)); this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true)); this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F)); this.tasks.addTask(6, new EntityAIMate(this, 1.0D)); this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(9, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true)); this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, false)); this.Tamed = 0; lvl = 1; } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D); if (this.isTamed()) { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D); } else { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); } } /** * Returns true if the newer Entity AI code should be run */ public boolean isAIEnabled() { return true; } /** * Sets the active target the Task system uses for tracking */ public void setAttackTarget(EntityLivingBase p_70624_1_) { super.setAttackTarget(p_70624_1_); if (p_70624_1_ == null) { this.setAngry(false); } else if (!this.isTamed()) { this.setAngry(true); } } /** * main AI tick function, replaces updateEntityActionState */ protected void updateAITick() { this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth())); } protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, new Float(this.getHealth())); this.dataWatcher.addObject(19, new Byte((byte) 0)); this.dataWatcher.addObject(20, new Byte((byte) BlockColored.func_150032_b(1))); } protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) { this.playSound("mob.wolf.step", 0.15F, 1.0F); } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound p_70014_1_) { super.writeEntityToNBT(p_70014_1_); p_70014_1_.setBoolean("Angry", this.isAngry()); p_70014_1_.setByte("CollarColor", (byte) this.getCollarColor()); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound p_70037_1_) { super.readEntityFromNBT(p_70037_1_); this.setAngry(p_70037_1_.getBoolean("Angry")); if (p_70037_1_.hasKey("CollarColor", 99)) { this.setCollarColor(p_70037_1_.getByte("CollarColor")); } } /** * Returns the sound this mob makes while it's alive. */ public void updateEntityActionState() { List list = worldObj.getEntitiesWithinAABB(EntityCreature.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1)); for (int i = 0; i < list.size(); i++) { Entity entity = (Entity) list.get(i); if (!list.isEmpty()) { if (!(entity instanceof EntityPlayer)) { this.setTarget(entity); } } } super.updateEntityActionState(); } /** * Returns the volume for the sounds this mob makes. */ protected float getSoundVolume() { return 0.4F; } /** * Called frequently so the entity can update its state every tick as * required. For example, zombies and skeletons use this to react to * sunlight and start to burn. */ public void onLivingUpdate() { super.onLivingUpdate(); if (!this.worldObj.isRemote && this.isShaking && !this.field_70928_h && !this.hasPath() && this.onGround) { this.field_70928_h = true; this.timeWolfIsShaking = 0.0F; this.prevTimeWolfIsShaking = 0.0F; this.worldObj.setEntityState(this, (byte) 8); } for (k = 0; k < 2; ++k) { this.worldObj.spawnParticle("enchantmenttable", this.posX + (this.rand.nextDouble() - 0.5D) * (double) this.width, this.posY + this.rand.nextDouble() * (double) this.height - 0.25D, this.posZ + (this.rand.nextDouble() - 0.5D) * (double) this.width, (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), (this.rand.nextDouble() - 0.5D) * 2.0D); } } public void onUpdate() { super.onUpdate(); this.field_70924_f = this.field_70926_e; if (this.func_70922_bv()) { this.field_70926_e += (1.0F - this.field_70926_e) * 0.4F; } else { this.field_70926_e += (0.0F - this.field_70926_e) * 0.4F; } if (this.func_70922_bv()) { this.numTicksToChaseTarget = 10; } if (this.isWet()) { this.isShaking = true; this.field_70928_h = false; this.timeWolfIsShaking = 0.0F; this.prevTimeWolfIsShaking = 0.0F; } else if ((this.isShaking || this.field_70928_h) && this.field_70928_h) { if (this.timeWolfIsShaking == 0.0F) { this.playSound("mob.wolf.shake", this.getSoundVolume(), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); } this.prevTimeWolfIsShaking = this.timeWolfIsShaking; this.timeWolfIsShaking += 0.05F; if (this.prevTimeWolfIsShaking >= 2.0F) { this.isShaking = false; this.field_70928_h = false; this.prevTimeWolfIsShaking = 0.0F; this.timeWolfIsShaking = 0.0F; } if (this.timeWolfIsShaking > 0.4F) { float f = (float) this.boundingBox.minY; int i = (int) (MathHelper.sin((this.timeWolfIsShaking - 0.4F) * (float) Math.PI) * 7.0F); for (int j = 0; j < i; ++j) { float f1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; float f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; this.worldObj.spawnParticle("splash", this.posX + (double) f1, (double) (f + 0.8F), this.posZ + (double) f2, this.motionX, this.motionY, this.motionZ); } } } } @SideOnly(Side.CLIENT) public boolean getWolfShaking() { return this.isShaking; } @SideOnly(Side.CLIENT) public float getShadingWhileShaking(float p_70915_1_) { return 0.75F + (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70915_1_) / 2.0F * 0.25F; } @SideOnly(Side.CLIENT) public float getShakeAngle(float p_70923_1_, float p_70923_2_) { float f2 = (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70923_1_ + p_70923_2_) / 1.8F; if (f2 < 0.0F) { f2 = 0.0F; } else if (f2 > 1.0F) { f2 = 1.0F; } return MathHelper.sin(f2 * (float) Math.PI) * MathHelper.sin(f2 * (float) Math.PI * 11.0F) * 0.15F * (float) Math.PI; } public float getEyeHeight() { return this.height * 0.8F; } @SideOnly(Side.CLIENT) public float getInterestedAngle(float p_70917_1_) { return (this.field_70924_f + (this.field_70926_e - this.field_70924_f) * p_70917_1_) * 0.15F * (float) Math.PI; } /** * The speed it takes to move the entityliving's rotationPitch through the * faceEntity method. This is only currently use in wolves. */ public int getVerticalFaceSpeed() { return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); } /** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { if (this.isEntityInvulnerable()) { return false; } else { Entity entity = p_70097_1_.getEntity(); this.aiSit.setSitting(false); if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { p_70097_2_ = (p_70097_2_ + 1.0F) / 2.0F; } return super.attackEntityFrom(p_70097_1_, p_70097_2_); } } public boolean attackEntityAsMob(Entity p_70652_1_) { int i = this.isTamed() ? 4 : 2; return p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); } public int tamed() { if (Tamed == 1) { this.setTamed(true); } else if (Tamed == 0) { this.setTamed(false); } return Tamed; } public void setTamed(boolean p_70903_1_) { super.setTamed(p_70903_1_); if (this.isTamed()) { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D); } else { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); } } /** * Called when a player interacts with a mob. e.g. gets milk from a cow, * gets into the saddle on a pig. */ public boolean interact(EntityPlayer p_70085_1_) { ItemStack itemstack = p_70085_1_.inventory.getCurrentItem(); if (this.Tamed > 0 && this.lvl > 0) { if (itemstack != null) { if (itemstack.getItem() instanceof Baie) { Baie itemfood = (Baie) itemstack.getItem(); if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < 20.0F) { if (!p_70085_1_.capabilities.isCreativeMode) { –itemstack.stackSize; } this.heal((float) itemfood.func_150905_g(itemstack)); if (itemstack.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null); } return true; } } else if (itemstack.getItem() == Items.dye) { int i = BlockColored.func_150032_b(itemstack.getItemDamage()); if (i != this.getCollarColor()) { this.setCollarColor(i); if (!p_70085_1_.capabilities.isCreativeMode && --itemstack.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null); } return true; } } } if (this.func_152114_e(p_70085_1_) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack)) { this.aiSit.setSitting(!this.isSitting()); this.isJumping = false; this.setPathToEntity((PathEntity) null); this.setTarget((Entity) null); this.setAttackTarget((EntityLivingBase) null); } } else if (itemstack != null && itemstack.getItem() == enderdeath.GoldenCroquette && this.lvl == 1) { if (!p_70085_1_.capabilities.isCreativeMode) { --itemstack.stackSize; } if (itemstack.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null); } if (!this.worldObj.isRemote) { if (this.rand.nextInt(3) == 0) { this.Tamed = 1; this.setPathToEntity((PathEntity) null); this.setAttackTarget((EntityLivingBase) null); this.aiSit.setSitting(true); this.setHealth(100.0F); this.func_152115_b(p_70085_1_.getUniqueID().toString()); this.playTameEffect(true); this.worldObj.setEntityState(this, (byte) 7); this.lvl = 2; } else { this.playTameEffect(false); this.worldObj.setEntityState(this, (byte) 6); } } else if (itemstack != null && itemstack.getItem() == enderdeath.RubisCroquette && this.lvl == 2 && this.Tamed < 0) { if (!p_70085_1_.capabilities.isCreativeMode) { --itemstack.stackSize; } if (itemstack.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null); } if (!this.worldObj.isRemote) { if (this.rand.nextInt(3) == 0) { this.Tamed = 1; this.setPathToEntity((PathEntity) null); this.setAttackTarget((EntityLivingBase) null); this.aiSit.setSitting(true); this.setHealth(20.0F); this.func_152115_b(p_70085_1_.getUniqueID().toString()); this.playTameEffect(true); this.worldObj.setEntityState(this, (byte) 7); } else { this.playTameEffect(false); this.worldObj.setEntityState(this, (byte) 6); } } } return true; } return super.interact(p_70085_1_); } @SideOnly(Side.CLIENT) public void handleHealthUpdate(byte p_70103_1_) { if (p_70103_1_ == 8) { this.field_70928_h = true; this.timeWolfIsShaking = 0.0F; this.prevTimeWolfIsShaking = 0.0F; } else { super.handleHealthUpdate(p_70103_1_); } } @SideOnly(Side.CLIENT) public float getTailRotation() { return this.isAngry() ? 1.5393804F : (this.isTamed() ? (0.55F - (20.0F - this.dataWatcher.getWatchableObjectFloat(18)) * 0.02F) * (float) Math.PI : ((float) Math.PI / 5F)); } /** * Checks if the parameter is an item which this animal can be fed to breed * it (wheat, carrots or seeds depending on the animal type) */ public boolean isBreedingItem(ItemStack p_70877_1_) { return p_70877_1_ == null ? false : (!(p_70877_1_.getItem() instanceof Baie) ? false : ((Baie) p_70877_1_.getItem()).isWolfsFavoriteMeat()); } /** * Will return how many at most can spawn in a chunk at once. */ public int getMaxSpawnedInChunk() { return 8; } /** * Determines whether this wolf is angry or not. */ public boolean isAngry() { return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0; } /** * Sets whether this wolf is angry or not. */ public void setAngry(boolean p_70916_1_) { byte b0 = this.dataWatcher.getWatchableObjectByte(16); if (p_70916_1_) { this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2))); } else { this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3))); } } /** * Return this wolf's collar color. */ public int getCollarColor() { return this.dataWatcher.getWatchableObjectByte(20) & 15; } /** * Set this wolf's collar color. */ public void setCollarColor(int p_82185_1_) { this.dataWatcher.updateObject(20, Byte.valueOf((byte) (p_82185_1_ & 15))); } public Familiar createChild(EntityAgeable p_90011_1_) { Familiar entitywolf = new Familiar(this.worldObj); String s = this.func_152113_b(); if (s != null && s.trim().length() > 0) { entitywolf.func_152115_b(s); entitywolf.setTamed(false); } return entitywolf; } public void func_70918_i(boolean p_70918_1_) { if (p_70918_1_) { this.dataWatcher.updateObject(19, Byte.valueOf((byte) 1)); } else { this.dataWatcher.updateObject(19, Byte.valueOf((byte) 0)); } } /** * Returns true if the mob is currently able to mate with the specified mob. */ public boolean canMateWith(EntityAnimal p_70878_1_) { if (p_70878_1_ == this) { return false; } else if (!this.isTamed()) { return false; } else if (!(p_70878_1_ instanceof Familiar)) { return false; } else { Familiar entitywolf = (Familiar) p_70878_1_; return !entitywolf.isTamed() ? false : (entitywolf.isSitting() ? false : this.isInLove() && entitywolf.isInLove()); } } public boolean func_70922_bv() { return this.dataWatcher.getWatchableObjectByte(19) == 1; } /** * Determines if an entity can be despawned, used on idle far away entities */ protected boolean canDespawn() { return !this.isTamed() && this.ticksExisted > 2400; } public boolean func_142018_a(EntityLivingBase p_142018_1_, EntityLivingBase p_142018_2_) { if (!(p_142018_1_ instanceof EntityCreeper) && !(p_142018_1_ instanceof EntityGhast)) { if (p_142018_1_ instanceof Familiar) { Familiar entitywolf = (Familiar) p_142018_1_; if (entitywolf.isTamed() && entitywolf.getOwner() == p_142018_2_) { return false; } } return p_142018_1_ instanceof EntityPlayer && p_142018_2_ instanceof EntityPlayer && !((EntityPlayer) p_142018_2_).canAttackPlayer((EntityPlayer) p_142018_1_) ? false : !(p_142018_1_ instanceof EntityHorse) || !((EntityHorse) p_142018_1_).isTame(); } else { return false; } } }je bloque toujours au méme endroit

-
private int Tamed = 1;
Pour le reset à 0 dans le constructeur, utilité ?
Et pour le reste c’est pas compliqué, genre les conditions qui checkaient avant si tamed était à false, bah tu remplaces par if(this.tamed == 0), sinon, si ça checkait si il était tamed, bah if(this.tamed >= 1), puisque tu as dit qu’il pouvait avoir plusieurs lvl. Je ne reprends que ce qu’a dit robin. Genre dans ta méthode setAttackTarget(blabla), tu changes la condition avec ce que je t’ai dit juste avant, et ça fonctionnera correctement
Donc pareil pour les getters / setters, change bien le type retourné et le type du paramètre attendu (notamment pour setTamed, int à la place de boolean)Et puis j’ai pas tout regardé, car ton code n’est pas formatté, c’est pas agréable à lire, en + du nombre de variables et fonctions qui ne sont pas renommés explicitement. Bref si j’étais toi, je ferai petit à petit, dans l’ajotu des méthodes et diverses fonctionnalités, à la place de faire un gros copié collé ou la pluapart des lignes seront modifiées/retirées

-
@‘Plaigon’:
private int Tamed = 1;
Pour le reset à 0 dans le constructeur, utilité ?
Et pour le reste c’est pas compliqué, genre les conditions qui checkaient avant si tamed était à false, bah tu remplaces par if(this.tamed == 0), sinon, si ça checkait si il était tamed, bah if(this.tamed >= 1), puisque tu as dit qu’il pouvait avoir plusieurs lvl. Je ne reprends que ce qu’a dit robin. Genre dans ta méthode setAttackTarget(blabla), tu changes la condition avec ce que je t’ai dit juste avant, et ça fonctionnera correctement
Donc pareil pour les getters / setters, change bien le type retourné et le type du paramètre attendu (notamment pour setTamed, int à la place de boolean)Et puis j’ai pas tout regardé, car ton code n’est pas formatté, c’est pas agréable à lire, en + du nombre de variables et fonctions qui ne sont pas renommés explicitement. Bref si j’étais toi, je ferai petit à petit, dans l’ajotu des méthodes et diverses fonctionnalités, à la place de faire un gros copié collé ou la pluapart des lignes seront modifiées/retirées

Merci de ta réponse Plaigon

voici ma classe actuellement du familiépackage ed.enderdeath.mod.entity; import java.util.List; import java.util.Random; import org.lwjgl.Sys; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ed.enderdeath.mod.Food.Baie; import ed.enderdeath.mod.common.enderdeath; import net.minecraft.block.Block; import net.minecraft.block.BlockColored; import net.minecraft.block.BlockEnchantmentTable; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIFollowOwner; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILeapAtTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMate; import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget; import net.minecraft.entity.ai.EntityAIOwnerHurtTarget; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAITargetNonTamed; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.boss.IBossDisplayData; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.monster.EntityGhast; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityChicken; import net.minecraft.entity.passive.EntityCow; import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.passive.EntityPig; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.pathfinding.PathEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class Familiar extends EntityTameable implements IMob, IBossDisplayData { private float field_70926_e; private float field_70924_f; /** true is the wolf is wet else false */ private boolean isShaking; private boolean field_70928_h; /** * This time increases while wolf is shaking and emitting water particles. */ private float timeWolfIsShaking; private float prevTimeWolfIsShaking; private int lvl; private static final String __OBFID = "CL_00001654"; private int Tamed = 1; private World world; private int x; private int y; private int z; private Random random; private int short1; private double d3; private double d4; private double d5; private int k; public Familiar(World p_i1696_1_) { super(p_i1696_1_); this.setSize(0.6F, 0.8F); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(2, this.aiSit); this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F)); this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true)); this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F)); this.tasks.addTask(6, new EntityAIMate(this, 1.0D)); this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(9, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true)); this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, false)); this.Tamed = 0; lvl = 1; } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D); if (this.isTamed()) { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D); } else { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); } } /** * Returns true if the newer Entity AI code should be run */ public boolean isAIEnabled() { return true; } /** * Sets the active target the Task system uses for tracking */ public void setAttackTarget(EntityLivingBase p_70624_1_) { super.setAttackTarget(p_70624_1_); if (p_70624_1_ == null) { this.setAngry(false); } else if (!this.isTamed()) { this.setAngry(true); } } /** * main AI tick function, replaces updateEntityActionState */ protected void updateAITick() { this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth())); } protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, new Float(this.getHealth())); this.dataWatcher.addObject(19, new Byte((byte) 0)); this.dataWatcher.addObject(20, new Byte((byte) BlockColored.func_150032_b(1))); } protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) { this.playSound("mob.wolf.step", 0.15F, 1.0F); } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound p_70014_1_) { super.writeEntityToNBT(p_70014_1_); p_70014_1_.setBoolean("Angry", this.isAngry()); p_70014_1_.setByte("CollarColor", (byte) this.getCollarColor()); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound p_70037_1_) { super.readEntityFromNBT(p_70037_1_); this.setAngry(p_70037_1_.getBoolean("Angry")); if (p_70037_1_.hasKey("CollarColor", 99)) { this.setCollarColor(p_70037_1_.getByte("CollarColor")); } } /** * Returns the sound this mob makes while it's alive. */ public void updateEntityActionState() { List list = worldObj.getEntitiesWithinAABB(EntityCreature.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1)); for (int i = 0; i < list.size(); i++) { Entity entity = (Entity) list.get(i); if (!list.isEmpty()) { if (!(entity instanceof EntityPlayer)) { this.setTarget(entity); } } } super.updateEntityActionState(); } /** * Returns the volume for the sounds this mob makes. */ protected float getSoundVolume() { return 0.4F; } /** * Called frequently so the entity can update its state every tick as * required. For example, zombies and skeletons use this to react to * sunlight and start to burn. */ public void onLivingUpdate() { super.onLivingUpdate(); if (!this.worldObj.isRemote && this.isShaking && !this.field_70928_h && !this.hasPath() && this.onGround) { this.field_70928_h = true; this.timeWolfIsShaking = 0.0F; this.prevTimeWolfIsShaking = 0.0F; this.worldObj.setEntityState(this, (byte) 8); } for (k = 0; k < 2; ++k) { this.worldObj.spawnParticle("enchantmenttable", this.posX + (this.rand.nextDouble() - 0.5D) * (double) this.width, this.posY + this.rand.nextDouble() * (double) this.height - 0.25D, this.posZ + (this.rand.nextDouble() - 0.5D) * (double) this.width, (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), (this.rand.nextDouble() - 0.5D) * 2.0D); } } public void onUpdate() { super.onUpdate(); this.field_70924_f = this.field_70926_e; System.out.println("Ligne lvl" + lvl); System.out.println("Tamed" + Tamed); if (this.func_70922_bv()) { this.field_70926_e += (1.0F - this.field_70926_e) * 0.4F; } else { this.field_70926_e += (0.0F - this.field_70926_e) * 0.4F; } if (this.func_70922_bv()) { this.numTicksToChaseTarget = 10; } if (this.isWet()) { this.isShaking = true; this.field_70928_h = false; this.timeWolfIsShaking = 0.0F; this.prevTimeWolfIsShaking = 0.0F; } else if ((this.isShaking || this.field_70928_h) && this.field_70928_h) { if (this.timeWolfIsShaking == 0.0F) { this.playSound("mob.wolf.shake", this.getSoundVolume(), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); } this.prevTimeWolfIsShaking = this.timeWolfIsShaking; this.timeWolfIsShaking += 0.05F; if (this.prevTimeWolfIsShaking >= 2.0F) { this.isShaking = false; this.field_70928_h = false; this.prevTimeWolfIsShaking = 0.0F; this.timeWolfIsShaking = 0.0F; } if (this.timeWolfIsShaking > 0.4F) { float f = (float) this.boundingBox.minY; int i = (int) (MathHelper.sin((this.timeWolfIsShaking - 0.4F) * (float) Math.PI) * 7.0F); for (int j = 0; j < i; ++j) { float f1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; float f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; this.worldObj.spawnParticle("splash", this.posX + (double) f1, (double) (f + 0.8F), this.posZ + (double) f2, this.motionX, this.motionY, this.motionZ); } } } } @SideOnly(Side.CLIENT) public boolean getWolfShaking() { return this.isShaking; } @SideOnly(Side.CLIENT) public float getShadingWhileShaking(float p_70915_1_) { return 0.75F + (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70915_1_) / 2.0F * 0.25F; } @SideOnly(Side.CLIENT) public float getShakeAngle(float p_70923_1_, float p_70923_2_) { float f2 = (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70923_1_ + p_70923_2_) / 1.8F; if (f2 < 0.0F) { f2 = 0.0F; } else if (f2 > 1.0F) { f2 = 1.0F; } return MathHelper.sin(f2 * (float) Math.PI) * MathHelper.sin(f2 * (float) Math.PI * 11.0F) * 0.15F * (float) Math.PI; } public float getEyeHeight() { return this.height * 0.8F; } @SideOnly(Side.CLIENT) public float getInterestedAngle(float p_70917_1_) { return (this.field_70924_f + (this.field_70926_e - this.field_70924_f) * p_70917_1_) * 0.15F * (float) Math.PI; } /** * The speed it takes to move the entityliving's rotationPitch through the * faceEntity method. This is only currently use in wolves. */ public int getVerticalFaceSpeed() { return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); } /** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { if (this.isEntityInvulnerable()) { return false; } else { Entity entity = p_70097_1_.getEntity(); this.aiSit.setSitting(false); if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { p_70097_2_ = (p_70097_2_ + 1.0F) / 2.0F; } return super.attackEntityFrom(p_70097_1_, p_70097_2_); } } public boolean attackEntityAsMob(Entity p_70652_1_) { int i = this.isTamed() ? 4 : 2; return p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); } public int tamed() { if (Tamed == 1) { this.setTamed(true); } else if (Tamed == 0) { this.setTamed(false); } return Tamed; } public void setTamed(boolean p_70903_1_) { super.setTamed(p_70903_1_); if (this.isTamed()) { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D); } else { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); } } /** * Called when a player interacts with a mob. e.g. gets milk from a cow, * gets into the saddle on a pig. */ public boolean interact(EntityPlayer p_70085_1_) { ItemStack itemstack = p_70085_1_.inventory.getCurrentItem(); if (this.Tamed > 0 && this.lvl > 0) { if (itemstack != null) { if (itemstack.getItem() instanceof Baie) { Baie itemfood = (Baie) itemstack.getItem(); if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < 20.0F) { if (!p_70085_1_.capabilities.isCreativeMode) { –itemstack.stackSize; } this.heal((float) itemfood.func_150905_g(itemstack)); if (itemstack.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null); } return true; } } else if (itemstack.getItem() == Items.dye) { int i = BlockColored.func_150032_b(itemstack.getItemDamage()); if (i != this.getCollarColor()) { this.setCollarColor(i); if (!p_70085_1_.capabilities.isCreativeMode && --itemstack.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null); } return true; } } } if (this.func_152114_e(p_70085_1_) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack)) { this.aiSit.setSitting(!this.isSitting()); this.isJumping = false; this.setPathToEntity((PathEntity) null); this.setTarget((Entity) null); this.setAttackTarget((EntityLivingBase) null); } } else if (itemstack != null && itemstack.getItem() == enderdeath.GoldenCroquette && this.lvl >= 1) { if (!p_70085_1_.capabilities.isCreativeMode) { --itemstack.stackSize; } if (itemstack.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null); } if (!this.worldObj.isRemote) { if (this.rand.nextInt(3) == 0) { this.Tamed = 1; if (this.Tamed >= 1) ; this.setPathToEntity((PathEntity) null); this.setAttackTarget((EntityLivingBase) null); this.aiSit.setSitting(true); this.setHealth(100.0F); this.func_152115_b(p_70085_1_.getUniqueID().toString()); this.playTameEffect(true); this.worldObj.setEntityState(this, (byte) 7); this.lvl = 2; } else { this.playTameEffect(false); this.worldObj.setEntityState(this, (byte) 6); } } else if (itemstack != null && itemstack.getItem() == enderdeath.RubisCroquette && this.lvl >= 2 && this.Tamed >= 1) { if (!p_70085_1_.capabilities.isCreativeMode) { --itemstack.stackSize; } if (itemstack.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null); } if (!this.worldObj.isRemote) { if (this.rand.nextInt(3) == 0) { this.setPathToEntity((PathEntity) null); this.setAttackTarget((EntityLivingBase) null); this.aiSit.setSitting(true); this.setHealth(20.0F); this.func_152115_b(p_70085_1_.getUniqueID().toString()); this.playTameEffect(true); this.worldObj.setEntityState(this, (byte) 7); } else { this.playTameEffect(false); this.worldObj.setEntityState(this, (byte) 6); } } } return true; } return super.interact(p_70085_1_); } @SideOnly(Side.CLIENT) public void handleHealthUpdate(byte p_70103_1_) { if (p_70103_1_ == 8) { this.field_70928_h = true; this.timeWolfIsShaking = 0.0F; this.prevTimeWolfIsShaking = 0.0F; } else { super.handleHealthUpdate(p_70103_1_); } } @SideOnly(Side.CLIENT) public float getTailRotation() { return this.isAngry() ? 1.5393804F : (this.isTamed() ? (0.55F - (20.0F - this.dataWatcher.getWatchableObjectFloat(18)) * 0.02F) * (float) Math.PI : ((float) Math.PI / 5F)); } /** * Checks if the parameter is an item which this animal can be fed to breed * it (wheat, carrots or seeds depending on the animal type) */ public boolean isBreedingItem(ItemStack p_70877_1_) { return p_70877_1_ == null ? false : (!(p_70877_1_.getItem() instanceof Baie) ? false : ((Baie) p_70877_1_.getItem()).isWolfsFavoriteMeat()); } /** * Will return how many at most can spawn in a chunk at once. */ public int getMaxSpawnedInChunk() { return 8; } /** * Determines whether this wolf is angry or not. */ public boolean isAngry() { return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0; } /** * Sets whether this wolf is angry or not. */ public void setAngry(boolean p_70916_1_) { byte b0 = this.dataWatcher.getWatchableObjectByte(16); if (p_70916_1_) { this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2))); } else { this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3))); } } /** * Return this wolf's collar color. */ public int getCollarColor() { return this.dataWatcher.getWatchableObjectByte(20) & 15; } /** * Set this wolf's collar color. */ public void setCollarColor(int p_82185_1_) { this.dataWatcher.updateObject(20, Byte.valueOf((byte) (p_82185_1_ & 15))); } public Familiar createChild(EntityAgeable p_90011_1_) { Familiar entitywolf = new Familiar(this.worldObj); String s = this.func_152113_b(); if (s != null && s.trim().length() > 0) { entitywolf.func_152115_b(s); if (this.Tamed >= 1) ; } return entitywolf; } public void func_70918_i(boolean p_70918_1_) { if (p_70918_1_) { this.dataWatcher.updateObject(19, Byte.valueOf((byte) 1)); } else { this.dataWatcher.updateObject(19, Byte.valueOf((byte) 0)); } } /** * Returns true if the mob is currently able to mate with the specified mob. */ public boolean canMateWith(EntityAnimal p_70878_1_) { if (p_70878_1_ == this) { return false; } else if (!this.isTamed()) { return false; } else if (!(p_70878_1_ instanceof Familiar)) { return false; } else { Familiar entitywolf = (Familiar) p_70878_1_; return !entitywolf.isTamed() ? false : (entitywolf.isSitting() ? false : this.isInLove() && entitywolf.isInLove()); } } public boolean func_70922_bv() { return this.dataWatcher.getWatchableObjectByte(19) == 1; } /** * Determines if an entity can be despawned, used on idle far away entities */ protected boolean canDespawn() { return !this.isTamed() && this.ticksExisted > 2400; } public boolean func_142018_a(EntityLivingBase p_142018_1_, EntityLivingBase p_142018_2_) { if (!(p_142018_1_ instanceof EntityCreeper) && !(p_142018_1_ instanceof EntityGhast)) { if (p_142018_1_ instanceof Familiar) { Familiar entitywolf = (Familiar) p_142018_1_; if (entitywolf.isTamed() && entitywolf.getOwner() == p_142018_2_) { return false; } } return p_142018_1_ instanceof EntityPlayer && p_142018_2_ instanceof EntityPlayer && !((EntityPlayer) p_142018_2_).canAttackPlayer((EntityPlayer) p_142018_1_) ? false : !(p_142018_1_ instanceof EntityHorse) || !((EntityHorse) p_142018_1_).isTame(); } else { return false; } } }paste bin avec le ctrl + shif - f
http://pastebin.com/KXP9CrYU -
ma nouvelle classe actuelle
http://pastebin.com/BTPu6vyL
j’arrive toujours pas
-
“j’arrive toujours pas” -> plus de précision sur le problème ?
-
@‘SCAREX’:
“j’arrive toujours pas” -> plus de précision sur le problème ?
Excuse-moi x)
Voilà j’ai toujours le même problème, l’entity ne peut pas passé le lvl suivant
j’ai éssayé ce que ma dit robin et plaigon mais j’ai éssayé beaucoup de tentative mais sa na pas réussi.ma classe
:::
http://pastebin.com/5EiYuWQg
:::Merci de votre aide

-
C’est quoi le level suivant ?
-
@‘SCAREX’:
C’est quoi le level suivant ?
le lvl suivant c’est quand tu lui donne la rubis croquette