summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/ftbsc/bscv/modules/hud/NoOverlay.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/main/java/ftbsc/bscv/modules/hud/NoOverlay.java b/src/main/java/ftbsc/bscv/modules/hud/NoOverlay.java
new file mode 100644
index 0000000..474c759
--- /dev/null
+++ b/src/main/java/ftbsc/bscv/modules/hud/NoOverlay.java
@@ -0,0 +1,82 @@
+package ftbsc.bscv.modules.hud;
+
+import com.google.auto.service.AutoService;
+
+import ftbsc.bscv.api.ILoadable;
+import ftbsc.bscv.modules.AbstractModule;
+import ftbsc.bscv.tools.Setting;
+import net.minecraftforge.client.event.EntityViewRenderEvent;
+import net.minecraftforge.client.event.RenderBlockOverlayEvent;
+import net.minecraftforge.client.event.RenderGameOverlayEvent;
+import net.minecraftforge.common.ForgeConfigSpec;
+import net.minecraftforge.eventbus.api.SubscribeEvent;
+
+@AutoService(ILoadable.class)
+public class NoOverlay extends AbstractModule {
+
+ public final ForgeConfigSpec.ConfigValue<Boolean> liquid;
+ public final ForgeConfigSpec.ConfigValue<Boolean> block;
+ public final ForgeConfigSpec.ConfigValue<Boolean> helmet;
+ public final ForgeConfigSpec.ConfigValue<Boolean> portal;
+
+ public NoOverlay() {
+ super();
+
+ this.liquid = Setting.Bool.builder()
+ .fallback(true)
+ .name("liquid")
+ .comment("cancel overlay in water and lava")
+ .build(this);
+
+ this.block = Setting.Bool.builder()
+ .fallback(true)
+ .name("block")
+ .comment("cancel overlay of blocks on your head")
+ .build(this);
+
+ this.helmet = Setting.Bool.builder()
+ .fallback(true)
+ .name("helmet")
+ .comment("cancel overlay of pumpkins and helmets")
+ .build(this);
+
+ this.portal = Setting.Bool.builder()
+ .fallback(true)
+ .name("portal")
+ .comment("cancel overlay in nether portals")
+ .build(this);
+ }
+
+ @SubscribeEvent
+ public void onGameOverlay(RenderGameOverlayEvent event) {
+ switch (event.getType()) {
+ case HELMET:
+ if (event.isCancelable() && this.helmet.get())
+ event.setCanceled(true);
+ break;
+ case PORTAL:
+ if (event.isCancelable() && this.portal.get())
+ event.setCanceled(true);
+ break;
+ default:
+ break;
+ }
+ }
+
+ @SubscribeEvent
+ public void onRenderBlockOverlay(RenderBlockOverlayEvent event) {
+ if (this.block.get()) event.setCanceled(true);
+ }
+
+ @SubscribeEvent
+ public void onFogRender(EntityViewRenderEvent.FogDensity event) {
+ if (
+ this.liquid.get() &&
+ MC.player != null &&
+ (MC.player.isInLava() || MC.player.isInWater())
+ ) {
+ event.setDensity(0);
+ event.setCanceled(true);
+ }
+ }
+}