Jump to content

Recommended Posts

Posted

I've tried to spawn recolored redstone particles with my mod, but since 1.7.10, it doesn't work anymore and I can't figure out how I should now implement particle effects

 

thanks in advance

Posted

I do it for one of my custom entities like this, in the onUpdate() event (or some other event that happens every tick):

 

if (!worldObj.isRemote && rand.nextFloat()<0.1F)

{

double var4 = rand.nextGaussian() * 0.02D;

double var6 = rand.nextGaussian() * 0.02D;

double var8 = rand.nextGaussian() * 0.02D;

EntityFX particleMysterious = new EntityParticleFXMysterious(worldObj, posX + rand.nextFloat() * width * 2.0F - width, posY + 0.5D + rand.nextFloat() * height, posZ + rand.nextFloat() * width * 2.0F - width, var4, var6, var8);

Minecraft.getMinecraft().effectRenderer.addEffect(particleMysterious);

}

 

In this case, EntityParticleFXMysterious is a class I made that extends EntityParticleFX but you can also use the standard particles if you want.

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
  On 1/20/2015 at 6:35 PM, jabelar said:

if (!worldObj.isRemote && rand.nextFloat()<0.1F)

{

//....

Minecraft.getMinecraft().effectRenderer.addEffect(particleMysterious);

}

Aiiieeee {screams of agony as minecraft crashes randomly yet again with a strange error message}  :)

 

that should be

if (worldObj.isRemote)

Slip of the keys I guess?  you must not access Minecraft from the server side.

 

If you have access to a world or even better a worldclient, for a vanilla particle you can also use eg

 

  worldClient.spawnParticle("particlenamehere", spawnXpos, spawnYpos, spawnZpos, 0, 0, 0);

 

 

-TGG

 

 

Posted

NO check for isRemote - Spawning particles at first, then crashing with an exception referring to the particles

Check for isRemote - Not spawning particles

Check for !isRemote - Spawning particles at first, then crashing with an exception referring to a random entity in the world (e.g. a cow, a pig, a villager etc.)

 

I'm also calling this from onUpdate in an entity class

Posted

TGG,  I understand the concern over the running of Minecraft.getMinecraft() on server side.  I think it is odd too.  Some, vanilla code seems to do that when calling the Effect Renderer (from an mc that is found with Minecraft.getMinecraft().  And it doesn't crash and it works fine for me, which surprised me.

 

However, to be safe I switched it to remove the negation and it still works.  So yeah, probably better to do is that way.

 

NJay, can you post your onUpdate() method code as well as the actual error messages?

 

 

 

 

 

 

 

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

sooo... Meanwhile I put the particle spawning code into a method called by the model when the entity is rendered, but that - of course - doesn't work in multiplayer.

 

My onUpdate method:

 

public void onUpdate() {
    	super.onUpdate();
    	if(this.onGround || this.isInWater()){
    		this.setIsFlying(false); //Updating entity's logic, so the particles are only spawned for the "flying"-boolean true
    	}
    	
    	if(this.getIsFlying()){
    	if(worldObj.isRemote){     // or !worldObj.isRemote
    		EntityFX particle = new EntityReddustFX(this.worldObj, this.posX, posY, this.posZ, 1.0F, 2.0F, 1.0F); // actually, these three lines are repeated six times in a for loop,
		particle.setRBGColorF(colorsR[i], colorsG[i], colorsB[i]); // to change colors and position. I simplified it a little here.
		Mod.proxy.addParticleEffect(particle);   // This method does nothing on server side and is only overridden by client
    	}
    		
    	}
    	
    
    }

 

ClientProxy#addParticleEffect:

 

@Override
public void addParticleEffect(EntityFX particle) {
	Minecraft.getMinecraft().effectRenderer.addEffect(particle);
}

 

 

 

Error logs with no check for isRemote or !isRemote:

 

net.minecraft.util.ReportedException: Ticking Particle
at net.minecraft.client.particle.EffectRenderer.updateEffects(EffectRenderer.java:102) ~[EffectRenderer.class:?]
at net.minecraft.client.Minecraft.runTick(Minecraft.java:2136) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1029) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:951) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_55]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_55]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_55]
        [...]


 

 

Error with check for !isRemote:

 

