Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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.

  • Author

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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.