Skip to content

Commit

Permalink
Update for 1.21.4 and drop pre-1.21.4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Dec 31, 2024
1 parent ae424af commit f35bbe7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 48 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ indraSpotlessLicenser {
}

val runVersions = listOf(
"21.1",
"21.4",
)

tasks {
Expand Down Expand Up @@ -186,7 +186,7 @@ sourceSets {
}

val releaseNotes = providers.environmentVariable("RELEASE_NOTES")
val versions = listOf("1.19.4", "1.20.6", "1.21")
val versions = listOf("1.21.4")
val shadowJar = tasks.shadowJar.flatMap { it.archiveFile }

hangarPublish.publications.register("plugin") {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cloud-minecraft-extras = { module = "org.incendo:cloud-minecraft-extras" }
brigadier = "com.mojang:brigadier:1.0.18"

# paper
paperApi = "io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT"
paperApi = "io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT"
paperTrail = "io.papermc:paper-trail:1.0.1"

# config
Expand Down
Binary file modified resources/ChessCraft_Resource_Pack.zip
Binary file not shown.
60 changes: 16 additions & 44 deletions src/main/java/xyz/jpenilla/chesscraft/config/PieceOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
*/
package xyz.jpenilla.chesscraft.config;

import io.papermc.paper.datacomponent.DataComponentTypes;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
import net.kyori.adventure.key.Key;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.intellij.lang.annotations.Subst;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.serialize.SerializationException;
Expand Down Expand Up @@ -55,7 +59,6 @@ enum Mode {

@ConfigSerializable
final class DisplayEntity implements PieceOptions {
private Material material = Material.PAPER;
private Map<PieceType, Double> heights = Map.of(
PieceType.PAWN, 2.0D - 11.5D / 16.0D,
PieceType.BISHOP, 2.0D - 3.5D / 16.0D,
Expand All @@ -64,33 +67,18 @@ final class DisplayEntity implements PieceOptions {
PieceType.QUEEN, 2.0D - 4.0D / 16.0D,
PieceType.KING, 2.0D
);
private Map<PieceType, Integer> whiteCustomModelData = Map.of(
PieceType.PAWN, 7,
PieceType.BISHOP, 8,
PieceType.KNIGHT, 9,
PieceType.ROOK, 10,
PieceType.QUEEN, 11,
PieceType.KING, 12
);
private Map<PieceType, Integer> blackCustomModelData = Map.of(
PieceType.PAWN, 1,
PieceType.BISHOP, 2,
PieceType.KNIGHT, 3,
PieceType.ROOK, 4,
PieceType.QUEEN, 5,
PieceType.KING, 6
);

private int customModelData(final Piece piece) {
private Key itemModel(final Piece piece) {
@Subst("pawn") final String type = piece.type().name().toLowerCase(Locale.ROOT);
if (piece.color() == PieceColor.WHITE) {
return this.whiteCustomModelData.get(piece.type());
return Key.key("chesscraft", "chess_" + type + "_white");
}
return this.blackCustomModelData.get(piece.type());
return Key.key("chesscraft", "chess_" + type + "_black");
}

public ItemStack item(final Piece piece) {
final ItemStack stack = new ItemStack(this.material);
stack.editMeta(meta -> meta.setCustomModelData(this.customModelData(piece)));
final ItemStack stack = ItemStack.of(Material.PAPER);
stack.setData(DataComponentTypes.ITEM_MODEL, this.itemModel(piece));
return stack;
}

Expand All @@ -111,7 +99,6 @@ public Mode mode() {

@ConfigSerializable
final class ItemFrame implements PieceOptions {
private Material material = Material.PAPER;
private Map<PieceType, Double> heightOffsets = Map.of(
PieceType.PAWN, -11.5D / 16.0D,
PieceType.BISHOP, -3.5D / 16.0D,
Expand All @@ -120,37 +107,22 @@ final class ItemFrame implements PieceOptions {
PieceType.QUEEN, -4.0D / 16.0D,
PieceType.KING, 0.0D
);
private Map<PieceType, Integer> whiteCustomModelData = Map.of(
PieceType.PAWN, 7,
PieceType.BISHOP, 8,
PieceType.KNIGHT, 9,
PieceType.ROOK, 10,
PieceType.QUEEN, 11,
PieceType.KING, 12
);
private Map<PieceType, Integer> blackCustomModelData = Map.of(
PieceType.PAWN, 1,
PieceType.BISHOP, 2,
PieceType.KNIGHT, 3,
PieceType.ROOK, 4,
PieceType.QUEEN, 5,
PieceType.KING, 6
);

public double heightOffset(final PieceType type) {
return this.heightOffsets.getOrDefault(type, 0.0D);
}

private int customModelData(final Piece piece) {
private Key itemModel(final Piece piece) {
@Subst("pawn") final String type = piece.type().name().toLowerCase(Locale.ROOT);
if (piece.color() == PieceColor.WHITE) {
return this.whiteCustomModelData.get(piece.type());
return Key.key("chesscraft", "chess_" + type + "_white");
}
return this.blackCustomModelData.get(piece.type());
return Key.key("chesscraft", "chess_" + type + "_black");
}

public ItemStack item(final Piece piece) {
final ItemStack stack = new ItemStack(this.material);
stack.editMeta(meta -> meta.setCustomModelData(this.customModelData(piece)));
final ItemStack stack = ItemStack.of(Material.PAPER);
stack.setData(DataComponentTypes.ITEM_MODEL, this.itemModel(piece));
return stack;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: ChessCraft
version: $version
main: xyz.jpenilla.chesscraft.dependency.io.papermc.papertrail.RequiresPaperPlugins
author: jmp
api-version: 1.21.1
api-version: 1.21.4

0 comments on commit f35bbe7

Please sign in to comment.