Skip to content

Commit

Permalink
1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
JustS-js committed Jun 10, 2023
1 parent b5fc815 commit 2e0ccc9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.28
minecraft_version=1.20
yarn_mappings=1.20+build.1
loader_version=0.14.21

#Fabric api
fabric_version=0.76.0+1.19.2
fabric_version=0.83.0+1.20

# Mod Properties
mod_version=1.0
maven_group=net.just_s
archives_base_name=world-day

modmenu_version = 4.2.0-beta.2
cloth_version = 8.2.88
modmenu_version = 7.0.1
cloth_version = 11.0.99
25 changes: 16 additions & 9 deletions src/client/java/net/just_s/WorldDaysModClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
Expand All @@ -29,7 +32,7 @@ private static int rgb2argb(int rgb, int alpha) {
return (((((alpha << 8) + red) << 8) + green) << 8) + blue;
}

private void renderText(MatrixStack matrices, float v) {
private void renderText(DrawContext context, float tickDelta) {
if (MC.options.debugEnabled || !CONFIG.enable) return;

// Calculate current day in the world
Expand Down Expand Up @@ -59,37 +62,41 @@ private void renderText(MatrixStack matrices, float v) {
}

// Create "layer" for text rendering
matrices.push();
context.getMatrices().push();

// Move said layer to Text coordinates
matrices.translate(CONFIG.hudX, CONFIG.hudY, 0);
context.getMatrices().translate(CONFIG.hudX, CONFIG.hudY, 0);

// scale layer to Font Size
matrices.scale(CONFIG.fontSize, CONFIG.fontSize, 0.0F);
context.getMatrices().scale(CONFIG.fontSize, CONFIG.fontSize, 0.0F);

// Render Shadow first if needed
if (CONFIG.shouldDrawShadow) {
MC.textRenderer.draw(
matrices, text,
text,
CONFIG.shadowRelativeX, CONFIG.shadowRelativeY,
rgb2argb(
Integer.parseInt(CONFIG.shadowColor.substring(1), 16),
CONFIG.alpha
)
), false,
context.getMatrices().peek().getPositionMatrix(), context.getVertexConsumers(),
TextRenderer.TextLayerType.NORMAL, 0, 15728880
);
}

// Render text
MC.textRenderer.draw(
matrices, text,
text,
0, 0,
rgb2argb(
Integer.parseInt(CONFIG.hudColor.substring(1), 16),
CONFIG.alpha
)
), false,
context.getMatrices().peek().getPositionMatrix(), context.getVertexConsumers(),
TextRenderer.TextLayerType.NORMAL, 0, 15728880
);

// Revert all settings, so other can render their things
matrices.pop();
context.getMatrices().pop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import net.just_s.util.ClothConfigIntegration;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.option.VideoOptionsScreen;
import net.minecraft.client.gui.widget.ButtonListWidget;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.OptionListWidget;
import net.minecraft.client.option.SimpleOption;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -19,25 +19,24 @@

@Mixin(VideoOptionsScreen.class)
public class MixinVideoOptionsScreen extends Screen {
@Shadow private ButtonListWidget list;

@Shadow private OptionListWidget list;

protected MixinVideoOptionsScreen(Text title) {
super(title);
}

@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/ButtonListWidget;addAll([Lnet/minecraft/client/option/SimpleOption;)V", shift = At.Shift.AFTER))
@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/OptionListWidget;addAll([Lnet/minecraft/client/option/SimpleOption;)V", shift = At.Shift.AFTER))
private void run(CallbackInfo info) {
if (isLoaded("modmenu") && isLoaded("cloth-config")) return;

if (isLoaded("cloth-config")) {
ButtonWidget btn = new ButtonWidget(
5, 5,
150, 20,
ButtonWidget btn = ButtonWidget.builder(
Text.translatable("config.world-days.title"),
(button) -> WorldDaysModClient.MC.setScreen(
ClothConfigIntegration.generateScreen((VideoOptionsScreen)(Object)this)
)
);
).size(150, 20).position(5, 5).build();
this.addDrawableChild(btn);
} else {
SimpleOption<Boolean> simpleOption = SimpleOption.ofBoolean(
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
],
"depends": {
"fabricloader": ">=0.14.6",
"minecraft": "1.19.2",
"minecraft": "1.20",
"java": ">=17",
"fabric-api": "*"
},
Expand Down

0 comments on commit 2e0ccc9

Please sign in to comment.