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; }
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); } }
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; } }
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(); } }
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; }
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; }
@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); }
@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; } }
@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; }
@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]); }
@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; }
@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; }
@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"); } } }
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; }
@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"); } }
/** * 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); } } }
@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));*/ }
@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"); } }
/** * 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); } } }
/** * 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; }
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"}); }
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); }
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; } }
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(); } }
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(); } }
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(); } }
@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"))); } }
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); } }
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; } }
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"); }
@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); } }
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(); } }
/** * 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); }