package makeo.gadomancy.client.events; import java.util.ArrayList; import java.util.zip.GZIPInputStream; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GLAllocation; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraftforge.client.event.DrawBlockHighlightEvent; import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.client.model.IModelCustom; import net.minecraftforge.client.model.obj.WavefrontObject; import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import makeo.gadomancy.api.GadomancyApi; import makeo.gadomancy.api.golems.cores.AdditionalGolemCore; import makeo.gadomancy.client.gui.GuiResearchRecipeAuraEffects; import makeo.gadomancy.client.util.ExtendedTypeDisplayManager; import makeo.gadomancy.client.util.FamiliarHandlerClient; import makeo.gadomancy.client.util.MultiTickEffectDispatcher; import makeo.gadomancy.common.CommonProxy; import makeo.gadomancy.common.Gadomancy; import makeo.gadomancy.common.blocks.tiles.TileExtendedNode; import makeo.gadomancy.common.blocks.tiles.TileExtendedNodeJar; import makeo.gadomancy.common.data.DataAchromatic; import makeo.gadomancy.common.data.SyncDataHolder; import makeo.gadomancy.common.registration.RegisteredBlocks; import makeo.gadomancy.common.utils.Injector; import makeo.gadomancy.common.utils.MiscUtils; import makeo.gadomancy.common.utils.NBTHelper; import makeo.gadomancy.common.utils.Vector3; import thaumcraft.api.BlockCoordinates; import thaumcraft.api.IArchitect; import thaumcraft.api.research.ResearchItem; import thaumcraft.api.wands.ItemFocusBasic; import thaumcraft.client.gui.GuiGolem; import thaumcraft.client.gui.GuiResearchRecipe; import thaumcraft.client.lib.REHWandHandler; import thaumcraft.common.entities.golems.EntityGolemBase; import thaumcraft.common.items.relics.ItemThaumometer; import thaumcraft.common.items.wands.ItemWandCasting; /** * This class is part of the Gadomancy Mod Gadomancy is Open Source and distributed under the GNU LESSER GENERAL PUBLIC * LICENSE for more read the LICENSE file *
* Created by makeo @ 13.10.2015 16:11
*/
public final class RenderEventHandler {
private static final IModelCustom obj;
private static final ResourceLocation texture = new ResourceLocation("gadomancy:textures/misc/texW.png");
static {
ResourceLocation resourceLocation = new ResourceLocation("gadomancy:textures/models/modelAssec.obj");
IModelCustom buf;
try {
buf = new WavefrontObject(
"gadomancy:wRender",
new GZIPInputStream(
Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation)
.getInputStream()));
} catch (Exception exc) {
// shush.
buf = null;
}
obj = buf;
}
private final REHWandHandler WAND_HANDLER = new REHWandHandler();
private final FakeArchitectItem ARCHITECT_ITEM = new FakeArchitectItem();
private Object oldGolemblurb;
private int blurbId;
private int dList = -1;
@SubscribeEvent
public void on(GuiScreenEvent.DrawScreenEvent.Pre e) {
if (e.gui instanceof GuiGolem gui) {
EntityGolemBase golem = new Injector(gui, GuiGolem.class).getField("golem");
if (golem != null) {
AdditionalGolemCore core = GadomancyApi.getAdditionalGolemCore(golem);
if (core != null) {
this.blurbId = core.getBaseCore();
String key = "golemblurb." + this.blurbId + ".text";
this.oldGolemblurb = ResourceReloadListener.languageList.get(key);
ResourceReloadListener.languageList
.put(key, StatCollector.translateToLocal(core.getUnlocalizedGuiText()));
}
}
}
}
@SubscribeEvent
public void on(GuiScreenEvent.DrawScreenEvent.Post e) {
if (this.oldGolemblurb != null) {
String key = "golemblurb." + this.blurbId + ".text";
ResourceReloadListener.languageList.put(key, this.oldGolemblurb);
this.oldGolemblurb = null;
}
}
@SubscribeEvent
public void on(DrawBlockHighlightEvent e) {
if (e.currentItem == null) return;
if (e.currentItem.getItem() instanceof ItemWandCasting) {
ItemFocusBasic focus = ((ItemWandCasting) e.currentItem.getItem()).getFocus(e.currentItem);
if (!(focus instanceof IArchitect)) {
Block block = e.player.worldObj.getBlock(e.target.blockX, e.target.blockY, e.target.blockZ);
if (block != null && block == RegisteredBlocks.blockArcaneDropper) {
ForgeDirection dir = ForgeDirection.getOrientation(
e.player.worldObj.getBlockMetadata(e.target.blockX, e.target.blockY, e.target.blockZ) & 7);
ArrayList