Java 类cpw.mods.fml.common.ObfuscationReflectionHelper 实例源码

项目:ExtraUtilities    文件:TConTextureResourcePackBedrockium.java   
public static BufferedImage getBedrockImage() {
    if (TConTextureResourcePackBedrockium.bedrockImage == null) {
        final ResourceLocation bedrockLocation = new ResourceLocation("minecraft", "textures/blocks/bedrock.png");
        try {
            final DefaultResourcePack mcDefaultResourcePack = (DefaultResourcePack)ObfuscationReflectionHelper.getPrivateValue((Class)Minecraft.class, (Object)Minecraft.getMinecraft(), new String[] { "field_110450_ap", "mcDefaultResourcePack" });
            InputStream inputStream = mcDefaultResourcePack.getInputStream(bedrockLocation);
            final List<ResourcePackRepository.Entry> t = (List<ResourcePackRepository.Entry>)Minecraft.getMinecraft().getResourcePackRepository().getRepositoryEntries();
            for (final ResourcePackRepository.Entry entry : t) {
                final IResourcePack resourcePack = entry.getResourcePack();
                if (resourcePack.resourceExists(bedrockLocation)) {
                    inputStream = resourcePack.getInputStream(bedrockLocation);
                }
            }
            TConTextureResourcePackBedrockium.bedrockImage = ImageIO.read(inputStream);
        }
        catch (IOException e) {
            throw Throwables.propagate((Throwable)e);
        }
    }
    return TConTextureResourcePackBedrockium.bedrockImage;
}
项目:FiveNightsAtFreddysUniverseMod    文件:GuiOverride.java   
public void drawScreen(int mouseX, int mouseY, float partalTicks)
{
    super.drawScreen(mouseX, mouseY, partalTicks);
       List buttonList = ObfuscationReflectionHelper.getPrivateValue(GuiScreen.class, overriddenScreen, "buttonList", "field_146292_n");
       List labelList = ObfuscationReflectionHelper.getPrivateValue(GuiScreen.class, overriddenScreen, "labelList", "field_146293_o");
       int k1;

       for (k1 = 0; k1 < buttonList.size(); ++k1)
       {
        ((GuiButton)buttonList.get(k1)).drawButton(mc, mouseX, mouseY);
       }

       for (k1 = 0; k1 < labelList.size(); ++k1)
       {
        ((GuiLabel)labelList.get(k1)).func_146159_a(mc, mouseX, mouseY);
       }
}
项目:bfsr    文件:BfsrRegenTutorialDimension.java   
protected void overwriteTutorialWorld()
{
    Minecraft mc = Minecraft.getMinecraft();

    File mcDataDir = mc.mcDataDir;

    String folderName = ObfuscationReflectionHelper.getPrivateValue(BfsrRegenTutorialDimension.class, this, folderNameObfuscated);

    try
    {
        FileUtils.copyDirectory(new File(mcDataDir.getAbsoluteFile() + File.separator + templateName + File.separator + tutorialDimensionFolder),
                new File(mcDataDir.getAbsoluteFile() + File.separator + "saves" + File.separator + folderName + File.separator + tutorialDimensionFolder));
    }
    catch (IOException e)
    {
        FMLLog.info("The template world does not exist at " + templateName, e);
        return;
    }
}
项目:ThaumicThings    文件:ReflectionHelper.java   
public static <T, E> void setPrivateFinalWithValue(Class<? super T> c, T obj, E value, String... fieldNames)
{
    Field field = cpw.mods.fml.relauncher.ReflectionHelper.findField(c, ObfuscationReflectionHelper.remapFieldNames(c.getName(), fieldNames));

    try
    {
        Field e = Field.class.getDeclaredField("modifiers");
        e.setAccessible(true);
        e.setInt(field, field.getModifiers() & -17);
        field.set(obj, value);
    } catch (Exception var6)
    {
        var6.printStackTrace();
    }

}
项目:DaVincing    文件:SculptureRenderCompiler.java   
private double[] getTesOffsets() {
  double[] off = new double[3];

  int count = 0;
  int xoff = 0;
  Field[] fields = Tessellator.class.getDeclaredFields();
  for (int i = 0; i < fields.length; i++) {
    if (fields[i].getType() == double.class) {
      count++;
      if (count == 3) {
        xoff = i - 2;
      }
    } else {
      count = 0;
    }
  }

  off[0] = ObfuscationReflectionHelper.getPrivateValue(Tessellator.class, Tessellator.instance, xoff);
  off[1] = ObfuscationReflectionHelper.getPrivateValue(Tessellator.class, Tessellator.instance, xoff + 1);
  off[2] = ObfuscationReflectionHelper.getPrivateValue(Tessellator.class, Tessellator.instance, xoff + 2);

  return off;
}
项目:minepainter    文件:SculptureRenderCompiler.java   
private double[] getTesOffsets(){
    double[] off = new double[3];

    int count = 0;
    int xoff = 0;
    Field[] fields = Tessellator.class.getDeclaredFields();
    for(int i = 0;i < fields.length; i++)
        if(fields[i].getType() == double.class){
            count++;
            if(count == 3)xoff = i-2;
        }else
            count = 0;

    off[0] = ObfuscationReflectionHelper.getPrivateValue(Tessellator.class, Tessellator.instance, xoff  );
    off[1] = ObfuscationReflectionHelper.getPrivateValue(Tessellator.class, Tessellator.instance, xoff+1);
    off[2] = ObfuscationReflectionHelper.getPrivateValue(Tessellator.class, Tessellator.instance, xoff+2);

    return off;
}
项目:Metallurgy4    文件:Metallurgy.java   
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
    LogHandler.setLog(event.getModLog());
    ConfigHandler.setFile(event.getSuggestedConfigurationFile());

    Object value = ObfuscationReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "canonicalModsDir");

    if (value instanceof File)
    {
        this.modsFolder = (File) value;
    }

    Configs.init();
    BlockList.init();
    ItemList.init();
    BucketsHandler.instance.init();

    initTabs();

    Integration.preinit(event);
}
项目:CubesEdge    文件:MovementSlowClient.java   
@Override
public void controlClient(EntityPlayerCustom playerCustom, EntityPlayer player) {
    if (keyPressedSlow && !playerCustom.slow) {
        ObfuscationReflectionHelper.setPrivateValue(Timer.class,
                ((Timer) ObfuscationReflectionHelper.getPrivateValue(
                        Minecraft.class, Minecraft.getMinecraft(), 16)),
                5F, 0);
        playerCustom.slow = true;
    }
    if (playerCustom.slow) {
        playerCustom.slowTime++;
    }
    if (playerCustom.slowTime == 25 && playerCustom.slow) {
        ObfuscationReflectionHelper.setPrivateValue(Timer.class,
                ((Timer) ObfuscationReflectionHelper.getPrivateValue(
                        Minecraft.class, Minecraft.getMinecraft(), 16)),
                20F, 0);
        playerCustom.slowTime = 0;
        Minecraft.getMinecraft().gameSettings.mouseSensitivity = defaultSensitivity;
        keyPressedSlow = false;
        playerCustom.slow = false;
    }
}
项目:recipedumper    文件:ShapedOreModule.java   
@Override
public String generateDescription() {
    if(description!=null) return description;
    description = getPrefix()+"!";
    int width =  (Integer) ObfuscationReflectionHelper.getPrivateValue(ShapedOreRecipe.class, sr, 4);
    int height = (Integer) ObfuscationReflectionHelper.getPrivateValue(ShapedOreRecipe.class, sr, 5);
    Object[] items = ObfuscationReflectionHelper.getPrivateValue(ShapedOreRecipe.class, sr, 3);

    description += Formatter.getWHString(width, height);

    for(Object o : items)
    {
        if(o == null) {
            description += "(None)";
        } else if (o instanceof ItemStack) {
            description+=Formatter.getISDescription((ItemStack) o);
        } else {
            description+=Formatter.getItemOreDescription(o);
        }
    }
    ItemStack result = sr.getRecipeOutput();
    description+="->"+Formatter.getISDescription(result);

    return description;
}
项目:recipedumper    文件:SmeltingModule.java   
@Override
public IRecipeData[] getAllRecipes() {
    ArrayList<IRecipeData> list = new ArrayList<IRecipeData>();

    Map<Integer, ItemStack> smeltingList = ObfuscationReflectionHelper.getPrivateValue(FurnaceRecipes.class, FurnaceRecipes.smelting(), 1);

    for(int id : smeltingList.keySet()) {
        ItemStack source = new ItemStack(id, 1, -1);
        ItemStack target = smeltingList.get(id);
        list.add(new RecipeData(source, target));
    }

    for(Entry<List<Integer>, ItemStack> smEntry: FurnaceRecipes.smelting().getMetaSmeltingList().entrySet()) {
        List<Integer> sourceItemIDandMeta = smEntry.getKey();
        ItemStack targetItemstack = smEntry.getValue();
        if (sourceItemIDandMeta.size() == 2) {
            list.add(new RecipeData(
                    new ItemStack(sourceItemIDandMeta.get(0), 1, sourceItemIDandMeta.get(1))
                    , targetItemstack));
        }
    }

    return list.toArray(new IRecipeData[0]);
}
项目:recipedumper    文件:ShapedRecipesModule.java   
@Override
public String generateDescription() {
    if(this.description!=null) return this.description;

    description = getPrefix()+"!";
    int width = (Integer) ObfuscationReflectionHelper.getPrivateValue(ShapedRecipes.class, sr, 0);
    int height = (Integer) ObfuscationReflectionHelper.getPrivateValue(ShapedRecipes.class, sr, 1);
    ItemStack[] items = (ItemStack[]) ObfuscationReflectionHelper.getPrivateValue(ShapedRecipes.class, sr, 2);

    description += Formatter.getWHString(width, height);

    for (ItemStack is: items) {
        description += Formatter.getISDescription(is);
    }

    ItemStack result = sr.getRecipeOutput();
    description += "->" + Formatter.getISDescription(result);

    return this.description;
}
项目:recipedumper    文件:ShapelessOreModule.java   
@Override
    public String generateDescription() {
        if(description!=null) return description;

        description = getPrefix()+"!";
        ArrayList items = ObfuscationReflectionHelper.getPrivateValue(ShapelessOreRecipe.class, sr, 1);
        for(Object o : items)
        {
            if(o instanceof ItemStack)
            {
    description += Formatter.getISDescription((ItemStack) o);
} else {
    description += Formatter.getItemOreDescription(o);
}                
        }
        ItemStack result = sr.getRecipeOutput();
        description+="->"+Formatter.getISDescription(result);

        return description;
    }
