Skip to content

Commit

Permalink
Port to 1.19
Browse files Browse the repository at this point in the history
- Updated Gradle wrapper to 7.4.2
- Updated buildscript dependencies
- Removed "conflicts" metadata
- Renamed LICENSE.md to LICENSE
- Improved regex pattern in ModelBakeryMixin
- Migrated to implicit local variable typing
- Set compiler release version to Java 17
- Updated copyright headers
  • Loading branch information
ChloeDawn committed Jun 16, 2022
1 parent da86c6a commit 5560ea5
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 66 deletions.
File renamed without changes.
47 changes: 25 additions & 22 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import java.time.Instant

plugins {
id(/*net.fabricmc.*/ "fabric-loom") version "0.10.66"
id("io.github.juuxel.loom-quiltflower-mini") version "1.2.1"
id("net.nemerosa.versioning") version "2.15.1"
id(/*net.fabricmc.*/ "fabric-loom") version "0.12.48"
id("io.github.juuxel.loom-quiltflower") version "1.7.2"
id("net.nemerosa.versioning") version "3.0.0"
id("org.gradle.signing")
}

group = "dev.sapphic"
version = "2.2.0"
version = "2.3.0"

if ("CI" in System.getenv()) {
version = "$version-${versioning.info.build}"
Expand Down Expand Up @@ -46,19 +46,25 @@ repositories {
}

dependencies {
minecraft("com.mojang:minecraft:1.18.1")
mappings(loom.officialMojangMappings())
minecraft("com.mojang:minecraft:1.19")
mappings(loom.layered {
officialMojangMappings {
nameSyntheticMembers = true
}
})

modImplementation("net.fabricmc:fabric-loader:0.13.0")
modImplementation("net.fabricmc:fabric-loader:0.14.7")
implementation("com.google.code.findbugs:jsr305:3.0.2")
implementation("org.jetbrains:annotations:23.0.0")
implementation("org.checkerframework:checker-qual:3.21.1")
implementation("org.checkerframework:checker-qual:3.22.1")

modCompileOnly("curse.maven:charm-318872:3393290") { // 1.17-3.3.2
modCompileOnly("curse.maven:charm-318872:3829804") { // 1.19-4.1.2
isTransitive = false
}

modCompileOnly("curse.maven:red-bits-403914:3612273") { // 1.12.0
// Binary compatible with unpublished 1.19 codebase
// https://github.com/magistermaks/mod-redbits/tree/ab96a1aa0625e662065789802625423b8ffd7a51
modCompileOnly("curse.maven:red-bits-403914:3822702") { // 1.13.3
isTransitive = false
}
}
Expand All @@ -71,12 +77,13 @@ tasks {
isFork = true
compilerArgs.addAll(
listOf(
"-Xlint:all",
"-Xlint:-processing",
"-parameters" // JEP 118
"-Xlint:all", "-Xlint:-processing",
// Enable parameter name class metadata
// https://openjdk.java.net/jeps/118
"-parameters"
)
)
release.set(8)
release.set(17)
}
}

Expand All @@ -87,7 +94,7 @@ tasks {
}

jar {
from("/LICENSE.md")
from("/LICENSE")

manifest.attributes(
"Build-Timestamp" to Instant.now(),
Expand Down Expand Up @@ -138,19 +145,15 @@ tasks {

sign(remapJar.get())
}

val signSourcesJar by creating(Sign::class) {
dependsOn(remapSourcesJar)
/*
Loom does not expose remapSourcesJar as a Jar task
so we target the original sourcesJar task here
NOTE This will fail when the internals change
*/

doFirst {
antSignJar(getByName<Jar>("sourcesJar"))
antSignJar(remapSourcesJar.get())
}

sign(getByName<Jar>("sourcesJar"))
sign(remapSourcesJar.get())
}

assemble {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=c9490e938b221daf0094982288e4038deed954a3f12fb54cbf270ddf4e37d879
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
distributionSha256Sum=e6d864e3b5bc05cc62041842b306383fc1fefcec359e70cebb1d470a6094ca82
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion src/main/java/dev/sapphic/plated/PressurePlates.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Chloe Dawn
* Copyright 2022 Chloe Dawn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
36 changes: 17 additions & 19 deletions src/main/java/dev/sapphic/plated/client/mixin/ModelBakeryMixin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Chloe Dawn
* Copyright 2022 Chloe Dawn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,23 +40,20 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Mixin(ModelBakery.class)
@Environment(EnvType.CLIENT)
abstract class ModelBakeryMixin {
@Unique
private static final Pattern BLOCK_STATE_KEY_PATTERN =
Pattern.compile("blockstates/(?<key>.*)[.]json");
Pattern.compile("^blockstates/(?<key>.*)[.]json$");

@Unique private static final Direction[] DIRECTIONS = Direction.values();

@Unique
private static @Nullable ResourceLocation resolve(final ResourceLocation rl) {
final Matcher matcher = BLOCK_STATE_KEY_PATTERN.matcher(rl.getPath());
final var matcher = BLOCK_STATE_KEY_PATTERN.matcher(rl.getPath());

if (matcher.find()) {
return ResourceLocation.tryParse(rl.getNamespace() + ':' + matcher.group("key"));
Expand All @@ -72,8 +69,8 @@ private static Variant rotated(final Variant v, final Transformation transformat

@Unique
private static String facing(final Direction direction, final String variantString) {
final String facing = PressurePlates.FACING.getName() + '=' + direction.getName();
final String[] variants = ObjectArrays.concat(facing, variantString.split("[,]"));
final var facing = PressurePlates.FACING.getName() + '=' + direction.getName();
final var variants = ObjectArrays.concat(facing, variantString.split(","));

Arrays.sort(variants);

Expand All @@ -82,26 +79,27 @@ private static String facing(final Direction direction, final String variantStri

@ModifyVariable(
method =
"lambda$loadModel$17("
+ "Lnet/minecraft/server/packs/resources/Resource;"
"lambda$loadModel$17("
+ "Lnet/minecraft/resources/ResourceLocation;"
+ "Lnet/minecraft/server/packs/resources/Resource;"
+ ")Lcom/mojang/datafixers/util/Pair;",
require = 1,
allow = 1,
at = @At("RETURN"))
private Pair<String, BlockModelDefinition> applyPressurePlateRotation(
final Pair<String, BlockModelDefinition> pair, final Resource resource) {
if (Registry.BLOCK.get(resolve(resource.getLocation())) instanceof BasePressurePlateBlock) {
final Map<String, MultiVariant> groups = pair.getSecond().getVariants();
final Pair<String, BlockModelDefinition> pair, final ResourceLocation location, final Resource resource) {
if (Registry.BLOCK.get(resolve(location)) instanceof BasePressurePlateBlock) {
final var groups = pair.getSecond().getVariants();

for (final String variantString : new HashSet<>(groups.keySet())) {
final List<Variant> variants = groups.remove(variantString).getVariants();
for (final var variantString : new HashSet<>(groups.keySet())) {
final var variants = groups.remove(variantString).getVariants();

for (final Direction direction : DIRECTIONS) {
final List<Variant> rotatedVariants = new ArrayList<>(variants.size());
final Transformation transformation =
for (final var direction : DIRECTIONS) {
final var rotatedVariants = new ArrayList<Variant>(variants.size());
final var transformation =
new Transformation(null, direction.getRotation(), null, null);

for (final Variant variant : variants) {
for (final var variant : variants) {
rotatedVariants.add(rotated(variant, transformation));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Chloe Dawn
* Copyright 2022 Chloe Dawn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Chloe Dawn
* Copyright 2022 Chloe Dawn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -55,19 +55,19 @@ abstract class BasePressurePlateBlockMixin extends Block implements SimpleWaterl

@Override
public @Nullable BlockState getStateForPlacement(final BlockPlaceContext context) {
final Level level = context.getLevel();
final BlockPos pos = context.getClickedPos();
final Direction clickedFace = context.getClickedFace();
final boolean waterlogged = level.getFluidState(pos).getType() == Fluids.WATER;
BlockState state =
final var level = context.getLevel();
final var pos = context.getClickedPos();
final var clickedFace = context.getClickedFace();
final var waterlogged = level.getFluidState(pos).getType() == Fluids.WATER;
var state =
this.defaultBlockState().setValue(FACING, clickedFace).setValue(WATERLOGGED, waterlogged);

// Always prefer the clicked face
if (state.canSurvive(level, pos)) {
return state;
}

for (final Direction face : FACES) {
for (final var face : FACES) {
if (face == clickedFace) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Chloe Dawn
* Copyright 2022 Chloe Dawn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Chloe Dawn
* Copyright 2022 Chloe Dawn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Chloe Dawn
* Copyright 2022 Chloe Dawn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Chloe Dawn
* Copyright 2022 Chloe Dawn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/sapphic/plated/mixin/package-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Chloe Dawn
* Copyright 2022 Chloe Dawn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Chloe Dawn
* Copyright 2022 Chloe Dawn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Chloe Dawn
* Copyright 2022 Chloe Dawn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/sapphic/plated/package-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Chloe Dawn
* Copyright 2022 Chloe Dawn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
8 changes: 2 additions & 6 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@
"description": "Allows placement of pressure plates on any solid face of a block.",
"license": "Apache-2.0",
"depends": {
"minecraft": "1.18.x",
"fabricloader": ">=0.12.11",
"minecraft": "1.19",
"fabricloader": ">=0.14.6",
"java": ">=8"
},
"conflicts": {
"charm": "<3.1.1",
"red-bits": "<1.7.0"
},
"mixins": [
"mixins/plated/mixins.client.json",
"mixins/plated/mixins.server.json"
Expand Down

0 comments on commit 5560ea5

Please sign in to comment.