Monture apprivoisable par 1 personne
-
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édent
Logiquement, ç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);
-
@‘Superloup10’:
C’est ça, vérifie bien que tu as tous les paramètres de onItemRightClick en mettant @Override dessus.
Quand je mais le @Override il me dit de l’enlever
-
Cela veux dire que la méthode est incorrecte, regarde dans la class Item pour trouver la bonne méthode.
-
@‘Superloup10’:
Cela veux dire que la méthode est incorrecte, regarde dans la class Item pour trouver la bonne méthode.
C’est les int
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { return p_77659_1_; }
Mais si je les enleves j’ai cette erreur logique
entityName.setPosition(x, y, z);
-
Regarde si tu peux faire ```java
entityName.setPosition(world.getX(), world.getY(), world.getZ()); -
@‘Superloup10’:
Regarde si tu peux faire ```java
entityName.setPosition(world.getX(), world.getY(), world.getZ());non plus
-
Essaye sans cette méthode, alors.
-
@‘Superloup10’:
Essaye sans cette méthode, alors.
J’ai essayé le probleme il spawn pas
-
C’est onItemUse la bonne fonction.
-
Voilà avec onItemUse se que sa me fait sa spawn toujours pas
@Override public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { 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.setPosition(x, y, z); world.spawnEntityInWorld(new EntityDragonDindeSauvage(world)); // Même chose que le commentaire précédent return false; }
J’ai ajouté un System.out.print(“spawn”); est sa l’ecrie bien dans la console
Edit: c’est bon il spawn j’ai fait comme sa je vais test en multi si tous marche
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if (world.isRemote) { return true; } 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.setPosition(x, y, z); //world.spawnEntityInWorld(new EntityDragonDindeSauvage(world)); // Même chose que le commentaire précédent world.spawnEntityInWorld(entityName); System.out.print("spawn"); return true; }
Le crash en multi
---- Minecraft Crash Report ---- // Why did you do that? Time: 5/19/16 9:20 PM 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.oeufDragonDinde.func_77648_a(oeufDragonDinde.java:37) 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: 109466816 bytes (104 MB) / 349081600 bytes (332 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: 1467 (82152 bytes; 0 MB) allocated, 426 (23856 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: 34 (1904 bytes; 0 MB) allocated, 6 (336 bytes; 0 MB) used Player Count: 1 / 100; [EntityPlayerMP['darkvince_'/36, l='world', x=-10.13, y=63.00, z=122.09](darkvince_ at -10.133819263271905,63.0,122.09285613271233)] Is Modded: Definitely; Server brand changed to 'cauldron,craftbukkit,mcpc,fml,forge' Type: Dedicated Server (map_server.txt)