added crosshair mod
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Code from: https://github.com/Selyss
|
||||
* Repo: https://github.com/Selyss/CrosshairIndicator/tree/main
|
||||
*/
|
||||
|
||||
package org.saturnclient.saturnclient.mixin;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
@Mixin(InGameHud.class)
|
||||
public class Crosshair {
|
||||
@Shadow
|
||||
@Final
|
||||
private MinecraftClient client;
|
||||
@Unique
|
||||
Identifier textureLocation = Identifier.of("saturnclient", "textures/gui/hud/crosshair_range.png");
|
||||
|
||||
@Inject(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Ljava/util/function/Function;Lnet/minecraft/util/Identifier;IIII)V", ordinal = 0))
|
||||
private void drawCrosshair(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) {
|
||||
if (org.saturnclient.saturnmods.mods.Crosshair.enabled.value
|
||||
&& org.saturnclient.saturnmods.mods.Crosshair.range_indicator.value
|
||||
&& this.client.targetedEntity != null
|
||||
&& this.client.targetedEntity.isAlive()) {
|
||||
RenderSystem.setShaderTexture(0, textureLocation);
|
||||
int scaledWidth = 15;
|
||||
int scaledHeight = 15;
|
||||
|
||||
context.drawTexture(RenderLayer::getCrosshair, textureLocation,
|
||||
(context.getScaledWindowWidth() - scaledWidth) / 2,
|
||||
(context.getScaledWindowHeight() - scaledHeight) / 2, 0.0F, 0.0F, scaledWidth, scaledHeight,
|
||||
scaledWidth, scaledHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,8 @@ public class ModManager {
|
||||
new Coordinates(),
|
||||
new ArmorDisplay(),
|
||||
new FpsDisplay(),
|
||||
new Particles()
|
||||
new Particles(),
|
||||
new Crosshair()
|
||||
};
|
||||
|
||||
public static void init() {
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package org.saturnclient.saturnmods.mods;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.saturnclient.saturnclient.config.ConfigManager;
|
||||
import org.saturnclient.saturnclient.config.Property;
|
||||
import org.saturnclient.saturnmods.SaturnMod;
|
||||
import org.saturnclient.ui.Textures;
|
||||
|
||||
public class Crosshair implements SaturnMod {
|
||||
public static ConfigManager config = new ConfigManager("Crosshair");
|
||||
|
||||
public static Property<Boolean> enabled = config.property(
|
||||
"Enabled",
|
||||
new Property<>(false));
|
||||
|
||||
public static Property<Boolean> range_indicator = config.property(
|
||||
"Hit range indicator",
|
||||
new Property<>(false));
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean e) {
|
||||
enabled.value = e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Crosshair";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getIconTexture() {
|
||||
return Textures.getModIcon("crosshair");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigManager getConfig() {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 105 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
@@ -9,7 +9,7 @@
|
||||
"website": "https://kleo-dev.netlify.app",
|
||||
"sources": "https://github.com/saturnclientmc/saturnclient"
|
||||
},
|
||||
"license": "GPL-3.0",
|
||||
"license": "Apache-2.0",
|
||||
"icon": "assets/saturnclient/icon.png",
|
||||
"environment": "client",
|
||||
"entrypoints": {
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
"PlayerEntityRendererMixin",
|
||||
"WhoAmI",
|
||||
"SaturnReload",
|
||||
"TotemParticleMixin"
|
||||
"TotemParticleMixin",
|
||||
"Crosshair"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
||||
Reference in New Issue
Block a user