项目:TPPI-Tweaks    文件:TPPIEventHandler.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onGui(GuiOpenEvent event)
{
    if (event.gui instanceof GuiMainMenu)
    {
        if (shouldLoadGUI && ConfigurationHandler.showIRCGui)
        {
            event.gui = new IRCGui();
            shouldLoadGUI = false;
        }
        else
        {
            ObfuscationReflectionHelper.setPrivateValue(GuiMainMenu.class, (GuiMainMenu) event.gui, getRandTPPISplash(), "splashText", "field_73975_c");
        }
    }
}
项目:ExtraUtilities    文件:TConTextureResourcePackBase.java   
public List<IResourcePack> getiResourcePacks() {
    List<IResourcePack> packs1 = TConTextureResourcePackBase.packs;
    if (packs1 == null) {
        packs1 = (List<IResourcePack>)ObfuscationReflectionHelper.getPrivateValue((Class)FMLClientHandler.class, (Object)FMLClientHandler.instance(), new String[] { "resourcePackList" });
    }
    return packs1;
}
项目:TRHS_Club_Mod_2016    文件:FMLClientHandler.java   
@Override
public void serverStopped()
{
    // If the server crashes during startup, it might hang the client- reset the client so it can abend properly.
    MinecraftServer server = getServer();

    if (server != null && !server.func_71200_ad())
    {
        ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, true, "field_71296"+"_Q","serverIs"+"Running");
    }
}
项目:TRHS_Club_Mod_2016    文件:GameRegistry.java   
/**
 * Register a tile entity, with alternative TileEntity identifiers. Use with caution!
 * This method allows for you to "rename" the 'id' of the tile entity.
 *
 * @param tileEntityClass The tileEntity class to register
 * @param id The primary ID, this will be the ID that the tileentity saves as
 * @param alternatives A list of alternative IDs that will also map to this class. These will never save, but they will load
 */
