Jump to content

anotherhumanity

Members
  • Posts

    1
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

anotherhumanity's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. i'm using eventhandler to create an event which will consume a certain item to grant the player immunity for a duration if their health falls bellow 15%. The actual immortality effect works ok (minor issue of not triggering on the inital damage that brings you bellow 15%) , but the particles are not working and i can't figure out how to play sounds. Here's my code: package com.axel.main; import java.util.Random; import com.axel.item.MainItemClass; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; import net.minecraftforge.event.entity.living.LivingHurtEvent; public class EventHandlerCommon { @SubscribeEvent public void LivinghurtEvent(LivingHurtEvent event) { if (event.entity instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP) event.entity; InventoryPlayer inventory = player.inventory; World world = player.getEntityWorld(); float currenthealth = player.getHealth(); float maxhealth = player.getMaxHealth(); float percenthealth = (currenthealth / maxhealth) * 100; if (inventory.hasItem(MainItemClass.DivineIntervention) && 15 >= percenthealth) { player.setHealth(maxhealth); player.extinguish(); player.clearActivePotions(); player.addPotionEffect(new PotionEffect (12, 1200 , 1)); player.addPotionEffect(new PotionEffect (1, 600 , 2)); player.addPotionEffect(new PotionEffect (5, 60 , 4)); player.addPotionEffect(new PotionEffect (6, 5 , 1)); player.addPotionEffect(new PotionEffect (23, 60 , 4)); player.addPotionEffect(new PotionEffect (11, 60 , 255)); inventory.consumeInventoryItem(MainItemClass.DivineIntervention); Random rand = new Random(); player.addChatMessage(new ChatComponentText("2A2A00" + "Spell Casted: Divine Intervention")); for(int countparticles = 0; countparticles <= 10; ++countparticles) { world.spawnParticle("reddust", player.posX + (rand.nextDouble() - 0.5D) * (double)player.width, player.posY + rand.nextDouble() * (double)player.height - (double)player.yOffset, player.posZ + (rand.nextDouble() - 0.5D) * (double)player.width, 0.0D, 0.0D, 0.0D); world.spawnParticle("enchantmenttable", player.posX + (rand.nextDouble() - 0.5D) * (double)player.width, player.posY + rand.nextDouble() * (double)player.height - (double)player.yOffset, player.posZ + (rand.nextDouble() - 0.5D) * (double)player.width, 0.0D, 0.0D, 0.0D); world.spawnParticle("portal", player.posX + (rand.nextDouble() - 0.5D) * (double)player.width, player.posY + rand.nextDouble() * (double)player.height - (double)player.yOffset, player.posZ + (rand.nextDouble() - 0.5D) * (double)player.width, 0.0D, 0.0D, 0.0D); } { } } } } }
×
×
  • Create New...

Important Information

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