move some more patchouli stuff around

This commit is contained in:
Ellpeck 2019-03-01 20:51:43 +01:00
parent 62ccda3025
commit 9bb3951b11
5 changed files with 40 additions and 36 deletions

View file

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

View file

@ -1,7 +1,5 @@
package de.ellpeck.naturesaura.compat;
import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.compat.crafttweaker.CraftTweakerCompat;
import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat;
import net.minecraftforge.common.MinecraftForge;
@ -24,10 +22,6 @@ public final class Compat {
PatchouliCompat.preInit();
}
public static void preInitClient(){
PatchouliCompat.preInitClient();
}
public static void postInit() {
if (craftTweaker && mtLib)
CraftTweakerCompat.postInit();

View file

@ -3,22 +3,54 @@ package de.ellpeck.naturesaura.compat.patchouli;
import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.multiblock.Matcher;
import de.ellpeck.naturesaura.events.ClientEvents;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.client.config.GuiUtils;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import vazkii.patchouli.api.PatchouliAPI;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.Collections;
public final class PatchouliCompat {
public static Class bookGuiClass;
private static final ResourceLocation BOOK = new ResourceLocation(NaturesAura.MOD_ID, "book");
public static void preInit() {
PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":rf_converter", ModConfig.enabledFeatures.rfConverter);
}
public static void preInitClient() {
@SideOnly(Side.CLIENT)
public static void onGuiRender(GuiScreen gui, int mouseX, int mouseY) {
boolean display = false;
try {
bookGuiClass = Class.forName("vazkii.patchouli.client.book.gui.GuiBook");
} catch (ClassNotFoundException e) {
NaturesAura.LOGGER.warn("Couldn't find Patchouli book class, not loading special visuals :(");
ResourceLocation open = PatchouliAPI.instance.getOpenBookGui();
display = open != null && open.equals(BOOK);
} catch (Throwable ignored) {
// TODO remove this once Patchouli update is out long enough
}
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();
GlStateManager.color(1, 1, 1, 1);
gui.mc.getTextureManager().bindTexture(ClientEvents.BOOK_GUI);
Gui.drawModalRectWithCustomSizedTexture(x, y, 469, 0, 43, 42, 512, 256);
if (mouseX >= x && mouseY >= y && mouseX < x + 43 && mouseY < y + 42)
GuiUtils.drawHoveringText(Collections.singletonList(TextFormatting.GOLD + "It's the author Ellpeck's birthday!"),
mouseX, mouseY, gui.width, gui.height, 0, gui.mc.fontRenderer);
}
}
}

View file

@ -58,9 +58,6 @@ import org.apache.commons.lang3.mutable.MutableInt;
import org.lwjgl.opengl.GL11;
import java.text.NumberFormat;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -69,7 +66,7 @@ import java.util.Map;
public class ClientEvents {
public static final ResourceLocation OVERLAYS = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/overlays.png");
private static final ResourceLocation BOOK_GUI = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/book.png");
public static final ResourceLocation BOOK_GUI = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/book.png");
private static final ItemStack ITEM_FRAME = new ItemStack(Items.ITEM_FRAME);
private static final Map<ResourceLocation, Tuple<ItemStack, Boolean>> SHOWING_EFFECTS = new HashMap<>();
private static ItemStack heldCache = ItemStack.EMPTY;
@ -107,25 +104,7 @@ public class ClientEvents {
@SubscribeEvent
public void onGuiRender(GuiScreenEvent.DrawScreenEvent.Post event) {
GuiScreen gui = event.getGui();
if (PatchouliCompat.bookGuiClass != null && PatchouliCompat.bookGuiClass.isAssignableFrom(gui.getClass())) {
int mouseX = event.getMouseX();
int mouseY = event.getMouseY();
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();
GlStateManager.color(1, 1, 1, 1);
gui.mc.getTextureManager().bindTexture(BOOK_GUI);
Gui.drawModalRectWithCustomSizedTexture(x, y, 469, 0, 43, 42, 512, 256);
if (mouseX >= x && mouseY >= y && mouseX < x + 43 && mouseY < y + 42)
GuiUtils.drawHoveringText(Collections.singletonList(TextFormatting.GOLD + "It's the author Ellpeck's birthday!"),
mouseX, mouseY, gui.width, gui.height, 0, gui.mc.fontRenderer);
}
}
PatchouliCompat.onGuiRender(event.getGui(), event.getMouseX(), event.getMouseY());
}
@SubscribeEvent

View file

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