public static void registerTileEntityWithAlternatives(Class<? extends TileEntity> tileEntityClass, String id, String... alternatives)
{
    TileEntity.func_145826_a(tileEntityClass, id);
    Map<String,Class<?>> teMappings = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "145855_i", "nameToClassMap");
    for (String s: alternatives)
    {
        if (!teMappings.containsKey(s))
        {
            teMappings.put(s, tileEntityClass);
        }
    }
}
项目:Coding    文件:VillagerBakeryTradeHandler.java   
@Override
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random rand) 
{
       Calendar calendar = Calendar.getInstance();

       if((calendar.get(2) + 1 == 10 && calendar.get(5) >= 28 && calendar.get(5) <= 31) || (calendar.get(2) + 1 == 11 && calendar.get(5) >= 1 && calendar.get(5) <= 2))
       {  
        isHalloween = true;
    }
       else
       {
        isHalloween = false;
       }

       baseChance = ObfuscationReflectionHelper.<Float, EntityVillager>getPrivateValue(EntityVillager.class, villager, "field_82191_bN");
       if(!isHalloween)
       {
        addTrade(recipeList, rand, 0.7F, new Offer(Items.bread, 2), new Offer(Items.emerald, 1));
        addTrade(recipeList, rand, 0.7F, new Offer(Items.emerald, 3), new Offer(Items.bread, 2));

        addTrade(recipeList, rand, 0.7F, new Offer(Items.bread, 6), new Offer(Items.wheat, 16));
       }
       else
       {
        addTrade(recipeList, rand, 0.7F, new Offer(Items.string, 6), new Offer(Items.emerald, 1));
        addTrade(recipeList, rand, 0.7F, new Offer(Items.apple, 3), new Offer(Items.emerald, 1));

        addTrade(recipeList, rand, 0.7F, new Offer(Item.getItemFromBlock(Blocks.netherrack), 64), new Offer(Item.getItemFromBlock(Blocks.cobblestone), 64));
        addTrade(recipeList, rand, 0.7F, new Offer(Item.getItemFromBlock(Blocks.cobblestone), 64), new Offer(Item.getItemFromBlock(Blocks.netherrack), 64));

        addTrade(recipeList, rand, 0.7F, new Offer(Item.getItemFromBlock(Blocks.pumpkin), 2), new Offer(Items.emerald, 1));
        addTrade(recipeList, rand, 0.7F, new Offer(Item.getItemFromBlock(Blocks.lit_pumpkin), 2), new Offer(Items.emerald, 2));
       }
    /*   addTrade(recipeList, rand, 0.7F, new Offer(Items.fish, 3), new Offer(Items.emerald, 1));
       addTrade(recipeList, rand, 0.7F, new Offer(Items.emerald, 5), new Offer(Items.fish, 8));*/
}
项目:CauldronGit    文件:FMLClientHandler.java   
@Override
public void serverStopped()
{
    // If the server crashes during startup, it might hang the client- reset the client so it can abend properly.
    MinecraftServer server = getServer();

    if (server != null && !server.serverIsInRunLoop())
    {
        ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, true, "field_71296"+"_Q","serverIs"+"Running");
    }
}
项目:CauldronGit    文件:GameRegistry.java   
/**
 * Register a tile entity, with alternative TileEntity identifiers. Use with caution!
 * This method allows for you to "rename" the 'id' of the tile entity.
 *
 * @param tileEntityClass The tileEntity class to register
 * @param id The primary ID, this will be the ID that the tileentity saves as
 * @param alternatives A list of alternative IDs that will also map to this class. These will never save, but they will load
 */
