Posted May 11, 201510 yr 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
May 11, 201510 yr 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.
May 11, 201510 yr 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.