Search in sources :

Example 11 with Potion

use of net.minecraft.potion.Potion in project Galacticraft by micdoodle8.

the class ItemInfo method addIDDumps.

private static void addIDDumps() {
    API.addOption(new RegistryDumper<Item>("tools.dump.item") {

        @Override
        public String[] header() {
            return new String[] { "Name", "ID", "Has Block", "Mod", "Class" };
        }

        @Override
        public String[] dump(Item item, int id, String name) {
            return new String[] { name, Integer.toString(id), Boolean.toString(Block.getBlockFromItem(item) != Blocks.air), ItemInfo.itemOwners.get(item), item.getClass().getCanonicalName() };
        }

        @Override
        public RegistryNamespaced registry() {
            return Item.itemRegistry;
        }
    });
    API.addOption(new RegistryDumper<Block>("tools.dump.block") {

        @Override
        public String[] header() {
            return new String[] { "Name", "ID", "Has Item", "Mod", "Class" };
        }

        @Override
        public String[] dump(Block item, int id, String name) {
            return new String[] { name, Integer.toString(id), Boolean.toString(Item.getItemFromBlock(item) != null), ItemInfo.itemOwners.get(item), item.getClass().getCanonicalName() };
        }

        @Override
        public RegistryNamespaced registry() {
            return Block.blockRegistry;
        }
    });
    API.addOption(new ArrayDumper<Potion>("tools.dump.potion") {

        public String[] header() {
            return new String[] { "ID", "Unlocalised name", "Class" };
        }

        @Override
        public String[] dump(Potion potion, int id) {
            return new String[] { Integer.toString(id), potion.getName(), potion.getClass().getCanonicalName() };
        }

        @Override
        public Potion[] array() {
            return Potion.potionTypes;
        }
    });
    API.addOption(new ArrayDumper<Enchantment>("tools.dump.enchantment") {

        public String[] header() {
            return new String[] { "ID", "Unlocalised name", "Type", "Min Level", "Max Level", "Class" };
        }

        @Override
        public String[] dump(Enchantment ench, int id) {
            return new String[] { Integer.toString(id), ench.getName(), ench.type.toString(), Integer.toString(ench.getMinLevel()), Integer.toString(ench.getMaxLevel()), ench.getClass().getCanonicalName() };
        }

        @Override
        public Enchantment[] array() {
            return Enchantment.enchantmentsList;
        }
    });
    API.addOption(new ArrayDumper<BiomeGenBase>("tools.dump.biome") {

        @Override
        public String[] header() {
            return new String[] { "ID", "Name", "Temperature", "Rainfall", "Spawn Chance", "Root Height", "Height Variation", "Types", "Class" };
        }

        @Override
        public String[] dump(BiomeGenBase biome, int id) {
            BiomeDictionary.Type[] types = BiomeDictionary.getTypesForBiome(biome);
            StringBuilder s_types = new StringBuilder();
            for (BiomeDictionary.Type t : types) {
                if (s_types.length() > 0) {
                    s_types.append(", ");
                }
                s_types.append(t.name());
            }
            return new String[] { Integer.toString(id), biome.biomeName, Float.toString(biome.getFloatTemperature(BlockPos.ORIGIN)), Float.toString(biome.getFloatRainfall()), Float.toString(biome.getSpawningChance()), Float.toString(biome.minHeight), Float.toString(biome.maxHeight), s_types.toString(), biome.getClass().getCanonicalName() };
        }

        @Override
        public BiomeGenBase[] array() {
            return BiomeGenBase.getBiomeGenArray();
        }
    });
    API.addOption(new ItemPanelDumper("tools.dump.itempanel"));
// TODO Fluid registry Dumper.
}
Also used : Potion(net.minecraft.potion.Potion) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase) ItemPanelDumper(codechicken.nei.config.ItemPanelDumper) BiomeDictionary(net.minecraftforge.common.BiomeDictionary) Block(net.minecraft.block.Block) Enchantment(net.minecraft.enchantment.Enchantment) RegistryNamespaced(net.minecraft.util.RegistryNamespaced)

Example 12 with Potion

use of net.minecraft.potion.Potion in project Minechem by iopleke.

the class PotionInjector method inject.

public static void inject() {
    int potionTotal = Potion.potionTypes.length;
    Potion[] effectAray = new Potion[potionTotal + 1];
    System.arraycopy(Potion.potionTypes, 0, effectAray, 0, potionTotal);
    Field field = null;
    Field[] fields = Potion.class.getDeclaredFields();
    for (Field f : fields) {
        if (f.getName().equals("potionTypes") || f.getName().equals("field_76425_a")) {
            field = f;
            break;
        }
    }
    try {
        field.setAccessible(true);
        Field modfield = Field.class.getDeclaredField("modifiers");
        modfield.setAccessible(true);
        modfield.setInt(field, field.getModifiers() & ~Modifier.FINAL);
        field.set(null, effectAray);
    } catch (Exception e) {
        LogHelper.debug("PotionInjector threw an exception:");
        LogHelper.debug(e);
    }
    atropineHigh = new PotionProvider(potionTotal, true, 0x00FF6E).setPotionName("Delirium");
}
Also used : Field(java.lang.reflect.Field) Potion(net.minecraft.potion.Potion)

