Monture apprivoisable par 1 personne
-
Oui, au moment où tu fais spawner ton entité, tu fais un truc de se genre ```java
EntityName entityName = new EntityName(world);
entityName.setOwner(playerName); // Le nom de la méthode peut différer d’une version de Minecraft à l’autre
world.spawnEntityInWorld(entityName); // Même chose que le commentaire précédentOublie pas de positionner correctement ton entité par rapport au joueur. -
@‘Superloup10’:
Oui, au moment où tu fais spawner ton entité, tu fais un truc de se genre ```java
EntityName entityName = new EntityName(world);
entityName.setOwner(playerName); // Le nom de la méthode peut différer d’une version de Minecraft à l’autre
world.spawnEntityInWorld(entityName); // Même chose que le commentaire précédentOublie pas de positionner correctement ton entité par rapport au joueur.Voilà se que j’ai fait
public IEntityLivingData onSpawnWithEgg(IEntityLivingData p_110161_1_) { p_110161_1_ = super.onSpawnWithEgg(p_110161_1_); if (this.worldObj.rand.nextInt(7) == 0) { for (int i = 0; i < 2; ++i) { EntityPlayer playerName; EntityDragonDindeSauvage entityName = new EntityDragonDindeSauvage(this.worldObj); entityName.setOwner(playerName); // Le nom de la méthode peut différer d'une version de Minecraft à l'autre entityName.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 1.0F); this.worldObj.spawnEntityInWorld(entityName); // Même chose que le commentaire précédent } } return p_110161_1_; }Mais j’ai une erreur sur setOwner il me demande cast
-
Déjà tu n’as pas l’instance du joueur, du coup, tu auras un NPE.
Ensuite, il te demande de cast en quoi? -
@‘Superloup10’:
Déjà tu n’as pas l’instance du joueur, du coup, tu auras un NPE.
Ensuite, il te demande de cast en quoi?De cast en EntityName mais sa remais l’erreur apres
EntityPlayer playerName = Minecraft.getMinecraft().thePlayer; ``` comme sa c'est mieux ? -
En 1.7.10, il semble que tu doives faire ça :
public IEntityLivingData onSpawnWithEgg(IEntityLivingData p_110161_1_) { p_110161_1_ = super.onSpawnWithEgg(p_110161_1_); if (this.worldObj.rand.nextInt(7) == 0) { for (int i = 0; i < 2; ++i) { EntityPlayer playerName; EntityDragonDindeSauvage entityName = new EntityDragonDindeSauvage(this.worldObj); entityName.setTamed(true); // Le nom de la méthode peut différer d'une version de Minecraft à l'autre entityName.func_152115_b(playerName.getUniqueID().toString()); entityName.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 1.0F); this.worldObj.spawnEntityInWorld(entityName); // Même chose que le commentaire précédent } } return p_110161_1_; }Tu as mis ce code dans quelle class?
-
Je les mis dans ma class Entity
J’ai juste changer sa
EntityPlayer playerName;par sa
EntityPlayer playerName = Minecraft.getMinecraft().thePlayer;car j’avais une erreur sur
entityName.func_152115_b(playerName.getUniqueID().toString()); -
Du coup, ça fonctionne?
-
@‘Superloup10’:
Du coup, ça fonctionne?
Quand je le mais sur le serveur
---- Minecraft Crash Report ---- // Hey, that tickles! Hehehe! Time: 19/05/16 00:40 Description: Exception in server tick loop java.lang.NoClassDefFoundError: net/minecraft/client/entity/EntityClientPlayerMP at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) at java.lang.Class.getConstructor0(Class.java:3075) at java.lang.Class.getConstructor(Class.java:1825) at net.minecraft.entity.EntityList.func_75615_a(EntityList.java:160) at net.minecraft.world.chunk.storage.AnvilChunkLoader.loadEntities(AnvilChunkLoader.java:476) at net.minecraftforge.common.chunkio.ChunkIOProvider.callStage2(ChunkIOProvider.java:43) at net.minecraftforge.common.chunkio.ChunkIOProvider.callStage2(ChunkIOProvider.java:14) at net.minecraftforge.common.util.AsynchronousExecutor.skipQueue(AsynchronousExecutor.java:344) at net.minecraftforge.common.util.AsynchronousExecutor.getSkipQueue(AsynchronousExecutor.java:302) at net.minecraftforge.common.chunkio.ChunkIOExecutor.syncChunkLoad(ChunkIOExecutor.java:12) at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:158) at net.minecraft.world.gen.ChunkProviderServer.func_73158_c(ChunkProviderServer.java:131) at net.minecraft.server.MinecraftServer.func_71222_d(MinecraftServer.java:470) at net.minecraft.server.MinecraftServer.func_71247_a(MinecraftServer.java:418) at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:309) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:607) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassNotFoundException: net.minecraft.client.entity.EntityClientPlayerMP at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 18 more Caused by: java.lang.NullPointerException at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:180) ... 20 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.7.2 Operating System: Linux (amd64) version 3.5.0-47-generic Java Version: 1.8.0_60, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 86966960 bytes (82 MB) / 259522560 bytes (247 MB) up to 10416029696 bytes (9933 MB) JVM Flags: 23 total; -Xmx10000M -Xms256M -XX:MaxPermSize=256m -XX:PermSize=128m -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+UseNUMA -XX:+CMSParallelRemarkEnabled -XX:MaxGCPauseMillis=50 -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=15 -XX:UseSSE=3 -XX:+UseLargePages -XX:+UseFastAccessorMethods -XX:+UseStringCache -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+AggressiveOpts AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 13, tcache: 0, allocated: 13, tallocated: 95 FML: MCP v9.03 FML v7.2.217.1147 Minecraft Forge 10.12.2.1147 5 mods loaded, 5 mods active mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available FML{7.2.217.1147} [Forge Mod Loader] (cauldron-1.7.2-1.1147.04.98-server.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available Forge{10.12.2.1147} [Minecraft Forge] (cauldron-1.7.2-1.1147.04.98-server.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available facrpg{1.0} [facrpg] (facrpg-1.0.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available ModCustomMenu{1.0} [ModCustomMenu] (facrpg-1.0.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Player Count: 0 / 100; [] Is Modded: Definitely; Server brand changed to 'cauldron,craftbukkit,mcpc,fml,forge' Type: Dedicated Server (map_server.txt) -
Pour le coup, je sais pourquoi ça crash, en revanche, je ne suis pas sur du fix, tu peux essayer de get le player depuis la list des joueurs, il te suffit de faire ```java
world.playerEntities.get(id); // id = position du joueur dans la listeSinon, tu as ```java world.getPlayerEntityByName("nom du joueur");Si le problème n’est toujours pas résolu, il faudra voir avec robin.
-
world.playerEntities.get(id);
Je c’est pas quoi faire du id j’ai jamais fait sa
-
Sert toi de la seconde méthode, la liste est utilisé dans cette méthode.
-
Toujours le crash voilà ma class complete
package fr.darkvince.facrpg.monture; import java.util.UUID; import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IEntityLivingData; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIControlledByPlayer; import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.scoreboard.Team; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class EntityDragonDindeSauvage extends EntityTameable { private float prevRearingAmount; public int mobSizeGen; public EntityDragonDindeSauvage(World world) { super(world); mobSizeGen = 0 ;//(int) Math.round(Math.random()*5); //this.setCustomNameTag("test"); this.setSize(0.9F, 1.5F); this.tasks.addTask(1, new EntityAIControlledByPlayer(this, 5.0F)); } public EntityDragonDindeSauvage(World world, double d, double d1, double d2) { this(world); setPosition(d, d1, d2); } public void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1.66D); } @Override public EntityAgeable createChild(EntityAgeable p_90011_1_) { // TODO Auto-generated method stub return null; } public boolean interact(EntityPlayer par1EntityPlayer) { par1EntityPlayer.rotationYaw = this.rotationYaw; par1EntityPlayer.rotationPitch = this.rotationPitch; par1EntityPlayer.mountEntity(this); return super.interact(par1EntityPlayer); } public boolean stationary; protected boolean isMovementCeased() { return stationary; } /*public void updateRiderPosition() { super.updateRiderPosition(); if (this.prevRearingAmount > 0.0F) { float var1 = MathHelper.sin(this.renderYawOffset * (float)Math.PI / 180.0F); float var2 = MathHelper.cos(this.renderYawOffset * (float)Math.PI / 180.0F); float var3 = 0.7F * this.prevRearingAmount; float var4 = 0.15F * this.prevRearingAmount; this.riddenByEntity.setPosition(this.posX + (double)(var3 * var1), this.posY + this.getMountedYOffset() + this.riddenByEntity.getYOffset() + (double)var4, this.posZ - (double)(var3 * var2)); if (this.riddenByEntity instanceof EntityLivingBase) { ((EntityLivingBase)this.riddenByEntity).renderYawOffset = this.renderYawOffset; } } }*/ //////////////////// /*public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_) { if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityLivingBase) { this.prevRotationYaw = this.rotationYaw = this.riddenByEntity.rotationYaw; this.rotationPitch = this.riddenByEntity.rotationPitch * 0.5F; this.setRotation(this.rotationYaw, this.rotationPitch); this.rotationYawHead = this.renderYawOffset = this.rotationYaw; p_70612_1_ = ((EntityLivingBase)this.riddenByEntity).moveStrafing*50000.0F; //0.5F; p_70612_2_ = ((EntityLivingBase)this.riddenByEntity).moveForward*50000.0F; this.stepHeight = 1.0F; this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F; if (!this.worldObj.isRemote) { this.setAIMoveSpeed((float)this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue()); super.moveEntityWithHeading(p_70612_1_, p_70612_2_); } if (this.onGround) { // this.jumpPower = 0.0F; // this.setHorseJumping(false); } this.prevLimbSwingAmount = this.limbSwingAmount; double d1 = this.posX - this.prevPosX; double d0 = this.posZ - this.prevPosZ; float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F; if (f4 > 1.0F) { f4 = 1.0F; } this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F; this.limbSwing += this.limbSwingAmount; } else { this.stepHeight = 0.5F; this.jumpMovementFactor = 0.02F; super.moveEntityWithHeading(p_70612_1_, p_70612_2_); } }*/ public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_) { if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityLivingBase) { this.prevRotationYaw = this.rotationYaw = this.riddenByEntity.rotationYaw; this.rotationPitch = this.riddenByEntity.rotationPitch * 0.5F; this.setRotation(this.rotationYaw, this.rotationPitch); this.rotationYawHead = this.renderYawOffset = this.rotationYaw; p_70612_1_ = ((EntityLivingBase)this.riddenByEntity).moveStrafing * 5.0F; p_70612_2_ = ((EntityLivingBase)this.riddenByEntity).moveForward; this.isAirBorne = true; } this.stepHeight = 1.0F; if (!this.worldObj.isRemote) { this.setAIMoveSpeed((float)this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue()); super.moveEntityWithHeading(p_70612_1_, p_70612_2_); } this.prevLimbSwingAmount = this.limbSwingAmount; double d1 = this.posX - this.prevPosX; double d0 = this.posZ - this.prevPosZ; float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F; if (f4 > 1.0F) { f4 = 1.0F; } this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F; this.limbSwing += this.limbSwingAmount; } public IEntityLivingData onSpawnWithEgg(IEntityLivingData p_110161_1_) { p_110161_1_ = super.onSpawnWithEgg(p_110161_1_); if (this.worldObj.rand.nextInt(7) == 0) { for (int i = 0; i < 2; ++i) { EntityPlayer playerName = Minecraft.getMinecraft().thePlayer; worldObj.getPlayerEntityByName("darkvince_"); EntityDragonDindeSauvage entityName = new EntityDragonDindeSauvage(this.worldObj); entityName.setTamed(true); // Le nom de la méthode peut différer d'une version de Minecraft à l'autre entityName.func_152115_b(playerName.getUniqueID().toString()); entityName.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 1.0F); this.worldObj.spawnEntityInWorld(entityName); // Même chose que le commentaire précédent } } return p_110161_1_; } public double getMountedYOffset() { return 1.0D; } } -
Comme ça plutôt : ```java
EntityPlayer playerName = worldObj.getPlayerEntityByName(“darkvince_”); -
@‘Superloup10’:
Comme ça plutôt : ```java
EntityPlayer playerName = worldObj.getPlayerEntityByName(“darkvince_”);Sa crash plus j’attend mon pote pour test, mais la si j’ai bien compris quoi qu’il arrive meme si c’ets une autre personne qui pose l’oeuf y aura que moi qui pourra monter dessus
Edit: Quand je veut le faire spawn avec l’oeuf sa crash
---- Minecraft Crash Report ---- // Why is it breaking :( Time: 5/19/16 1:42 AM Description: Exception in server tick loop java.lang.NoSuchMethodError: fr.darkvince.facrpg.monture.EntityDragonDindeSauvage.func_152115_b(Ljava/lang/String;)V at fr.darkvince.facrpg.monture.EntityDragonDindeSauvage.func_110161_a(EntityDragonDindeSauvage.java:201) at net.minecraft.item.ItemMonsterPlacer.func_77840_a(ItemMonsterPlacer.java:170) at net.minecraft.item.ItemMonsterPlacer.func_77648_a(ItemMonsterPlacer.java:75) at net.minecraft.item.ItemStack.func_77943_a(ItemStack.java:169) at net.minecraft.server.management.ItemInWorldManager.func_73078_a(ItemInWorldManager.java:487) at net.minecraft.network.NetHandlerPlayServer.func_147346_a(NetHandlerPlayServer.java:869) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.func_148833_a(SourceFile:60) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.func_148833_a(SourceFile:9) at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:206) at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:173) at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:953) at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:432) at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:783) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:646) at java.lang.Thread.run(Thread.java:745) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.7.2 Operating System: Linux (amd64) version 3.5.0-47-generic Java Version: 1.8.0_60, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 60029216 bytes (57 MB) / 294563840 bytes (280 MB) up to 10416029696 bytes (9933 MB) JVM Flags: 23 total; -Xmx10000M -Xms256M -XX:MaxPermSize=256m -XX:PermSize=128m -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+UseNUMA -XX:+CMSParallelRemarkEnabled -XX:MaxGCPauseMillis=50 -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=15 -XX:UseSSE=3 -XX:+UseLargePages -XX:+UseFastAccessorMethods -XX:+UseStringCache -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+AggressiveOpts AABB Pool Size: 552 (30912 bytes; 0 MB) allocated, 352 (19712 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94 FML: MCP v9.03 FML v7.2.217.1147 Minecraft Forge 10.12.2.1147 5 mods loaded, 5 mods active mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available FML{7.2.217.1147} [Forge Mod Loader] (cauldron-1.7.2-1.1147.04.98-server.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{10.12.2.1147} [Minecraft Forge] (cauldron-1.7.2-1.1147.04.98-server.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available facrpg{1.0} [facrpg] (facrpg-1.0.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available ModCustomMenu{1.0} [ModCustomMenu] (facrpg-1.0.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Profiler Position: N/A (disabled) Vec3 Pool Size: 16 (896 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Player Count: 1 / 100; [EntityPlayerMP['darkvince_'/46, l='world', x=90.71, y=69.92, z=-71.18](darkvince_ at 90.70591955389942,69.92092454360332,-71.17800743670055)] Is Modded: Definitely; Server brand changed to 'cauldron,craftbukkit,mcpc,fml,forge' Type: Dedicated Server (map_server.txt) ```A se que je comprend sa vient de la entityName.func_152115_b(playerName.getUniqueID().toString()); -
J’ai une autre solution à te proposer. Je te la donne demain, mais en gros, c’est créer un oeuf spécifique pour ton entité qui ne dépend pas des oeufs vanilla.
-
@‘Superloup10’:
J’ai une autre solution à te proposer. Je te la donne demain, mais en gros, c’est créer un oeuf spécifique pour ton entité qui ne dépend pas des oeufs vanilla.
Pas de probleme Merci
-
L’autre solution que j’ai à te proposer est celle-ci.
Tu créais un item classique dans lequel tu définit une méthode ```java
onItemUse() // C’est le nom qu’elle porte en 1.9, tu vas sans doute utiliser onItemRightClickDans cette méthode, tu dois avoir en paramètre ItemStack, EntityPlayer, World, 3 int (x, y, z), et d'autres paramètres qui m'échappe. Tu mets dans cette méthode ```java EntityDragonDindeSauvage entityName = new EntityDragonDindeSauvage(world); entityName.setTamed(true); // Le nom de la méthode peut différer d'une version de Minecraft à l'autre entityName.func_152115_b(player.getUniqueID().toString()); // Le joueur est obtenu grâce à la méthode. entityName.setLocationAndAngles(x, y, z, this.rotationYaw, 1.0F); // Tu dois remplacer this.rotationYaw par l'un des paramètres de la méthode world.spawnEntityInWorld(entityName); // Même chose que le commentaire précédentLogiquement, ça devrait fonctionner.
-
En gros faire sa:
package fr.darkvince.facrpg; import fr.darkvince.facrpg.druide.EntityHeal; import fr.darkvince.facrpg.monture.EntityDragonDindeSauvage; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.world.World; public class oeufDragonDinde extends Item{ public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player, int x, int y, int z) { world.spawnEntityInWorld(new EntityDragonDindeSauvage(world)); EntityDragonDindeSauvage entityName = new EntityDragonDindeSauvage(world); entityName.setTamed(true); // Le nom de la méthode peut différer d'une version de Minecraft à l'autre entityName.func_152115_b(player.getUniqueID().toString()); // Le joueur est obtenu grâce à la méthode. world.spawnEntityInWorld(entityName); // Même chose que le commentaire précédent return item; } }Parcontre j’ai pas mis cette ligne car y a pas mal d’erreur
entityName.setLocationAndAngles(x, y, z, this.rotationYaw, 1.0F); -
C’est ça, vérifie bien que tu as tous les paramètres de onItemRightClick en mettant @Override dessus.
-
“entityName.setLocationAndAngles(x, y, z, this.rotationYaw, 1.0F);” remplace ça par entityName.setPosition(x, y, z);