public static void registerTileEntityWithAlternatives(Class<? extends TileEntity> tileEntityClass, String id, String... alternatives)
{
    TileEntity.addMapping(tileEntityClass, id);
    Map<String,Class<?>> teMappings = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "145855_i", "nameToClassMap");
    for (String s: alternatives)
    {
        if (!teMappings.containsKey(s))
        {
            teMappings.put(s, tileEntityClass);
        }
    }
}
项目:EnderCore    文件:TechneUtil.java   
/**
 * Use this to convert TechneModel to it's static representation
 */
@SuppressWarnings("unchecked")
public static Map<String, GroupObject> bakeModel(TechneModel model, float scale, Matrix4f m, boolean rotateYFirst) {
  Map<String, ModelRenderer> parts = (Map<String, ModelRenderer>) ObfuscationReflectionHelper.getPrivateValue(TechneModel.class, model, "parts");
  Map<String, GroupObject> res = Maps.newHashMap();

  for (Map.Entry<String, ModelRenderer> e : parts.entrySet()) {
    GroupObject obj = bakeModel(e.getValue(), model, scale, m, rotateYFirst).get(0);
    res.put(e.getKey(), obj);
  }

  return res;
}
项目:Gravitation-Suite-Reloaded    文件:ItemElectricArmorJetpack.java   
public void resetPlayerInAirTime(EntityPlayer player) {
    if (!(player instanceof EntityPlayerMP)) {
        return;
    }

    ObfuscationReflectionHelper.setPrivateValue(NetHandlerPlayServer.class, ((EntityPlayerMP) player).playerNetServerHandler,
            Integer.valueOf(0), new String[]{"field_147365_f", "floatingTickCount"});
}
项目:Gadomancy    文件:TileInfusionClaw.java   
private void loadResearch(EntityPlayer fakePlayer) {
    boolean online = false;
    for(String username : MinecraftServer.getServer().getAllUsernames()) {
        if(username.equals(player)) {
            online = true;
            break;
        }
    }

    if(online) {
        this.research = ResearchManager.getResearchForPlayer(player);
    } else {
        if(research == null) {
            Thaumcraft.proxy.getCompletedResearch().put(fakePlayer.getCommandSenderName(), new ArrayList<String>());

            IPlayerFileData playerNBTManagerObj = MinecraftServer.getServer().worldServerForDimension(0).getSaveHandler().getSaveHandler();
            SaveHandler sh = (SaveHandler)playerNBTManagerObj;
            File dir = ObfuscationReflectionHelper.getPrivateValue(SaveHandler.class, sh, "playersDirectory", "field_75771_c");
            File file1 = new File(dir, player + ".thaum");
            File file2 = new File(dir, player + ".thaumbak");
            ResearchManager.loadPlayerData(fakePlayer, file1, file2, false);

            this.research = ResearchManager.getResearchForPlayerSafe(fakePlayer.getCommandSenderName());
        }
    }

    Thaumcraft.proxy.getCompletedResearch().put(fakePlayer.getCommandSenderName(), research == null ? new ArrayList<String>() : research);
}
项目:CustomAI    文件:GuiComboBox.java   
public void drawButton(Minecraft mc, int mx, int my)
    {
        if (this.visible)
        {
//            if(drawList)
//            {
//                list.render(mc, mx, my);
//            }
            ObfuscationReflectionHelper.setPrivateValue(GuiTextField.class, field, xPosition, 1);
            ObfuscationReflectionHelper.setPrivateValue(GuiTextField.class, field, yPosition, 2);
            list.xPos = this.xPosition;
            list.yPos = this.yPosition+height;
            field.drawTextBox();
            mc.getTextureManager().bindTexture(GuiSpinnerButton.spinnerTextures);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            this.field_146123_n = mx >= this.xPosition && my >= this.yPosition && mx < this.xPosition + this.width && my < this.yPosition + this.height;
            GL11.glEnable(GL11.GL_BLEND);
            OpenGlHelper.glBlendFunc(770, 771, 1, 0);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

            boolean arrowHovered = mx >= this.xPosition +width-12 && mx <= this.xPosition+width && my >= yPosition && my <= yPosition + height;
            func_146110_a(xPosition+width-12, yPosition+height/2-7/2, 0, arrowHovered ? 7 : 0, 11, 7, 22, 14);
            this.mouseDragged(mc, mx, my);

            int k = this.getHoverState(this.field_146123_n);
            int l = 14737632;

        }
    }
