make this whole thing work way better with that new patchouli feature I just added

This commit is contained in:
Ellpeck 2019-03-03 23:33:38 +01:00
parent 3ba3c064fc
commit 0ff2f5198d
5 changed files with 55 additions and 52 deletions

View file

@ -38,7 +38,7 @@ repositories {
} }
dependencies { dependencies {
compile "vazkii.patchouli:Patchouli:1.0-18.92" compile "vazkii.patchouli:Patchouli:1.0-18.93"
deobfCompile "mezz.jei:jei_1.12.2:4.14.4.267" deobfCompile "mezz.jei:jei_1.12.2:4.14.4.267"
deobfCompile "com.azanor.baubles:Baubles:1.12-1.5.2" deobfCompile "com.azanor.baubles:Baubles:1.12-1.5.2"

View file

@ -4,6 +4,8 @@ import de.ellpeck.naturesaura.compat.crafttweaker.CraftTweakerCompat;
import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat; import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public final class Compat { public final class Compat {
@ -22,6 +24,10 @@ public final class Compat {
PatchouliCompat.preInit(); PatchouliCompat.preInit();
} }
public static void preInitClient() {
PatchouliCompat.preInitClient();
}
public static void postInit() { public static void postInit() {
if (craftTweaker && mtLib) if (craftTweaker && mtLib)
CraftTweakerCompat.postInit(); CraftTweakerCompat.postInit();

View file

@ -13,9 +13,12 @@ import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.client.config.GuiUtils;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import vazkii.patchouli.api.BookDrawScreenEvent;
import vazkii.patchouli.api.PatchouliAPI; import vazkii.patchouli.api.PatchouliAPI;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -30,59 +33,57 @@ public final class PatchouliCompat {
PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":rf_converter", ModConfig.enabledFeatures.rfConverter); PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":rf_converter", ModConfig.enabledFeatures.rfConverter);
} }
public static void preInitClient() {
MinecraftForge.EVENT_BUS.register(new PatchouliCompat());
}
@SubscribeEvent
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public static void onGuiRender(GuiScreen gui, int mouseX, int mouseY) { public void onBookDraw(BookDrawScreenEvent event) {
boolean display = false; if (event.book == null || !event.book.equals(BOOK))
try { return;
ResourceLocation open = PatchouliAPI.instance.getOpenBookGui(); LocalDateTime now = LocalDateTime.now();
display = open != null && open.equals(BOOK); if (now.getMonth() == Month.MAY && now.getDayOfMonth() == 21) {
} catch (Throwable ignored) { int x = event.gui.width / 2 + 272 / 2 - 16;
// TODO remove this once Patchouli update is out long enough int y = event.gui.height / 2 - 180 / 2 - 26;
RenderHelper.disableStandardItemLighting();
GlStateManager.color(1, 1, 1, 1);
event.gui.mc.getTextureManager().bindTexture(ClientEvents.BOOK_GUI);
Gui.drawModalRectWithCustomSizedTexture(x, y, 469, 0, 43, 42, 512, 256);
if (event.mouseX >= x && event.mouseY >= y && event.mouseX < x + 43 && event.mouseY < y + 42)
GuiUtils.drawHoveringText(
Collections.singletonList(TextFormatting.GOLD + "It's the author Ellpeck's birthday!"),
event.mouseX, event.mouseY, event.gui.width, event.gui.height, 0, event.gui.mc.fontRenderer);
} }
if (display) {
LocalDateTime now = LocalDateTime.now();
if (now.getMonth() == Month.MAY && now.getDayOfMonth() == 21) {
int x = gui.width / 2 + 272 / 2 - 16;
int y = gui.height / 2 - 180 / 2 - 26;
RenderHelper.disableStandardItemLighting(); String name = event.gui.mc.player.getName();
GlStateManager.color(1, 1, 1, 1); FancyInfo info = SupporterFancyHandler.FANCY_INFOS.get(name);
gui.mc.getTextureManager().bindTexture(ClientEvents.BOOK_GUI); if (info != null) {
Gui.drawModalRectWithCustomSizedTexture(x, y, 469, 0, 43, 42, 512, 256); int x = event.gui.width / 2 - 272 / 2 + 20;
int y = event.gui.height / 2 + 180 / 2;
if (mouseX >= x && mouseY >= y && mouseX < x + 43 && mouseY < y + 42) RenderHelper.disableStandardItemLighting();
GuiUtils.drawHoveringText( GlStateManager.color(1, 1, 1, 1);
Collections.singletonList(TextFormatting.GOLD + "It's the author Ellpeck's birthday!"), event.gui.mc.getTextureManager().bindTexture(ClientEvents.BOOK_GUI);
mouseX, mouseY, gui.width, gui.height, 0, gui.mc.fontRenderer);
Gui.drawModalRectWithCustomSizedTexture(x, y, 496, 44, 16, 18, 512, 256);
if (info.tier == 1) {
Gui.drawModalRectWithCustomSizedTexture(x, y, 496 - 16, 44, 16, 18, 512, 256);
} else {
float r = ((info.color >> 16) & 255) / 255F;
float g = ((info.color >> 8) & 255) / 255F;
float b = (info.color & 255) / 255F;
GlStateManager.color(r, g, b);
Gui.drawModalRectWithCustomSizedTexture(x, y, 496 - 32, 44, 16, 18, 512, 256);
} }
String name = gui.mc.player.getName(); if (event.mouseX >= x && event.mouseY >= y && event.mouseX < x + 16 && event.mouseY < y + 18)
FancyInfo info = SupporterFancyHandler.FANCY_INFOS.get(name); GuiUtils.drawHoveringText(
if (info != null) { Collections.singletonList(TextFormatting.YELLOW + "Thanks for your support, " + name + "!"),
int x = gui.width / 2 - 272 / 2 + 20; event.mouseX, event.mouseY, event.gui.width, event.gui.height, 0, event.gui.mc.fontRenderer);
int y = gui.height / 2 + 180 / 2;
RenderHelper.disableStandardItemLighting();
GlStateManager.color(1, 1, 1, 1);
gui.mc.getTextureManager().bindTexture(ClientEvents.BOOK_GUI);
Gui.drawModalRectWithCustomSizedTexture(x, y, 496, 44, 16, 18, 512, 256);
if (info.tier == 1) {
Gui.drawModalRectWithCustomSizedTexture(x, y, 496 - 16, 44, 16, 18, 512, 256);
} else {
float r = ((info.color >> 16) & 255) / 255F;
float g = ((info.color >> 8) & 255) / 255F;
float b = (info.color & 255) / 255F;
GlStateManager.color(r, g, b);
Gui.drawModalRectWithCustomSizedTexture(x, y, 496 - 32, 44, 16, 18, 512, 256);
}
if (mouseX >= x && mouseY >= y && mouseX < x + 16 && mouseY < y + 18)
GuiUtils.drawHoveringText(
Collections.singletonList(TextFormatting.YELLOW + "Thanks for your support, " + name + "!"),
mouseX, mouseY, gui.width, gui.height, 0, gui.mc.fontRenderer);
}
} }
} }

View file

@ -102,11 +102,6 @@ public class ClientEvents {
mc.profiler.endSection(); mc.profiler.endSection();
} }
@SubscribeEvent
public void onGuiRender(GuiScreenEvent.DrawScreenEvent.Post event) {
PatchouliCompat.onGuiRender(event.getGui(), event.getMouseX(), event.getMouseY());
}
@SubscribeEvent @SubscribeEvent
public void onRenderLast(RenderWorldLastEvent event) { public void onRenderLast(RenderWorldLastEvent event) {
Minecraft mc = Minecraft.getMinecraft(); Minecraft mc = Minecraft.getMinecraft();

View file

@ -37,6 +37,7 @@ public class ClientProxy implements IProxy {
@Override @Override
public void preInit(FMLPreInitializationEvent event) { public void preInit(FMLPreInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new ClientEvents()); MinecraftForge.EVENT_BUS.register(new ClientEvents());
Compat.preInitClient();
} }
@Override @Override