Skip to content

Commit

Permalink
Support 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Toshimichi0915 committed Dec 6, 2024
1 parent 99b85a2 commit c51e26e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 20 deletions.
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.2
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
loader_version=0.16.7
# Mod Properties
mod_version=1.8.7
mod_version=1.8.8
maven_group=net.toshimichi
archives_base_name=thymine
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.102.1+1.21.1
# Fabric API
fabric_version=0.107.0+1.21.3
7 changes: 4 additions & 3 deletions src/main/java/net/toshimichi/thymine/ArmorHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.item.ItemStack;
import net.minecraft.util.profiler.Profilers;
import net.minecraft.world.GameMode;
import net.toshimichi.thymine.mixin.ClientPlayerInteractionManagerAccessor;

Expand All @@ -16,7 +17,7 @@ public void render(DrawContext context) {
GameMode current = ((ClientPlayerInteractionManagerAccessor) client.interactionManager).getGameMode();
if (current != GameMode.SURVIVAL && current != GameMode.ADVENTURE) return;

client.getProfiler().push("armorHud");
Profilers.get().push("armorHud");

int index = 0;
ArrayList<ItemStack> armorItems = new ArrayList<>();
Expand All @@ -28,9 +29,9 @@ public void render(DrawContext context) {
int x = width / 2 + 12 + (index * 20);
int y = height - 57;
context.drawItem(itemStack, x, y);
context.drawItemInSlot(client.textRenderer, itemStack, x, y);
context.drawStackOverlay(client.textRenderer, itemStack, x, y);
index++;
}
client.getProfiler().pop();
Profilers.get().pop();
}
}
11 changes: 6 additions & 5 deletions src/main/java/net/toshimichi/thymine/PotionHud.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package net.toshimichi.thymine;

import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.texture.Sprite;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.util.math.ColorHelper;
import net.minecraft.util.profiler.Profilers;

public class PotionHud {

public void render(DrawContext context) {
MinecraftClient client = MinecraftClient.getInstance();
client.getProfiler().push("potionHud");
Profilers.get().push("potionHud");
TextRenderer renderer = client.textRenderer;

float x = ThymineMod.getOptions().potionHudOptions.getX();
Expand All @@ -26,8 +28,7 @@ public void render(DrawContext context) {

String text = String.format("%02d:%02d", minutes, seconds % 60);
Sprite sprite = client.getStatusEffectSpriteManager().getSprite(effect.getEffectType());
RenderSystem.setShaderTexture(0, sprite.getAtlasId());
context.drawSprite((int) x, (int) y + (index * 25), 0, 18, 18, sprite);
context.drawSpriteStretched(RenderLayer::getGuiTextured, sprite, (int) x, (int) y + (index * 25), 18, 18, ColorHelper.getWhite(1));
context.drawTextWithShadow(renderer, text, (int) (x + 21), (int) (y + 5 + (index * 25)),
ThymineMod.getOptions().potionHudOptions.color);
if (effect.getAmplifier() > 0) {
Expand All @@ -36,6 +37,6 @@ public void render(DrawContext context) {
}
index++;
}
client.getProfiler().pop();
Profilers.get().pop();
}
}
5 changes: 3 additions & 2 deletions src/main/java/net/toshimichi/thymine/ToggleSprintHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;
import net.minecraft.util.profiler.Profilers;

public class ToggleSprintHud {

public void render(DrawContext context) {
MinecraftClient client = MinecraftClient.getInstance();
client.getProfiler().push("toggleSprint");
Profilers.get().push("toggleSprint");
TextRenderer renderer = client.textRenderer;

int x = (int) ThymineMod.getOptions().toggleSprintHud.getX();
Expand All @@ -22,6 +23,6 @@ public void render(DrawContext context) {
String toggleSprintDisabled = Text.translatable("thymine.messages.toggleSprint.disabled").getString();
context.drawTextWithShadow(renderer, toggleSprintDisabled, x, y, color);
}
client.getProfiler().pop();
Profilers.get().pop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.render.VertexRendering;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.state.EntityRenderState;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.Box;
Expand All @@ -17,11 +19,11 @@
@Mixin(EntityRenderDispatcher.class)
public class EntityRenderDispatcherMixin {

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;pop()V"), method = "render")
public void render(Entity entity, double x, double y, double z, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/EntityRenderer;render(Lnet/minecraft/client/render/entity/state/EntityRenderState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V"), method = "render(Lnet/minecraft/entity/Entity;DDDFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/EntityRenderer;)V")
public void render(Entity entity, double x, double y, double z, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, EntityRenderer<? extends Entity, ? extends EntityRenderState> renderer, CallbackInfo ci) {
if (ThymineMod.getOptions().showHitBox && !entity.isInvisible() && !(entity instanceof ClientPlayerEntity)) {
Box box = entity.getBoundingBox().offset(-entity.getX(), -entity.getY(), -entity.getZ());
WorldRenderer.drawBox(matrices, vertexConsumers.getBuffer(RenderLayer.getLines()), box, 1.0f, 1.0f, 1.0f, 1.0f);
VertexRendering.drawBox(matrices, vertexConsumers.getBuffer(RenderLayer.getLines()), box, 1.0f, 1.0f, 1.0f, 1.0f);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
import net.toshimichi.thymine.ThymineMod;
import net.toshimichi.thymine.ToggleSprintHud;
import org.spongepowered.asm.mixin.Mixin;
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;

@Mixin(InGameHud.class)
public class InGameHudMixin {

@Unique
private final ToggleSprintHud toggleSprintHud = new ToggleSprintHud();
@Unique
private final PotionHud potionHud = new PotionHud();
@Unique
private final ArmorHud armorHud = new ArmorHud();

@Inject(at = @At("TAIL"), method = "render")
Expand Down

0 comments on commit c51e26e

Please sign in to comment.