當前位置: 首頁>>代碼示例>>Java>>正文


Java ReflectionHelper.findField方法代碼示例

本文整理匯總了Java中net.minecraftforge.fml.relauncher.ReflectionHelper.findField方法的典型用法代碼示例。如果您正苦於以下問題:Java ReflectionHelper.findField方法的具體用法?Java ReflectionHelper.findField怎麽用?Java ReflectionHelper.findField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.fml.relauncher.ReflectionHelper的用法示例。


在下文中一共展示了ReflectionHelper.findField方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shutupForge

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
/**
 * Make forge not spew "dangerous alternative prefix" messages in this block.
 */
public static void shutupForge(Runnable op) {
    Logger log = (Logger) FMLLog.log;
    try {
        Object privateConfig = ReflectionHelper.findField(Logger.class, "privateConfig").get(log);
        Field intLevelF = ReflectionHelper.findField(privateConfig.getClass(), "intLevel");
        int intLevel = (int) intLevelF.get(privateConfig);
        intLevelF.set(privateConfig, 299); // disable WARN logging

        try {
            op.run();
        } finally {
            intLevelF.set(privateConfig, intLevel);
        }
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}
 
開發者ID:DaedalusGame,項目名稱:Soot,代碼行數:21,代碼來源:Nope.java

示例2: makeOurList

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
private void makeOurList()
{
    if (serverListInternetField == null)
    {
        if (serverListInternetField == null)
        {
            serverListInternetField = ReflectionHelper.findField(ServerSelectionList.class, "field_148198_l", "serverListInternet");
            serverListInternetField.setAccessible(true);
        }
    }

    try
    {
        ourList = (List<ServerListEntryPublic>) serverListInternetField.get(this);
    }
    catch (IllegalAccessException e)
    {
        CreeperHost.logger.warn("Reflection to get server list failed.", e);
    }
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:21,代碼來源:ServerSelectionListPublic.java

示例3: setServerList

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
private void setServerList(ServerListPublic serverList)
{
    ourSavedServerList = serverList;
    if (savedServerListField == null)
    {
        savedServerListField = ReflectionHelper.findField(GuiMultiplayer.class, "field_146804_i", "savedServerList");
        savedServerListField.setAccessible(true);
    }

    try
    {
        savedServerListField.set(this, serverList);
    }
    catch (IllegalAccessException e)
    {
        CreeperHost.logger.error("Unable to set server list", e);
    }
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:19,代碼來源:GuiMultiplayerPublic.java

示例4: setLanServerDetector

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
private void setLanServerDetector(LanServerDetector.ThreadLanServerFind detector)
{
    ourLanServerDetector = detector;
    if (lanServerDetectorField == null)
    {
        lanServerDetectorField = ReflectionHelper.findField(GuiMultiplayer.class, "field_146800_B", "lanServerDetector");
        lanServerDetectorField.setAccessible(true);
    }

    try
    {
        lanServerDetectorField.set(this, detector);
    }
    catch (IllegalAccessException e)
    {
        CreeperHost.logger.error("Unable to set server list", e);
    }
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:19,代碼來源:GuiMultiplayerPublic.java

示例5: setLanServerList

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
private void setLanServerList(LanServerDetector.LanServerList detector)
{
    ourLanServerList = detector;
    if (lanServerListField == null)
    {
        lanServerListField = ReflectionHelper.findField(GuiMultiplayer.class, "field_146799_A", "lanServerList");
        lanServerListField.setAccessible(true);
    }

    try
    {
        lanServerListField.set(this, detector);
    }
    catch (IllegalAccessException e)
    {
        CreeperHost.logger.error("Unable to set server list", e);
    }
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:19,代碼來源:GuiMultiplayerPublic.java

示例6: setServerListSelector

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
private void setServerListSelector(ServerSelectionListPublic list)
{
    ourServerListSelector = list;
    if (serverListSelectorField == null)
    {
        serverListSelectorField = ReflectionHelper.findField(GuiMultiplayer.class, "field_146803_h", "serverListSelector");
        serverListSelectorField.setAccessible(true);
    }

    try
    {
        serverListSelectorField.set(this, list);
    }
    catch (IllegalAccessException e)
    {
        CreeperHost.logger.error("Unable to set server list", e);
    }
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:19,代碼來源:GuiMultiplayerPublic.java

示例7: getTabLabel

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
private static String getTabLabel(CreativeTabs tab)
{
    if (tabLabelField == null)
    {
        tabLabelField = ReflectionHelper.findField(CreativeTabs.class, "tabLabel", "field_78034_o", "o");
        tabLabelField.setAccessible(true);
    }

    try
    {
        return (String) tabLabelField.get(tab);
    } catch (IllegalAccessException e)
    {
        e.printStackTrace();
    }

    return null;
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:19,代碼來源:ItemHelper.java

示例8: initialize

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public static void initialize()
{
    inLove = ReflectionHelper.findField(EntityAnimal.class, "field_70881_d", "inLove");

    //Standard
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntityCow(world)),100));
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntitySheep(world)),100));
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntityPig(world)),100));
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntityChicken(world)),50)); //Lower chance for egg hatching animal

    //Parent species
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,mother.createChild(mother)),100));
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,father.createChild(father)),100));

    //Abominations
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnEntityAt(world,pos,new EntitySilverfish(world)),200));
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnEntityAt(world,pos,new EntityCaveSpider(world)),100));
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnEntityAt(world,pos,new EntitySlime(world)),50));

    //Enviroment dependent
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnEntityAt(world,pos,new EntitySquid(world)),0).setCustomWeight(AnimalCrossbreedHandler::getSquidWeight));
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntityWolf(world)),0).setCustomWeight(AnimalCrossbreedHandler::getWolfWeight));
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntityOcelot(world)),0).setCustomWeight(AnimalCrossbreedHandler::getOcelotWeight));
}
 
