/** * Clears potion metadata values if the entity has no potion effects. Otherwise, updates potion effect color, * ambience, and invisibility metadata values */ protected void updatePotionMetadata() { if (this.activePotionsMap.isEmpty()) { this.resetPotionEffectMetadata(); this.setInvisible(false); } else { int i = PotionHelper.calcPotionLiquidColor(this.activePotionsMap.values()); this.dataWatcher.updateObject(8, Byte.valueOf((byte)(PotionHelper.getAreAmbient(this.activePotionsMap.values()) ? 1 : 0))); this.dataWatcher.updateObject(7, Integer.valueOf(i)); this.setInvisible(this.isPotionActive(Potion.invisibility.id)); } }
@SuppressWarnings("unchecked") public RabbitFoot() { setTextureName("rabbit_foot"); setUnlocalizedName(Utils.getUnlocalisedName("rabbit_foot")); setCreativeTab(EtFuturum.enableRabbit ? EtFuturum.creativeTab : null); if (EtFuturum.enableRabbit) try { Field f = ReflectionHelper.findField(PotionHelper.class, "potionRequirements", "field_77927_l"); f.setAccessible(true); HashMap<Integer, String> potionRequirements = (HashMap<Integer, String>) f.get(null); potionRequirements.put(Potion.jump.getId(), "0 & 1 & !2 & 3"); Field f2 = ReflectionHelper.findField(PotionHelper.class, "potionAmplifiers", "field_77928_m"); f2.setAccessible(true); HashMap<Integer, String> potionAmplifiers = (HashMap<Integer, String>) f2.get(null); potionAmplifiers.put(Potion.jump.getId(), "5"); Field f3 = ReflectionHelper.findField(Potion.class, "liquidColor", "field_76414_N"); f3.setAccessible(true); f3.set(Potion.jump, 0x22FF4C); } catch (Exception e) { } }
@Override public String getItemStackDisplayName(ItemStack stack) { if (stack.getItemDamage() == 0) return StatCollector.translateToLocal("item.emptyPotion.name").trim(); else { String s = StatCollector.translateToLocal("potion.prefix.lingering").trim() + " "; List<PotionEffect> list = getEffects(stack); String s1; if (list != null && !list.isEmpty()) { s1 = list.get(0).getEffectName(); s1 = s1 + ".postfix"; return s + StatCollector.translateToLocal(s1).trim(); } else { s1 = PotionHelper.func_77905_c(stack.getItemDamage()); return StatCollector.translateToLocal(s1).trim() + " " + super.getItemStackDisplayName(stack); } } }
/** * Registers blocks, items, stats, etc. */ public static void register() { if (!alreadyRegistered) { alreadyRegistered = true; redirectOutputToLog(); SoundEvent.registerSounds(); Block.registerBlocks(); BlockFire.init(); Potion.registerPotions(); Enchantment.registerEnchantments(); Item.registerItems(); PotionType.registerPotionTypes(); PotionHelper.init(); EntityList.init(); StatList.init(); Biome.registerBiomes(); registerDispenserBehaviors(); } }
/** * Code copied from TileEntityBrewingStand.brewPotions() * It brews the potion by doing the bit-shifting magic and then checking if the new PotionEffect list is different to the old one, * or if the new potion is a splash potion when the old one wasn't. */ @Override public ItemStack getOutput(ItemStack input, ItemStack ingredient) { if (ingredient != null && input != null && isIngredient(ingredient)) { ItemStack result = PotionHelper.doReaction(ingredient, input); if (result != input) { return result; } return null; } return null; }
/** * Registers blocks, items, stats, etc. */ public static void register() { if (!alreadyRegistered) { alreadyRegistered = true; if (LOGGER.isDebugEnabled()) { redirectOutputToLog(); } SoundEvent.registerSounds(); Block.registerBlocks(); BlockFire.init(); Potion.registerPotions(); Enchantment.registerEnchantments(); Item.registerItems(); PotionType.registerPotionTypes(); PotionHelper.init(); StatList.init(); Biome.registerBiomes(); registerDispenserBehaviors(); net.minecraftforge.fml.common.registry.GameData.vanillaSnapshot(); } }
@SubscribeEvent public static void registerPotionTypes(final RegistryEvent.Register<PotionType> event) { event.getRegistry().registerAll(PURIFICATION_TYPE, RUST_TYPE, BONE_SKIN_TYPE, RECALL_TYPE, BURNING_TYPE, BLEEDING_TYPE, INFERNO_TYPE); event.getRegistry().registerAll(HUNGER_TYPE, BLINDNESS_TYPE, NAUSEA_TYPE, RESISTANCE_TYPE, LEVITATION_TYPE); PotionHelper.addMix(PotionTypes.AWKWARD, GSItem.TOXIC_SLIME, RUST_TYPE); PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.GOLDEN_KOI.ordinal())), PURIFICATION_TYPE); PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.BONE_FISH.ordinal())), BONE_SKIN_TYPE); PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.SPECULAR_FISH.ordinal())), RECALL_TYPE); PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.MAGMA_JELLYFISH.ordinal())), BURNING_TYPE); PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.PIRANHA.ordinal())), BLEEDING_TYPE); PotionHelper.addMix(BURNING_TYPE, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.FLAREFIN_KOI.ordinal())), INFERNO_TYPE); // vanilla potions PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(Items.FISH, 1, 2)), PotionType.getPotionTypeForName("luck")); PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(Items.ROTTEN_FLESH, 1)), HUNGER_TYPE); PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.BLUE_JELLYFISH.ordinal())), NAUSEA_TYPE); PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.SPOOKYFIN.ordinal())), BLINDNESS_TYPE); PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.CAVEFISH.ordinal())), RESISTANCE_TYPE); PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.CHORUS_KOI.ordinal())), LEVITATION_TYPE); }
public void registerPotion(){ try{ Class potHepler = PotionHelper.class; Field potFields[] = potHepler.getDeclaredFields(); Field mods; mods = Field.class.getDeclaredField("modifiers"); mods.setAccessible(true); for(Field f : potFields){ if(f.getName() == "potionRequirements" || f.getName() == "field_77927_l"){ mods.setInt(f, f.getModifiers() & ~Modifier.FINAL); f.setAccessible(true); final HashMap<Integer,String> newReq = (HashMap<Integer,String>)((HashMap<Integer,String>)f.get(null)).clone(); newReq.put(HackeryMod.config.idEffectGlitch, HackeryMod.config.gfPotionReq); f.set(null, newReq); } } }catch (Exception e){ HackeryMod.logger.error("Something went wrong while registering potions!"); e.printStackTrace(); } }
public List func_77832_l(ItemStack p_77832_1_) { if(p_77832_1_.func_77942_o() && p_77832_1_.func_77978_p().func_74764_b("CustomPotionEffects")) { ArrayList var6 = new ArrayList(); NBTTagList var3 = p_77832_1_.func_77978_p().func_74761_m("CustomPotionEffects"); for(int var4 = 0; var4 < var3.func_74745_c(); ++var4) { NBTTagCompound var5 = (NBTTagCompound)var3.func_74743_b(var4); var6.add(PotionEffect.func_82722_b(var5)); } return var6; } else { List var2 = (List)this.field_77836_a.get(Integer.valueOf(p_77832_1_.func_77960_j())); if(var2 == null) { var2 = PotionHelper.func_77917_b(p_77832_1_.func_77960_j(), false); this.field_77836_a.put(Integer.valueOf(p_77832_1_.func_77960_j()), var2); } return var2; } }
public String func_77628_j(ItemStack p_77628_1_) { if(p_77628_1_.func_77960_j() == 0) { return StatCollector.func_74838_a("item.emptyPotion.name").trim(); } else { String var2 = ""; if(func_77831_g(p_77628_1_.func_77960_j())) { var2 = StatCollector.func_74838_a("potion.prefix.grenade").trim() + " "; } List var3 = Item.field_77726_bs.func_77832_l(p_77628_1_); String var4; if(var3 != null && !var3.isEmpty()) { var4 = ((PotionEffect)var3.get(0)).func_76453_d(); var4 = var4 + ".postfix"; return var2 + StatCollector.func_74838_a(var4).trim(); } else { var4 = PotionHelper.func_77905_c(p_77628_1_.func_77960_j()); return StatCollector.func_74838_a(var4).trim() + " " + super.func_77628_j(p_77628_1_); } } }
public void func_76986_a(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { Icon var10 = this.field_94151_a.func_77617_a(this.field_94150_f); if(var10 != null) { GL11.glPushMatrix(); GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_, (float)p_76986_6_); GL11.glEnable('\u803a'); GL11.glScalef(0.5F, 0.5F, 0.5F); this.func_110777_b(p_76986_1_); Tessellator var11 = Tessellator.field_78398_a; if(var10 == ItemPotion.func_94589_d("bottle_splash")) { int var12 = PotionHelper.func_77915_a(((EntityPotion)p_76986_1_).func_70196_i(), false); float var13 = (float)(var12 >> 16 & 255) / 255.0F; float var14 = (float)(var12 >> 8 & 255) / 255.0F; float var15 = (float)(var12 & 255) / 255.0F; GL11.glColor3f(var13, var14, var15); GL11.glPushMatrix(); this.func_77026_a(var11, ItemPotion.func_94589_d("overlay")); GL11.glPopMatrix(); GL11.glColor3f(1.0F, 1.0F, 1.0F); } this.func_77026_a(var11, var10); GL11.glDisable('\u803a'); GL11.glPopMatrix(); } }
public static int convertVanilla(int damage) { final List l = PotionHelper.getPotionEffects(damage, false); if (l != null && !l.isEmpty()) { final PotionEffect p = (PotionEffect) l.get(0); final Potion what = Potion.potionTypes[p.getPotionID()]; if ((what.isInstant() && p.getAmplifier() >= 1) || (p.getDuration() >= (int) (9600 * what.getEffectiveness()))) { for (int i = 0; i < validPotions.size(); ++i) { if (validPotions.get(i).id == what.id) return freshEffect(i); } } } return -1; }
@Override public void doRender(Entity par1, double par2, double par4, double par6, float par8, float par9) { GL11.glPushMatrix(); GL11.glTranslatef((float) par2, (float) par4, (float) par6); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glScalef(0.5F, 0.5F, 0.5F); this.loadTexture(AmitReference.Sprites.ITEMS_PATH + "thorshammer.png"); Tessellator var10 = Tessellator.instance; if (this.iconIndex == 154) { int var11 = PotionHelper.func_77915_a(((EntityPotion) par1).getPotionDamage(), false); float var12 = (var11 >> 16 & 255) / 255.0F; float var13 = (var11 >> 8 & 255) / 255.0F; float var14 = (var11 & 255) / 255.0F; GL11.glColor3f(var12, var13, var14); GL11.glPushMatrix(); this.func_77026_a(var10, 141); GL11.glPopMatrix(); GL11.glColor3f(1.0F, 1.0F, 1.0F); } this.func_77026_a(var10, this.iconIndex); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
public List<PotionEffect> getEffects(ItemStack stack) { if (stack.hasTagCompound() && stack.getTagCompound().hasKey("CustomPotionEffects", 9)) { List<PotionEffect> list1 = Lists.<PotionEffect>newArrayList(); NBTTagList nbttaglist = stack.getTagCompound().getTagList("CustomPotionEffects", 10); for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); PotionEffect potioneffect = PotionEffect.readCustomPotionEffectFromNBT(nbttagcompound); if (potioneffect != null) { list1.add(potioneffect); } } return list1; } else { List<PotionEffect> list = (List)this.effectCache.get(Integer.valueOf(stack.getMetadata())); if (list == null) { list = PotionHelper.getPotionEffects(stack.getMetadata(), false); this.effectCache.put(Integer.valueOf(stack.getMetadata()), list); } return list; } }
public List<PotionEffect> getEffects(int meta) { List<PotionEffect> list = (List)this.effectCache.get(Integer.valueOf(meta)); if (list == null) { list = PotionHelper.getPotionEffects(meta, false); this.effectCache.put(Integer.valueOf(meta), list); } return list; }
public String getItemStackDisplayName(ItemStack stack) { if (stack.getMetadata() == 0) { return StatCollector.translateToLocal("item.emptyPotion.name").trim(); } else { String s = ""; if (isSplash(stack.getMetadata())) { s = StatCollector.translateToLocal("potion.prefix.grenade").trim() + " "; } List<PotionEffect> list = Items.potionitem.getEffects(stack); if (list != null && !list.isEmpty()) { String s2 = ((PotionEffect)list.get(0)).getEffectName(); s2 = s2 + ".postfix"; return s + StatCollector.translateToLocal(s2).trim(); } else { String s1 = PotionHelper.getPotionPrefix(stack.getMetadata()); return StatCollector.translateToLocal(s1).trim() + " " + super.getItemStackDisplayName(stack); } } }
@Override @SideOnly(Side.CLIENT) @SuppressWarnings({ "rawtypes", "unchecked" }) public void getSubItems(Item item, CreativeTabs tab, List list) { List<ItemStack> potions = new ArrayList<ItemStack>(); ModItems.lingering_potion.getSubItems(ModItems.lingering_potion, tab, potions); for (ItemStack potion : potions) { List<PotionEffect> effects = PotionHelper.getPotionEffects(potion.getItemDamage(), false); if (effects != null && !effects.isEmpty()) for (PotionEffect effect : effects) list.add(setEffect(new ItemStack(this), Potion.potionTypes[effect.getPotionID()], effect.getDuration() / 2)); } }
private boolean canBrew() { ItemStack itemstack = (ItemStack)this.brewingItemStacks.get(3); if (itemstack.func_190926_b()) { return false; } else if (!PotionHelper.isReagent(itemstack)) { return false; } else { for (int i = 0; i < 3; ++i) { ItemStack itemstack1 = (ItemStack)this.brewingItemStacks.get(i); if (!itemstack1.func_190926_b() && PotionHelper.hasConversions(itemstack1, itemstack)) { return true; } } return false; } }
private void brewPotions() { ItemStack itemstack = (ItemStack)this.brewingItemStacks.get(3); for (int i = 0; i < 3; ++i) { this.brewingItemStacks.set(i, PotionHelper.doReaction(itemstack, (ItemStack)this.brewingItemStacks.get(i))); } itemstack.func_190918_g(1); BlockPos blockpos = this.getPos(); if (itemstack.getItem().hasContainerItem()) { ItemStack itemstack1 = new ItemStack(itemstack.getItem().getContainerItem()); if (itemstack.func_190926_b()) { itemstack = itemstack1; } else { InventoryHelper.spawnItemStack(this.world, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), itemstack1); } } this.brewingItemStacks.set(3, itemstack); this.world.playEvent(1035, blockpos, 0); }
/** * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. For * guis use Slot.isItemValid */ public boolean isItemValidForSlot(int index, ItemStack stack) { if (index == 3) { return PotionHelper.isReagent(stack); } else { Item item = stack.getItem(); return index == 4 ? item == Items.BLAZE_POWDER : (item == Items.POTIONITEM || item == Items.SPLASH_POTION || item == Items.LINGERING_POTION || item == Items.GLASS_BOTTLE) && this.getStackInSlot(index) == ItemStack.field_190927_a; } }
/** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { Icon icon = this.field_94151_a.getIconFromDamage(this.field_94150_f); if (icon != null) { GL11.glPushMatrix(); GL11.glTranslatef((float)par2, (float)par4, (float)par6); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glScalef(0.5F, 0.5F, 0.5F); this.bindEntityTexture(par1Entity); Tessellator tessellator = Tessellator.instance; if (icon == ItemPotion.func_94589_d("bottle_splash")) { int i = PotionHelper.func_77915_a(((EntityPotion)par1Entity).getPotionDamage(), false); float f2 = (float)(i >> 16 & 255) / 255.0F; float f3 = (float)(i >> 8 & 255) / 255.0F; float f4 = (float)(i & 255) / 255.0F; GL11.glColor3f(f2, f3, f4); GL11.glPushMatrix(); this.func_77026_a(tessellator, ItemPotion.func_94589_d("overlay")); GL11.glPopMatrix(); GL11.glColor3f(1.0F, 1.0F, 1.0F); } this.func_77026_a(tessellator, icon); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); } }
private boolean canBrew() { if (this.brewingItemStacks[3] != null && this.brewingItemStacks[3].stackSize > 0 && false) // Code moved to net.minecraftforge.common.brewing.VanillaBrewingRecipe { ItemStack itemstack = this.brewingItemStacks[3]; if (!PotionHelper.isReagent(itemstack)) { return false; } else { for (int i = 0; i < 3; ++i) { ItemStack itemstack1 = this.brewingItemStacks[i]; if (itemstack1 != null && PotionHelper.hasConversions(itemstack1, itemstack)) { return true; } } return false; } } else { return net.minecraftforge.common.brewing.BrewingRecipeRegistry.canBrew(brewingItemStacks, brewingItemStacks[3], OUTPUT_SLOTS); } }
public static void genPotionLevels() { XUHelper.resetTimer(); final HashSet<Item> ingredientIDs = new HashSet<Item>(); final List<Integer> potionIDs = new ArrayList<Integer>(); for (final Object anItemRegistry : Item.itemRegistry) { final Item i = (Item)anItemRegistry; for (int num = getMaxMeta(i), meta = 0; meta < num; ++meta) { if (i.isPotionIngredient(new ItemStack(i, 1, meta))) { ingredientIDs.add(i); } } } TileEntityGeneratorPotion.powerMap.put(0, 0); potionIDs.add(0); for (int j = 0; j < potionIDs.size(); ++j) { final int potion = potionIDs.get(j); for (final Item ingredient : ingredientIDs) { String k = ""; String s = ""; for (int num2 = getMaxMeta(ingredient), meta2 = 0; meta2 < num2 || !k.equals(s); ++meta2) { if (ingredient.isPotionIngredient(new ItemStack(ingredient, 1, meta2))) { try { s = ingredient.getPotionEffect(new ItemStack(ingredient, 1, meta2)); final int c = PotionHelper.applyIngredient(potion, s); if (!potionIDs.contains(c)) { potionIDs.add(c); TileEntityGeneratorPotion.powerMap.put(c, TileEntityGeneratorPotion.powerMap.get(potion) + 1); } k = ((s == null) ? "" : s); } catch (Exception err) { throw new RuntimeException("Caught error while applying potion ingredient " + ingredient.toString() + " to " + potion, err); } } } } } XUHelper.printTimer("Potion generation"); }
public static void initRecipes() { PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromItem(Items.EMERALD), TQPotionTypes.ROYALTY); PotionHelper.addMix(TQPotionTypes.ROYALTY, Ingredient.fromItem(Items.REDSTONE), TQPotionTypes.ROYALTY_LONG); PotionHelper.addMix(TQPotionTypes.ROYALTY, Ingredient.fromItem(Items.GLOWSTONE_DUST), TQPotionTypes.ROYALTY_STRONG); PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromItem(Items.DIAMOND), TQPotionTypes.LOYALTY); PotionHelper.addMix(TQPotionTypes.LOYALTY, Ingredient.fromItem(Items.REDSTONE), TQPotionTypes.LOYALTY_LONG); PotionHelper.addMix(TQPotionTypes.LOYALTY, Ingredient.fromItem(Items.GLOWSTONE_DUST), TQPotionTypes.LOYALTY_STRONG); }
public void addVanillaBrewingRecipes(ArrayList<DrawableRecipe> recipes) { ArrayList<ItemStack> ingredients = new ArrayList<ItemStack>(); ArrayList<Object> typeConversions = ReflectionHelper.getPrivateValue(PotionHelper.class, null, 0); ArrayList<Object> itemConversions = ReflectionHelper.getPrivateValue(PotionHelper.class, null, 1); addIngredients(ingredients, typeConversions); addIngredients(ingredients, itemConversions); ArrayList<ItemStack> knownPotions = new ArrayList<ItemStack>(); ItemStack waterBottle = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.WATER); knownPotions.add(waterBottle); int brewingStep = 1; boolean foundNewPotions; do { List<ItemStack> newPotions = getNewPotions(knownPotions, ingredients, recipes); foundNewPotions = !newPotions.isEmpty(); knownPotions.addAll(newPotions); brewingStep++; if (brewingStep > 100) { FMLCommonHandler.instance().raiseException(null, "Calculation of vanilla brewing recipes is broken, aborting after 100 brewing steps.", false); return; } } while (foundNewPotions); }