Posted July 10, 20205 yr I am trying to make an event that will spawn armor stands with arms whenever an armor stand is spawned but I cannot get it to work. I included a logger to see if it gets past the if statement that checks if the entity spawned was an armor stand and it does not log anything so I am assuming that is the problem(I put one outside of the if statement and it does log when things spawn). Any ideas? package com.chaoticsoul.evolate.events; import com.chaoticsoul.evolate.Evolate; import net.minecraft.entity.item.ArmorStandEntity; import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; @Mod.EventBusSubscriber(modid = Evolate.MOD_ID, bus = Bus.FORGE) public class SpawnArmorStandEvent { @SubscribeEvent public static void spawnArmorStandEvent(LivingSpawnEvent event) { if (event.getEntityLiving() instanceof ArmorStandEntity) { Evolate.LOGGER.info("test"); ArmorStandEntity stand = (ArmorStandEntity) event.getEntityLiving(); CompoundNBT compound = new CompoundNBT(); compound.putBoolean("ShowArms", true); stand.writeAdditional(compound); } } } Also, I am new to nbt data so that part may be wrong as well.
July 10, 20205 yr Author Thanks, it now works For anyone else trying to do this, the final code is: package com.chaoticsoul.evolate.events; import com.chaoticsoul.evolate.Evolate; import net.minecraft.entity.item.ArmorStandEntity; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; @Mod.EventBusSubscriber(modid = Evolate.MOD_ID, bus = Bus.FORGE) public class SpawnArmorStandEvent { @SubscribeEvent public static void spawnArmorStandEvent(EntityJoinWorldEvent event) { if (event.getEntity() instanceof ArmorStandEntity) { ArmorStandEntity stand = (ArmorStandEntity) event.getEntity(); CompoundNBT compound = new CompoundNBT(); compound.putBoolean("ShowArms", true); stand.readAdditional(compound); } } } Edited July 10, 20205 yr by clearcut mistake in code
July 10, 20205 yr Author Ah, I didn't know about the overwriting. stand.writeAdditional(compound); compound.putBoolean("ShowArms", true); Adding the lines above before the readAdditional method seems to work but does it fix the overwriting issue? I wanted to find a work around using setShowArms since I did not know how to use it.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.