Skip to content

Commit

Permalink
idfk i added stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
exhq committed Aug 21, 2023
1 parent a3a4961 commit 7cc097d
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 18 deletions.
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'maven-publish'
id 'idea'
}

version = project.mod_version
Expand All @@ -27,6 +28,12 @@ loom {

}

idea {
module {
generatedSourceDirs.add(file("build/generated/sources/annotationProcessor/java/client/"))
}
}

dependencies {
modImplementation "io.wispforest:owo-lib:${project.owo_version}"
// only if you plan to use owo-config
Expand Down
24 changes: 24 additions & 0 deletions src/client/java/dev/exhq/ESSMConfigModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package dev.exhq;

import io.wispforest.owo.config.annotation.Config;
import io.wispforest.owo.config.annotation.ExcludeFromScreen;
import io.wispforest.owo.config.annotation.Modmenu;

@Modmenu(modId = "essm")
@Config(name = "ESSMConfig", wrapperName = "ESSMConfig")
public class ESSMConfigModel {

public boolean VanillaHeartToggle = false;

@ExcludeFromScreen
public ESSMhud.PosData Heart = new ESSMhud.PosData();
public ESSMhud.PosData XP = new ESSMhud.PosData();

public ESSMhud.PosData Health = new ESSMhud.PosData();

public ESSMhud.PosData Mana = new ESSMhud.PosData();
public ESSMhud.PosData UsedMana = new ESSMhud.PosData();



}
19 changes: 15 additions & 4 deletions src/client/java/dev/exhq/ESSMhud.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,18 @@ public ESSMhud(Text label, int width, int height, double defaultX, double defaul
posdata.y = defaultY;
posdata.scale = 1f;
}
public ESSMhud(Text label, int width, int height, PosData posdata){

allhud.add(this);
this.label = label;
this.width = width;
this.height = height;
this.posdata = posdata;
}
public static class PosData{
double x;
double y;
float scale;
float scale = 1f;
}


Expand Down Expand Up @@ -70,9 +78,12 @@ public int getHeight() {
return this.height;
}
public static ESSMhud hotBarPos = new ESSMhud(Text.of("Hotbar"), 182,22, 1,1);
public static ESSMhud heartPos = new ESSMhud(Text.of("Heart"), 182,22, 1,1);
public static ESSMhud Xp = new ESSMhud(Text.of("XP"), 182,5, 1,1);
public static ESSMhud Trolley = new ESSMhud(Text.of("Trolley"), 128,128, 0,0);

public static ESSMhud heartPos = new ESSMhud(Text.of("Heart"), 182,22, EchosShittySkyBlockMod.CONFIG.Heart());
public static ESSMhud Xp = new ESSMhud(Text.of("XP"), 182,5, EchosShittySkyBlockMod.CONFIG.XP());
public static ESSMhud Trolley = new ESSMhud(Text.of("Health"), 128,16, EchosShittySkyBlockMod.CONFIG.Health());
public static ESSMhud Trolleymana = new ESSMhud(Text.of("Mana"), 128,16, EchosShittySkyBlockMod.CONFIG.Mana());
public static ESSMhud UsedMana = new ESSMhud(Text.of("UsedMana"), 128,16, EchosShittySkyBlockMod.CONFIG.UsedMana());



Expand Down
46 changes: 41 additions & 5 deletions src/client/java/dev/exhq/EchosShittySkyBlockMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,34 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class EchosShittySkyBlockMod implements ClientModInitializer {
public static final dev.exhq.ESSMConfig CONFIG = dev.exhq.ESSMConfig.createAndLoad();
public static final String MOD_ID = "essm";
public class RegexSubstringMatcher {

public static String findMatchingSubstring(String input, String regexPattern) {
Pattern pattern = Pattern.compile(regexPattern);
Matcher matcher = pattern.matcher(input);

if (matcher.find()) {
return matcher.group();
}

return "";
}
}
@Override
public void onInitializeClient() {

ClientReceiveMessageEvents.GAME.register((message, overlay) -> {
if (overlay){
var noColor = message.getString().replaceAll("§[a-f0-9]", "");
//System.out.println(noColor);
var scoreboard = MinecraftClient.getInstance().world.getScoreboard();
var activeObjective = scoreboard.getObjectiveForSlot(Scoreboard.SIDEBAR_DISPLAY_SLOT_ID);
var actualScoreboardContent = new ArrayList<Text>();
Expand All @@ -35,9 +55,26 @@ public void onInitializeClient() {
}
Collections.reverse(actualScoreboardContent);
for (Text i : actualScoreboardContent) {
System.out.println(i.getString().replaceAll("§[^a-f0-9]", ""));
//System.out.println(i.getString().replaceAll("§[^a-f0-9]", ""));
}

var health = Objects.requireNonNull(RegexSubstringMatcher.findMatchingSubstring(noColor, "[0-9,]+/[0-9,]+❤")).replaceAll(",", "").replaceAll("❤", "").split("/");

var mana = Objects.requireNonNull(RegexSubstringMatcher.findMatchingSubstring(noColor, "[0-9,]+/[0-9,]+✎")).replaceAll(",", "").replaceAll("✎", "").split("/");

var usedMana = RegexSubstringMatcher.findMatchingSubstring(noColor, "(\\+|-)[1-9]+ Mana \\([^)]+\\)");

if (!usedMana.isEmpty()){
System.out.println("you used mana");
ManaUsage.showMana = true;
ManaUsage.ManaUsage = RegexSubstringMatcher.findMatchingSubstring(usedMana, "(\\+|-)[1-9]+");
} else {
ManaUsage.showMana = false;
}
System.out.println(message.getString());

Trolley.healthprogress = (Integer.parseInt(health[0]) * 128 ) / (Integer.parseInt(health[1]));

Trolley.manaprogress = (Integer.parseInt(mana[0]) * 128 ) / (Integer.parseInt(mana[1]));
}
});

Expand All @@ -48,20 +85,19 @@ public void onInitializeClient() {
if (player == null){
return;
}

Trolley.progress = (int)(player.getHealth()/player.getMaxHealth()*128);
});

ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
dispatcher.register(literal("trolgessbar")
.then(argument("progress", IntegerArgumentType.integer(0,128)).executes(context -> {
int progress = IntegerArgumentType.getInteger(context, "progress");
Trolley.progress=progress;
Trolley.healthprogress =progress;
context.getSource().sendFeedback(Text.literal(":trolley:"));
return 0;
})));
});
HudRenderCallback.EVENT.register(new Trolley());
HudRenderCallback.EVENT.register(new ManaUsage());
HudRenderCallback.EVENT.register((maxtrixStack, tickDelta) -> {

});
Expand Down
5 changes: 5 additions & 0 deletions src/client/java/dev/exhq/JarvisInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ public class JarvisInit implements JarvisPlugin {
public @NotNull @Unmodifiable List<@NotNull JarvisHud> getAllHuds() {
return ESSMhud.allhud;
}

@Override
public void onHudEditorClosed() {
EchosShittySkyBlockMod.CONFIG.save();
}
}
20 changes: 20 additions & 0 deletions src/client/java/dev/exhq/ManaUsage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package dev.exhq;

