From 369e4b348b84d613c802fa5d18da388fe4097caf Mon Sep 17 00:00:00 2001 From: Pyrofab Date: Sun, 21 Jul 2024 01:40:19 +0200 Subject: [PATCH] Update to CCA 6.0 --- README.md | 7 +++++-- gradle.properties | 2 +- gradle/libs.versions.toml | 6 +++--- .../org/ladysnake/impersonate/Impersonate.java | 10 +++++----- .../org/ladysnake/impersonate/Impersonator.java | 2 +- .../impersonate/impl/PlayerImpersonator.java | 16 +++++++++------- src/main/resources/fabric.mod.json | 6 +++--- 7 files changed, 27 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 48b6e00..2d89b46 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,9 @@ If you only grant `impersonate.command.disguise.self`, players will only be able ## Adding Impersonate to your project +> [!NOTE] +> You can find buildscript samples for any Minecraft version on the wiki: https://ladysnake.org/wiki/impersonate#using-impersonate-for-developers + You can add the library by inserting the following in your `build.gradle` : **Note 1: since MC 1.17 builds, the Impersonate dependency must be lowercase.** @@ -83,8 +86,8 @@ dependencies { include "org.ladysnake:impersonate:${impersonate_version}" // Impersonate dependencies include "me.lucko:fabric-permissions-api:${fpa_version}" - include "dev.onyxstudios.cardinal-components-api:cardinal-components-base:${cca_version}" - include "dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${cca_version}" + include "org.ladysnake.cardinal-components-api:cardinal-components-base:${cca_version}" + include "org.ladysnake.cardinal-components-api:cardinal-components-entity:${cca_version}" } ``` diff --git a/gradle.properties b/gradle.properties index bb7792e..587a070 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ jb_annotations_version = 23.0.0 apiguardian_version = 1.1.2 # Mod Properties -mod_version = 3.0.1 +mod_version = 3.1.0 maven_group = org.ladysnake archives_base_name = impersonate diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 00df816..c6c09d1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,10 +1,10 @@ [versions] -cca = "5.4.0" +cca = "6.0.0" fpa = "0.2-SNAPSHOT" elmendorf = "0.12.0-SNAPSHOT" [libraries] -cca-base = { module = "dev.onyxstudios.cardinal-components-api:cardinal-components-base", version.ref = "cca" } -cca-entity = { module = "dev.onyxstudios.cardinal-components-api:cardinal-components-entity", version.ref = "cca" } +cca-base = { module = "org.ladysnake.cardinal-components-api:cardinal-components-base", version.ref = "cca" } +cca-entity = { module = "org.ladysnake.cardinal-components-api:cardinal-components-entity", version.ref = "cca" } fpa = { module = "me.lucko:fabric-permissions-api", version.ref = "fpa" } elmendorf = { module = "org.ladysnake:elmendorf", version.ref = "elmendorf"} diff --git a/src/main/java/org/ladysnake/impersonate/Impersonate.java b/src/main/java/org/ladysnake/impersonate/Impersonate.java index e97e42d..9f41283 100644 --- a/src/main/java/org/ladysnake/impersonate/Impersonate.java +++ b/src/main/java/org/ladysnake/impersonate/Impersonate.java @@ -17,11 +17,11 @@ */ package org.ladysnake.impersonate; -import dev.onyxstudios.cca.api.v3.component.ComponentKey; -import dev.onyxstudios.cca.api.v3.component.ComponentRegistryV3; -import dev.onyxstudios.cca.api.v3.entity.EntityComponentFactoryRegistry; -import dev.onyxstudios.cca.api.v3.entity.EntityComponentInitializer; -import dev.onyxstudios.cca.api.v3.entity.RespawnCopyStrategy; +import org.ladysnake.cca.api.v3.component.ComponentKey; +import org.ladysnake.cca.api.v3.component.ComponentRegistryV3; +import org.ladysnake.cca.api.v3.entity.EntityComponentFactoryRegistry; +import org.ladysnake.cca.api.v3.entity.EntityComponentInitializer; +import org.ladysnake.cca.api.v3.entity.RespawnCopyStrategy; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; diff --git a/src/main/java/org/ladysnake/impersonate/Impersonator.java b/src/main/java/org/ladysnake/impersonate/Impersonator.java index 3ce32f6..317d457 100644 --- a/src/main/java/org/ladysnake/impersonate/Impersonator.java +++ b/src/main/java/org/ladysnake/impersonate/Impersonator.java @@ -18,7 +18,7 @@ package org.ladysnake.impersonate; import com.mojang.authlib.GameProfile; -import dev.onyxstudios.cca.api.v3.component.Component; +import org.ladysnake.cca.api.v3.component.Component; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Identifier; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/org/ladysnake/impersonate/impl/PlayerImpersonator.java b/src/main/java/org/ladysnake/impersonate/impl/PlayerImpersonator.java index 9353bc5..813d080 100644 --- a/src/main/java/org/ladysnake/impersonate/impl/PlayerImpersonator.java +++ b/src/main/java/org/ladysnake/impersonate/impl/PlayerImpersonator.java @@ -18,8 +18,10 @@ package org.ladysnake.impersonate.impl; import com.mojang.authlib.GameProfile; -import dev.onyxstudios.cca.api.v3.component.CopyableComponent; -import dev.onyxstudios.cca.api.v3.component.sync.AutoSyncedComponent; +import net.minecraft.network.RegistryByteBuf; +import net.minecraft.registry.RegistryWrapper; +import org.ladysnake.cca.api.v3.component.CopyableComponent; +import org.ladysnake.cca.api.v3.component.sync.AutoSyncedComponent; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.minecraft.component.type.ProfileComponent; import net.minecraft.entity.player.PlayerEntity; @@ -184,7 +186,7 @@ public GameProfile getImpersonatedProfile() { } @Override - public void copyFrom(PlayerImpersonator other) { + public void copyFrom(PlayerImpersonator other, RegistryWrapper.WrapperLookup registryLookup) { this.stopImpersonations(); this.stackedImpersonations.putAll(other.stackedImpersonations); this.resetImpersonation(); @@ -199,7 +201,7 @@ public boolean shouldSyncWith(ServerPlayerEntity player) { } @Override - public void writeSyncPacket(PacketByteBuf buf, ServerPlayerEntity recipient) { + public void writeSyncPacket(RegistryByteBuf buf, ServerPlayerEntity recipient) { GameProfile profile = this.getImpersonatedProfile(); if (profile == null) { buf.writeBoolean(false); @@ -210,14 +212,14 @@ public void writeSyncPacket(PacketByteBuf buf, ServerPlayerEntity recipient) { } @Override - public void applySyncPacket(PacketByteBuf buf) { + public void applySyncPacket(RegistryByteBuf buf) { boolean present = buf.readBoolean(); GameProfile profile = present ? PacketCodecs.GAME_PROFILE.decode(buf) : null; this.setImpersonatedProfile(profile); } @Override - public void readFromNbt(@NotNull NbtCompound tag) { + public void readFromNbt(@NotNull NbtCompound tag, RegistryWrapper.WrapperLookup registryLookup) { if (tag.contains("impersonations", NbtElement.LIST_TYPE)) { this.stopImpersonations(); NbtList impersonations = tag.getList("impersonations", NbtElement.COMPOUND_TYPE); @@ -236,7 +238,7 @@ public void readFromNbt(@NotNull NbtCompound tag) { } @Override - public void writeToNbt(@NotNull NbtCompound tag) { + public void writeToNbt(@NotNull NbtCompound tag, RegistryWrapper.WrapperLookup registryLookup) { if (this.isImpersonating()) { NbtList profiles = new NbtList(); for (var entry : this.stackedImpersonations.entrySet()) { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 4f9d4d4..3f230ff 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -40,10 +40,10 @@ } ], "depends": { - "minecraft": ">=1.19-", + "minecraft": "~1.20.5-", "fabric": "*", - "cardinal-components-base": "^5.0.0-", - "cardinal-components-entity": "^5.0.0-", + "cardinal-components-base": "^6.0.0-", + "cardinal-components-entity": "^6.0.0-", "fabric-permissions-api-v0": "*" }, "custom": {