diff options
author | alemi <me@alemi.dev> | 2023-03-19 00:54:19 +0100 |
---|---|---|
committer | alemi <me@alemi.dev> | 2023-03-19 00:54:19 +0100 |
commit | ed0d7d9621f357a01a30d353731972befda848d8 (patch) | |
tree | 2950fcc26e365c4e94f75270a6d6157d1f01374c /src/main | |
parent | 9196cb9df2a4e34f546accf6c35f0c15c9593039 (diff) |
feat: added NoOverlay mod0.3.8
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/ftbsc/bscv/modules/hud/NoOverlay.java | 82 |
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); + } + } +} |