Jump to content

[solved... nearly] No Particles Spawn!


Bedrock_Miner

Recommended Posts

Hi!

 

I tried to create a custom Minecart with furnace. Everything worked well, except the fact, that the Minecart isn't spawning any Particles.

I copied this Method from EntityMinecartFurnace:

public void onUpdate()
    {
        if (this.isMinecartPowered() && this.rand.nextInt(3) == 0)
        this.worldObj.spawnParticle("largesmoke", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
        [...]
    }

 

But there are no Particles Spawning.

I tried to replace this.worldObj with Minecraft.getMinecraft().theWorld. This worked, but only in Singleplayer, because Minecraft.getMinecraft() is client only.

 

Has Anybody got an Idea how to persuade my Particles to spawn anyway?

Link to comment
Share on other sites

It returns, whether the minecart has fuel or not.

It's copied from EntityMinecartFurnace.class.

 

If I leave it out, it won't work too.

 

I tried it also without any if-construction... Without success.

Then the problem may be that the client doesn't know your minecart has fuel, so always returns false. When you add fuel, does the client know about it? Things that work in single player easily break in multi-player due to these kinds of problems.

Link to comment
Share on other sites

It should work just fine from onUpdate. Did you call 'super.onUpdate' as well? You should.

 

Here's some code I have for a projectile Entity that spawns particles in either single- or multi-player just fine. You really only need to spawn on the client side, like Goto mentioned, but I didn't check for that in the code here.

@Override
public void onUpdate()
{
super.onUpdate();

if (!this.isDead && !this.inGround)
{
	for (int k = 0; k < 4; ++k)
	{
		float f4 = 0.25F;
		this.worldObj.spawnParticle("crit", this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ);
	}
}
}

Link to comment
Share on other sites

The problem is, that exactly this wont work  >:(

 

I tried the following: I added this line of Code to onUpdate():

System.out.println("this.worldObj.isRemote: " + this.worldObj.isRemote);

This printed out "this.worldObj.isRemote: false" on Server side all the time, but nothing on client side.

Why is this method not called on client side?

 

EDIT: Even other methods like getDefaultDisplayTileData() wont work.. All methods of the Entity are only called at ServerSide. WHY?  >:(

Link to comment
Share on other sites

If that code didn't work, then the problem lies elsewhere, which you've suggested yourself in that the method isn't being called client side.

 

How and where do you register your new entity? That's my guess as to the source of the problem.

 

Check http://www.minecraftforge.net/forum/index.php/topic,12577.0.html for how to properly do so.

Link to comment
Share on other sites

I registered it like this:

EntityRegistry.registerModEntity(EntityMinecartFurnaceMod.class, "minecartfurnaceinventory.entity.name", EntityMinecartFurnaceMod.getEntityID(), Main.instance, 64, 1, true);

 

The Method is still only called on Server side.

I think I registered something wrong in my base classes.

 

Main:

package mod;

import mod.classes.Entities;
import mod.classes.Items;
import mod.classes.LocalisationHandler;
import mod.proxies.CommonProxy;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;

@Mod(modid=Resources.MOD_ID, name=Resources.MOD_NAME, version=Resources.MOD_VERSION)
@NetworkMod(clientSideRequired=Resources.REQUIREMENT_CLIENT, serverSideRequired=Resources.REQUIREMENT_SERVER)

public class Main {

    // The instance of your mod that Forge uses.
    @Instance(value = Resources.MOD_ID)
    public static Main instance;
       
    // Says where the client and server 'proxy' code is loaded.
    @SidedProxy(clientSide="mod.proxies.ClientProxy", serverSide="mod.proxies.CommonProxy")
    public static CommonProxy proxy;
       
    @EventHandler 
    public void preInit(FMLPreInitializationEvent event) {

    }
       
    @EventHandler
    public void load(FMLInitializationEvent event) {
    	Items.init(5000);
    	Entities.init();
    	proxy.registerRenderers();
    	LocalisationHandler.loadLanguages();
    }
       
    @EventHandler 
    public void postInit(FMLPostInitializationEvent event) {
        	
    }
}

Resources:

package mod;

public class Resources {

/**
 * The Program-intern ID of your Mod.
 */
public static final String MOD_ID = "FMI";
/**
 * A human readable Name for your Mod.
 */
public static final String MOD_NAME = "Furnace Minecart Inventory Mod";
/**
 * A version Number of your Mod. Doesn't need special Format.
 */
public static final String MOD_VERSION = "1.0.0";

//=============================================================================================

/**
 * Asks if you need this on the client to use this mod. This should be true. 
 * Can only be false, if the Mod doens't add any Blocks, Items, Entities or GUIs.
 */
public static final boolean REQUIREMENT_CLIENT = true;
/**
 * Asks if you need this on the server for the client to be able to connect. 
 * This should always be false, else you can't join a server if the server 
 * doesn't have the mod installed, but you do. It is false by default anyway. 
 */
public static final boolean REQUIREMENT_SERVER = false;

//=============================================================================================

/**
 * Path to the LAnguage-XML Files. Used as Placeholder.
 */
private static final String path = "/assets/" + MOD_ID.toLowerCase() + "/lang/";
/**
 * String List containing all Language-XML Files installed by the Mod.
 */
public static final String[] LANG_LOCALISATION = {path + "de_DE.xml", path + "en_US.xml"}; 

}

Items:

package mod.classes;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

public class Items {

//Variables:
public static Item FurnaceMinecartInventory;

public static void init(int ID)
{
	FurnaceMinecartInventory = new ModItemMinecart(ID, EntityMinecartFurnaceMod.getMinecartID())._setUnlocalizedName("minecartInventory")._setCreativeTab(CreativeTabs.tabTransport)._setMaxStackSize(1);
}

}

Entities:

package mod.classes;

import mod.Main;
import cpw.mods.fml.common.registry.EntityRegistry;

public class Entities {

public static void init()
{
	EntityRegistry.registerModEntity(EntityMinecartFurnaceMod.class, "minecartfurnaceinventory.entity.name", 
				EntityMinecartFurnaceMod.getEntityID(), Main.instance, 64, 1, true);
}

}

 

 

Anything MUST be wrong, otherwise it should work...

 

If you need to see some other classes, please write!

Link to comment
Share on other sites

Hi

 

This is a start.  It wasn't terribly clear to me at first, but might be of some help to you.

 

The key thing about DataWatchers is that the Server code automatically sends them to all nearby Clients whenever they change, so you don't need to worry about that.  Just change them on the Server side, and read them on the Client side.

 

http://www.minecraftforge.net/wiki/Datawatcher

 

Cheers

  TGG

 

 

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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