Mob qui traverse le sol
-
Tu bloques sur quoi ?
-
Bah comment faire pour que le mob suivent le joueur il ne me manque que ça après je me débrouille mais bon sans ça pas de vente serveur = pas de revenue = je l’ai ou je pense la machine coûtant très cher =p
-
Dans la classe du loup il y a tout ce qu’il te faut non ?
-
Bah oui et non on va dire que j’ai tout test ou presque j’ai copié cette fonction :
public boolean interact(EntityPlayer p_70085_1_) { ItemStack var2 = p_70085_1_.inventory.getCurrentItem(); if (this.isTamed()) { if (var2 != null) { if (var2.getItem() instanceof ItemFood) { ItemFood var3 = (ItemFood)var2.getItem(); if (var3.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < 20.0F) { if (!p_70085_1_.capabilities.isCreativeMode) { –var2.stackSize; } this.heal((float)var3.func_150905_g(var2)); if (var2.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack)null); } return true; } } else if (var2.getItem() == Items.dye) { int var4 = BlockColored.func_150032_b(var2.getItemDamage()); if (var4 != this.getCollarColor()) { this.setCollarColor(var4); if (!p_70085_1_.capabilities.isCreativeMode && --var2.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.isClient && !this.isBreedingItem(var2)) { this.aiSit.setSitting(!this.isSitting()); this.isJumping = false; this.setPathToEntity((PathEntity)null); this.setTarget((Entity)null); this.setAttackTarget((EntityLivingBase)null); } } else if (var2 != null && var2.getItem() == Items.bone && !this.isAngry()) { if (!p_70085_1_.capabilities.isCreativeMode) { --var2.stackSize; } if (var2.stackSize <= 0) { p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack)null); } if (!this.worldObj.isClient) { if (this.rand.nextInt(3) == 0) { this.setTamed(true); 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_); } -
Ce n’est pas dans interact que c’est géré. interact c’est pour adopter l’entité/la nourrir/faire qu’elle s’assoie. C’est plutôt dans la fonction update.
-
Non il me semble qu’il y a une AI dédiée à ça
-
package fr.Mosca421.Mobs; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.BlockColored; import net.minecraft.client.Minecraft; 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.EntityAIFollowOwner; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.pathfinding.PathEntity; import net.minecraft.world.World; public class MobKurby extends EntityTameable { private float field_70926_e; private float field_70924_f; public MobKurby (World world) { super(world); this.setSize(0.7F, 0.7F); this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F)); } public void applyEntityAttributes(EntityPlayer player) { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(5000D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1D); } public boolean isAIEnabled() { return true; } @Override public boolean isEntityInvulnerable() { return true; } protected boolean canDespawn() { return false; } public boolean interact(EntityPlayer player) { this.setTamed(true); this.setPathToEntity((PathEntity)null); this.setAttackTarget((EntityLivingBase)null); this.func_152115_b(player.getUniqueID().toString()); this.worldObj.setEntityState(this, (byte)7); return true; } public void onUpdate(EntityPlayer player) { super.onUpdate(); 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; } } @Override public EntityAgeable createChild(EntityAgeable p_90011_1_) { return null; } public boolean func_70922_bv() { return this.dataWatcher.getWatchableObjectByte(19) == 1; } public void setTamed(boolean p_70903_1_) { super.setTamed(p_70903_1_); } }En tout cas ça marche plus ou moins comme ça

