mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 04:09:40 +00:00
Reduce some accesses to Patchouli internals
This commit is contained in:
1 parent
c564648a52
commit
2c72183f77
4 files changed
+9
-15
No files matched your search
@@ -11,7 +11,6 @@ package vazkii.botania.client.core.handler;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -25,9 +24,9 @@ import vazkii.botania.client.render.tile.RenderTileRedString;
|
||||
import vazkii.botania.common.block.subtile.functional.SubTileVinculotus;
|
||||
import vazkii.botania.common.core.handler.ManaNetworkHandler;
|
||||
import vazkii.botania.common.core.helper.PlayerHelper;
|
||||
import vazkii.botania.common.item.ItemLexicon;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.patchouli.client.book.gui.GuiBook;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@@ -98,8 +97,7 @@ public final class ClientTickHandler {
|
||||
}
|
||||
|
||||
int ticksToOpen = 10;
|
||||
Screen gui = Minecraft.getInstance().currentScreen;
|
||||
if (gui instanceof GuiBook && ((GuiBook) gui).book.getBookItem().getItem() == ModItems.lexicon) {
|
||||
if (ItemLexicon.isOpen()) {
|
||||
if (ticksWithLexicaOpen < 0) {
|
||||
ticksWithLexicaOpen = 0;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.item.ItemLexicon;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.patchouli.api.BookDrawScreenEvent;
|
||||
import vazkii.patchouli.client.book.gui.GuiBook;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID, value = Dist.CLIENT)
|
||||
public class KonamiHandler {
|
||||
@@ -39,18 +38,13 @@ public class KonamiHandler {
|
||||
private static int nextLetter = 0;
|
||||
private static int konamiTime = 0;
|
||||
|
||||
private static boolean isBookOpen() {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
return mc.currentScreen instanceof GuiBook && ((GuiBook) mc.currentScreen).book == ItemLexicon.getBook();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void clientTick(TickEvent.ClientTickEvent evt) {
|
||||
if (konamiTime > 0) {
|
||||
konamiTime--;
|
||||
}
|
||||
|
||||
if (!isBookOpen()) {
|
||||
if (!ItemLexicon.isOpen()) {
|
||||
nextLetter = 0;
|
||||
}
|
||||
}
|
||||
@@ -58,7 +52,7 @@ public class KonamiHandler {
|
||||
@SubscribeEvent
|
||||
public static void handleInput(InputEvent.KeyInputEvent evt) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if (evt.getModifiers() == 0 && evt.getAction() == GLFW.GLFW_PRESS && isBookOpen()) {
|
||||
if (evt.getModifiers() == 0 && evt.getAction() == GLFW.GLFW_PRESS && ItemLexicon.isOpen()) {
|
||||
if (konamiTime == 0 && evt.getKey() == KONAMI_CODE[nextLetter]) {
|
||||
nextLetter++;
|
||||
if (nextLetter >= KONAMI_CODE.length) {
|
||||
|
||||
@@ -43,7 +43,6 @@ import vazkii.botania.common.item.ItemLexicon;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
import vazkii.patchouli.client.book.gui.GuiBook;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.util.ArrayList;
|
||||
@@ -120,8 +119,7 @@ public class RenderLexicon {
|
||||
|
||||
float ticks = ClientTickHandler.ticksWithLexicaOpen;
|
||||
if (ticks > 0 && ticks < 10) {
|
||||
if (Minecraft.getInstance().currentScreen instanceof GuiBook
|
||||
&& ((GuiBook) Minecraft.getInstance().currentScreen).book.getBookItem().getItem() == ModItems.lexicon) {
|
||||
if (ItemLexicon.isOpen()) {
|
||||
ticks += partialTicks;
|
||||
} else {
|
||||
ticks -= partialTicks;
|
||||
|
||||
@@ -54,6 +54,10 @@ public class ItemLexicon extends Item implements IElvenItem {
|
||||
return BookRegistry.INSTANCE.books.get(ModItems.lexicon.getRegistryName());
|
||||
}
|
||||
|
||||
public static boolean isOpen() {
|
||||
return ModItems.lexicon.getRegistryName().equals(PatchouliAPI.instance.getOpenBookGui());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList<ItemStack> list) {
|
||||
if (isInGroup(tab)) {
|
||||
|
||||
Reference in new issue
Block a user