Advertisement
Guest User

BioWarfare event handler

a guest
Oct 31st, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.48 KB | None | 0 0
  1. package com.Looke81.BioWarfare.handler;
  2.  
  3. import java.util.Random;
  4.  
  5. import com.Looke81.BioWarfare.BioWarfare;
  6. import com.Looke81.BioWarfare.ReflectionHelper;
  7. import com.Looke81.BioWarfare.Potion.ShaderChange;
  8. import com.Looke81.BioWarfare.armor.HazmatSuit;
  9. import com.Looke81.BioWarfare.blocks.BacteriaTest;
  10. import com.Looke81.BioWarfare.blocks.twobytwoDirt;
  11. import com.Looke81.BioWarfare.items.Microscope;
  12. import com.google.common.base.Throwables;
  13.  
  14. import net.minecraft.client.Minecraft;
  15. import net.minecraft.client.shader.ShaderGroup;
  16. import net.minecraft.client.util.JsonException;
  17. import net.minecraft.entity.DataWatcher;
  18. import net.minecraft.entity.Entity;
  19. import net.minecraft.entity.EntityLivingBase;
  20. import net.minecraft.entity.monster.EntityCreeper;
  21. import net.minecraft.entity.player.EntityPlayer;
  22. import net.minecraft.init.Blocks;
  23. import net.minecraft.item.ItemStack;
  24. import net.minecraft.potion.Potion;
  25. import net.minecraft.potion.PotionEffect;
  26. import net.minecraft.server.MinecraftServer;
  27. import net.minecraft.util.ChatComponentText;
  28. import net.minecraft.util.ChatComponentTranslation;
  29. import net.minecraft.util.DamageSource;
  30. import net.minecraft.util.ResourceLocation;
  31. import net.minecraft.world.World;
  32. import net.minecraftforge.event.entity.living.LivingAttackEvent;
  33. import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
  34. import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  35. import cpw.mods.fml.relauncher.Side;
  36. import cpw.mods.fml.relauncher.SideOnly;
  37.  
  38.  
  39. public class BioWarfareEventHandler {
  40. public static boolean ShouldBeEffected = false;
  41. public static int tickcounter = 0;
  42. public static boolean damagebypotiontest = false;
  43. private static final Random random = new Random();
  44. public static boolean HasMicroscopeInInv = false;
  45. public static boolean isRemote;
  46.  
  47.  
  48. @SubscribeEvent
  49. public void onLivingUpdateEvent(LivingUpdateEvent event)
  50. {
  51.  
  52. // do something to player every update tick:
  53.  
  54.  
  55.  
  56. if (event.entity instanceof EntityPlayer){
  57. EntityPlayer player = (EntityPlayer) event.entity;
  58. if (HazmatSuit.HazmatSuitBootsEquiped == true && HazmatSuit.HazmatSuitLegsEquiped == true && HazmatSuit.HazmatSuitChestEquiped == true && HazmatSuit.HazmatSuitHelmEquiped == true){
  59. HazmatSuit.HazmatSuitBootsEquiped = false;
  60. HazmatSuit.HazmatSuitLegsEquiped = false;
  61. HazmatSuit.HazmatSuitChestEquiped = false;
  62. HazmatSuit.HazmatSuitHelmEquiped = false;
  63. HazmatSuit.HazmatSuitOn = true;
  64. }else{
  65. HazmatSuit.HazmatSuitOn = false;
  66. }
  67.  
  68. tickcounter ++;
  69.  
  70. int x = (int) Math.floor(player.posX);
  71. int y = (int) (player.posY - player.getYOffset());
  72. int z = (int) Math.floor(player.posZ);
  73. if (player.worldObj.getBlock(x, y , z) == BioWarfare.blockBacteriaTest && (HazmatSuit.HazmatSuitOn== true)){
  74. }else if(player.worldObj.getBlock(x, y , z) == BioWarfare.blockBacteriaTest && (HazmatSuit.HazmatSuitOn== false)){
  75. player.addPotionEffect(new PotionEffect(Potion.poison.getId(), 20, 30));
  76. }
  77.  
  78.  
  79. if (player.getActivePotionEffect(BioWarfare.PotionTest) != null && player.getActivePotionEffect(BioWarfare.PotionTest).getDuration() != 1) {
  80.  
  81.  
  82. /* if (event.entityLiving.worldObj.rand.nextInt(200) == 0){
  83.  
  84. EntityCreeper creeper = new EntityCreeper(player.worldObj);
  85. try {
  86. ReflectionHelper.setProperty(creeper, 0, "explosionRadius", "field_82226_g");
  87. DataWatcher watcher = ReflectionHelper.getProperty(creeper, "dataWatcher", "field_70180_af");
  88.  
  89. } catch (Throwable t) {
  90. throw Throwables.propagate(t);
  91. }
  92.  
  93. creeper.setPosition(player.posX ,player.posY ,player.posZ );
  94. player.worldObj.spawnEntityInWorld(creeper);
  95.  
  96. }*/
  97. ShaderChange.flip(random, player);
  98.  
  99. }else if (player.getActivePotionEffect(BioWarfare.PotionTest) != null && player.getActivePotionEffect(BioWarfare.PotionTest).getDuration() == 1){
  100.  
  101. ShaderChange.noShader(random, player);
  102.  
  103. }
  104.  
  105.  
  106.  
  107.  
  108. if (player.isPotionActive(BioWarfare.Toxic)) {
  109.  
  110. double x2 = event.entity.posX ;
  111. double y2 = event.entity.posY ;
  112. double z2 = event.entity.posZ ;
  113.  
  114.  
  115.  
  116.  
  117.  
  118. if (event.entityLiving.worldObj.rand.nextInt(6) == 0){
  119. player.worldObj.spawnParticle("mobSpell", x2,y2 -0.5,z2, 0, 255, 0);
  120.  
  121. }
  122. if (event.entityLiving.worldObj.rand.nextInt(20) == 0 && !(player.capabilities.isCreativeMode)) {
  123.  
  124.  
  125. player.heal(-2);
  126.  
  127.  
  128.  
  129.  
  130.  
  131. }
  132. }
  133. //____________________________________________________________________________________________________________
  134. if (player.inventory.hasItem(BioWarfare.itemUnknownPathogen) && (HazmatSuit.HazmatSuitOn== true)){
  135. ShouldBeEffected = false;
  136. HazmatSuit.HazmatSuitOn=false;
  137. }else if (player.inventory.hasItem(BioWarfare.itemUnknownPathogen)){
  138.  
  139. ShouldBeEffected = true;
  140. }else{
  141. ShouldBeEffected = false;
  142. }
  143. if (ShouldBeEffected == true){
  144. player.addPotionEffect(new PotionEffect(Potion.poison.getId(), 20, 30));
  145. }
  146.  
  147. if (player.inventory.hasItem(BioWarfare.itemMicroscope) && (player.capabilities.isCreativeMode == false)){
  148. HasMicroscopeInInv = true;
  149. }else{
  150. HasMicroscopeInInv = false;
  151. }
  152. if (player.worldObj.isRemote == true){
  153. isRemote=true;
  154. }
  155. if (player.worldObj.isRemote == false){
  156. isRemote=false;
  157.  
  158. }
  159. }
  160.  
  161.  
  162. }
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169. @SubscribeEvent
  170. public void onEntityDamaged(LivingAttackEvent event){
  171.  
  172. }
  173.  
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement