Jump to content

[1.8] [SOLVED] Explosion Particles not Appearing


Himself12794

Recommended Posts

I'm trying to create an armor that gives the player a chance to dodge an attack. I've got the dodging part down, but when I try to add a smoke cloud to accommodate this, it does not show.

 

I tried mimicking the affect that happens when you shear a mooshroom, but unfortunately it does not seem to work. I've tried limiting it to server side, client side, and not limiting it at all, but whatever I do, no explosion cloud appears. Here's what I have:

        @SubscribeEvent
public void avoidDamage(LivingAttackEvent event) {
	EntityLivingBase dodger = event.entityLiving;
	if (UsefulMethods.hasEquipped(dodger, ModItems.assassinRobes)) {
		//System.out.println(event.source.getDamageType());
		event.entityLiving.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, dodger.posX, dodger.posY /*+ (double)(event.entityLiving.height / 2.0F)*/, dodger.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
		//int noDamageChance = event.entityLiving.worldObj.rand.nextInt(4);
		int noDamageChance = 1;
		if (noDamageChance == 1) {
			event.setCanceled(true);
		}
	}
}

 

Any help I can get is appreciated.

With all due respect, sir: I do, what I do, the way I do it. ~ MacGyver

Link to comment
Share on other sites

I'm trying to create an armor that gives the player a chance to dodge an attack. I've got the dodging part down, but when I try to add a smoke cloud to accommodate this, it does not show.

 

I tried mimicking the affect that happens when you shear a mooshroom, but unfortunately it does not seem to work. I've tried limiting it to server side, client side, and not limiting it at all, but whatever I do, no explosion cloud appears. Here's what I have:

        @SubscribeEvent
public void avoidDamage(LivingAttackEvent event) {
	EntityLivingBase dodger = event.entityLiving;
	if (UsefulMethods.hasEquipped(dodger, ModItems.assassinRobes)) {
		//System.out.println(event.source.getDamageType());
		event.entityLiving.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, dodger.posX, dodger.posY /*+ (double)(event.entityLiving.height / 2.0F)*/, dodger.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
		//int noDamageChance = event.entityLiving.worldObj.rand.nextInt(4);
		int noDamageChance = 1;
		if (noDamageChance == 1) {
			event.setCanceled(true);
		}
	}
}

 

Any help I can get is appreciated.

 

So the print statement prints, but it does not spawns any particles? There is nothing wrong in spawning code.

Check the value of worldObj.isRemote, it might always be false, which means that it is server side.

And you cannot spawn any particles on server side.

 

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

Ahah! Right you are. Sending a packet to the client fixed that nicely. Now it's just a matter of dialing in how exactly I want it to look. Thanks!

Here's what I ended up with:

	@SubscribeEvent
public void avoidDamage(LivingAttackEvent event) {
	EntityLivingBase dodger = event.entityLiving;
	if (UsefulMethods.hasEquipped(dodger, ModItems.assassinRobes) && dodger instanceof EntityPlayerMP) {
		System.out.println(event.source.getDamageType());
		System.out.println(event.entityLiving.worldObj.isRemote);			
		event.entityLiving.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, dodger.posX, dodger.posY /*+ (double)(event.entityLiving.height / 2.0F)*/, dodger.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
		NBTTagCompound data = new NBTTagCompound();
		data.setBoolean("doSmoke", true);
		UsefulThings.proxy.network.sendTo(new MessageClient(data), (EntityPlayerMP) dodger);
		//int noDamageChance = event.entityLiving.worldObj.rand.nextInt(4);
		int noDamageChance = 1;
		if (noDamageChance == 1) {
			event.setCanceled(true);
		}
	}
}

Thanks for your help!

With all due respect, sir: I do, what I do, the way I do it. ~ MacGyver

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.