Package net.minecraft.potion

Examples of net.minecraft.potion.PotionEffect


  @Override
  public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
    if(par3Entity instanceof EntityPlayer) {
      EntityPlayer player = (EntityPlayer) par3Entity;
      PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed);
      float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F;

      if(player.getCurrentEquippedItem() == par1ItemStack && player.swingProgress == check && !par2World.isRemote && par2World.rand.nextInt(2) == 0) {
        EntityManaBurst burst = getBurst(player, par1ItemStack);
        par2World.spawnEntityInWorld(burst);
        ToolCommons.damageItem(par1ItemStack, 1, player, MANA_PER_DAMAGE);
View Full Code Here


        player.worldObj.createExplosion(null, player.posX, player.posY, player.posZ, 0.25F, false);
      break;
    }
    case 4 : { // Mega Jump
      if(!player.worldObj.isRemote)
        player.addPotionEffect(new PotionEffect(Potion.resistance.id, 300, 5));
      player.motionY = 6;
      break;
    }
    case 5 : { // Randomly set HP
      if(!player.worldObj.isRemote)
        player.setHealth(player.worldObj.rand.nextInt(19) + 1);
      break;
    }
    case 6 : { // Lots O' Hearts
      if(!player.worldObj.isRemote)
        player.addPotionEffect(new PotionEffect(Potion.field_76444_x.id, 20 * 60 * 2, 9));
      break;
    }
    case 7 : { // All your inventory is belong to us
      if(!player.worldObj.isRemote)
        for(int i = 0; i < player.inventory.getSizeInventory(); i++)
          if(i != player.inventory.currentItem) {
            ItemStack stackAt = player.inventory.getStackInSlot(i);
            if(stackAt != null)
              player.dropPlayerItemWithRandomChoice(stackAt, true);
            player.inventory.setInventorySlotContents(i, null);
          }

      break;
    }
    case 8 : { // Break your neck
      player.rotationPitch = (float) Math.random() * 360F;
      player.rotationYaw = (float) Math.random() * 180F;


      break;
    }
    case 9 : { // Highest Possible
      int x = MathHelper.floor_double(player.posX);
      MathHelper.floor_double(player.posY);
      int z = MathHelper.floor_double(player.posZ);
      for(int i = 256; i > 0; i--) {
        Block block = player.worldObj.getBlock(x, i, z);
        if(!block.isAir(player.worldObj, x, i, z)) {
          if(player instanceof EntityPlayerMP) {
            EntityPlayerMP mp = (EntityPlayerMP) player;
            mp.playerNetServerHandler.setPlayerLocation(player.posX, i + 1.6, player.posZ, player.rotationYaw, player.rotationPitch);
          }
          break;
        }
      }

      break;
    }
    case 10 : { // HYPERSPEEEEEED
      if(!player.worldObj.isRemote)
        player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 60, 200));
      break;
    }
    case 11 : { // Night Vision
      if(!player.worldObj.isRemote)
        player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 6000, 0));
      break;
    }
    case 12 : { // Flare
      if(!player.worldObj.isRemote) {
        EntitySignalFlare flare = new EntitySignalFlare(player.worldObj);
        flare.setPosition(player.posX, player.posY, player.posZ);
        flare.setColor(player.worldObj.rand.nextInt(16));
        player.worldObj.playSoundAtEntity(player, "random.explode", 40F, (1.0F + (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.2F) * 0.7F);

        player.worldObj.spawnEntityInWorld(flare);

        int range = 5;
        List<EntityLivingBase> entities = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range));
        for(EntityLivingBase entity : entities)
          if(entity != player && (!(entity instanceof EntityPlayer) || MinecraftServer.getServer() == null || MinecraftServer.getServer().isPVPEnabled()))
            entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 50, 5));
      }

      break;
    }
    case 13 : { // Pixie Friend
      if(!player.worldObj.isRemote) {
        EntityPixie pixie = new EntityPixie(player.worldObj);
        pixie.setPosition(player.posX, player.posY + 1.5, player.posZ);
        player.worldObj.spawnEntityInWorld(pixie);
      }
      break;
    }
    case 14 : { // Nausea + Blindness :3
      if(!player.worldObj.isRemote) {
        player.addPotionEffect(new PotionEffect(Potion.confusion.id, 160, 3));
        player.addPotionEffect(new PotionEffect(Potion.blindness.id, 160, 0));
      }

      break;
    }
    case 15 : { // Drop own Head
View Full Code Here

        int range = 5;
        List<EntityLivingBase> entities = par2World.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(par3EntityPlayer.posX - range, par3EntityPlayer.posY - range, par3EntityPlayer.posZ - range, par3EntityPlayer.posX + range, par3EntityPlayer.posY + range, par3EntityPlayer.posZ + range));
        for(EntityLivingBase entity : entities)
          if(entity != par3EntityPlayer && (!(entity instanceof EntityPlayer) || MinecraftServer.getServer() == null || MinecraftServer.getServer().isPVPEnabled()))
            entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 50, 5));
      }
      par1ItemStack.damageItem(200, par3EntityPlayer);
    }

    return par1ItemStack;
