Skip to content

Commit

Permalink
Update to CCA 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Jul 20, 2024
1 parent d69fcdd commit 369e4b3
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 22 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.**
Expand Down Expand Up @@ -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}"
}
```

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"}
10 changes: 5 additions & 5 deletions src/main/java/org/ladysnake/impersonate/Impersonate.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/ladysnake/impersonate/Impersonator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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()) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 369e4b3

Please sign in to comment.