Skip to content

Commit

Permalink
Fix crash when using jump pads
Browse files Browse the repository at this point in the history
  • Loading branch information
nea89o committed Sep 1, 2023
1 parent 90066b3 commit 9dc816c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
14 changes: 11 additions & 3 deletions src/main/java/dev/exhq/mixin/client/ComponentMover.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
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;
Expand All @@ -26,9 +27,9 @@ public class ComponentMover {
private @Nullable Text overlayMessage;

@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);
context.getMatrices().translate((float) -scaledWidth / 2 + 91, -scaledHeight + 22, 0);
ESSMhud.hotBarPos.applyTransformations(context.getMatrices());
}

Expand Down Expand Up @@ -67,16 +68,23 @@ private void resetHeart(DrawContext context, PlayerEntity player, int x, int y,
context.getMatrices().pop();
}

@Unique
boolean didPushForFood = false;

@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) {
context.getMatrices().push();
context.getMatrices().translate(10000, 0, 0);
didPushForFood = true;
}


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


Expand Down
21 changes: 10 additions & 11 deletions src/main/java/dev/exhq/mixin/client/TitleScreenMixin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.exhq.mixin.client;


import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.widget.TextWidget;
Expand All @@ -12,17 +13,15 @@

@Mixin(TitleScreen.class)
public class TitleScreenMixin extends Screen {
protected TitleScreenMixin(Text text) {
super(text);
}
protected TitleScreenMixin(Text text) {
super(text);
}

Text idk = Text.of("gay sex");
Text idk = Text.of("gay sex");

@Inject(method = "init", at = @At("RETURN"))
private void addText(CallbackInfo ci) {

addDrawableChild(new TextWidget(4, 5, textRenderer.getWidth(idk) + 4, 20,idk, textRenderer));


}
@Inject(method = "init", at = @At("RETURN"))
private void addText(CallbackInfo ci) {
if (FabricLoader.getInstance().isDevelopmentEnvironment())
addDrawableChild(new TextWidget(4, 5, textRenderer.getWidth(idk) + 4, 20, idk, textRenderer));
}
}

0 comments on commit 9dc816c

Please sign in to comment.