From 5655fd39f563875768e9ad21441a8294380373aa Mon Sep 17 00:00:00 2001 From: Vasco Lavos Date: Tue, 22 Jul 2014 16:02:30 +0100 Subject: [PATCH] Removed Capes before Grum throws a hissy fit. --- .../client/core/handler/CapeHandler.java | 78 ------------------- MODSRC/vazkii/botania/test/Corruption.java | 65 ---------------- 2 files changed, 143 deletions(-) delete mode 100644 MODSRC/vazkii/botania/client/core/handler/CapeHandler.java delete mode 100644 MODSRC/vazkii/botania/test/Corruption.java diff --git a/MODSRC/vazkii/botania/client/core/handler/CapeHandler.java b/MODSRC/vazkii/botania/client/core/handler/CapeHandler.java deleted file mode 100644 index 4e60cab20..000000000 --- a/MODSRC/vazkii/botania/client/core/handler/CapeHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) - * - * File Created @ [? (GMT)] - */ -package vazkii.botania.client.core.handler; - -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.util.ArrayList; - -import javax.imageio.ImageIO; - -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.renderer.ThreadDownloadImageData; -import net.minecraftforge.client.event.RenderPlayerEvent; -import vazkii.botania.client.lib.LibResources; -import vazkii.botania.common.Botania; -import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.ReflectionHelper; - -public class CapeHandler { - - private ArrayList capePlayers = new ArrayList(); - - public static CapeHandler instance; - - public CapeHandler() { - instance = this; - } - - @SubscribeEvent - public void onPreRenderSpecials (RenderPlayerEvent.Specials.Pre event) { - if(Loader.isModLoaded("shadersmod")) - return; - - if(event.entityPlayer instanceof AbstractClientPlayer && event.entityPlayer.getCommandSenderName().equals("Vazkii")) { - AbstractClientPlayer abstractClientPlayer = (AbstractClientPlayer) event.entityPlayer; - - if (!capePlayers.contains(abstractClientPlayer)) { - ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, abstractClientPlayer.getTextureCape(), false, LibObfuscation.TEXTURE_UPLOADED); - new Thread(new CloakThread(abstractClientPlayer)).start(); - event.renderCape = true; - } - } - } - - private class CloakThread implements Runnable { - - AbstractClientPlayer abstractClientPlayer; - - public CloakThread(AbstractClientPlayer player) { - abstractClientPlayer = player; - } - - @Override - public void run() { - try { - BufferedImage bo = ImageIO.read(Botania.class.getResourceAsStream(LibResources.MODEL_CAPE)); - ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, abstractClientPlayer.getTextureCape(), bo, LibObfuscation.BUFFERED_IMAGE); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - public void refreshCapes() { - capePlayers.clear(); - } -} \ No newline at end of file diff --git a/MODSRC/vazkii/botania/test/Corruption.java b/MODSRC/vazkii/botania/test/Corruption.java deleted file mode 100644 index 1543b6e52..000000000 --- a/MODSRC/vazkii/botania/test/Corruption.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) - * - * File Created @ [Apr 30, 2014, 11:15:16 PM (GMT)] - */ -package vazkii.botania.test; - -import java.awt.Color; -import java.awt.image.BufferedImage; -import java.util.Random; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityClientPlayerMP; -import net.minecraft.client.renderer.ThreadDownloadImageData; -import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.relauncher.ReflectionHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class Corruption { - - Random rand = new Random(); - - public static void init() { - FMLCommonHandler.instance().bus().register(new Corruption()); - } - - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void onPlayerTick(ClientTickEvent event) { - if(event.phase == Phase.END) { - EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; - if(player != null && player.ticksExisted > 300) { - ThreadDownloadImageData tex = player.getTextureSkin(); - BufferedImage img = ReflectionHelper.getPrivateValue(ThreadDownloadImageData.class, tex, LibObfuscation.BUFFERED_IMAGE); - if(img != null) - for(int i = 0; i < 1 + (player.ticksExisted - 300) / 30; i++) - corruptRandomPixel(tex, img); - } - } - } - - public void corruptRandomPixel(ThreadDownloadImageData tex, BufferedImage img) { - int width = img.getWidth(); - int height = img.getHeight(); - - int x = rand.nextInt(width); - int y = rand.nextInt(height); - Color color = new Color(img.getRGB(x, y)); - if(color.getRed() + color.getGreen() + color.getRed() > 0) - img.setRGB(x, y, color.darker().darker().getRGB()); - ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, tex, false, LibObfuscation.TEXTURE_UPLOADED); - } - -}