Résolu Entité qui n'apparait pas
-
Bonjour a tous, je continue le développement le mon mod en voulant ajouter un poulet qui attaquerrait les joueurs.
Tous marche mais lorsque je veut faire spawn mon poulet, il dispawn aussitôt.
J’ai réussi a savoir que mon erreur venait de ma classe EntityFeuriumChicken :package fr.luky.feurimod.entity; import com.google.common.collect.Sets; import net.minecraft.block.Block; import net.minecraft.entity.*; import net.minecraft.entity.ai.*; import net.minecraft.entity.monster.EntityIronGolem; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityChicken; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.pathfinding.PathNodeType; import net.minecraft.util.DamageSource; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraft.util.datafix.DataFixer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraft.world.storage.loot.LootTableList; import javax.annotation.Nullable; import java.util.Set; public class EntityFeuriumChicken extends EntityMob { private static final Set<Item> TEMPTATION_ITEMS = Sets.newHashSet(Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS); public float wingRotation; public float destPos; public float oFlapSpeed; public float oFlap; public float wingRotDelta = 1.0F; public int timeUntilNextEgg; public boolean chickenJockey; public EntityFeuriumChicken(World worldIn) { super(worldIn); this.setSize(0.4F, 0.7F); this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000; this.setPathPriority(PathNodeType.WATER, 0.0F); } @Override protected void initEntityAI() { this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(2, new EntityAIAttackMelee(this, 1.0D, false)); this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(7, new EntityAIWanderAvoidWater(this, 1.0D)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(3, new EntityAITempt(this, 1.0D, false, TEMPTATION_ITEMS)); this.tasks.addTask(5, new EntityAIWanderAvoidWater(this, 1.0D)); this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); this.tasks.addTask(7, new EntityAILookIdle(this)); } public float getEyeHeight() { return this.height; } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(35.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D); this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(5.0D); this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(10.0D); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(30.0D); this.getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).setBaseValue(5.0D); this.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(0.23500986D); } public void onLivingUpdate() { super.onLivingUpdate(); this.oFlap = this.wingRotation; this.oFlapSpeed = this.destPos; this.destPos = (float)((double)this.destPos + (double)(this.onGround ? -1 : 4) * 0.3D); this.destPos = MathHelper.clamp(this.destPos, 0.0F, 1.0F); if (!this.onGround && this.wingRotDelta < 1.0F) { this.wingRotDelta = 1.0F; } this.wingRotDelta = (float)((double)this.wingRotDelta * 0.9D); if (!this.onGround && this.motionY < 0.0D) { this.motionY *= 0.6D; } this.wingRotation += this.wingRotDelta * 2.0F; if (!this.world.isRemote && !this.isChild() && !this.isChickenJockey() && --this.timeUntilNextEgg <= 0) { this.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); this.dropItem(Items.EGG, 1); this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000; } } public void fall(float distance, float damageMultiplier) { } protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_CHICKEN_AMBIENT; } protected SoundEvent getHurtSound(DamageSource damageSourceIn) { return SoundEvents.ENTITY_CHICKEN_HURT; } protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_CHICKEN_DEATH; } protected void playStepSound(BlockPos pos, Block blockIn) { this.playSound(SoundEvents.ENTITY_CHICKEN_STEP, 0.15F, 1.0F); } @Nullable protected ResourceLocation getLootTable() { return LootTableList.ENTITIES_CHICKEN; } public EntityChicken createChild(EntityAgeable ageable) { return new EntityChicken(this.world); } /** * 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 stack) { return TEMPTATION_ITEMS.contains(stack.getItem()); } /** * Get the experience points the entity currently has. */ protected int getExperiencePoints(EntityPlayer player) { return this.isChickenJockey() ? 10 : super.getExperiencePoints(player); } public static void registerFixesChicken(DataFixer fixer) { EntityLiving.registerFixesMob(fixer, EntityChicken.class); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound compound) { super.readEntityFromNBT(compound); this.chickenJockey = compound.getBoolean("IsChickenJockey"); if (compound.hasKey("EggLayTime")) { this.timeUntilNextEgg = compound.getInteger("EggLayTime"); } } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound compound) { super.writeEntityToNBT(compound); compound.setBoolean("IsChickenJockey", this.chickenJockey); compound.setInteger("EggLayTime", this.timeUntilNextEgg); } /** * Determines if an entity can be despawned, used on idle far away entities */ protected boolean canDespawn() { return this.isChickenJockey() && !this.isBeingRidden(); } public void updatePassenger(Entity passenger) { super.updatePassenger(passenger); float f = MathHelper.sin(this.renderYawOffset * 0.017453292F); float f1 = MathHelper.cos(this.renderYawOffset * 0.017453292F); float f2 = 0.1F; float f3 = 0.0F; passenger.setPosition(this.posX + (double)(0.1F * f), this.posY + (double)(this.height * 0.5F) + passenger.getYOffset() + 0.0D, this.posZ - (double)(0.1F * f1)); if (passenger instanceof EntityLivingBase) { ((EntityLivingBase)passenger).renderYawOffset = this.renderYawOffset; } } /** * Determines if this chicken is a jokey with a zombie riding it. */ public boolean isChickenJockey() { return this.chickenJockey; } /** * Sets whether this chicken is a jockey or not. */ public void setChickenJockey(boolean jockey) { this.chickenJockey = jockey; } }
Quelle est la solution, merci d’avance, Luky.
-
Peut-être que si tu étais pas en peacful, ça réglerai le problème, non ?
-
Peut être en effet je n’avais pas vu
-
Bonjour a tous, je reviens avec un autre problème d’entitée : cette fois ci c’est mon loot_table qui ne marche pas…
Mon message d’erreur :
[07:28:14] [Server thread/ERROR] [minecraft/LootTableManager]: Couldn't load loot table feurimod:feurium_chicken from file:/Users/Luc/Desktop/Feurimod/out/production/Feurimod/assets/feurimod/loot_tables/feurium_chicken.json com.google.gson.JsonParseException: Loot Table "feurimod:feurium_chicken" Missing `name` entry for pool #0 at net.minecraftforge.common.ForgeHooks.readPoolName(ForgeHooks.java:1252) ~[ForgeHooks.class:?] at net.minecraft.world.storage.loot.LootPool$Serializer.deserialize(LootPool.java:152) ~[LootPool$Serializer.class:?] at net.minecraft.world.storage.loot.LootPool$Serializer.deserialize(LootPool.java:147) ~[LootPool$Serializer.class:?] at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69) ~[TreeTypeAdapter.class:?] at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41) ~[TypeAdapterRuntimeTypeWrapper.class:?] at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72) ~[ArrayTypeAdapter.class:?] at com.google.gson.Gson.fromJson(Gson.java:887) ~[Gson.class:?] at com.google.gson.Gson.fromJson(Gson.java:952) ~[Gson.class:?] at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162) ~[TreeTypeAdapter$GsonContextImpl.class:?] at net.minecraft.util.JsonUtils.deserializeClass(JsonUtils.java:359) ~[JsonUtils.class:?] at net.minecraft.util.JsonUtils.deserializeClass(JsonUtils.java:381) ~[JsonUtils.class:?] at net.minecraft.world.storage.loot.LootTable$Serializer.deserialize(LootTable.java:210) ~[LootTable$Serializer.class:?] at net.minecraft.world.storage.loot.LootTable$Serializer.deserialize(LootTable.java:205) ~[LootTable$Serializer.class:?] at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69) ~[TreeTypeAdapter.class:?] at com.google.gson.Gson.fromJson(Gson.java:887) ~[Gson.class:?] at com.google.gson.Gson.fromJson(Gson.java:852) ~[Gson.class:?] at com.google.gson.Gson.fromJson(Gson.java:801) ~[Gson.class:?] at com.google.gson.Gson.fromJson(Gson.java:773) ~[Gson.class:?] at net.minecraftforge.common.ForgeHooks.loadLootTable(ForgeHooks.java:1176) ~[ForgeHooks.class:?] at net.minecraft.world.storage.loot.LootTableManager$Loader.loadBuiltinLootTable(LootTableManager.java:156) [LootTableManager$Loader.class:?] at net.minecraft.world.storage.loot.LootTableManager$Loader.load(LootTableManager.java:72) [LootTableManager$Loader.class:?] at net.minecraft.world.storage.loot.LootTableManager$Loader.load(LootTableManager.java:53) [LootTableManager$Loader.class:?] at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3716) [guava-21.0.jar:?] at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2424) [guava-21.0.jar:?] at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2298) [guava-21.0.jar:?] at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2211) [guava-21.0.jar:?] at com.google.common.cache.LocalCache.get(LocalCache.java:4154) [guava-21.0.jar:?] at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4158) [guava-21.0.jar:?] at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:5147) [guava-21.0.jar:?] at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:5153) [guava-21.0.jar:?] at net.minecraft.world.storage.loot.LootTableManager.getLootTableFromLocation(LootTableManager.java:40) [LootTableManager.class:?] at net.minecraft.entity.EntityLiving.dropLoot(EntityLiving.java:595) [EntityLiving.class:?] at net.minecraft.entity.EntityLivingBase.onDeath(EntityLivingBase.java:1320) [EntityLivingBase.class:?] at net.minecraft.entity.EntityLivingBase.attackEntityFrom(EntityLivingBase.java:1136) [EntityLivingBase.class:?] at net.minecraft.entity.monster.EntityMob.attackEntityFrom(EntityMob.java:80) [EntityMob.class:?] at net.minecraft.entity.player.EntityPlayer.attackTargetEntityWithCurrentItem(EntityPlayer.java:1438) [EntityPlayer.class:?] at net.minecraft.entity.player.EntityPlayerMP.attackTargetEntityWithCurrentItem(EntityPlayerMP.java:1572) [EntityPlayerMP.class:?] at net.minecraft.network.NetHandlerPlayServer.processUseEntity(NetHandlerPlayServer.java:1142) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketUseEntity.processPacket(CPacketUseEntity.java:94) [CPacketUseEntity.class:?] at net.minecraft.network.play.client.CPacketUseEntity.processPacket(CPacketUseEntity.java:15) [CPacketUseEntity.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) [PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_231] at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) [?:1.8.0_231] at java.util.concurrent.FutureTask.run(FutureTask.java) [?:1.8.0_231] at net.minecraft.util.Util.runTask(Util.java:53) [Util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:798) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) [MinecraftServer.class:?] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_231]
et mon loot_table:
{ "pools": [ { "name": "feurimod:feurium_chicken", "rolls": 1, "entries": [ { "type": "item", "name": "minecraft:feather", "weight": 1, "functions": [ { "function": "set_count", "count": { "min": 0, "max": 2 } }, { "function": "looting_enchant", "count": { "min": 0, "max": 1 } } ] } ] }, { "rolls": 1, "entries": [ { "type": "item", "name": "minecraft:chicken", "weight": 1, "functions": [ { "function": "furnace_smelt", "conditions": [ { "condition": "entity_properties", "entity": "this", "properties": { "on_fire": true } } ] }, { "function": "looting_enchant", "count": { "min": 0, "max": 1 } } ] } ] }, { "rolls": 1, "entries": [ { "type": "item", "name": "feurimod:feurium_chicken", "weight": 1, "functions": [ { "function": "set_count", "count": { "min": 0, "max": 1 } } ] } ] } ] }
Merci d’avance, Luky
-
Prends la loot table du poulet et modifie le, il doit y avoir un problème d virgule
EDIT : tu es sur qu’il faut mettre
"name": "feurimod:"feurium_chicken
? -
Je ne sais pas mais sans g la meme erreure
-
Toujours aucune réponse ??
-
Mais reprends celui du poulet et modifie juste ce que tu as besoin et au moins t’es sur que ça marchera
-
Tu m’explique pourquoi ici tu as marqué
minecraft:chicken
alors que c’estminecraft:cooked_chicken
"type": "item", "name": "minecraft:chicken", "weight": 1,
EDIT : et si tu le veut cru c’est
minecraft:raw_chicken
-
J’ai juste repris le code du poulet de base et j’ai rajouté ma dernière ligne
-
Sinon parfois les vanilla sur les mod les json marche donc en voici un de botania, puis tu recopie :
{ "pools": [ { "name": "life_essence", "conditions": [{ "condition": "killed_by_player" }], "rolls": 1, "entries": [{ "type": "item", "name": "botania:life_essence", "functions": [ { "function": "set_count", "count": 6 }, { "function": "set_count", "count": 8, "conditions": [{ "condition": "botania:true_guardian_killer" }] } ] }] }, { "name": "music_disc", "conditions": [ { "condition": "killed_by_player" }, { "condition": "random_chance", "chance": 0.2 } ], "rolls": 1, "entries": [{ "type": "item", "name": "botania:record_gaia_1" }] } ] }
-
Et donne le chemin vers ta loot table
-
ressources/assets/feurimod/loot_tables/feurium_chicken
-
J’ai fait ça mais toujours a meme erreur :
{ "pools": [ { "name": "feurium_chicken", "rolls": 1, "entries": [ { "type": "item", "name": "minecraft:feather", "weight": 1, "functions": [ { "function": "set_count", "count": { "min": 0, "max": 2 } }, { "function": "looting_enchant", "count": { "min": 0, "max": 1 } } ] } ] }, { "rolls": 1, "entries": [ { "type": "item", "name": "minecraft:chicken", "weight": 1, "functions": [ { "function": "furnace_smelt", "conditions": [ { "condition": "entity_properties", "entity": "this", "properties": { "on_fire": true } } ] }, { "function": "looting_enchant", "count": { "min": 0, "max": 1 } } ] } ] } ] }
-
Tu fais des tabs ou des doubles espaces ?
-
Problème résolu :
{ "pools": [ { "name": "feurium_chicken", "conditions": [{ "condition": "killed_by_player" }], "rolls": 1, "entries": [{ "type": "item", "name": "feurimod:feurium_chicken", "functions": [ { "function": "set_count", "count": 1 }, { "function": "set_count", "count": 1 } ] }] } ] }
Merci @DailyCraft pour ton aide et bonne journée à tous.