项目:CustomAI    文件:CustomAIHelper.java   
private static void clearExecutingTargetTasks(Entity entity)
{
    if(hasEntityAI(entity))
    {
        EntityLiving living = (EntityLiving)entity;
        EntityAITasks targetTasks = living.tasks;
        ((List<?>)ObfuscationReflectionHelper.getPrivateValue(EntityAITasks.class, targetTasks, 2)).clear();
    }
}
项目:CustomAI    文件:CustomAIHelper.java   
private static void clearExecutingTasks(Entity entity)
{
    if(hasEntityAI(entity))
    {
        EntityLiving living = (EntityLiving)entity;
        EntityAITasks tasks = living.tasks;
        ((List<?>)ObfuscationReflectionHelper.getPrivateValue(EntityAITasks.class, tasks, 2)).clear();
    }
}
项目:MiscUtils    文件:LocalizationUpdater.java   
public static void inject(HashMap<String, String> map) {
    try {
        Map<String, String> languageMap = ObfuscationReflectionHelper.getPrivateValue(StringTranslate.class, getInstance(), LANGUAGE_MAP);
        languageMap.putAll(map);
        ObfuscationReflectionHelper.setPrivateValue(StringTranslate.class, getInstance(), System.currentTimeMillis(), LAST_UPDATE);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
项目:RecipeIGE    文件:RIGETickHandler.java   
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData)
{
    if (FMLCommonHandler.instance().getEffectiveSide().isClient() && Minecraft.getMinecraft().currentScreen instanceof GuiContainerCreative)
    {
        GuiContainerCreative gui = (GuiContainerCreative) Minecraft.getMinecraft().currentScreen;
        List<GuiButton> buttons = ObfuscationReflectionHelper.<List<GuiButton>, GuiScreen> getPrivateValue(GuiScreen.class, Minecraft.getMinecraft().currentScreen, "buttonList", "field_73887_h");
        if (buttons.size() > 2)
            buttons.remove(2);
        buttons.add(new SmallButton(10, 0, (Integer) ObfuscationReflectionHelper.getPrivateValue(GuiContainer.class, gui, "guiLeft", "field_74198_m"), (Integer) ObfuscationReflectionHelper
                .getPrivateValue(GuiContainer.class, gui, "guiTop", "field_74197_n")));
    }
}
项目:ZeroQuest    文件:ThirdPersonCameraAccessor.java   
public void setThirdPersonDistance(float dist) {
    try {
        ObfuscationReflectionHelper.setPrivateValue(EntityRenderer.class, renderer, dist, FIELDS_THIRDPERSONDISTANCE);
    } catch (Exception ex) {
        L.log(Level.WARNING, "Can't set third person distance!", ex);
    }
}
项目:ZeroQuest    文件:ThirdPersonCameraAccessor.java   
public float getThirdPersonDistance() {
    try {
        return (Float) ObfuscationReflectionHelper.getPrivateValue(EntityRenderer.class, renderer, FIELDS_THIRDPERSONDISTANCE);
    } catch (Exception ex) {
        L.log(Level.WARNING, "Can't get third person distance!", ex);
        return 0;
    }
}
项目:IgnitionUtilities    文件:WorldChunkManagerIG.java   
public WorldChunkManagerIG(World world)
{
    super();

       GenLayer[] agenlayer = GenLayerBiomeIG.initializeAllBiomeGenerators(world.getSeed(), world.getWorldInfo().getTerrainType());
       agenlayer = getModdedBiomeGenerators(world.getWorldInfo().getTerrainType(), world.getSeed(), agenlayer);
       ObfuscationReflectionHelper.setPrivateValue(WorldChunkManager.class, this, agenlayer[0], "genBiomes", "field_76944_d");
       ObfuscationReflectionHelper.setPrivateValue(WorldChunkManager.class, this, agenlayer[1], "biomeIndexLayer", "field_76945_e");
}
项目:Metallurgy4    文件:ClientProxy.java   
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void injectZipAsResource(String zipDir)
{

    Object value = ObfuscationReflectionHelper.getPrivateValue(Minecraft.class, FMLClientHandler.instance().getClient(), "field_110449_ao", "defaultResourcePacks");

    if (value instanceof List)
    {
        FileResourcePack pack = new FileResourcePack(new File(zipDir));

        ((List) value).add(pack);
    }
}
项目:HarvestCraftWaila    文件:IconFixer.java   
public void setBlockIcon(Block block, Icon icon)
{
    if (block == null || icon == null)
        return;

    try
    {
        ReflectionHelper.setPrivateValue(Block.class, block, icon, ObfuscationReflectionHelper.remapFieldNames(Block.class.getName(), "blockIcon", "field_94336_cN", "cW"));
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}
项目:SecurityCraft    文件:ClientUtils.java   
/**
 * Sets the "zoom" of the client's view.
 *
 * Only works on the CLIENT side.
 */
@SideOnly(Side.CLIENT)
public static void setCameraZoom(double zoom){
    if(zoom == 0){
        ObfuscationReflectionHelper.setPrivateValue(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, 1.0D, 46);
        return;
    }

    double tempZoom = ObfuscationReflectionHelper.getPrivateValue(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, 46);
    ObfuscationReflectionHelper.setPrivateValue(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, tempZoom + zoom, 46);
}
项目:CosmeticArmor    文件:LocalizationUpdater.java   
public static void inject(HashMap<String, String> map) {
    try {
        Map<String, String> languageMap = ObfuscationReflectionHelper.getPrivateValue(StringTranslate.class, getInstance(), LANGUAGE_MAP);
        languageMap.putAll(map);
        ObfuscationReflectionHelper.setPrivateValue(StringTranslate.class, getInstance(), System.currentTimeMillis(), LAST_UPDATE);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
项目:Cauldron    文件:FMLClientHandler.java   
@Override
public void serverStopped()
{
    // If the server crashes during startup, it might hang the client- reset the client so it can abend properly.
    MinecraftServer server = getServer();

    if (server != null && !server.serverIsInRunLoop())
    {
        ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, true, "field_71296"+"_Q","serverIs"+"Running");
    }
}
项目:Cauldron    文件:GameRegistry.java   
/**
 * Register a tile entity, with alternative TileEntity identifiers. Use with caution!
 * This method allows for you to "rename" the 'id' of the tile entity.
 *
 * @param tileEntityClass The tileEntity class to register
 * @param id The primary ID, this will be the ID that the tileentity saves as
 * @param alternatives A list of alternative IDs that will also map to this class. These will never save, but they will load
 */
public static void registerTileEntityWithAlternatives(Class<? extends TileEntity> tileEntityClass, String id, String... alternatives)
{
    TileEntity.addMapping(tileEntityClass, id);
    Map<String,Class<?>> teMappings = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "145855_i", "nameToClassMap");
    for (String s: alternatives)
    {
        if (!teMappings.containsKey(s))
        {
            teMappings.put(s, tileEntityClass);
        }
    }
}
项目:Cauldron    文件:FMLClientHandler.java   
@Override
public void serverStopped()
{
    // If the server crashes during startup, it might hang the client- reset the client so it can abend properly.
    MinecraftServer server = getServer();

    if (server != null && !server.serverIsInRunLoop())
    {
        ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, true, "field_71296"+"_Q","serverIs"+"Running");
    }
}
项目:Cauldron    文件:GameRegistry.java   
/**
 * Register a tile entity, with alternative TileEntity identifiers. Use with caution!
 * This method allows for you to "rename" the 'id' of the tile entity.
 *
 * @param tileEntityClass The tileEntity class to register
 * @param id The primary ID, this will be the ID that the tileentity saves as
 * @param alternatives A list of alternative IDs that will also map to this class. These will never save, but they will load
 */
public static void registerTileEntityWithAlternatives(Class<? extends TileEntity> tileEntityClass, String id, String... alternatives)
{
    TileEntity.addMapping(tileEntityClass, id);
    Map<String,Class<?>> teMappings = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "145855_i", "nameToClassMap");
    for (String s: alternatives)
    {
        if (!teMappings.containsKey(s))
        {
            teMappings.put(s, tileEntityClass);
        }
    }
}
项目:Cauldron    文件:FMLClientHandler.java   
@Override
public void serverStopped()
{
    // If the server crashes during startup, it might hang the client- reset the client so it can abend properly.
    MinecraftServer server = getServer();

    if (server != null && !server.serverIsInRunLoop())
    {
        ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, true, "field_71296"+"_Q","serverIs"+"Running");
    }
}
项目:Cauldron    文件:GameRegistry.java   
/**
 * Register a tile entity, with alternative TileEntity identifiers. Use with caution!
 * This method allows for you to "rename" the 'id' of the tile entity.
 *
 * @param tileEntityClass The tileEntity class to register
 * @param id The primary ID, this will be the ID that the tileentity saves as
 * @param alternatives A list of alternative IDs that will also map to this class. These will never save, but they will load
 */
public static void registerTileEntityWithAlternatives(Class<? extends TileEntity> tileEntityClass, String id, String... alternatives)
{
    TileEntity.addMapping(tileEntityClass, id);
    Map<String,Class<?>> teMappings = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "145855_i", "nameToClassMap");
    for (String s: alternatives)
    {
        if (!teMappings.containsKey(s))
        {
            teMappings.put(s, tileEntityClass);
        }
    }
}