diff options
author | Lorenz <ESs95s3P5z8Pheb> | 2022-07-08 23:34:20 +0200 |
---|---|---|
committer | Lorenz <ESs95s3P5z8Pheb> | 2022-07-08 23:34:20 +0200 |
commit | 5a609c48b9d0ebb89c19627cd6dbbff21fc8324a (patch) | |
tree | 82d644a99141b8d62af2e5a999dcbbfa77b0f520 | |
parent | 5ac4f2123f2750a6a8d8a6ad1bb9c6e0177c270e (diff) | |
download | skyhanni-5a609c48b9d0ebb89c19627cd6dbbff21fc8324a.tar.gz skyhanni-5a609c48b9d0ebb89c19627cd6dbbff21fc8324a.tar.bz2 skyhanni-5a609c48b9d0ebb89c19627cd6dbbff21fc8324a.zip |
add hide exp bottles support
7 files changed, 84 insertions, 2 deletions
diff --git a/src/main/java/at/lorenz/mod/LorenzMod.java b/src/main/java/at/lorenz/mod/LorenzMod.java index fb6986293..41a90a13e 100644 --- a/src/main/java/at/lorenz/mod/LorenzMod.java +++ b/src/main/java/at/lorenz/mod/LorenzMod.java @@ -9,6 +9,7 @@ import at.lorenz.mod.config.Features; import at.lorenz.mod.dungeon.DungeonChatFilter; import at.lorenz.mod.dungeon.DungeonHighlightClickedBlocks; import at.lorenz.mod.misc.CurrentPetDisplay; +import at.lorenz.mod.misc.ExpBottleOnGroundHider; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.thatgravyboat.skyblockhud_2.commands.Commands; @@ -54,6 +55,7 @@ public class LorenzMod { MinecraftForge.EVENT_BUS.register(new DungeonHighlightClickedBlocks()); MinecraftForge.EVENT_BUS.register(new ItemDisplayOverlayFeatures()); MinecraftForge.EVENT_BUS.register(new CurrentPetDisplay()); + MinecraftForge.EVENT_BUS.register(new ExpBottleOnGroundHider()); Commands.init(); diff --git a/src/main/java/at/lorenz/mod/config/Features.java b/src/main/java/at/lorenz/mod/config/Features.java index 97f9be3d8..bb9939c13 100644 --- a/src/main/java/at/lorenz/mod/config/Features.java +++ b/src/main/java/at/lorenz/mod/config/Features.java @@ -154,6 +154,11 @@ public class Features { @ConfigOption(name = "Pet Display Position", desc = "") @ConfigEditorButton(runnableId = "petDisplay", buttonText = "Edit") public Position petDisplayPos = new Position(10, 10, false, true); + + @Expose + @ConfigOption(name = "Exp Bottles", desc = "Hides all the Exp bottles on the ground.") + @ConfigEditorBoolean + public boolean hideExpBottles = false; } public static class Test { @@ -164,7 +169,7 @@ public class Features { public boolean enabled = false; @Expose - @ConfigOption(name = "Test Location", desc = "testPos") + @ConfigOption(name = "Test Location", desc = "") @ConfigEditorButton(runnableId = "testPos", buttonText = "Edit") public Position testPos = new Position(10, 10, false, true); } diff --git a/src/main/java/at/lorenz/mod/events/CheckRenderEntityEvent.kt b/src/main/java/at/lorenz/mod/events/CheckRenderEntityEvent.kt new file mode 100644 index 000000000..b4b226e2b --- /dev/null +++ b/src/main/java/at/lorenz/mod/events/CheckRenderEntityEvent.kt @@ -0,0 +1,14 @@ +package at.lorenz.mod.events + +import net.minecraft.client.renderer.culling.ICamera +import net.minecraft.entity.Entity +import net.minecraftforge.fml.common.eventhandler.Cancelable + +@Cancelable +data class CheckRenderEntityEvent<T : Entity>( + val entity: T, + val camera: ICamera, + val camX: Double, + val camY: Double, + val camZ: Double +) : LorenzEvent()
\ No newline at end of file diff --git a/src/main/java/at/lorenz/mod/misc/ExpBottleOnGroundHider.kt b/src/main/java/at/lorenz/mod/misc/ExpBottleOnGroundHider.kt new file mode 100644 index 000000000..a82e22dc8 --- /dev/null +++ b/src/main/java/at/lorenz/mod/misc/ExpBottleOnGroundHider.kt @@ -0,0 +1,17 @@ +package at.lorenz.mod.misc + +import at.lorenz.mod.LorenzMod +import at.lorenz.mod.events.CheckRenderEntityEvent +import net.minecraft.entity.item.EntityXPOrb +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class ExpBottleOnGroundHider { + @SubscribeEvent + fun onCheckRender(event: CheckRenderEntityEvent<*>) { + if (!LorenzMod.feature.misc.hideExpBottles) return + + if (event.entity is EntityXPOrb) { + event.isCanceled = true + } + } +}
\ No newline at end of file diff --git a/src/main/java/at/lorenz/mod/mixinhooks/RenderManagerHook.kt b/src/main/java/at/lorenz/mod/mixinhooks/RenderManagerHook.kt new file mode 100644 index 000000000..69242d651 --- /dev/null +++ b/src/main/java/at/lorenz/mod/mixinhooks/RenderManagerHook.kt @@ -0,0 +1,25 @@ +package at.lorenz.mod.mixinhooks + +import at.lorenz.mod.events.CheckRenderEntityEvent +import net.minecraft.client.renderer.culling.ICamera +import net.minecraft.entity.Entity +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable + +fun shouldRender( + entityIn: Entity, + camera: ICamera, + camX: Double, + camY: Double, + camZ: Double, + cir: CallbackInfoReturnable<Boolean> +) { + if ( + CheckRenderEntityEvent( + entityIn, + camera, + camX, + camY, + camZ + ).postAndCatch() + ) cir.returnValue = false +}
\ No newline at end of file diff --git a/src/main/java/at/lorenz/mod/mixins/MixinRenderManager.java b/src/main/java/at/lorenz/mod/mixins/MixinRenderManager.java new file mode 100644 index 000000000..bdadc44df --- /dev/null +++ b/src/main/java/at/lorenz/mod/mixins/MixinRenderManager.java @@ -0,0 +1,18 @@ +package at.lorenz.mod.mixins; + +import at.lorenz.mod.mixinhooks.RenderManagerHookKt; +import net.minecraft.client.renderer.culling.ICamera; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.Entity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(RenderManager.class) +public class MixinRenderManager { + @Inject(method = "shouldRender", at = @At("HEAD"), cancellable = true) + private void shouldRender(Entity entityIn, ICamera camera, double camX, double camY, double camZ, CallbackInfoReturnable<Boolean> cir) { + RenderManagerHookKt.shouldRender(entityIn, camera, camX, camY, camZ, cir); + } +} diff --git a/src/main/resources/mixins.lorenzmod.json b/src/main/resources/mixins.lorenzmod.json index 32f423f03..fcbd5f82c 100644 --- a/src/main/resources/mixins.lorenzmod.json +++ b/src/main/resources/mixins.lorenzmod.json @@ -6,6 +6,7 @@ "MixinGuiContainer", "MixinNetworkManager", "MixinNetHandlerPlayClient", - "MixinRenderItem" + "MixinRenderItem", + "MixinRenderManager" ] } |