View Full Code Here

      if(!worldObj.isRemote) {
        List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range));
        for(EntityPlayer player : players) {
          player.attackEntityFrom(summoner == null ? DamageSource.generic : DamageSource.causeMobDamage(summoner), 10);
          player.addPotionEffect(new PotionEffect(Potion.blindness.id, 25, 0));
          player.addPotionEffect(new PotionEffect(Potion.wither.id, 70, 3));
        }
      }

      setDead();
    }
View Full Code Here

    }
    this.oldThings.clear();
   
    for (Object oeffect : player.getActivePotionEffects())
    {
      PotionEffect effect = (PotionEffect) oeffect;
     
      int id = effect.getPotionID();
      setValue(Integer.toString(id), getQuality(effect));
      this.oldThings.add(Integer.toString(id));
    }
  }
View Full Code Here

        @Override
        protected void drawSlot(int slot, int x, int y, int mx, int my, float frame) {
            GL11.glColor4f(1, 1, 1, 1);
            Potion potion = validPotions.get(slot);
            PotionEffect effect = getEffect(potion.id);
            boolean blank = effect == null;
            if (effect == null)
                effect = new PotionEffect(potion.id, 1200, 0);
            int shade = selectedslot == slot ? 2 : blank ? 1 : 0;

            CCRenderState.changeTexture("textures/gui/container/enchanting_table.png");
            drawTexturedModalRect(x, y, 0, 166 + getSlotHeight(slot) * shade, width - 30, getSlotHeight(slot));
            drawTexturedModalRect(x + width - 30, y, width - 23, 166 + getSlotHeight(slot) * shade, 30, getSlotHeight(slot));

            if (potion.hasStatusIcon()) {
                CCRenderState.changeTexture("textures/gui/container/inventory.png");
                int icon = potion.getStatusIconIndex();
                drawTexturedModalRect(x + 1, y + 1, icon % 8 * 18, 198 + icon / 8 * 18, 18, 18);
            }

            String name = StatCollector.translateToLocal(potion.getName());
            String amp = effect.getAmplifier() > 0 ? " " + translateAmplifier(effect.getAmplifier()) : "";
            int textColour = shade == 0 ? 0x685e4a : shade == 1 ? 0x407f10 : 0xffff80;
            if (fontRenderer.getStringWidth(name + amp) < width - 20) {
                fontRenderer.drawString(name + amp, x + 20, y + 1, textColour);
            } else {
                fontRenderer.drawString(name, x + 20, y + 1, textColour);
View Full Code Here

        private PotionEffect getEffect(int id) {
            ItemStack potion = container.potionInv.getStackInSlot(0);
            if (potion != null && potion.hasTagCompound() && potion.getTagCompound().hasKey("CustomPotionEffects")) {
                NBTTagList potionTagList = potion.getTagCompound().getTagList("CustomPotionEffects", 10);
                for (int i = 0; i < potionTagList.tagCount(); i++) {
                    PotionEffect effect = PotionEffect.readCustomPotionEffectFromNBT(potionTagList.getCompoundTagAt(i));
                    if (effect.getPotionID() == id)
                        return effect;
                }
            }
            return null;
        }
View Full Code Here

        }

        private void select(int slot) {
            selectedslot = slot;
            durationField.setEnabled(true);
            PotionEffect effect = getEffect(validPotions.get(slot).id);
            if (effect == null)
                effect = new PotionEffect(validPotions.get(slot).id, 1200, 0);
            durationField.setDurationTicks(effect.getDuration());
            amplifier = effect.getAmplifier();
            validateInputButtons();
        }
View Full Code Here

        NBTTagList effects = potion.getTagCompound().getTagList("CustomPotionEffects", 10);
        NBTTagList newEffects = new NBTTagList();
        for(int i = 0; i < effects.tagCount(); i++) {
            NBTTagCompound tag = effects.getCompoundTagAt(i);
            PotionEffect e = PotionEffect.readCustomPotionEffectFromNBT(tag);
            if(e.getPotionID() != effectID)
                newEffects.appendTag(tag);
        }
        if(add)
            newEffects.appendTag(new PotionEffect(effectID, packet.readInt(), packet.readUByte()).writeCustomPotionEffectToNBT(new NBTTagCompound()));
        potion.getTagCompound().setTag("CustomPotionEffects", newEffects);
    }
View Full Code Here

                player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, (WorldServer) worldNew);
                player.mcServer.getConfigurationManager().syncPlayerInventory(player);

                for (Object o : player.getActivePotionEffects())
                {
                    PotionEffect var10 = (PotionEffect) o;
                    player.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(player.getEntityId(), var10));
                }

                //  player.playerNetServerHandler.sendPacketToPlayer(new Packet43Experience(player.experience, player.experienceTotal, player.experienceLevel));
            }
View Full Code Here

TOP

Related Classes of net.minecraft.potion.PotionEffect

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.