From bffc5b089847b683b736d0b51b3587c5355447cd Mon Sep 17 00:00:00 2001 From: Pyrofab Date: Wed, 5 Jun 2024 12:05:24 +0200 Subject: [PATCH] Update to 1.21 --- README.md | 2 +- .../internal/base/AbstractComponentContainer.java | 2 +- .../cca/internal/base/CcaClientInternals.java | 3 ++- .../cca/internal/base/ComponentUpdatePayload.java | 2 +- .../cca/internal/base/asm/CcaBootstrap.java | 2 +- .../ladysnake/cca/internal/base/CcaTesting.java | 6 +++--- .../cca/test/base/LoadAwareTestComponent.java | 2 +- .../cca/test/base/TickingTestComponent.java | 2 +- .../java/org/ladysnake/cca/test/base/Vita.java | 2 +- .../cca/api/v3/block/BlockComponents.java | 2 +- .../cca/internal/CardinalComponentsBlock.java | 2 +- .../ladysnake/cca/test/block/CcaBlockTestMod.java | 2 +- .../cca/test/block/CcaBlockTestSuite.java | 2 +- .../org/ladysnake/cca/test/block/VitaCompound.java | 2 +- .../internal/chunk/CardinalComponentsChunk.java | 2 +- .../mixin/chunk/common/MixinChunkSerializer.java | 3 ++- .../cca/test/chunk/CcaChunkTestSuite.java | 3 ++- .../cca/api/v3/entity/RespawnCopyStrategy.java | 2 +- .../internal/entity/CardinalComponentsEntity.java | 4 ++-- .../mixin/entity/common/MixinPlayerManager.java | 5 +++-- .../cca/test/entity/CcaEntityTestMod.java | 2 +- .../org/ladysnake/cca/test/entity/TestEntity.java | 7 ------- .../v3/item/ItemComponentMigrationRegistry.java | 6 +++--- .../internal/item/StaticItemComponentPlugin.java | 12 +++++------- .../internal/level/CardinalComponentsLevel.java | 2 +- .../scoreboard/CardinalComponentsScoreboard.java | 4 ++-- changelog.md | 5 +++++ gradle.properties | 14 +++++++------- .../content/CardinalComponentsTest.java | 4 ++-- .../componenttest/content/TestComponents.java | 4 ++-- .../content/TestStaticComponentInitializer.java | 6 +++--- .../componenttest/content/VitalityStickItem.java | 2 +- .../componenttest/content/vita/ItemVita.java | 10 +++++----- 33 files changed, 65 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index 9cbaceb1..a6934207 100644 --- a/README.md +++ b/README.md @@ -211,7 +211,7 @@ component** to some providers (here, to players and worlds): ```java public final class MyComponents implements EntityComponentInitializer, WorldComponentInitializer { public static final ComponentKey MAGIK = - ComponentRegistryV3.INSTANCE.getOrCreate(new Identifier("mymod:magik"), IntComponent.class); + ComponentRegistryV3.INSTANCE.getOrCreate(Identifier.of("mymod:magik"), IntComponent.class); @Override public void registerEntityComponentFactories(EntityComponentFactoryRegistry registry) { diff --git a/cardinal-components-base/src/main/java/org/ladysnake/cca/internal/base/AbstractComponentContainer.java b/cardinal-components-base/src/main/java/org/ladysnake/cca/internal/base/AbstractComponentContainer.java index 688fb499..1cfba4ea 100644 --- a/cardinal-components-base/src/main/java/org/ladysnake/cca/internal/base/AbstractComponentContainer.java +++ b/cardinal-components-base/src/main/java/org/ladysnake/cca/internal/base/AbstractComponentContainer.java @@ -78,7 +78,7 @@ public void fromTag(NbtCompound tag, RegistryWrapper.WrapperLookup registryLooku NbtList componentList = tag.getList(NBT_KEY, NbtElement.COMPOUND_TYPE); for (int i = 0; i < componentList.size(); i++) { NbtCompound nbt = componentList.getCompound(i); - ComponentKey type = ComponentRegistry.get(new Identifier(nbt.getString("componentId"))); + ComponentKey type = ComponentRegistry.get(Identifier.of(nbt.getString("componentId"))); if (type != null) { Component component = type.getInternal(this); if (component != null) { diff --git a/cardinal-components-base/src/main/java/org/ladysnake/cca/internal/base/CcaClientInternals.java b/cardinal-components-base/src/main/java/org/ladysnake/cca/internal/base/CcaClientInternals.java index f5737e7c..6b716c18 100644 --- a/cardinal-components-base/src/main/java/org/ladysnake/cca/internal/base/CcaClientInternals.java +++ b/cardinal-components-base/src/main/java/org/ladysnake/cca/internal/base/CcaClientInternals.java @@ -23,6 +23,7 @@ package org.ladysnake.cca.internal.base; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; +import net.minecraft.network.DisconnectionInfo; import net.minecraft.network.packet.CustomPayload; import net.minecraft.text.Text; import org.ladysnake.cca.api.v3.component.Component; @@ -41,7 +42,7 @@ public static > void registerComponentSync(C } }); } catch (UnknownComponentException e) { - ctx.player().networkHandler.onDisconnected(Text.literal(e.getMessage() + "\n(you are probably missing a mod installed on the server)" + ComponentsInternals.getClientOptionalModAdvice())); + ctx.player().networkHandler.onDisconnected(new DisconnectionInfo(Text.literal(e.getMessage() + "\n(you are probably missing a mod installed on the server)" + ComponentsInternals.getClientOptionalModAdvice()))); } finally { payload.buf().release(); } diff --git a/cardinal-components-base/src/main/java/org/ladysnake/cca/internal/base/ComponentUpdatePayload.java b/cardinal-components-base/src/main/java/org/ladysnake/cca/internal/base/ComponentUpdatePayload.java index 37f4f137..3f0fab4d 100644 --- a/cardinal-components-base/src/main/java/org/ladysnake/cca/internal/base/ComponentUpdatePayload.java +++ b/cardinal-components-base/src/main/java/org/ladysnake/cca/internal/base/ComponentUpdatePayload.java @@ -41,7 +41,7 @@ public record ComponentUpdatePayload( RegistryByteBuf buf ) implements CustomPayload { public static CustomPayload.Id> id(String path) { - return CustomPayload.id("cardinal-components:" + path); + return new CustomPayload.Id<>(Identifier.of("cardinal-components", path)); } public static void register(Id> id, PacketCodec targetDataCodec) { diff --git a/cardinal-components-base/src/main/java/org/ladysnake/cca/internal/base/asm/CcaBootstrap.java b/cardinal-components-base/src/main/java/org/ladysnake/cca/internal/base/asm/CcaBootstrap.java index e45604cc..77c3f057 100644 --- a/cardinal-components-base/src/main/java/org/ladysnake/cca/internal/base/asm/CcaBootstrap.java +++ b/cardinal-components-base/src/main/java/org/ladysnake/cca/internal/base/asm/CcaBootstrap.java @@ -89,7 +89,7 @@ protected void init() { if (metadata.containsCustomValue("cardinal-components")) { try { for (CustomValue value : metadata.getCustomValue("cardinal-components").getAsArray()) { - staticComponentTypes.add(new Identifier(value.getAsString())); + staticComponentTypes.add(Identifier.of(value.getAsString())); } } catch (ClassCastException | InvalidIdentifierException e) { throw new StaticComponentLoadingException("Failed to load component ids declared by " + metadata.getName() + "(" + metadata.getId() + ")", e); diff --git a/cardinal-components-base/src/testmod/java/org/ladysnake/cca/internal/base/CcaTesting.java b/cardinal-components-base/src/testmod/java/org/ladysnake/cca/internal/base/CcaTesting.java index 59cfbd35..5521e787 100644 --- a/cardinal-components-base/src/testmod/java/org/ladysnake/cca/internal/base/CcaTesting.java +++ b/cardinal-components-base/src/testmod/java/org/ladysnake/cca/internal/base/CcaTesting.java @@ -27,8 +27,8 @@ import java.util.List; public class CcaTesting { - public static final Identifier TEST_ID_1 = new Identifier("testmod:test"); - public static final Identifier TEST_ID_2 = new Identifier("testmod:test_2"); - public static final Identifier TEST_ID_3 = new Identifier("testmod:test_3"); + public static final Identifier TEST_ID_1 = Identifier.of("testmod:test"); + public static final Identifier TEST_ID_2 = Identifier.of("testmod:test_2"); + public static final Identifier TEST_ID_3 = Identifier.of("testmod:test_3"); public static final List ALL_TEST_IDS = List.of(TEST_ID_1, TEST_ID_2, TEST_ID_3); } diff --git a/cardinal-components-base/src/testmod/java/org/ladysnake/cca/test/base/LoadAwareTestComponent.java b/cardinal-components-base/src/testmod/java/org/ladysnake/cca/test/base/LoadAwareTestComponent.java index 93f4421e..6b3dcbaf 100644 --- a/cardinal-components-base/src/testmod/java/org/ladysnake/cca/test/base/LoadAwareTestComponent.java +++ b/cardinal-components-base/src/testmod/java/org/ladysnake/cca/test/base/LoadAwareTestComponent.java @@ -30,7 +30,7 @@ import org.ladysnake.cca.api.v3.component.load.ServerUnloadAwareComponent; public class LoadAwareTestComponent implements TransientComponent, ServerLoadAwareComponent, ServerUnloadAwareComponent { - public static final ComponentKey KEY = ComponentRegistry.getOrCreate(new Identifier("cca-base-test", "loading"), LoadAwareTestComponent.class); + public static final ComponentKey KEY = ComponentRegistry.getOrCreate(Identifier.of("cca-base-test", "loading"), LoadAwareTestComponent.class); private int loadCounter = 0; diff --git a/cardinal-components-base/src/testmod/java/org/ladysnake/cca/test/base/TickingTestComponent.java b/cardinal-components-base/src/testmod/java/org/ladysnake/cca/test/base/TickingTestComponent.java index 2c66bbf6..70036846 100644 --- a/cardinal-components-base/src/testmod/java/org/ladysnake/cca/test/base/TickingTestComponent.java +++ b/cardinal-components-base/src/testmod/java/org/ladysnake/cca/test/base/TickingTestComponent.java @@ -31,7 +31,7 @@ import org.ladysnake.cca.api.v3.component.tick.ServerTickingComponent; public class TickingTestComponent implements ServerTickingComponent, ClientTickingComponent { - public static final ComponentKey KEY = ComponentRegistry.getOrCreate(new Identifier("cca-base-test", "ticking"), TickingTestComponent.class); + public static final ComponentKey KEY = ComponentRegistry.getOrCreate(Identifier.of("cca-base-test", "ticking"), TickingTestComponent.class); private int clientTicks; private int serverTicks; diff --git a/cardinal-components-base/src/testmod/java/org/ladysnake/cca/test/base/Vita.java b/cardinal-components-base/src/testmod/java/org/ladysnake/cca/test/base/Vita.java index afeb206c..094bfbb8 100644 --- a/cardinal-components-base/src/testmod/java/org/ladysnake/cca/test/base/Vita.java +++ b/cardinal-components-base/src/testmod/java/org/ladysnake/cca/test/base/Vita.java @@ -28,7 +28,7 @@ import org.ladysnake.cca.api.v3.component.ComponentV3; public interface Vita extends ComponentV3 { - ComponentKey KEY = ComponentRegistryV3.INSTANCE.getOrCreate(new Identifier("cca-base-test", "vita"), Vita.class); + ComponentKey KEY = ComponentRegistryV3.INSTANCE.getOrCreate(Identifier.of("cca-base-test", "vita"), Vita.class); static Vita get(Object provider) { return KEY.get(provider); diff --git a/cardinal-components-block/src/main/java/org/ladysnake/cca/api/v3/block/BlockComponents.java b/cardinal-components-block/src/main/java/org/ladysnake/cca/api/v3/block/BlockComponents.java index e7a86c8f..fe9d1996 100644 --- a/cardinal-components-block/src/main/java/org/ladysnake/cca/api/v3/block/BlockComponents.java +++ b/cardinal-components-block/src/main/java/org/ladysnake/cca/api/v3/block/BlockComponents.java @@ -79,7 +79,7 @@ public static void exposeApi(ComponentKey key, BlockApiLooku * *
{@code
      * public interface FluidContainerCompound extends Component {
-     *      ComponentKey KEY = ComponentRegistry.register(new Identifier("mymod:fluid_container_compound"), FluidContainerCompound.class);
+     *      ComponentKey KEY = ComponentRegistry.register(Identifier.of("mymod:fluid_container_compound"), FluidContainerCompound.class);
      *
      *      FluidContainer get(Direction side);
      * }
diff --git a/cardinal-components-block/src/main/java/org/ladysnake/cca/internal/CardinalComponentsBlock.java b/cardinal-components-block/src/main/java/org/ladysnake/cca/internal/CardinalComponentsBlock.java
index 585e9759..4111e972 100644
--- a/cardinal-components-block/src/main/java/org/ladysnake/cca/internal/CardinalComponentsBlock.java
+++ b/cardinal-components-block/src/main/java/org/ladysnake/cca/internal/CardinalComponentsBlock.java
@@ -42,7 +42,7 @@ public class CardinalComponentsBlock {
      * 

Components synchronized through this channel will have {@linkplain AutoSyncedComponent#applySyncPacket(net.minecraft.network.RegistryByteBuf)} * called on the game thread. */ - public static final CustomPayload.Id> PACKET_ID = CustomPayload.id("cardinal-components:block_entity_sync"); + public static final CustomPayload.Id> PACKET_ID = ComponentUpdatePayload.id("block_entity_sync"); public static void init() { if (FabricLoader.getInstance().isModLoaded("fabric-networking-api-v1")) { diff --git a/cardinal-components-block/src/testmod/java/org/ladysnake/cca/test/block/CcaBlockTestMod.java b/cardinal-components-block/src/testmod/java/org/ladysnake/cca/test/block/CcaBlockTestMod.java index b9a3c98a..1b51a4dd 100644 --- a/cardinal-components-block/src/testmod/java/org/ladysnake/cca/test/block/CcaBlockTestMod.java +++ b/cardinal-components-block/src/testmod/java/org/ladysnake/cca/test/block/CcaBlockTestMod.java @@ -39,7 +39,7 @@ public class CcaBlockTestMod implements ModInitializer, BlockComponentInitializer { public static final String MOD_ID = "cca-block-test"; - public static final BlockApiLookup VITA_API_LOOKUP = BlockApiLookup.get(new Identifier(MOD_ID, "sided_vita"), Vita.class, Direction.class); + public static final BlockApiLookup VITA_API_LOOKUP = BlockApiLookup.get(Identifier.of(MOD_ID, "sided_vita"), Vita.class, Direction.class); @Override public void registerBlockComponentFactories(BlockComponentFactoryRegistry registry) { diff --git a/cardinal-components-block/src/testmod/java/org/ladysnake/cca/test/block/CcaBlockTestSuite.java b/cardinal-components-block/src/testmod/java/org/ladysnake/cca/test/block/CcaBlockTestSuite.java index 9487dc0b..0944308a 100644 --- a/cardinal-components-block/src/testmod/java/org/ladysnake/cca/test/block/CcaBlockTestSuite.java +++ b/cardinal-components-block/src/testmod/java/org/ladysnake/cca/test/block/CcaBlockTestSuite.java @@ -94,7 +94,7 @@ public void beComponentsTick(TestContext ctx) { BlockPos pos = new BlockPos(1, 1, 1); ctx.setBlockState(pos, Blocks.END_PORTAL); ctx.addFinalTaskWithDuration(5, () -> { - int ticks = Objects.requireNonNull(ctx.getBlockEntity(pos)).getComponent(TickingTestComponent.KEY).serverTicks(); + int ticks = TickingTestComponent.KEY.get(ctx.getBlockEntity(pos)).serverTicks(); GameTestUtil.assertTrue("Component should tick 5 times", ticks == 5); }); } diff --git a/cardinal-components-block/src/testmod/java/org/ladysnake/cca/test/block/VitaCompound.java b/cardinal-components-block/src/testmod/java/org/ladysnake/cca/test/block/VitaCompound.java index 79e1eb5b..d19866c7 100644 --- a/cardinal-components-block/src/testmod/java/org/ladysnake/cca/test/block/VitaCompound.java +++ b/cardinal-components-block/src/testmod/java/org/ladysnake/cca/test/block/VitaCompound.java @@ -41,7 +41,7 @@ import java.util.Map; public class VitaCompound implements AutoSyncedComponent { - public static final ComponentKey KEY = ComponentRegistryV3.INSTANCE.getOrCreate(new Identifier(CcaBlockTestMod.MOD_ID, "vita_compound"), VitaCompound.class); + public static final ComponentKey KEY = ComponentRegistryV3.INSTANCE.getOrCreate(Identifier.of(CcaBlockTestMod.MOD_ID, "vita_compound"), VitaCompound.class); private final Map storage = new EnumMap<>(Direction.class); diff --git a/cardinal-components-chunk/src/main/java/org/ladysnake/cca/internal/chunk/CardinalComponentsChunk.java b/cardinal-components-chunk/src/main/java/org/ladysnake/cca/internal/chunk/CardinalComponentsChunk.java index 2bec8c67..3f5f081c 100644 --- a/cardinal-components-chunk/src/main/java/org/ladysnake/cca/internal/chunk/CardinalComponentsChunk.java +++ b/cardinal-components-chunk/src/main/java/org/ladysnake/cca/internal/chunk/CardinalComponentsChunk.java @@ -33,7 +33,7 @@ import org.ladysnake.cca.internal.base.MorePacketCodecs; public final class CardinalComponentsChunk { - public static final CustomPayload.Id> PACKET_ID = CustomPayload.id("cardinal-components:chunk_sync"); + public static final CustomPayload.Id> PACKET_ID = ComponentUpdatePayload.id("chunk_sync"); public static void init() { if (FabricLoader.getInstance().isModLoaded("fabric-networking-api-v1")) { diff --git a/cardinal-components-chunk/src/main/java/org/ladysnake/cca/mixin/chunk/common/MixinChunkSerializer.java b/cardinal-components-chunk/src/main/java/org/ladysnake/cca/mixin/chunk/common/MixinChunkSerializer.java index 73ee3d9d..5c476ed2 100644 --- a/cardinal-components-chunk/src/main/java/org/ladysnake/cca/mixin/chunk/common/MixinChunkSerializer.java +++ b/cardinal-components-chunk/src/main/java/org/ladysnake/cca/mixin/chunk/common/MixinChunkSerializer.java @@ -31,6 +31,7 @@ import net.minecraft.world.chunk.ProtoChunk; import net.minecraft.world.chunk.WrapperProtoChunk; import net.minecraft.world.poi.PointOfInterestStorage; +import net.minecraft.world.storage.StorageKey; import org.ladysnake.cca.internal.base.AbstractComponentContainer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -40,7 +41,7 @@ @Mixin(ChunkSerializer.class) public abstract class MixinChunkSerializer { @Inject(method = "deserialize", at = @At("RETURN")) - private static void deserialize(ServerWorld world, PointOfInterestStorage pointOfInterestStorage, ChunkPos chunkPos, NbtCompound tag, CallbackInfoReturnable cir) { + private static void deserialize(ServerWorld world, PointOfInterestStorage poiStorage, StorageKey key, ChunkPos chunkPos, NbtCompound tag, CallbackInfoReturnable cir) { ProtoChunk ret = cir.getReturnValue(); Chunk chunk = ret instanceof WrapperProtoChunk ? ((WrapperProtoChunk) ret).getWrappedChunk() : ret; chunk.asComponentProvider().getComponentContainer().fromTag(tag, world.getRegistryManager()); diff --git a/cardinal-components-chunk/src/testmod/java/org/ladysnake/cca/test/chunk/CcaChunkTestSuite.java b/cardinal-components-chunk/src/testmod/java/org/ladysnake/cca/test/chunk/CcaChunkTestSuite.java index 9742c731..0bdbf9c7 100644 --- a/cardinal-components-chunk/src/testmod/java/org/ladysnake/cca/test/chunk/CcaChunkTestSuite.java +++ b/cardinal-components-chunk/src/testmod/java/org/ladysnake/cca/test/chunk/CcaChunkTestSuite.java @@ -31,6 +31,7 @@ import net.minecraft.world.ChunkSerializer; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.WorldChunk; +import net.minecraft.world.storage.StorageKey; import org.ladysnake.cca.test.base.LoadAwareTestComponent; import org.ladysnake.cca.test.base.TickingTestComponent; import org.ladysnake.cca.test.base.Vita; @@ -43,7 +44,7 @@ public void chunksSerialize(TestContext ctx) { Chunk c = new WorldChunk(ctx.getWorld(), pos); c.getComponent(Vita.KEY).setVitality(42); NbtCompound nbt = ChunkSerializer.serialize(ctx.getWorld(), c); - Chunk c1 = ChunkSerializer.deserialize(ctx.getWorld(), ctx.getWorld().getPointOfInterestStorage(), pos, nbt); + Chunk c1 = ChunkSerializer.deserialize(ctx.getWorld(), ctx.getWorld().getPointOfInterestStorage(), new StorageKey("", ctx.getWorld().getRegistryKey(), ""), pos, nbt); GameTestUtil.assertTrue("Chunk component data should survive deserialization", c1.getComponent(Vita.KEY).getVitality() == 42); ctx.complete(); } diff --git a/cardinal-components-entity/src/main/java/org/ladysnake/cca/api/v3/entity/RespawnCopyStrategy.java b/cardinal-components-entity/src/main/java/org/ladysnake/cca/api/v3/entity/RespawnCopyStrategy.java index 2530e3b4..28668c87 100644 --- a/cardinal-components-entity/src/main/java/org/ladysnake/cca/api/v3/entity/RespawnCopyStrategy.java +++ b/cardinal-components-entity/src/main/java/org/ladysnake/cca/api/v3/entity/RespawnCopyStrategy.java @@ -101,7 +101,7 @@ public interface RespawnCopyStrategy { *

Mods that depend on component data for their own copying logic can {@linkplain net.fabricmc.fabric.api.event.Event#addPhaseOrdering(Identifier, Identifier) add a phase ordering} * to run after CCA's listeners. */ - Identifier EVENT_PHASE = new Identifier("cardinal-components", "component-copy"); + Identifier EVENT_PHASE = Identifier.of("cardinal-components", "component-copy"); /** * @param entityClass the class of the source entity being respawned or converted diff --git a/cardinal-components-entity/src/main/java/org/ladysnake/cca/internal/entity/CardinalComponentsEntity.java b/cardinal-components-entity/src/main/java/org/ladysnake/cca/internal/entity/CardinalComponentsEntity.java index beab3314..9d54a0f6 100644 --- a/cardinal-components-entity/src/main/java/org/ladysnake/cca/internal/entity/CardinalComponentsEntity.java +++ b/cardinal-components-entity/src/main/java/org/ladysnake/cca/internal/entity/CardinalComponentsEntity.java @@ -61,7 +61,7 @@ public final class CardinalComponentsEntity { *

Components synchronized through this channel will have {@linkplain AutoSyncedComponent#applySyncPacket(net.minecraft.network.RegistryByteBuf)} * called on the game thread. */ - public static final CustomPayload.Id> PACKET_ID = CustomPayload.id("cardinal-components:entity_sync"); + public static final CustomPayload.Id> PACKET_ID = ComponentUpdatePayload.id("entity_sync"); /** * {@link net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket} channel for C2S player component messages. * @@ -70,7 +70,7 @@ public final class CardinalComponentsEntity { *

Components synchronized through this channel will have {@linkplain org.ladysnake.cca.api.v3.entity.C2SSelfMessagingComponent#handleC2SMessage(net.minecraft.network.RegistryByteBuf)} * called on the game thread. */ - public static final CustomPayload.Id> C2S_SELF_PACKET_ID = CustomPayload.id("cardinal-components:player_message_c2s"); + public static final CustomPayload.Id> C2S_SELF_PACKET_ID = ComponentUpdatePayload.id("player_message_c2s"); private static final Set unknownC2SPlayerComponents = new HashSet<>(); public static void init() { diff --git a/cardinal-components-entity/src/main/java/org/ladysnake/cca/mixin/entity/common/MixinPlayerManager.java b/cardinal-components-entity/src/main/java/org/ladysnake/cca/mixin/entity/common/MixinPlayerManager.java index 538ea0fd..e9d21e90 100644 --- a/cardinal-components-entity/src/main/java/org/ladysnake/cca/mixin/entity/common/MixinPlayerManager.java +++ b/cardinal-components-entity/src/main/java/org/ladysnake/cca/mixin/entity/common/MixinPlayerManager.java @@ -22,6 +22,7 @@ */ package org.ladysnake.cca.mixin.entity.common; +import net.minecraft.entity.Entity; import net.minecraft.network.ClientConnection; import net.minecraft.server.PlayerManager; import net.minecraft.server.network.ConnectedClientData; @@ -39,7 +40,7 @@ public abstract class MixinPlayerManager { method = "onPlayerConnect", at = @At( value = "INVOKE", - target = "Lnet/minecraft/server/network/ServerPlayerEntity;getStatusEffects()Ljava/util/Collection;" + target = "Lnet/minecraft/server/PlayerManager;sendStatusEffects(Lnet/minecraft/server/network/ServerPlayerEntity;)V" ) ) private void onPlayerLogIn(ClientConnection connection, ServerPlayerEntity player, ConnectedClientData clientData, CallbackInfo ci) { @@ -58,7 +59,7 @@ private void sendPlayerStatus(ServerPlayerEntity player, CallbackInfo info) { method = "respawnPlayer", at = @At("RETURN") ) - private void respawnPlayer(ServerPlayerEntity player, boolean end, CallbackInfoReturnable cir) { + private void respawnPlayer(ServerPlayerEntity player, boolean alive, Entity.RemovalReason removalReason, CallbackInfoReturnable cir) { PlayerSyncCallback.EVENT.invoker().onPlayerSync(cir.getReturnValue()); } } diff --git a/cardinal-components-entity/src/testmod/java/org/ladysnake/cca/test/entity/CcaEntityTestMod.java b/cardinal-components-entity/src/testmod/java/org/ladysnake/cca/test/entity/CcaEntityTestMod.java index 59da3398..713494f6 100644 --- a/cardinal-components-entity/src/testmod/java/org/ladysnake/cca/test/entity/CcaEntityTestMod.java +++ b/cardinal-components-entity/src/testmod/java/org/ladysnake/cca/test/entity/CcaEntityTestMod.java @@ -59,6 +59,6 @@ public void registerEntityComponentFactories(EntityComponentFactoryRegistry regi @Override public void onInitialize() { - Registry.register(Registries.ENTITY_TYPE, new Identifier("cca-entity-test", "test"), TEST_ENTITY); + Registry.register(Registries.ENTITY_TYPE, Identifier.of("cca-entity-test", "test"), TEST_ENTITY); } } diff --git a/cardinal-components-entity/src/testmod/java/org/ladysnake/cca/test/entity/TestEntity.java b/cardinal-components-entity/src/testmod/java/org/ladysnake/cca/test/entity/TestEntity.java index c949a9f8..16e3db78 100644 --- a/cardinal-components-entity/src/testmod/java/org/ladysnake/cca/test/entity/TestEntity.java +++ b/cardinal-components-entity/src/testmod/java/org/ladysnake/cca/test/entity/TestEntity.java @@ -26,8 +26,6 @@ import net.minecraft.entity.EntityType; import net.minecraft.entity.data.DataTracker; import net.minecraft.nbt.NbtCompound; -import net.minecraft.network.listener.ClientPlayPacketListener; -import net.minecraft.network.packet.Packet; import net.minecraft.world.World; public class TestEntity extends Entity { @@ -49,9 +47,4 @@ protected void readCustomDataFromNbt(NbtCompound nbt) { protected void writeCustomDataToNbt(NbtCompound nbt) { } - - @Override - public Packet createSpawnPacket() { - return null; - } } diff --git a/cardinal-components-item/src/main/java/org/ladysnake/cca/api/v3/item/ItemComponentMigrationRegistry.java b/cardinal-components-item/src/main/java/org/ladysnake/cca/api/v3/item/ItemComponentMigrationRegistry.java index c2b168f3..2a45b053 100644 --- a/cardinal-components-item/src/main/java/org/ladysnake/cca/api/v3/item/ItemComponentMigrationRegistry.java +++ b/cardinal-components-item/src/main/java/org/ladysnake/cca/api/v3/item/ItemComponentMigrationRegistry.java @@ -22,7 +22,7 @@ */ package org.ladysnake.cca.api.v3.item; -import net.minecraft.component.DataComponentType; +import net.minecraft.component.ComponentType; import net.minecraft.util.Identifier; import org.ladysnake.cca.api.v3.component.ComponentKey; @@ -31,12 +31,12 @@ */ public interface ItemComponentMigrationRegistry { /** - * Registers an item component migration from the specified {@link ComponentKey#getId() CCA Component ID} to an equivalent {@link DataComponentType}. + * Registers an item component migration from the specified {@link ComponentKey#getId() CCA Component ID} to an equivalent {@link ComponentType}. * *

This hooks into the vanilla datafixing process and may therefore not correctly migrate data for stacks stored in modded containers. * * @param oldComponentId the item component ID from CCA days * @param mcComponentType the new vanilla component type */ - void registerMigration(Identifier oldComponentId, DataComponentType mcComponentType); + void registerMigration(Identifier oldComponentId, ComponentType mcComponentType); } diff --git a/cardinal-components-item/src/main/java/org/ladysnake/cca/internal/item/StaticItemComponentPlugin.java b/cardinal-components-item/src/main/java/org/ladysnake/cca/internal/item/StaticItemComponentPlugin.java index 9f65a49c..a1aa5cf1 100644 --- a/cardinal-components-item/src/main/java/org/ladysnake/cca/internal/item/StaticItemComponentPlugin.java +++ b/cardinal-components-item/src/main/java/org/ladysnake/cca/internal/item/StaticItemComponentPlugin.java @@ -22,15 +22,13 @@ */ package org.ladysnake.cca.internal.item; -import com.mojang.serialization.Dynamic; import net.fabricmc.api.ModInitializer; -import net.minecraft.component.DataComponentType; +import net.minecraft.component.ComponentType; import net.minecraft.datafixer.fix.ItemStackComponentizationFix; import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; -import org.ladysnake.cca.api.v3.item.ItemComponentMigrationRegistry; import org.ladysnake.cca.api.v3.item.ItemComponentInitializer; -import org.ladysnake.cca.internal.base.AbstractComponentContainer; +import org.ladysnake.cca.api.v3.item.ItemComponentMigrationRegistry; import org.ladysnake.cca.internal.base.ComponentsInternals; import org.ladysnake.cca.internal.base.asm.StaticComponentPluginBase; @@ -42,17 +40,17 @@ public final class StaticItemComponentPlugin implements ItemComponentMigrationRe private StaticItemComponentPlugin() {} - private final Map> migrations = new HashMap<>(); + private final Map> migrations = new HashMap<>(); @Override - public void registerMigration(Identifier oldComponentId, DataComponentType mcComponentType) { + public void registerMigration(Identifier oldComponentId, ComponentType mcComponentType) { if (this.migrations.put(oldComponentId, mcComponentType) != null) { ComponentsInternals.LOGGER.warn("[Cardinal-Components-API] Overwriting component migration for {}", oldComponentId); } } public void migrate(ItemStackComponentizationFix.StackData data) { - for (Map.Entry> entry : migrations.entrySet()) { + for (Map.Entry> entry : migrations.entrySet()) { String oldComponentId = entry.getKey().toString(); String mcComponentId = Registries.DATA_COMPONENT_TYPE.getKey(entry.getValue()).orElseThrow( () -> new IllegalStateException("Registered migration for component " + oldComponentId + " towards unregistered item component type " + entry.getValue()) diff --git a/cardinal-components-level/src/main/java/org/ladysnake/cca/internal/level/CardinalComponentsLevel.java b/cardinal-components-level/src/main/java/org/ladysnake/cca/internal/level/CardinalComponentsLevel.java index c6d0256f..3163c465 100644 --- a/cardinal-components-level/src/main/java/org/ladysnake/cca/internal/level/CardinalComponentsLevel.java +++ b/cardinal-components-level/src/main/java/org/ladysnake/cca/internal/level/CardinalComponentsLevel.java @@ -41,7 +41,7 @@ public final class CardinalComponentsLevel { *

Components synchronized through this channel will have {@linkplain AutoSyncedComponent#applySyncPacket(net.minecraft.network.RegistryByteBuf)} * called on the game thread. */ - public static final CustomPayload.Id> PACKET_ID = CustomPayload.id("cardinal-components:level_sync"); + public static final CustomPayload.Id> PACKET_ID = ComponentUpdatePayload.id("level_sync"); public static void init() { if (FabricLoader.getInstance().isModLoaded("fabric-networking-api-v1")) { diff --git a/cardinal-components-scoreboard/src/main/java/org/ladysnake/cca/internal/scoreboard/CardinalComponentsScoreboard.java b/cardinal-components-scoreboard/src/main/java/org/ladysnake/cca/internal/scoreboard/CardinalComponentsScoreboard.java index 262cc11d..31334bd3 100644 --- a/cardinal-components-scoreboard/src/main/java/org/ladysnake/cca/internal/scoreboard/CardinalComponentsScoreboard.java +++ b/cardinal-components-scoreboard/src/main/java/org/ladysnake/cca/internal/scoreboard/CardinalComponentsScoreboard.java @@ -44,14 +44,14 @@ public final class CardinalComponentsScoreboard { *

Components synchronized through this channel will have {@linkplain AutoSyncedComponent#applySyncPacket(net.minecraft.network.RegistryByteBuf)} * called on the game thread. */ - public static final CustomPayload.Id> SCOREBOARD_PACKET_ID = CustomPayload.id("cardinal-components:scoreboard_sync"); + public static final CustomPayload.Id> SCOREBOARD_PACKET_ID = ComponentUpdatePayload.id("scoreboard_sync"); /** * {@link CustomPayloadS2CPacket} channel for default team component synchronization. * *

Components synchronized through this channel will have {@linkplain AutoSyncedComponent#applySyncPacket(net.minecraft.network.RegistryByteBuf)} * called on the game thread. */ - public static final CustomPayload.Id> TEAM_PACKET_ID = CustomPayload.id("cardinal-components:team_sync"); + public static final CustomPayload.Id> TEAM_PACKET_ID = ComponentUpdatePayload.id("team_sync"); public static void init() { if (FabricLoader.getInstance().isModLoaded("fabric-networking-api-v1")) { diff --git a/changelog.md b/changelog.md index 221bbc4e..50ac75ec 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,8 @@ +------------------------------------------------------ +Version 6.1.0 +------------------------------------------------------ +Updated to 1.21 + ------------------------------------------------------ Version 6.0.0 ------------------------------------------------------ diff --git a/gradle.properties b/gradle.properties index 47253d0c..b36ca918 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,20 +4,20 @@ org.gradle.parallel=true fabric.loom.multiProjectOptimisation=true #see https://fabricmc.net/develop/ -minecraft_version=1.20.6 -yarn_mappings=1 +minecraft_version=1.21-pre2 +yarn_mappings=2 loader_version=0.15.11 #Fabric api -fabric_api_version=0.98.0+1.20.6 +fabric_api_version=0.99.4+1.21 -elmendorf_version=0.12.0-SNAPSHOT +elmendorf_version=0.13.0 #Publishing -mod_version = 6.0.0 +mod_version = 6.1.0 curseforge_id = 318449 modrinth_id = K01OU20C -curseforge_versions = 1.20.5; 1.20.6 -modrinth_versions = 1.20.5; 1.20.6 +curseforge_versions = 1.21-Snapshot +modrinth_versions = 1.21-pre2 release_type = release display_name = Cardinal-Components-API owners = Ladysnake diff --git a/src/testmod/java/org/ladysnake/componenttest/content/CardinalComponentsTest.java b/src/testmod/java/org/ladysnake/componenttest/content/CardinalComponentsTest.java index fa5301db..a73024f3 100644 --- a/src/testmod/java/org/ladysnake/componenttest/content/CardinalComponentsTest.java +++ b/src/testmod/java/org/ladysnake/componenttest/content/CardinalComponentsTest.java @@ -82,7 +82,7 @@ public class CardinalComponentsTest { FabricEntityTypeBuilder.create(SpawnGroup.MONSTER, VitalityZombieEntity::new).dimensions(EntityType.ZOMBIE.getDimensions()).build()); public static Identifier id(String path) { - return new Identifier("componenttest", path); + return Identifier.of("componenttest", path); } public static void init() { @@ -110,7 +110,7 @@ public static void init() { } catch (IllegalStateException ignored) { } try { - ComponentRegistryV3.INSTANCE.getOrCreate(new Identifier("hi"), Vita.class); + ComponentRegistryV3.INSTANCE.getOrCreate(Identifier.of("hi"), Vita.class); assert false : "Static components must be registered through mod metadata or plugin"; } catch (IllegalStateException ignored) { } diff --git a/src/testmod/java/org/ladysnake/componenttest/content/TestComponents.java b/src/testmod/java/org/ladysnake/componenttest/content/TestComponents.java index f49756d8..36992a7d 100644 --- a/src/testmod/java/org/ladysnake/componenttest/content/TestComponents.java +++ b/src/testmod/java/org/ladysnake/componenttest/content/TestComponents.java @@ -52,8 +52,8 @@ public final class TestComponents implements ItemComponentInitializer, ScoreboardComponentInitializer { - public static final Identifier CUSTOM_PROVIDER_1 = new Identifier("componenttest:custom/1"); - public static final Identifier CUSTOM_PROVIDER_2 = new Identifier("componenttest:custom/2"); + public static final Identifier CUSTOM_PROVIDER_1 = Identifier.of("componenttest:custom/1"); + public static final Identifier CUSTOM_PROVIDER_2 = Identifier.of("componenttest:custom/2"); public static final ComponentKey ALT_VITA = ComponentRegistryV3.INSTANCE.getOrCreate(TestStaticComponentInitializer.ALT_VITA_ID, Vita.class); diff --git a/src/testmod/java/org/ladysnake/componenttest/content/TestStaticComponentInitializer.java b/src/testmod/java/org/ladysnake/componenttest/content/TestStaticComponentInitializer.java index 7670c5cb..94d66afd 100644 --- a/src/testmod/java/org/ladysnake/componenttest/content/TestStaticComponentInitializer.java +++ b/src/testmod/java/org/ladysnake/componenttest/content/TestStaticComponentInitializer.java @@ -41,13 +41,13 @@ public final class TestStaticComponentInitializer implements StaticComponentInit public static final Logger LOGGER = LogManager.getLogger("Component Test Bootstrap"); // note: the actual ComponentKey must not be registered in this class' , to avoid circular initialization - public static final Identifier ALT_VITA_ID = new Identifier("componenttest", "alt-vita"); + public static final Identifier ALT_VITA_ID = Identifier.of("componenttest", "alt-vita"); @Override public Collection getSupportedComponentKeys() { List ret = new ArrayList<>(Collections.singleton(ALT_VITA_ID)); for (int i = 0; i < 128; i++) { - ret.add(new Identifier("-.-", "-random/test." + i)); + ret.add(Identifier.of("-.-", "-random/test." + i)); } return ret; } @@ -58,7 +58,7 @@ public void finalizeStaticBootstrap() { LOGGER.info(ComponentRegistry.getOrCreate(ALT_VITA_ID, Vita.class)); ComponentContainer.Factory.Builder builder = ComponentContainer.Factory.builder(Void.class); for (int i = 127; i >= 0; i--) { - builder.component(ComponentRegistryV3.INSTANCE.getOrCreate(new Identifier("-.-", "-random/test." + i), Vita.class), v -> new BaseVita()); + builder.component(ComponentRegistryV3.INSTANCE.getOrCreate(Identifier.of("-.-", "-random/test." + i), Vita.class), v -> new BaseVita()); } LOGGER.info(builder.build().createContainer(null)); } diff --git a/src/testmod/java/org/ladysnake/componenttest/content/VitalityStickItem.java b/src/testmod/java/org/ladysnake/componenttest/content/VitalityStickItem.java index a08a9e9d..e55b0543 100644 --- a/src/testmod/java/org/ladysnake/componenttest/content/VitalityStickItem.java +++ b/src/testmod/java/org/ladysnake/componenttest/content/VitalityStickItem.java @@ -24,7 +24,6 @@ import net.minecraft.block.BlockState; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.item.TooltipType; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.LivingEntity; @@ -32,6 +31,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUsageContext; +import net.minecraft.item.tooltip.TooltipType; import net.minecraft.scoreboard.AbstractTeam; import net.minecraft.server.world.ServerWorld; import net.minecraft.text.Text; diff --git a/src/testmod/java/org/ladysnake/componenttest/content/vita/ItemVita.java b/src/testmod/java/org/ladysnake/componenttest/content/vita/ItemVita.java index 73239518..06a755fc 100644 --- a/src/testmod/java/org/ladysnake/componenttest/content/vita/ItemVita.java +++ b/src/testmod/java/org/ladysnake/componenttest/content/vita/ItemVita.java @@ -25,7 +25,7 @@ import com.mojang.serialization.Codec; import io.netty.buffer.ByteBuf; import net.fabricmc.fabric.api.lookup.v1.item.ItemApiLookup; -import net.minecraft.component.DataComponentType; +import net.minecraft.component.ComponentType; import net.minecraft.item.ItemStack; import net.minecraft.network.codec.PacketCodec; import net.minecraft.network.codec.PacketCodecs; @@ -48,10 +48,10 @@ public static Optional maybeGet(ItemStack stack) { return Optional.ofNullable(LOOKUP.find(stack, null)); } - private final DataComponentType componentType; + private final ComponentType componentType; private final ItemStack stack; - public ItemVita(DataComponentType componentType, ItemStack stack) { + public ItemVita(ComponentType componentType, ItemStack stack) { this.componentType = componentType; this.stack = stack; } @@ -70,11 +70,11 @@ public record Data(int vitality) { public static final Data EMPTY = new Data(0); public static final Codec CODEC = Codec.INT.xmap(Data::new, Data::vitality); public static final PacketCodec PACKET_CODEC = PacketCodecs.INTEGER.xmap(Data::new, Data::vitality); - public static final DataComponentType COMPONENT_TYPE = DataComponentType.builder() + public static final ComponentType COMPONENT_TYPE = ComponentType.builder() .codec(CODEC) .packetCodec(PACKET_CODEC) .build(); - public static final DataComponentType ALT_COMPONENT_TYPE = DataComponentType.builder() + public static final ComponentType ALT_COMPONENT_TYPE = ComponentType.builder() .codec(CODEC) .packetCodec(PACKET_CODEC) .build();