feat: added NoOverlay mod

This commit is contained in:
əlemi 2023-03-19 00:54:19 +01:00
parent 9196cb9df2
commit ed0d7d9621
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -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);
}
}
}