import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;

public class ManaUsage implements HudRenderCallback {
public static boolean showMana = false;
public static String ManaUsage = "0";

@Override
public void onHudRender(DrawContext drawContext, float tickDelta) {
if (showMana){
drawContext.getMatrices().push();
ESSMhud.UsedMana.applyTransformations(drawContext.getMatrices());
drawContext.drawTextWithShadow(MinecraftClient.getInstance().textRenderer, ManaUsage, 0,0, 0xff54fcfc);
drawContext.getMatrices().pop();
}
}
}
21 changes: 19 additions & 2 deletions src/client/java/dev/exhq/Trolley.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,39 @@
package dev.exhq;

import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;

public class Trolley implements HudRenderCallback {
private static final Identifier TROLLEYEMPTY = new Identifier(EchosShittySkyBlockMod.MOD_ID, "textures/trolley/trolleyempty.png");
private static final Identifier TROLLEY = new Identifier(EchosShittySkyBlockMod.MOD_ID, "textures/trolley/trolley.png");

private static final Identifier TROLLEYMANAEMPTY = new Identifier(EchosShittySkyBlockMod.MOD_ID, "textures/trolley/trolleymanaempty.png");
private static final Identifier TROLLEYMANA = new Identifier(EchosShittySkyBlockMod.MOD_ID, "textures/trolley/trolleymana.png");
public static int healthprogress = 128;

public static int progress = 128;
public static int manaprogress = 128;

@Override
public void onHudRender(DrawContext drawContext, float tickDelta) {
int x = 0;
int y = 0;
drawContext.getMatrices().push();
ESSMhud.Trolley.applyTransformations(drawContext.getMatrices());
drawContext.drawTexture(TROLLEY, x,y,0,0,progress,128, 128,128);
drawContext.drawTexture(TROLLEYEMPTY, x,y,0,0,128,16, 128,16);
drawContext.drawTexture(TROLLEY, x,y,0,0, healthprogress,16, 128,16);
drawContext.getMatrices().pop();

drawContext.getMatrices().push();
ESSMhud.Trolleymana.applyTransformations(drawContext.getMatrices());
drawContext.drawTexture(TROLLEYMANAEMPTY, x,y,0,0,128,16, 128,16);
drawContext.drawTexture(TROLLEYMANA, x,y,0,0, manaprogress,16, 128,16);
drawContext.getMatrices().pop();



}
}
29 changes: 22 additions & 7 deletions src/client/java/dev/exhq/mixin/client/componentMover.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ public class componentMover {
@Shadow private int scaledHeight;

@Inject(method = "renderHotbar", at = @At("HEAD"))
private void ResetHotbarPos(float tickDelta, DrawContext context, CallbackInfo ci){
private void resetHotbarPos(float tickDelta, DrawContext context, CallbackInfo ci){
context.getMatrices().push();
context.getMatrices().translate((float) -scaledWidth /2+91, -scaledHeight+22,0);
ESSMhud.hotBarPos.applyTransformations(context.getMatrixStack());
}
@Inject(method = "renderHotbar", at = @At("TAIL"))
private void HotbarMove(float tickDelta, DrawContext context, CallbackInfo ci){
private void hotbarMove(float tickDelta, DrawContext context, CallbackInfo ci){
context.getMatrices().pop();
}


@Inject(method = "renderExperienceBar", at = @At("HEAD"))
private void ResetXP(DrawContext context, int x, CallbackInfo ci){
private void resetXP(DrawContext context, int x, CallbackInfo ci){
context.getMatrices().push();
context.getMatrices().translate((float) -scaledWidth /2+91, -scaledHeight+28,0);
ESSMhud.Xp.applyTransformations(context.getMatrixStack());
Expand All @@ -42,26 +42,41 @@ private void XPMove(DrawContext context, int x, CallbackInfo ci){


@Inject(method = "renderHealthBar", at = @At("HEAD"))
private void ResetHeart(DrawContext context, PlayerEntity player, int x, int y, int lines, int regeneratingHeartIndex, float maxHealth, int lastHealth, int health, int absorption, boolean blinking, CallbackInfo ci){
private void heartMove(DrawContext context, PlayerEntity player, int x, int y, int lines, int regeneratingHeartIndex, float maxHealth, int lastHealth, int health, int absorption, boolean blinking, CallbackInfo ci){
context.getMatrices().push();
context.getMatrices().translate((float) -x, -y,0);
ESSMhud.heartPos.applyTransformations(context.getMatrixStack());
}
@Inject(method = "renderHealthBar", at = @At("TAIL"))
private void HeartMove(DrawContext context, PlayerEntity player, int x, int y, int lines, int regeneratingHeartIndex, float maxHealth, int lastHealth, int health, int absorption, boolean blinking, CallbackInfo ci){
private void resetHeart(DrawContext context, PlayerEntity player, int x, int y, int lines, int regeneratingHeartIndex, float maxHealth, int lastHealth, int health, int absorption, boolean blinking, CallbackInfo ci){
context.getMatrices().pop();
}

@Inject(method = "renderStatusBars", at = @At(value = "INVOKE_STRING",target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V",args = "ldc=food"))
private void RemoveHunger(DrawContext context, CallbackInfo ci){
private void removeHunger(DrawContext context, CallbackInfo ci){
context.getMatrices().push();
context.getMatrices().translate(10000,0,0);
}


@Inject(method = "renderStatusBars", at = @At(value = "INVOKE_STRING",target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V",args = "ldc=air"))
private void RestoreAir(DrawContext context, CallbackInfo ci){
private void restoreHunger(DrawContext context, CallbackInfo ci){
context.getMatrices().pop();
}


@Inject(method = "renderStatusBars", at = @At(value = "INVOKE_STRING",target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V",args = "ldc=armor"))
private void removeArmor(DrawContext context, CallbackInfo ci){
context.getMatrices().push();
context.getMatrices().translate(10000,0,0);
}


@Inject(method = "renderStatusBars", at = @At(value = "INVOKE_STRING",target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V",args = "ldc=health"))
private void restoreArmor(DrawContext context, CallbackInfo ci){
context.getMatrices().pop();
}



}
Binary file modified src/client/resources/assets/essm/textures/trolley/trolley.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7cc097d

Please sign in to comment.