Example 13 with Potion

use of net.minecraft.potion.Potion in project BetterStorage by copygirl.

the class ItemBucketSlime method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advancedTooltips) {
    String id = getSlimeId(stack);
    Handler handler = getHandler(id);
    String name = StackUtils.get(stack, (String) null, "Slime", "name");
    if ((name != null) || advancedTooltips)
        list.add("Contains: " + ((name != null) ? ("\"" + name + "\"" + (advancedTooltips ? " (" + id + ")" : "")) : id));
    NBTTagList effectList = (NBTTagList) StackUtils.getTag(stack, "Effects");
    if ((effectList != null) && (handler != null)) {
        int max = ((advancedTooltips || GuiScreen.isShiftKeyDown()) ? 6 : 3);
        for (int i = 0; i < Math.min(effectList.tagCount(), max); i++) {
            PotionEffect effect = PotionEffect.readCustomPotionEffectFromNBT(effectList.getCompoundTagAt(i));
            Potion potion = Potion.potionTypes[effect.getPotionID()];
            int duration = (int) (effect.getDuration() * handler.durationMultiplier());
            StringBuilder str = new StringBuilder().append(potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY).append(StatCollector.translateToLocal(effect.getEffectName()));
            if (effect.getAmplifier() > 0)
                str.append(" ").append(StatCollector.translateToLocal("potion.potency." + effect.getAmplifier()));
            str.append(" (").append(StringUtils.ticksToElapsedTime(duration)).append(")");
            list.add(str.toString());
        }
        int more = (effectList.tagCount() - max);
        if (more > 0)
            list.add(EnumChatFormatting.DARK_GRAY.toString() + EnumChatFormatting.ITALIC + LanguageUtils.translateTooltip("bucketSlime.more." + ((more == 1) ? "1" : "x"), "%X%", Integer.toString(more)));
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) PotionEffect(net.minecraft.potion.PotionEffect) Potion(net.minecraft.potion.Potion) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 14 with Potion

use of net.minecraft.potion.Potion in project Gaspunk by Ladysnake.

the class PotionAgent method applyEffect.

@Override
public void applyEffect(EntityLivingBase entity, IBreathingHandler handler, float concentration, boolean firstTick, float potency, boolean forced) {
    // still check for server-side because doing otherwise is stupid
    if (!entity.world.isRemote && (forced || entity.world.getWorldTime() % 20 == 0)) {
        Potion potion = getPotion();
        entity.addPotionEffect(new PotionEffect(potion, potionDuration, potionAmplifier));
    }
}
Also used : Potion(net.minecraft.potion.Potion) PotionEffect(net.minecraft.potion.PotionEffect)

Example 15 with Potion

use of net.minecraft.potion.Potion in project SpongeCommon by SpongePowered.

the class MixinPotion method onPotionRegister.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Redirect(method = "registerPotions", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/registry/RegistryNamespaced;register(ILjava/lang/Object;Ljava/lang/Object;)V"))
private static void onPotionRegister(RegistryNamespaced registry, int id, Object location, Object potion) {
    final ResourceLocation resource = (ResourceLocation) location;
    final Potion mcPotion = (Potion) potion;
    ((IMixinPotion) mcPotion).setId(resource.toString().toLowerCase(Locale.ENGLISH));
    PotionEffectTypeRegistryModule.getInstance().registerFromGameData(resource.toString(), (PotionEffectType) mcPotion);
    registry.register(id, location, potion);
}
Also used : IMixinPotion(org.spongepowered.common.interfaces.potion.IMixinPotion) Potion(net.minecraft.potion.Potion) ResourceLocation(net.minecraft.util.ResourceLocation) IMixinPotion(org.spongepowered.common.interfaces.potion.IMixinPotion) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Aggregations

Potion (net.minecraft.potion.Potion)32 PotionEffect (net.minecraft.potion.PotionEffect)18 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)3 IAttribute (net.minecraft.entity.ai.attributes.IAttribute)3 ItemStack (net.minecraft.item.ItemStack)3 Tuple (net.minecraft.util.Tuple)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 Field (java.lang.reflect.Field)2 Optional (java.util.Optional)2 Minecraft (net.minecraft.client.Minecraft)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 Item (net.minecraft.item.Item)2 PotionType (net.minecraft.potion.PotionType)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 BlockPos (net.minecraft.util.math.BlockPos)2 PotionEffectType (org.spongepowered.api.effect.potion.PotionEffectType)2 AMVector2 (am2.api.math.AMVector2)1 InventoryBaubles (baubles.common.container.InventoryBaubles)1 ChemthrowerEffect_Damage (blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Damage)1