-
J’ai juste une petite demande mais comment je peux faire pour lorsque le joueur pose l’oeuf le kirby soit direct adopter par celui qui l’a poser
Et comment faire pour que celui qui la poser lorsque qu’il interact avec lui il le recup mais que lui pas d’autre personne
J’ai vite fais bricoler ça :public boolean interact(EntityPlayer player) { if (adopt == 0) { this.setTamed(true); this.setPathToEntity((PathEntity)null); this.setAttackTarget((EntityLivingBase)null); this.func_152115_b(player.getUniqueID().toString()); this.worldObj.setEntityState(this, (byte)7); } if (adopt == 1 && isTamed() && player()){ this.setDead(); player.inventory.addItemStackToInventory(new ItemStack(Items.spawn_egg, 1, 23)); } adopt = 1; return true; } -
Sujet ici Monture custom
Récupérer l’UUID du joueur, le stocker dans la monture et n’autorise le mountEntity que si les UUID correspondent
-
Alors j’ai fais un peux comme tu as dis :
[15:08:17] [Server thread/INFO] [STDOUT]: [fr.Mosca421.Mobs.MobKurby:interact:78]: 1 ae45ff8b-f50f-371e-b691-661c04edb569
[15:08:17] [Server thread/INFO] [STDOUT]: [fr.Mosca421.Mobs.MobKurby:interact:79]: 2 ae45ff8b-f50f-371e-b691-661c04edb569public boolean interact(EntityPlayer player) { if (adopt == 0) { this.setTamed(true); this.setPathToEntity((PathEntity)null); this.setAttackTarget((EntityLivingBase)null); this.func_152115_b(player.getUniqueID().toString()); this.worldObj.setEntityState(this, (byte)7); } String uiid = func_152113_b(); String uuid = player.getGameProfile().getId().toString(); System.out.println("1 "+uiid); System.out.println("2 "+uuid); if (adopt == 1 && isTamed() && uuid == uiid){ this.setDead(); player.inventory.addItemStackToInventory(new ItemStack(Items.spawn_egg, 1, 23)); } adopt = 1; return true; }Mais ici if (adopt == 1 && isTamed() && uuid == uiid){
Si je dis != je ramasse mais sinon == je ramasse pas pourtant c’est égal non ? -
Tu devrais regarder plus généralement le post.
Notamment les passages sur les datawatchers, leur enregistrement dans l’event au moment où l’entité est créée.
public void handleConstruction(EntityConstructing event) […] else if(event.entity instanceof EntityBaignoire) { DataWatcher dw = event.entity.getDataWatcher(); dw.addObject(31, "id"); }Au final dans ta condition tu devrais avoir qqch comme:
player.getUniqueID().toString().equals(this.getDataWatcher().getWatchableObjectString(31) //le 31 est en exempleEdit:
J’utilise un item pour faire spawn mes entités, par exemple, dans la méthode onItemUse:else if (metadata == 9) { EntityBaignoire e = new EntityBaignoire(world); if(!world.isRemote) { e.setPosition(x, y + 1.0F, z); world.spawnEntityInWorld(e); stack.stackSize–; e.getDataWatcher().updateObject(31, player.getGameProfile().getId().toString()); } return true; } -
Je ne comprends pas les datawatcher =/ comment ça fonctionne ? a quoi ils servent ?
-
-
Okey ça marche en multi mais j’ai un petit bug : quand mon perso 1 adopte et l’enleve ça marche mais quand le perso 1 adopte et le perso deux essaye de le viré ça le vire pour perso 2 mais pas pour perso 1
public boolean interact(EntityPlayer player) { DataWatcher dw = this.getDataWatcher(); if (adopt == 0) { this.setTamed(true); this.setPathToEntity((PathEntity)null); this.setAttackTarget((EntityLivingBase)null); this.func_152115_b(player.getUniqueID().toString()); this.worldObj.setEntityState(this, (byte)7); dw.addObject(31, func_152113_b()); } boolean uiid = player.getUniqueID().toString().equals(this.getDataWatcher().getWatchableObjectString(31)); String uuid = player.getGameProfile().getId().toString(); System.out.println("1 "+uiid); System.out.println("2 "+uuid); if (adopt == 1 && player.getUniqueID().toString().equals(this.getDataWatcher().getWatchableObjectString(31)) == true){ this.setDead(); player.inventory.addItemStackToInventory(new ItemStack(Items.spawn_egg, 1, 23)); } adopt = 1; return true; }