mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-15 09:34:53 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d9db1f814 | ||
|
|
a3656ff05a | ||
|
|
ad399f7d88 | ||
|
|
8b3d1dfb86 | ||
|
|
f28e333c9e | ||
|
|
f31fe49226 | ||
|
|
f6c341a73c | ||
|
|
faa23e1183 |
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.7.54-GTNH:dev')
|
||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.7.57-GTNH:dev')
|
||||
|
||||
shadowImplementation('au.com.bytecode:opencsv:2.4')
|
||||
}
|
||||
@@ -79,8 +79,7 @@ public class Waila {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
|
||||
MinecraftForge.EVENT_BUS.register(new DecoratorRenderer());
|
||||
FMLCommonHandler.instance().bus().register(new KeyEvent());
|
||||
FMLCommonHandler.instance().bus().register(WailaTickHandler.instance());
|
||||
|
||||
FMLCommonHandler.instance().bus().register(new WailaTickHandler());
|
||||
}
|
||||
FMLCommonHandler.instance().bus().register(new NetworkHandler());
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.gui.screens.config.ScreenConfig;
|
||||
import mcp.mobius.waila.handlers.nei.NEIHandler;
|
||||
@@ -70,4 +71,15 @@ public class KeyEvent {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void tickClient(TickEvent.ClientTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.START) return;
|
||||
if (!KeyEvent.key_show.getIsKeyPressed()
|
||||
&& !ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, false)
|
||||
&& ConfigHandler.instance()
|
||||
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, false)) {
|
||||
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -68,7 +68,9 @@ public class ProxyClient extends ProxyServer {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldUnload(WorldEvent.Unload event) {
|
||||
DataAccessorCommon.instance = new DataAccessorCommon();
|
||||
if (event.world.isRemote) {
|
||||
DataAccessorCommon.instance = new DataAccessorCommon();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,16 +11,11 @@ import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
|
||||
public class OverlayRenderer {
|
||||
|
||||
protected static boolean hasBlending;
|
||||
protected static boolean hasLight;
|
||||
protected static boolean hasDepthTest;
|
||||
protected static boolean hasLight0;
|
||||
protected static boolean hasLight1;
|
||||
protected static boolean hasRescaleNormal;
|
||||
protected static boolean hasColorMaterial;
|
||||
protected static int boundTexIndex;
|
||||
private static boolean hasBlending;
|
||||
private static boolean hasDepthTest;
|
||||
private static int boundTexIndex;
|
||||
|
||||
public static void renderOverlay() {
|
||||
public static void renderOverlay(Tooltip tooltip) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (!(mc.currentScreen == null && mc.theWorld != null
|
||||
&& Minecraft.isGuiEnabled()
|
||||
@@ -31,16 +26,16 @@ public class OverlayRenderer {
|
||||
|
||||
if (RayTracing.instance().getTarget().typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK
|
||||
&& RayTracing.instance().getTargetStack() != null) {
|
||||
renderOverlay(WailaTickHandler.instance().tooltip);
|
||||
doRenderOverlay(tooltip);
|
||||
}
|
||||
|
||||
if (RayTracing.instance().getTarget().typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY
|
||||
&& ConfigHandler.instance().getConfig("general.showents")) {
|
||||
renderOverlay(WailaTickHandler.instance().tooltip);
|
||||
doRenderOverlay(tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
public static void renderOverlay(Tooltip tooltip) {
|
||||
private static void doRenderOverlay(Tooltip tooltip) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
saveGLState();
|
||||
@@ -80,26 +75,23 @@ public class OverlayRenderer {
|
||||
|
||||
}
|
||||
|
||||
public static void saveGLState() {
|
||||
private static void saveGLState() {
|
||||
hasBlending = GL11.glGetBoolean(GL11.GL_BLEND);
|
||||
hasLight = GL11.glGetBoolean(GL11.GL_LIGHTING);
|
||||
hasDepthTest = GL11.glGetBoolean(GL11.GL_DEPTH_TEST);
|
||||
boundTexIndex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
|
||||
GL11.glPushAttrib(GL11.GL_CURRENT_BIT);
|
||||
}
|
||||
|
||||
public static void loadGLState() {
|
||||
private static void loadGLState() {
|
||||
if (hasBlending) GL11.glEnable(GL11.GL_BLEND);
|
||||
else GL11.glDisable(GL11.GL_BLEND);
|
||||
if (hasLight1) GL11.glEnable(GL11.GL_LIGHT1);
|
||||
else GL11.glDisable(GL11.GL_LIGHT1);
|
||||
if (hasDepthTest) GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
else GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, boundTexIndex);
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
public static void drawTooltipBox(int x, int y, int w, int h, int bg, int grad1, int grad2) {
|
||||
private static void drawTooltipBox(int x, int y, int w, int h, int bg, int grad1, int grad2) {
|
||||
DisplayUtil.drawGradientRect(x + 1, y, w - 1, 1, bg, bg);
|
||||
DisplayUtil.drawGradientRect(x + 1, y + h, w - 1, 1, bg, bg);
|
||||
DisplayUtil.drawGradientRect(x + 1, y + 1, w - 1, h - 1, bg, bg);// center
|
||||
@@ -107,7 +99,6 @@ public class OverlayRenderer {
|
||||
DisplayUtil.drawGradientRect(x + w, y + 1, 1, h - 1, bg, bg);
|
||||
DisplayUtil.drawGradientRect(x + 1, y + 2, 1, h - 3, grad1, grad2);
|
||||
DisplayUtil.drawGradientRect(x + w - 1, y + 2, 1, h - 3, grad1, grad2);
|
||||
|
||||
DisplayUtil.drawGradientRect(x + 1, y + 1, w - 1, 1, grad1, grad1);
|
||||
DisplayUtil.drawGradientRect(x + 1, y + h - 1, w - 1, 1, grad2, grad2);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import mcp.mobius.waila.utils.Constants;
|
||||
|
||||
public class RayTracing {
|
||||
|
||||
private MovingObjectPosition target = null;
|
||||
private static RayTracing _instance;
|
||||
|
||||
private RayTracing() {}
|
||||
@@ -35,22 +36,22 @@ public class RayTracing {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
private MovingObjectPosition target = null;
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public void fire() {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY
|
||||
&& !shouldHidePlayer(mc.objectMouseOver.entityHit)) {
|
||||
this.target = mc.objectMouseOver;
|
||||
return;
|
||||
}
|
||||
|
||||
EntityLivingBase viewpoint = mc.renderViewEntity;
|
||||
if (viewpoint == null) return;
|
||||
|
||||
this.target = this.rayTrace(viewpoint, mc.playerController.getBlockReachDistance(), 0);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
target = null;
|
||||
}
|
||||
|
||||
private static boolean shouldHidePlayer(Entity targetEnt) {
|
||||
// Check if entity is player with invisibility effect
|
||||
if (targetEnt instanceof EntityPlayer thePlayer) {
|
||||
@@ -116,7 +117,7 @@ public class RayTracing {
|
||||
|
||||
if (this.target == null) return items;
|
||||
|
||||
World world = mc.theWorld;
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
|
||||
int x = this.target.blockX;
|
||||
int y = this.target.blockY;
|
||||
|
||||
@@ -12,169 +12,138 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.MetaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.TipList;
|
||||
import mcp.mobius.waila.cbcore.Layout;
|
||||
import mcp.mobius.waila.client.KeyEvent;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
|
||||
public class WailaTickHandler {
|
||||
|
||||
public Tooltip tooltip = null;
|
||||
public MetaDataProvider handler = new MetaDataProvider();
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
private static WailaTickHandler _instance;
|
||||
|
||||
private WailaTickHandler() {}
|
||||
|
||||
public static WailaTickHandler instance() {
|
||||
if (_instance == null) _instance = new WailaTickHandler();
|
||||
return _instance;
|
||||
}
|
||||
private Tooltip tooltip = null;
|
||||
private final MetaDataProvider handler = new MetaDataProvider();
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void tickRender(TickEvent.RenderTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
OverlayRenderer.renderOverlay();
|
||||
OverlayRenderer.renderOverlay(tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void tickClient(TickEvent.ClientTickEvent event) {
|
||||
|
||||
if (event.phase == TickEvent.Phase.START) return;
|
||||
|
||||
if (!Keyboard.isKeyDown(KeyEvent.key_show.getKeyCode())
|
||||
&& !ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, false)
|
||||
&& ConfigHandler.instance()
|
||||
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, false)) {
|
||||
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, false);
|
||||
}
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
World world = mc.theWorld;
|
||||
EntityPlayer player = mc.thePlayer;
|
||||
if (world != null && player != null) {
|
||||
RayTracing.instance().fire();
|
||||
MovingObjectPosition target = RayTracing.instance().getTarget();
|
||||
if (world == null || player == null) {
|
||||
this.tooltip = null;
|
||||
RayTracing.instance().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> currenttip;
|
||||
List<String> currenttipHead;
|
||||
List<String> currenttipBody;
|
||||
List<String> currenttipTail;
|
||||
if (target != null && target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
DataAccessorCommon accessor = DataAccessorCommon.instance;
|
||||
accessor.set(world, player, target);
|
||||
ItemStack targetStack = RayTracing.instance().getTargetStack(); // Here we get either the proper stack
|
||||
// or the override
|
||||
RayTracing.instance().fire();
|
||||
MovingObjectPosition target = RayTracing.instance().getTarget();
|
||||
|
||||
if (targetStack != null) {
|
||||
currenttip = new TipList<String, String>();
|
||||
currenttipHead = new TipList<String, String>();
|
||||
currenttipBody = new TipList<String, String>();
|
||||
currenttipTail = new TipList<String, String>();
|
||||
List<String> currenttip;
|
||||
List<String> currenttipHead;
|
||||
List<String> currenttipBody;
|
||||
List<String> currenttipTail;
|
||||
if (target != null && target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
DataAccessorCommon accessor = DataAccessorCommon.instance;
|
||||
accessor.set(world, player, target);
|
||||
ItemStack targetStack = RayTracing.instance().getTargetStack(); // Here we get either the proper stack
|
||||
// or the override
|
||||
|
||||
currenttipHead = handler.handleBlockTextData(
|
||||
targetStack,
|
||||
world,
|
||||
player,
|
||||
target,
|
||||
accessor,
|
||||
currenttipHead,
|
||||
Layout.HEADER);
|
||||
currenttipBody = handler.handleBlockTextData(
|
||||
targetStack,
|
||||
world,
|
||||
player,
|
||||
target,
|
||||
accessor,
|
||||
currenttipBody,
|
||||
Layout.BODY);
|
||||
currenttipTail = handler.handleBlockTextData(
|
||||
targetStack,
|
||||
world,
|
||||
player,
|
||||
target,
|
||||
accessor,
|
||||
currenttipTail,
|
||||
Layout.FOOTER);
|
||||
if (targetStack != null) {
|
||||
currenttip = new TipList<String, String>();
|
||||
currenttipHead = new TipList<String, String>();
|
||||
currenttipBody = new TipList<String, String>();
|
||||
currenttipTail = new TipList<String, String>();
|
||||
|
||||
if (ConfigHandler.instance()
|
||||
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHIFTBLOCK, false)
|
||||
&& !currenttipBody.isEmpty()
|
||||
&& !accessor.getPlayer().isSneaking()) {
|
||||
currenttipBody.clear();
|
||||
currenttipBody.add(ITALIC + "Press shift for more data");
|
||||
}
|
||||
currenttipHead = handler.handleBlockTextData(
|
||||
targetStack,
|
||||
world,
|
||||
player,
|
||||
target,
|
||||
accessor,
|
||||
currenttipHead,
|
||||
Layout.HEADER);
|
||||
currenttipBody = handler
|
||||
.handleBlockTextData(targetStack, world, player, target, accessor, currenttipBody, Layout.BODY);
|
||||
currenttipTail = handler.handleBlockTextData(
|
||||
targetStack,
|
||||
world,
|
||||
player,
|
||||
target,
|
||||
accessor,
|
||||
currenttipTail,
|
||||
Layout.FOOTER);
|
||||
|
||||
currenttip.addAll(currenttipHead);
|
||||
currenttip.addAll(currenttipBody);
|
||||
currenttip.addAll(currenttipTail);
|
||||
|
||||
this.tooltip = new Tooltip(currenttip, targetStack);
|
||||
if (ConfigHandler.instance()
|
||||
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHIFTBLOCK, false)
|
||||
&& !currenttipBody.isEmpty()
|
||||
&& !accessor.getPlayer().isSneaking()) {
|
||||
currenttipBody.clear();
|
||||
currenttipBody.add(ITALIC + "Press shift for more data");
|
||||
}
|
||||
} else if (target != null && target.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
|
||||
DataAccessorCommon accessor = DataAccessorCommon.instance;
|
||||
accessor.set(world, player, target);
|
||||
|
||||
Entity targetEnt = RayTracing.instance().getTargetEntity(); // This need to be replaced by the override
|
||||
// check.
|
||||
currenttip.addAll(currenttipHead);
|
||||
currenttip.addAll(currenttipBody);
|
||||
currenttip.addAll(currenttipTail);
|
||||
|
||||
if (targetEnt != null) {
|
||||
currenttip = new TipList<String, String>();
|
||||
currenttipHead = new TipList<String, String>();
|
||||
currenttipBody = new TipList<String, String>();
|
||||
currenttipTail = new TipList<String, String>();
|
||||
this.tooltip = new Tooltip(currenttip, targetStack);
|
||||
}
|
||||
} else if (target != null && target.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
|
||||
DataAccessorCommon accessor = DataAccessorCommon.instance;
|
||||
accessor.set(world, player, target);
|
||||
|
||||
currenttipHead = handler.handleEntityTextData(
|
||||
targetEnt,
|
||||
world,
|
||||
player,
|
||||
target,
|
||||
accessor,
|
||||
currenttipHead,
|
||||
Layout.HEADER);
|
||||
currenttipBody = handler.handleEntityTextData(
|
||||
targetEnt,
|
||||
world,
|
||||
player,
|
||||
target,
|
||||
accessor,
|
||||
currenttipBody,
|
||||
Layout.BODY);
|
||||
currenttipTail = handler.handleEntityTextData(
|
||||
targetEnt,
|
||||
world,
|
||||
player,
|
||||
target,
|
||||
accessor,
|
||||
currenttipTail,
|
||||
Layout.FOOTER);
|
||||
Entity targetEnt = RayTracing.instance().getTargetEntity(); // This need to be replaced by the override
|
||||
// check.
|
||||
|
||||
if (ConfigHandler.instance()
|
||||
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHIFTENTS, false)
|
||||
&& !currenttipBody.isEmpty()
|
||||
&& !accessor.getPlayer().isSneaking()) {
|
||||
currenttipBody.clear();
|
||||
currenttipBody.add(ITALIC + "Press shift for more data");
|
||||
}
|
||||
if (targetEnt != null) {
|
||||
currenttip = new TipList<String, String>();
|
||||
currenttipHead = new TipList<String, String>();
|
||||
currenttipBody = new TipList<String, String>();
|
||||
currenttipTail = new TipList<String, String>();
|
||||
|
||||
currenttip.addAll(currenttipHead);
|
||||
currenttip.addAll(currenttipBody);
|
||||
currenttip.addAll(currenttipTail);
|
||||
currenttipHead = handler.handleEntityTextData(
|
||||
targetEnt,
|
||||
world,
|
||||
player,
|
||||
target,
|
||||
accessor,
|
||||
currenttipHead,
|
||||
Layout.HEADER);
|
||||
currenttipBody = handler
|
||||
.handleEntityTextData(targetEnt, world, player, target, accessor, currenttipBody, Layout.BODY);
|
||||
currenttipTail = handler.handleEntityTextData(
|
||||
targetEnt,
|
||||
world,
|
||||
player,
|
||||
target,
|
||||
accessor,
|
||||
currenttipTail,
|
||||
Layout.FOOTER);
|
||||
|
||||
this.tooltip = new Tooltip(currenttip, false);
|
||||
if (ConfigHandler.instance()
|
||||
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHIFTENTS, false)
|
||||
&& !currenttipBody.isEmpty()
|
||||
&& !accessor.getPlayer().isSneaking()) {
|
||||
currenttipBody.clear();
|
||||
currenttipBody.add(ITALIC + "Press shift for more data");
|
||||
}
|
||||
|
||||
currenttip.addAll(currenttipHead);
|
||||
currenttip.addAll(currenttipBody);
|
||||
currenttip.addAll(currenttipTail);
|
||||
|
||||
this.tooltip = new Tooltip(currenttip, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user