Skip to content

Commit

Permalink
Update to Minecraft 1.21/1.21.1
Browse files Browse the repository at this point in the history
- Adapt to minor API changes.
- Update Gradle, Loom, FLoader/FAPI, Yarn.
  • Loading branch information
retrixe committed Dec 5, 2024
1 parent 73fad36 commit 405f5b3
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 19 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ org.gradle.jvmargs=-Xmx1G
# To remap the mixin locations:
# gradlew migrateMappings --mappings "1.16.1+build.9"

minecraft_version=1.20.6
yarn_mappings=1.20.6+build.3
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.9

#Fabric api
fabric_version=0.100.8+1.20.6
fabric_version=0.110.0+1.21.1

# Mod Properties
mod_version = 1.20.5-fabric-1
mod_version = 1.21.1-fabric-1
maven_group = net.torocraft
archives_base_name = torohealth
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
Expand All @@ -29,7 +30,7 @@

public class HealthBarRenderer {

private static final Identifier GUI_BARS_TEXTURES = new Identifier(ToroHealth.MODID + ":textures/gui/bars.png");
private static final Identifier GUI_BARS_TEXTURES = Identifier.of(ToroHealth.MODID + ":textures/gui/bars.png");
private static final int DARK_GRAY = 0x808080;
private static final float FULL_SIZE = 40;

Expand Down Expand Up @@ -101,7 +102,7 @@ public static void renderInWorld(MatrixStack matrix,
boolean sneaking = entity.isInSneakingPose();
float height = entity.getHeight() + 0.6F - (sneaking ? 0.25F : 0.0F);

float tickDelta = client.getTickDelta();
float tickDelta = client.getRenderTickCounter().getTickDelta(true);
double x = MathHelper.lerp((double) tickDelta, entity.prevX, entity.getX());
double y = MathHelper.lerp((double) tickDelta, entity.prevY, entity.getY());
double z = MathHelper.lerp((double) tickDelta, entity.prevZ, entity.getZ());
Expand Down Expand Up @@ -201,16 +202,15 @@ private static void drawBar(Matrix4f matrix4f, double x, double y, float width,
float zOffsetAmount = inWorld ? -0.1F : 0.1F;

Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
buffer.vertex(matrix4f, (float) (-half + x), (float) y, zOffset * zOffsetAmount)
.texture(u * c, v * c).next();
.texture(u * c, v * c);
buffer.vertex(matrix4f, (float) (-half + x), (float) (h + y), zOffset * zOffsetAmount)
.texture(u * c, (v + vh) * c).next();
.texture(u * c, (v + vh) * c);
buffer.vertex(matrix4f, (float) (-half + size + x), (float) (h + y), zOffset * zOffsetAmount)
.texture((u + uw) * c, (v + vh) * c).next();
.texture((u + uw) * c, (v + vh) * c);
buffer.vertex(matrix4f, (float) (-half + size + x), (float) y, zOffset * zOffsetAmount)
.texture(((u + uw) * c), v * c).next();
tessellator.draw();
.texture(((u + uw) * c), v * c);
BufferRenderer.drawWithGlobalProgram(buffer.end());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private static void renderParticle(MatrixStack matrix, VertexConsumerProvider ve
float scaleToGui = 0.025f;

MinecraftClient client = MinecraftClient.getInstance();
float tickDelta = client.getTickDelta();
float tickDelta = client.getRenderTickCounter().getTickDelta(true);

double x = MathHelper.lerp((double) tickDelta, particle.xPrev, particle.x);
double y = MathHelper.lerp((double) tickDelta, particle.yPrev, particle.y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

public class BarDisplay {

private static final Identifier ARMOR_TEXTURE = new Identifier("hud/armor_full");
private static final Identifier HEART_TEXTURE = new Identifier("hud/heart/full");
private static final Identifier ARMOR_TEXTURE = Identifier.of("hud/armor_full");
private static final Identifier HEART_TEXTURE = Identifier.of("hud/heart/full");
private final MinecraftClient mc;

public BarDisplay(MinecraftClient mc) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/torocraft/torohealth/display/Hud.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

public class Hud extends Screen {
private static final Identifier BACKGROUND_TEXTURE =
new Identifier(ToroHealth.MODID + ":textures/gui/default_skin_basic.png");
Identifier.of(ToroHealth.MODID + ":textures/gui/default_skin_basic.png");
private EntityDisplay entityDisplay = new EntityDisplay();
private LivingEntity entity;
private BarDisplay barDisplay;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.render.RenderTickCounter;
import net.torocraft.torohealth.ToroHealth;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -12,7 +13,7 @@
public class InGameHudMixin {

@Inject(method = "render", at = @At("RETURN"))
private void render(DrawContext drawContext, float partial, CallbackInfo info) {
private void render(DrawContext drawContext, RenderTickCounter tickCounter, CallbackInfo ci) {
ToroHealth.HUD.draw(drawContext, ToroHealth.CONFIG);
}

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 @@ -29,7 +29,7 @@
"depends": {
"fabricloader": ">=0.14.21",
"fabric": "*",
"minecraft": "1.20.x",
"minecraft": "1.21.x",
"java": ">=21"
}
}

0 comments on commit 405f5b3

Please sign in to comment.