Skip to content

Commit

Permalink
Port to Minecraft 1.19.3
Browse files Browse the repository at this point in the history
- Upgrade to Minecraft 1.19.3
- Upgrade to Gradle 7.6
- Upgrade to Fabric Loom 1.0
- Upgrade to Fabric Loader 0.14.11
- Upgrade to Yarn Mappings 1.19.3+build.3
- Upgrade to Fabric API 0.69.1+1.19.3
- Change build.gradle, settings.gradle to fix warnings.
- Change references that were renamed in updated Yarn (shaders, canHit).
- Migrate to JOML, which replaced Minecraft's built-in math classes.
  • Loading branch information
retrixe committed Dec 21, 2022
1 parent 2e0bed3 commit 89b6382
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 53 deletions.
55 changes: 29 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -10,6 +10,13 @@ archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
}

dependencies {
//to change the versions see the gradle.properties file
Expand All @@ -23,48 +30,44 @@ dependencies {
}

processResources {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

inputs.property "version", project.mod_version
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": project.version
}
}

// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
}

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}

jar {
from "LICENSE"
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
gpr(MavenPublication) {
from(components.java)
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
10 changes: 5 additions & 5 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.19
yarn_mappings=1.19+build.1
loader_version=0.14.6
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.3
loader_version=0.14.11

#Fabric api
fabric_version=0.55.2+1.19
fabric_version=0.69.1+1.19.3

# Mod Properties
mod_version = 1.19-fabric-1
mod_version = 1.19.3-fabric-1
maven_group = net.torocraft
archives_base_name = torohealth
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-7.3.1-bin.zip
distributionUrl=https://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.RotationAxis;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3f;
import net.torocraft.torohealth.ToroHealth;
import net.torocraft.torohealth.config.Config;
import net.torocraft.torohealth.config.Config.InWorld;
import net.torocraft.torohealth.config.Config.Mode;
import net.torocraft.torohealth.util.EntityUtil;
import net.torocraft.torohealth.util.EntityUtil.Relation;
import org.joml.Matrix4f;
import org.lwjgl.opengl.GL11;

public class HealthBarRenderer {
Expand Down Expand Up @@ -87,7 +87,7 @@ public static void renderInWorld(MatrixStack matrix, Camera camera) {
return;
}

RenderSystem.setShader(GameRenderer::getPositionColorShader);
RenderSystem.setShader(GameRenderer::getPositionColorProgram);
RenderSystem.enableDepthTest();
RenderSystem.enableBlend();
RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE,
Expand All @@ -110,8 +110,8 @@ public static void renderInWorld(MatrixStack matrix, Camera camera) {

matrix.push();
matrix.translate(x - camX, (y + height) - camY, z - camZ);
matrix.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-camera.getYaw()));
matrix.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
matrix.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-camera.getYaw()));
matrix.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch()));
matrix.scale(-scaleToGui, -scaleToGui, scaleToGui);

render(matrix, entity, 0, 0, FULL_SIZE, true);
Expand Down Expand Up @@ -183,7 +183,7 @@ private static void drawBar(Matrix4f matrix4f, double x, double y, float width,
float b = (color & 255) / 255.0F;

RenderSystem.setShaderColor(r, g, b, 1);
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
RenderSystem.setShaderTexture(0, GUI_BARS_TEXTURES);
RenderSystem.enableBlend();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3f;
import net.torocraft.torohealth.ToroHealth;
import org.lwjgl.opengl.GL11;

Expand Down Expand Up @@ -41,11 +41,11 @@ private static void renderParticle(MatrixStack matrix, BarParticle particle, Cam

matrix.push();
matrix.translate(x - camX, y - camY, z - camZ);
matrix.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-camera.getYaw()));
matrix.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
matrix.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-camera.getYaw()));
matrix.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch()));
matrix.scale(-scaleToGui, -scaleToGui, scaleToGui);

RenderSystem.setShader(GameRenderer::getPositionColorShader);
RenderSystem.setShader(GameRenderer::getPositionColorProgram);
RenderSystem.enableDepthTest();
RenderSystem.enableBlend();
RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void draw(MatrixStack matrix, LivingEntity entity) {
int xOffset = 0;

RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
RenderSystem.setShaderTexture(0, ICON_TEXTURES);
RenderSystem.enableBlend();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import net.minecraft.entity.passive.ChickenEntity;
import net.minecraft.entity.passive.VillagerEntity;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Quaternion;
import net.minecraft.util.math.Vec3f;
import net.minecraft.util.math.RotationAxis;
import org.joml.Quaternionf;

public class EntityDisplay {

Expand Down Expand Up @@ -82,10 +82,9 @@ public static void drawEntity(MatrixStack matrixStack2, int x, int y, int size,
matrixStack2.push();
matrixStack2.translate(0.0D, 0.0D, 1000.0D);
matrixStack2.scale((float) size, (float) size, (float) size);
Quaternion quaternion = Vec3f.POSITIVE_Z.getDegreesQuaternion(180.0F);
Quaternion quaternion2 = Vec3f.POSITIVE_X.getDegreesQuaternion(g * 20.0F);
quaternion.hamiltonProduct(quaternion2);
matrixStack2.multiply(quaternion);
Quaternionf quaternion = RotationAxis.POSITIVE_Z.rotationDegrees(180.0F);
Quaternionf quaternion2 = RotationAxis.POSITIVE_X.rotationDegrees(g * 20.0F);
matrixStack2.multiply(quaternion.mul(quaternion2));
float h = entity.bodyYaw;
float i = entity.getYaw();
float j = entity.getPitch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.Matrix4f;
import net.torocraft.torohealth.bars.HealthBarRenderer;
import net.torocraft.torohealth.bars.ParticleRenderer;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/torocraft/torohealth/util/RayTrace.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import net.minecraft.world.RaycastContext.FluidHandling;

public class RayTrace implements BlockView {
private static Predicate<Entity> isVisible = entity -> !entity.isSpectator() && entity.collides();
private static Predicate<Entity> isVisible = entity -> !entity.isSpectator() && entity.canHit();
private static MinecraftClient minecraft = MinecraftClient.getInstance();

@Override
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 @@ -27,7 +27,7 @@
"modmenu": "*"
},
"depends": {
"fabricloader": ">=0.14.6",
"fabricloader": ">=0.14.11",
"fabric": "*",
"minecraft": "1.19.x",
"java": ">=17"
Expand Down

0 comments on commit 89b6382

Please sign in to comment.