at net.minecraft.entity.Entity.moveEntity(Entity.java:723)
at net.minecraft.entity.EntityLivingBase.moveEntityWithHeading(EntityLivingBase.java:1678)
at net.minecraft.entity.EntityLivingBase.onLivingUpdate(EntityLivingBase.java:2021)
at net.minecraft.entity.EntityLiving.onLivingUpdate(EntityLiving.java:431)
at net.minecraft.entity.EntityAgeable.onLivingUpdate(EntityAgeable.java:138)
at net.minecraft.entity.passive.EntityAnimal.onLivingUpdate(EntityAnimal.java:56)
at net.minecraft.entity.passive.EntitySheep.onLivingUpdate(EntitySheep.java:98)
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1814)
at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:250)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2296)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:684)
at net.minecraft.world.World.updateEntity(World.java:2256)

-- Entity being ticked --
Details:
Entity Type: Sheep (net.minecraft.entity.passive.EntitySheep)
Entity ID: 153
Entity Name: Sheep
Entity's Exact location: -200,78, 72,00, 415,77
Entity's Block location: World: (-201,72,415), Chunk: (at 7,4,15 in -13,25; contains blocks -208,0,400 to -193,255,415), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
Entity's Momentum: 0,00, -0,08, 0,00


 

Sometimes Sheep, sometimes Pig, sometimes Villager, sometimes Wolf. lol

Posted

Yes, yes, it was commented out at the time when I copied it, which doesn't change the funcionality of the code, since onUpdate seemingly doesn't get called by client. The getHorseWatchableBoolean worked fine for me, I was able to get / set the right booleans... How would I solve it else?

Posted

Sorry, I don't get it  :( To be honest, I copied that code from the EntityHorse to be able to get the booleans from the model class. Is the 256 the wrong part? I mean, it's over 32, but in the EntityHorse class the method gets called with 128 and 64, so I took 256, because it was the next power of 2... Sorry if I miss something obvious

 

NJay

Posted

It is. When I don't check for isRemote, the particles are actually spawned while flying. Also, accessing the boolean from the model class worked which only spawned the particles in singleplayer worlds. I'm really stuck here.

Posted

I somehow managed the particles to spawn...

Now I know whose fault this was, this.onGround isn't working and returning always false which makes no sense but - somehow - forced my onUpdate to always set isFlyin to false. My problem now is that I don't know how to determine if the Entity is standing on the ground.

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

    • The problem occurs also in 1.20.1 Forge, but with an "Error executing task on client" instead. I have "Sinytra Connector" installed. On 1.21.5 Fabric, there is no problem. When this happens, the chat message before the death screen appears gets sent, with an extra dash added.
    • Well, as usual, it was user error. Naming mismatch in sounds.json.  Please delete this post if you find it necessary. 
    • Hello Forge community.  I'm running into an issue with a mod I'm working on.  To preface, I can call /playsound modId:name music @a and I can hear the sound I registered being played in game. Great!  However, I cannot get it to trigger via my mod code.    Registration: public static final RegistryObject<SoundEvent> A_WORLD_OF_MADNESS = SOUND_EVENTS.register("a_world_of_madness", () -> new SoundEvent(new ResourceLocation("tetheredsouls", "a_world_of_madness")));   Playback: Minecraft mc = Minecraft.getInstance(); if (!(mc.player instanceof LocalPlayer) || mc.level == null) return; LocalPlayer player = (LocalPlayer) mc.player; BlockPos pos = player.blockPosition(); SoundEvent track = ModSounds.A_WORLD_OF_MADNESS.get(); System.out.println(track); System.out.println(pos); System.out.println(player); // play exactly like the tutorial: client-only, at the player's position try { mc.level.playLocalSound( player.getX(), player.getY(), player.getZ(), track, SoundSource.MUSIC, // Or MASTER if needed 1f, 1f, false ); System.out.println("[DEBUG] playSound success: " + track.getLocation()); } catch (Exception e) { System.err.println("[ERROR] Failed to play sound: " + track.getLocation()); e.printStackTrace(); } Sounds.json:   { "theme_of_laura": { "category": "music", "sounds": [ { "name": "tetheredsouls:a_world_of_madness", "stream": true } ] } } Things I have tried: - multiple .ogg files. Short .ogg files (5 seconds, <100KB).  - default minecraft sounds imported from import net.minecraft.sounds.SoundEvents; These work given my code. No idea why these are different.  - playSound() method, as well as several others in past iterations that did not work   I would be forever grateful if somebody could point me in the right direction. I've looked at several mod github repositories and found extremely similar code to what I'm doing. I've also found several threads in this forum that did not solve my issue. I just cannot figure out what I'm doing differently, and why I'm able to queue sounds manually with playsound but the code won't play it (despite confirming the code is being run with the debug statements.)
    • Delete the tensura-reincarnated/common.toml file (config folder)
  • Topics

  • Create New...

Important Information

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