Java Code Examples for net.minecraft.potion.Potion#potionTypes()
The following examples show how to use
net.minecraft.potion.Potion#potionTypes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShowArmor.java From ehacks-pro with GNU General Public License v3.0 | 5 votes |
private void drawPotionEffects(EntityLiving entity) { int i = 100; int j = 10; boolean flag = true; Collection collection = entity.getActivePotionEffects(); if (!collection.isEmpty()) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); int k = 33; if (collection.size() > 5) { k = 132 / (collection.size() - 1); } for (Iterator iterator = entity.getActivePotionEffects().iterator(); iterator.hasNext(); j += k) { PotionEffect potioneffect = (PotionEffect) iterator.next(); Potion potion = Potion.potionTypes[potioneffect.getPotionID()]; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Wrapper.INSTANCE.mc().getTextureManager().bindTexture(new ResourceLocation("textures/gui/container/inventory.png")); this.drawTexturedModalRect(i, j, 0, 166, 140, 32); if (potion.hasStatusIcon()) { int l = potion.getStatusIconIndex(); this.drawTexturedModalRect(i + 6, j + 7, l % 8 * 18, 198 + l / 8 * 18, 18, 18); } potion.renderInventoryEffect(i, j, potioneffect, Wrapper.INSTANCE.mc()); String s1 = I18n.format(potion.getName()); s1 += " " + potioneffect.getAmplifier(); Wrapper.INSTANCE.fontRenderer().drawStringWithShadow(s1, i + 10 + 18, j + 6, 16777215); String s = Potion.getDurationString(potioneffect); Wrapper.INSTANCE.fontRenderer().drawStringWithShadow(s, i + 10 + 18, j + 6 + 10, 8355711); } } }
Example 2
Source File: HazardousItemsCommand.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 5 votes |
/** * Send a list of all valid potions to the command sender * @param pCmdSender */ private void SendPotionsToPlayer(ICommandSender pCmdSender) { if (!InGame(pCmdSender)) { PlayerChatHelper.SendPlain(pCmdSender, "[HAZIT] List of known Potions; Name(ID)"); } else { PlayerChatHelper.SendInfo(pCmdSender, "List of known Potions; Name(ID)"); } StringBuilder tMsg = new StringBuilder(32); for (Potion p : Potion.potionTypes) { if (p == null) { continue; } if (tMsg.length()>0) { tMsg.append(", "); } String t = String.format("%s(%d)", p.getName(), p.id); if (tMsg.length() + t.length() > 50) { if (!InGame(pCmdSender)) { PlayerChatHelper.SendPlain(pCmdSender, tMsg.toString()); } else { PlayerChatHelper.SendInfo(pCmdSender, tMsg.toString()); } tMsg=new StringBuilder(t); } else { tMsg.append(t); } } if (!InGame(pCmdSender)) { PlayerChatHelper.SendPlain(pCmdSender, "[HAZIT] End of list"); } else { PlayerChatHelper.SendInfo(pCmdSender, "End of list"); } }
Example 3
Source File: RegisteredPotions.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
private static <T extends Potion> T registerPotion(Class<T> potionClass) { int id = ModConfig.loadPotionId(potionClass.getSimpleName()); if(id == -1) { for(int i = 0; i < Potion.potionTypes.length; i++) { if(Potion.potionTypes[i] == null) { id = i; break; } } if(id == -1) { id = Potion.potionTypes.length; FMLLog.warning("Gadomancy could not find a free potion id and will extend the potionTypes array! This might cause fatal errors. Please consider changing the config!"); } } if(id > 127) { FMLLog.warning("The potion id '" + id + "' of potion '" + Gadomancy.NAME + ":" + potionClass.getSimpleName() + "' is bigger then 127 this might cause errors as well. Please consider changing the config."); } if(id >= Potion.potionTypes.length) { Potion[] potions = new Potion[Potion.potionTypes.length + 1]; System.arraycopy(Potion.potionTypes, 0, potions, 0, Potion.potionTypes.length); Potion.potionTypes = potions; } else if(Potion.potionTypes[id] != null) { Potion conflict = Potion.potionTypes[id]; throw new RuntimeException("Potion id conflict! Do not report this bug you just have to change the configuration files. Failed to register potion '" + Gadomancy.NAME + ":" + potionClass.getSimpleName() + "' with id '" + id + "'. Another potion with this id already exists: " + conflict.getName() + " (as " + conflict.getClass().getName() + ")"); } return new Injector(potionClass).invokeConstructor(int.class, id); }
Example 4
Source File: TippedArrow.java From Et-Futurum with The Unlicense | 5 votes |
@Override public String getUnlocalizedName(ItemStack stack) { PotionEffect effect = getEffect(stack); if (effect == null || effect.getPotionID() < 0 || effect.getPotionID() >= Potion.potionTypes.length) return super.getUnlocalizedName(stack); Potion potion = Potion.potionTypes[effect.getPotionID()]; return "tipped_arrow." + potion.getName(); }
Example 5
Source File: GuiPotionCreator.java From NotEnoughItems with MIT License | 5 votes |
public GuiSlotPotionEffects(int x, int y) { super(x, y, 108, 76); for (Potion p : Potion.potionTypes) if (p != null) validPotions.add(p); setSmoothScroll(false); setMargins(0, 0, 0, 0); }
Example 6
Source File: ItemPotionMetaProvider.java From OpenPeripheral-Integration with MIT License | 5 votes |
public static Map<String, Object> getPotionInfo(int potionId) { if (potionId < 0 || potionId >= Potion.potionTypes.length) return null; final Map<String, Object> result = Maps.newHashMap(); final Potion potion = Potion.potionTypes[potionId]; result.put("name", potion.getName()); result.put("instant", potion.isInstant()); result.put("color", potion.getLiquidColor()); return result; }
Example 7
Source File: EntityPotionCloud.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override protected void entityInit(){ int potionID; do { potionID = rand.nextInt(Potion.potionTypes.length); } while(Potion.potionTypes[potionID] == null); dataWatcher.addObject(POTION_DATAWATCHER_ID, potionID); }
Example 8
Source File: EntityPotionCloud.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void onUpdate(){ age++; radius -= 0.001D; if(radius <= 0.0D && !worldObj.isRemote) { EntityItem seed = new EntityItem(worldObj, posX, posY, posZ, new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.POTION_PLANT_DAMAGE)); seed.lifespan = 300; ItemPlasticPlants.markInactive(seed); worldObj.spawnEntityInWorld(seed); setDead(); } if(age % 60 == 0) { motionX += (rand.nextDouble() - 0.5D) * 0.1D; motionY += (rand.nextDouble() - 0.6D) * 0.1D; motionZ += (rand.nextDouble() - 0.5D) * 0.1D; } super.onUpdate(); moveEntity(motionX, motionY, motionZ); if(worldObj.isRemote) { int potionColor = getPotionID() < Potion.potionTypes.length && Potion.potionTypes[getPotionID()] != null ? Potion.potionTypes[getPotionID()].getLiquidColor() : 0xFFFFFF; for(int i = 0; i < 4; i++) worldObj.spawnParticle("mobSpell", posX + (rand.nextDouble() - 0.5D) * 2 * radius, posY + (rand.nextDouble() - 0.5D) * 2 * radius, posZ + (rand.nextDouble() - 0.5D) * 2 * radius, (potionColor >> 16 & 255) / 255.0F, (potionColor >> 8 & 255) / 255.0F, (potionColor >> 0 & 255) / 255.0F); } else if(getPotionID() >= Potion.potionTypes.length) { setDead(); } AxisAlignedBB bbBox = AxisAlignedBB.getBoundingBox(posX - radius, posY - radius, posZ - radius, posX + radius, posY + radius, posZ + radius); List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, bbBox); for(EntityLivingBase entity : entities) { entity.addPotionEffect(new PotionEffect(getPotionID(), 200)); } }
Example 9
Source File: PotionEffects.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
public void draw(int x, double y, boolean isConfig) { int row = 0; double scale = ElementRenderer.getCurrentScale(); Collection<PotionEffect> effects = new ArrayList<>(); if (isConfig) { effects.add(new PotionEffect(1, 100, 1)); effects.add(new PotionEffect(3, 100, 2)); } else { effects = Minecraft.getMinecraft().thePlayer.getActivePotionEffects(); } List<String> tmp = new ArrayList<>(); for (PotionEffect potioneffect : effects) { Potion potion = Potion.potionTypes[potioneffect.getPotionID()]; if (potionIcon) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/gui/container/inventory.png")); if (potion.hasStatusIcon()) { int potionStatusIconIndex = potion.getStatusIconIndex(); drawTexturedModalRect(!ElementRenderer.getCurrent().isRightSided() ? (int) (x / scale) - 20 : (int) (x / scale), (int) ((y + row * 16)) - 4, potionStatusIconIndex % 8 * 18, 198 + potionStatusIconIndex / 8 * 18, 18, 18); } } StringBuilder s1 = new StringBuilder(I18n.format(potion.getName())); switch (potioneffect.getAmplifier()) { case 1: s1.append(" ").append(I18n.format("enchantment.level.2")); break; case 2: s1.append(" ").append(I18n.format("enchantment.level.3")); break; case 3: s1.append(" ").append(I18n.format("enchantment.level.4")); break; } String s = Potion.getDurationString(potioneffect); String text = s1 + " - " + s; tmp.add(text); ElementRenderer.draw((int) (x / scale), ((y + row * 16)), text); row++; } width = isConfig ? ElementRenderer.maxWidth(tmp) : 0; height = row * 16; }
Example 10
Source File: EntityTippedArrow.java From Et-Futurum with The Unlicense | 4 votes |
private boolean isEffectValid() { return effect != null && Potion.potionTypes[effect.getPotionID()] != null; }
Example 11
Source File: LingeringPotion.java From Et-Futurum with The Unlicense | 4 votes |
@Override @SideOnly(Side.CLIENT) @SuppressWarnings({ "rawtypes", "unchecked" }) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isComplex) { if (stack.getItemDamage() == 0) return; List<PotionEffect> effects = getEffects(stack); HashMultimap<String, AttributeModifier> attributes = HashMultimap.create(); if (effects == null || effects.isEmpty()) { String s = StatCollector.translateToLocal("potion.empty").trim(); list.add(EnumChatFormatting.GRAY + s); } else for (PotionEffect potioneffect : effects) { String s1 = StatCollector.translateToLocal(potioneffect.getEffectName()).trim(); Potion potion = Potion.potionTypes[potioneffect.getPotionID()]; Map<IAttribute, AttributeModifier> map = potion.func_111186_k(); if (map != null && map.size() > 0) for (Entry<IAttribute, AttributeModifier> entry : map.entrySet()) { AttributeModifier attributemodifier = entry.getValue(); AttributeModifier attributemodifier1 = new AttributeModifier(attributemodifier.getName(), potion.func_111183_a(potioneffect.getAmplifier(), attributemodifier), attributemodifier.getOperation()); attributes.put(entry.getKey().getAttributeUnlocalizedName(), attributemodifier1); } if (potioneffect.getAmplifier() > 0) s1 = s1 + " " + StatCollector.translateToLocal("potion.potency." + potioneffect.getAmplifier()).trim(); if (potioneffect.getDuration() > 20) s1 = s1 + " (" + Potion.getDurationString(potioneffect) + ")"; if (potion.isBadEffect()) list.add(EnumChatFormatting.RED + s1); else list.add(EnumChatFormatting.GRAY + s1); } if (!attributes.isEmpty()) { list.add(""); list.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("potion.effects.whenDrank")); for (Entry<String, AttributeModifier> entry1 : attributes.entries()) { AttributeModifier attributemodifier2 = entry1.getValue(); double d0 = attributemodifier2.getAmount(); double d1; if (attributemodifier2.getOperation() != 1 && attributemodifier2.getOperation() != 2) d1 = attributemodifier2.getAmount(); else d1 = attributemodifier2.getAmount() * 100.0D; if (d0 > 0.0D) list.add(EnumChatFormatting.BLUE + StatCollector.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier2.getOperation(), new Object[] { ItemStack.field_111284_a.format(d1), StatCollector.translateToLocal("attribute.name." + entry1.getKey()) })); else if (d0 < 0.0D) { d1 *= -1.0D; list.add(EnumChatFormatting.RED + StatCollector.translateToLocalFormatted("attribute.modifier.take." + attributemodifier2.getOperation(), new Object[] { ItemStack.field_111284_a.format(d1), StatCollector.translateToLocal("attribute.name." + entry1.getKey()) })); } } } }