Jump to content

Recommended Posts

Posted

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!

Posted

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.

  • 2 weeks later...

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
    • Maybe you need to create file in assets/<modid>/items/<itemname>.json with content like this:   { "model": { "type": "minecraft:model", "model": "modname:item/itemname" } }  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.