開發者ID:DaedalusGame,項目名稱:BetterWithAddons,代碼行數:25,代碼來源:AnimalCrossbreedHandler.java

示例9: getField

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
/**
 * Finds and caches a field.
 *
 * @param clazz        The class
 * @param fieldName    The unobfuscated name of the field
 * @param fieldObfName the obfuscated name of the field
 * @return The field
 */
@Nullable
public static Field getField(@Nonnull Class clazz,
                             @Nonnull String fieldName,
                             @Nonnull String fieldObfName) {
    String key = String.format("%s.%s", clazz.getName(), fieldObfName);
    Field field = null;
    if(CACHED_REFLECTION_FIELDS.containsKey(key)) {
        field = CACHED_REFLECTION_FIELDS.get(key);
    }
    if(field == null) {
        try {
            field = ReflectionHelper.findField(clazz, fieldName, fieldObfName);
            CACHED_REFLECTION_FIELDS.put(key, field);
        } catch (Exception ex) {
            WolfArmorMod.getLogger().error(ex);
            setLastError(ex);
        }
    }

    return field;
}
 
開發者ID:CenturionFox,項目名稱:wolfarmor,代碼行數:30,代碼來源:ReflectionCache.java

示例10: replaceTradeList

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public static void replaceTradeList(EntityVillager villager, MerchantRecipeList newlist) {
    if (buyingList == null)
        buyingList = ReflectionHelper.findField(EntityVillager.class, "buyingList", "field_70963_i");

    if (villager != null) {
        try {
            buyingList.set(villager, newlist);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:DaedalusGame,項目名稱:Soot,代碼行數:13,代碼來源:VillagerAntimonyHandler.java

示例11: actionPerformed

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
protected void actionPerformed(GuiButton button) throws IOException
{
    if (button.id == 0)
    {
        if (captiveConnecting != null)
        {
            if (lastNetworkManager != null)
            {
                lastNetworkManager.closeChannel(new TextComponentString("Aborted"));
            }

            try
            {
                if (cancelField == null)
                {
                    cancelField = ReflectionHelper.findField(GuiConnecting.class, "field_146373_h", "cancel");
                }
                cancelField.set(captiveConnecting, true);
            }
            catch (Throwable e)
            {

            }
        }
        this.mc.displayGuiScreen(this.parentScreen);
    }
    super.actionPerformed(button);
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:29,代碼來源:GuiProgressDisconnected.java

示例12: findFieldGetter

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public static MethodHandle findFieldGetter(Class<?> clazz, String... fieldNames) {
    final Field field = ReflectionHelper.findField(clazz, fieldNames);

    try {
        return MethodHandles.lookup().unreflectGetter(field);
    } catch (IllegalAccessException e) {
        throw new ReflectionHelper.UnableToAccessFieldException(fieldNames, e);
    }
}
 
開發者ID:TerminatorNL,項目名稱:LagGoggles,代碼行數:10,代碼來源:ConfigData.java

示例13: doImmenseEvil

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public static void doImmenseEvil() throws Exception {
    // de-finalise the grass colour field
    Field grass_color = ReflectionHelper.findField(BiomeColorHelper.class, GRASS_COLOR);
    grass_color.setAccessible(true);

    Field modifiers = Field.class.getDeclaredField("modifiers");

    AccessController.doPrivileged((PrivilegedAction) () -> {
        modifiers.setAccessible(true);
        return null;
    });

    modifiers.setInt(grass_color, grass_color.getModifiers() & ~Modifier.FINAL);

    // get the interface
    Class colorResolver = ReflectionHelper.getClass(Minecraft.class.getClassLoader(), COLOR_RESOLVER);

    // get what the field was so it can be wrapped
    Object wrappedResolver = grass_color.get(null);

    // get the version of the method used by the object to be wrapped - avoids exceptions for calling an abstract method
    Class wrappedResolverClass = wrappedResolver.getClass();
    Method wrappedGetColorAtPos = ReflectionHelper.findMethod(wrappedResolverClass, "getColorAtPos", "func_180283_a", Biome.class, BlockPos.class);

    // build a proxy
    Method getColorAtPos = ReflectionHelper.findMethod(colorResolver, "getColorAtPos", "func_180283_a", Biome.class, BlockPos.class);
    Object proxy = Proxy.newProxyInstance(colorResolver.getClassLoader(), new Class[] { colorResolver }, new GrassHandler(getColorAtPos, wrappedResolver, wrappedGetColorAtPos) );

    // set the field
    grass_color.set(null, proxy);
}
 
開發者ID:stuebz88,項目名稱:modName,代碼行數:32,代碼來源:GrassColours.java

示例14: syncRange

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public NetworkRegistry.TargetPoint syncRange() {
    if (viewRange == -1 && !world.isRemote) {
        Field f = ReflectionHelper.findField(PlayerChunkMap.class, "playerViewRadius", "field_72698_e");
        f.setAccessible(true);
        try {
            viewRange = f.getInt(((WorldServer) world).getPlayerChunkMap());
        } catch (IllegalAccessException e) {
            LogHelper.error("A THING BROKE!!!!!!!");
            e.printStackTrace();
        }
    } else if (world.isRemote) {
        LogHelper.error("Hay! Someone is doing a bad thing!!! Check your side!!!!!!!");
    }
    return new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), viewRange * 16);
}
 
開發者ID:TheDragonTeam,項目名稱:TheDragonLib,代碼行數:16,代碼來源:TileTDLBase.java

示例15: findFieldGetter

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
/**
 * Get a {@link MethodHandle} for a field's getter.
 *
 * @param clazz      The class
 * @param fieldNames The possible names of the field
 * @return The MethodHandle
 */
public static MethodHandle findFieldGetter(Class<?> clazz, String... fieldNames) {
    final Field field = ReflectionHelper.findField(clazz, fieldNames);

    try {
        return MethodHandles.lookup().unreflectGetter(field);
    } catch (IllegalAccessException e) {
        throw new ReflectionHelper.UnableToAccessFieldException(fieldNames, e);
    }
}
 
開發者ID:droidicus,項目名稱:AquaRegia,代碼行數:17,代碼來源:ReflectionUtil.java


注:本文中的net.minecraftforge.fml.relauncher.ReflectionHelper.findField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。