Posted July 1, 201312 yr Hey guys! I am attempting to make a mod which causes a living entity to emit a particles which looks like blood. I have already handled the particle, but which ForgeSubscribe method is right for a entity attack listener? Here is my code so far; Main Mod File: package romejanic.blood.common; import net.minecraftforge.common.MinecraftForge; import romejanic.blood.common.core.CommonProxy; import romejanic.blood.common.core.ConfigHandler; import romejanic.blood.common.core.EntityListener; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.PreInit; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; @Mod(modid="BloodParticles", name="Blood Particles", version="1.0") @NetworkMod(clientSideRequired=true, serverSideRequired=false) public class BloodParticles { @SidedProxy(clientSide="romejanic.blood.client.core.ClientCore", serverSide="romejanic.blood.common.core.CommonProxy") public static CommonProxy proxy; @PreInit public void preLoad(FMLPreInitializationEvent event){ ConfigHandler.load(); MinecraftForge.EVENT_BUS.register(new EntityListener()); } @Init public void load(FMLInitializationEvent event){ } } ConfigHandler package romejanic.blood.common.core; import java.io.File; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraftforge.common.Configuration; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; public class ConfigHandler { public static int blockID; private static final String set = "Settings"; public static void load(){ File location = null; Side s = FMLCommonHandler.instance().getEffectiveSide(); if(s == s.CLIENT){ location = new File(Minecraft.getMinecraftDir().toString()+"/romejanic/Blood Particles.txt"); } if(s == s.SERVER){ location = new File("./romejanic/Blood Particles.txt"); } config(location); } private static void config(File location){ Configuration config = new Configuration(location); config.load(); config.addCustomCategoryComment(set, "Various settings which control how the mod operates"); blockID = config.get(set, "Blood Block ID", Block.blockRedstone.blockID, "The ID of the block which the mod uses for the blood particles.").getInt(); config.save(); } } EntityListener package romejanic.blood.common.core; import net.minecraft.entity.EntityLiving; import net.minecraft.world.World; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.EntityEvent; public class EntityListener { @ForgeSubscribe public void onEntityAttacked(EntityEvent event){ World world = event.entity.worldObj; if(event.entity instanceof EntityLiving){ world.spawnParticle("tilecrack_"+ConfigHandler.blockID+"_0", event.entity.posX, event.entity.posY, event.entity.posZ, 0, 0, 0); } } } What happens at this point is that living entities ALWAYS emit the particle, and a bunch of errors spam the console. Where have I gone wrong? How can this be resolved? Any help would be greatly appreciated Thanks! Romejanic Romejanic Creator of Witch Hats, Explosive Chickens and Battlefield!
July 2, 201312 yr How would you do this if you only wanted it to spawn particles if the living entity was hit by a certain item? If you really want help, give that modder a thank you. Modders LOVE thank yous.
July 11, 201312 yr Author Thanks Guys! I appreciate it! Thanks! Romejanic Romejanic Creator of Witch Hats, Explosive Chickens and Battlefield!
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.