mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 04:09:40 +00:00
Removed Capes before Grum throws a hissy fit.
This commit is contained in:
1 parent
2a3da6ac67
commit
5655fd39f5
2 files changed
-143
No files matched your search
@@ -1,78 +0,0 @@
|
||||
/**
|
||||
* This class was created by <The TConstruct Team>. 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<AbstractClientPlayer> capePlayers = new ArrayList<AbstractClientPlayer>();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. 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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user