Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.21 KB | None | 0 0
  1. public static void chooseRandom(ItemStack stack, World worldIn, final EntityLivingBase target,
  2.             final EntityLivingBase attacker) {
  3.  
  4.         Random rand = new Random(10);
  5.         int random = rand.nextInt();
  6.  
  7.         switch (random) {
  8.  
  9.         case 0: // Explosion
  10.  
  11.             explosion(stack, worldIn, target, attacker);
  12.             break;
  13.  
  14.         case 1: // Lightning
  15.  
  16.             lightning(stack, worldIn, target, attacker);
  17.             break;
  18.  
  19.         case 2: // Positive Potion Effect for Player
  20.  
  21.             playerEffect(stack, worldIn, target, attacker);
  22.             break;
  23.  
  24.         case 3: // Negative Potion Effect for Enemies
  25.  
  26.             negativeEntityEffect(stack, worldIn, target, attacker);
  27.             break;
  28.  
  29.         case 4: // Get Rid of Hunger
  30.  
  31.             noHunger(stack, worldIn, target, attacker);
  32.             break;
  33.  
  34.         case 5: // Get Rid of All Bad Effects
  35.  
  36.             removeEffects(stack, worldIn, target, attacker);
  37.             break;
  38.  
  39.         case 6: // Spawn Cobwebs in Enemy
  40.  
  41.             cobWeb(stack, worldIn, target, attacker);
  42.             break;
  43.  
  44.         case 7: // Spawn Lava on Enemy
  45.  
  46.             lava(stack, worldIn, target, attacker);
  47.             break;
  48.  
  49.         case 8: // Spawn Flaming Arrows
  50.  
  51.             flamingArrows(stack, worldIn, target, attacker);
  52.             break;
  53.  
  54.         case 9: // Do Nothing
  55.  
  56.             doNothing();
  57.             break;
  58.            
  59.         case 10 : // Spawn Hole
  60.            
  61.             spawnHole(stack, worldIn, target, attacker);
  62.             break;
  63.  
  64.         }  
  65.            
  66.  
  67.     }
  68.  
  69.     public static void explosion(ItemStack stack, World worldIn, final EntityLivingBase target,
  70.             final EntityLivingBase attacker) {
  71.  
  72.         int x = target.chunkCoordX;
  73.         int y = target.chunkCoordY;
  74.         int z = target.chunkCoordZ;
  75.  
  76.         worldIn.createExplosion(attacker, x, y, z, 10F, true);
  77.  
  78.     }
  79.  
  80.     public static void lightning(ItemStack stack, World worldIn, final EntityLivingBase target,
  81.             final EntityLivingBase attacker) {
  82.  
  83.         int x = target.chunkCoordX;
  84.         int y = target.chunkCoordY;
  85.         int z = target.chunkCoordZ;
  86.  
  87.         worldIn.addWeatherEffect(new EntityLightningBolt(worldIn, x, y, z, false));
  88.  
  89.     }
  90.  
  91.     public static void playerEffect(ItemStack stack, World worldIn, final EntityLivingBase target,
  92.             final EntityLivingBase attacker) {
  93.  
  94.         PotionEffect[] positiveEffects = {
  95.  
  96.                 new PotionEffect(MobEffects.SPEED, 30, 5), new PotionEffect(MobEffects.HASTE, 30, 5),
  97.                 new PotionEffect(MobEffects.STRENGTH, 30, 5), new PotionEffect(MobEffects.INSTANT_HEALTH, 30, 5),
  98.                 new PotionEffect(MobEffects.JUMP_BOOST, 30, 5), new PotionEffect(MobEffects.REGENERATION, 30, 5),
  99.                 new PotionEffect(MobEffects.RESISTANCE, 30, 5), new PotionEffect(MobEffects.FIRE_RESISTANCE, 30, 5),
  100.                 new PotionEffect(MobEffects.WATER_BREATHING, 30, 5), new PotionEffect(MobEffects.INVISIBILITY, 30, 5),
  101.                 new PotionEffect(MobEffects.NIGHT_VISION, 30, 5), new PotionEffect(MobEffects.HEALTH_BOOST, 30, 20),
  102.                 new PotionEffect(MobEffects.ABSORPTION, 30, 5), new PotionEffect(MobEffects.SATURATION, 30, 5),
  103.                 new PotionEffect(MobEffects.LUCK, 30, 5)
  104.  
  105.         };
  106.  
  107.         Random rand = new Random();
  108.         int random = rand.nextInt(positiveEffects.length);
  109.  
  110.         if (target instanceof EntityPlayer) {
  111.  
  112.             target.addPotionEffect(positiveEffects[random]);
  113.  
  114.         }
  115.  
  116.     }
  117.  
  118.     public static void negativeEntityEffect(ItemStack stack, World worldIn, final EntityLivingBase target,
  119.             final EntityLivingBase attacker) {
  120.  
  121.         PotionEffect[] negativeEffects = {
  122.  
  123.                 new PotionEffect(MobEffects.SLOWNESS, 30, 5), new PotionEffect(MobEffects.MINING_FATIGUE, 30, 5),
  124.                 new PotionEffect(MobEffects.NAUSEA, 30, 5), new PotionEffect(MobEffects.BLINDNESS, 30, 5),
  125.                 new PotionEffect(MobEffects.HUNGER, 30, 5), new PotionEffect(MobEffects.WEAKNESS, 30, 5),
  126.                 new PotionEffect(MobEffects.LEVITATION, 30, 5), new PotionEffect(MobEffects.GLOWING, 30, 5),
  127.  
  128.         };
  129.  
  130.         Random rand = new Random();
  131.         int random = rand.nextInt(negativeEffects.length);
  132.  
  133.         attacker.addPotionEffect(negativeEffects[random]);
  134.  
  135.     }
  136.  
  137.     public static void noHunger(ItemStack stack, World worldIn, final EntityLivingBase target,
  138.             final EntityLivingBase attacker) {
  139.        
  140.         if (attacker instanceof EntityPlayer) {
  141.            
  142.             EntityPlayer player = (EntityPlayer) attacker;
  143.             player.getFoodStats().setFoodLevel(10);
  144.            
  145.         }
  146.  
  147.     }
  148.  
  149.     public static void removeEffects(ItemStack stack, World worldIn, final EntityLivingBase target,
  150.             final EntityLivingBase attacker) {
  151.  
  152.         for (PotionEffect effect : attacker.getActivePotionEffects()) {
  153.  
  154.             attacker.removePotionEffect(effect.getPotion());
  155.  
  156.         }
  157.  
  158.     }
  159.  
  160.     public static void cobWeb(ItemStack stack, World worldIn, final EntityLivingBase target,
  161.             final EntityLivingBase attacker) {
  162.        
  163.         int x = target.chunkCoordX;
  164.         int y = target.chunkCoordY;
  165.         int z = target.chunkCoordZ;
  166.        
  167.         BlockPos normal = new BlockPos(x, y, z);
  168.         BlockPos right = new BlockPos(x + 1, y, z);
  169.         BlockPos left = new BlockPos(x - 1, y, z);
  170.         BlockPos up = new BlockPos(x, y + 1, z);
  171.         BlockPos down = new BlockPos(x, y - 1, z);
  172.        
  173.         worldIn.setBlockState(normal, Blocks.WEB.getDefaultState());
  174.         worldIn.setBlockState(right, Blocks.WEB.getDefaultState());
  175.         worldIn.setBlockState(left, Blocks.WEB.getDefaultState());
  176.         worldIn.setBlockState(up, Blocks.WEB.getDefaultState());
  177.         worldIn.setBlockState(down, Blocks.WEB.getDefaultState());
  178.  
  179.     }
  180.  
  181.     public static void lava(ItemStack stack, World worldIn, final EntityLivingBase target,
  182.             final EntityLivingBase attacker) {
  183.        
  184.         int x = target.chunkCoordX;
  185.         int y = target.chunkCoordY;
  186.         int z = target.chunkCoordZ;
  187.        
  188.         BlockPos normal = new BlockPos(x, y, z);
  189.         BlockPos right = new BlockPos(x + 1, y, z);
  190.         BlockPos left = new BlockPos(x - 1, y, z);
  191.         BlockPos up = new BlockPos(x, y + 1, z);
  192.         BlockPos down = new BlockPos(x, y - 1, z);
  193.        
  194.         worldIn.setBlockState(normal, Blocks.LAVA.getDefaultState());
  195.         worldIn.setBlockState(right, Blocks.LAVA.getDefaultState());
  196.         worldIn.setBlockState(left, Blocks.LAVA.getDefaultState());
  197.         worldIn.setBlockState(up, Blocks.LAVA.getDefaultState());
  198.         worldIn.setBlockState(down, Blocks.LAVA.getDefaultState());
  199.        
  200.  
  201.     }
  202.  
  203.     public static void flamingArrows(ItemStack stack, World worldIn, final EntityLivingBase target,
  204.             final EntityLivingBase attacker) {
  205.        
  206.         int x = target.chunkCoordX;
  207.         int y = target.chunkCoordY;
  208.         int z = target.chunkCoordZ;
  209.        
  210.         int playerX = attacker.chunkCoordX;
  211.         int playerY = attacker.chunkCoordY;
  212.         int playerZ = attacker.chunkCoordZ;
  213.        
  214.         EntityTippedArrow arrow = new EntityTippedArrow(worldIn, playerX, playerY, playerZ + 1);
  215.         EntityTippedArrow arrow1 = new EntityTippedArrow(worldIn, playerX, playerY, playerZ + 1);
  216.         EntityTippedArrow arrow2 = new EntityTippedArrow(worldIn, playerX, playerY, playerZ + 1);
  217.        
  218.         arrow.shoot(x, y, z, 5.0F, 0);
  219.         arrow1.shoot(x, y, z, 5.0F, 0);
  220.         arrow2.shoot(x, y, z, 5.0F, 0);
  221.  
  222.     }
  223.  
  224.     public static void doNothing() {}
  225.    
  226.     public static void spawnHole(ItemStack stack, World worldIn, final EntityLivingBase target,
  227.             final EntityLivingBase attacker) {
  228.        
  229.         int x = target.chunkCoordX;
  230.         int y = target.chunkCoordY;
  231.         int z = target.chunkCoordZ;
  232.        
  233.         BlockPos normal = new BlockPos(x, y, z);
  234.         BlockPos down = new BlockPos(x, y - 1, z);
  235.         BlockPos up = new BlockPos(x, y + 1, z);
  236.         BlockPos left = new BlockPos(x - 1, y, z);
  237.         BlockPos right = new BlockPos(x + 1, y, z);
  238.        
  239.         worldIn.setBlockToAir(normal);
  240.         worldIn.setBlockToAir(down);
  241.         worldIn.setBlockToAir(up);
  242.         worldIn.setBlockToAir(left);
  243.         worldIn.setBlockToAir(right);
  244.        
  245.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement