Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

25 changes: 8 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,25 @@ on: [pull_request, push]

jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [
21 # Minimum supported by Minecraft
]
# and run on both Linux and Windows
os: [ubuntu-20.04, windows-latest]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-24.04
steps:
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
filter: 'blob:none'
fetch-depth: 0
filter: 'blob:none'
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v1
uses: gradle/actions/wrapper-validation@v4
- name: setup jdk
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
java-version: '21'
distribution: 'microsoft'
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v4
with:
name: Artifacts
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import net.fabricmc.loom.task.RemapJarTask
import java.net.URI

plugins {
id("fabric-loom") version "1.10-SNAPSHOT"
id("fabric-loom") version "1.11-SNAPSHOT"
id("io.github.ladysnake.chenille") version "0.15.0"
id("org.cadixdev.licenser") version "0.6.1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public void syncWith(ServerPlayerEntity player, ComponentProvider provider) {
@ApiStatus.Experimental
public void syncWith(ServerPlayerEntity player, ComponentProvider provider, ComponentPacketWriter writer, PlayerSyncPredicate predicate) {
if (predicate.shouldSyncWith(player)) {
RegistryByteBuf buf = new RegistryByteBuf(Unpooled.buffer(), player.getWorld().getRegistryManager());
RegistryByteBuf buf = new RegistryByteBuf(Unpooled.buffer(), player.getEntityWorld().getRegistryManager());
writer.writeSyncPacket(buf, player);
CustomPayload payload = provider.toComponentPacket(this, predicate.isRequiredOnClient(), buf);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ private StaticBlockComponentPlugin() {

@Nullable
public <T extends BlockEntity> BlockEntityTicker<T> getComponentTicker(World world, T be, @Nullable BlockEntityTicker<T> base) {
if (world.isClient && this.clientTicking.contains(be.getClass())) {
if (world.isClient() && this.clientTicking.contains(be.getClass())) {
if (base == null) return (w, pos, state, blockEntity) -> blockEntity.asComponentProvider().getComponentContainer().tickClientComponents();
return (w, pos, state, blockEntity) -> {
blockEntity.asComponentProvider().getComponentContainer().tickClientComponents();
base.tick(w, pos, state, blockEntity);
};
} else if (!world.isClient && this.serverTicking.contains(be.getClass())) {
} else if (!world.isClient() && this.serverTicking.contains(be.getClass())) {
if (base == null) return (w, pos, state, blockEntity) -> blockEntity.asComponentProvider().getComponentContainer().tickServerComponents();
return (w, pos, state, blockEntity) -> {
blockEntity.asComponentProvider().getComponentContainer().tickServerComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public ComponentContainer getComponentContainer() {
public Iterable<ServerPlayerEntity> getRecipientsForComponentSync() {
World world = this.getWorld();

if (world != null && !world.isClient) {
if (world != null && !world.isClient()) {
return PlayerLookup.tracking((BlockEntity) (Object) this);
}
return List.of();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
*/
package org.ladysnake.cca.mixin.chunk.common;

import net.minecraft.registry.Registry;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.HeightLimitView;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkSection;
import net.minecraft.world.chunk.PalettesFactory;
import net.minecraft.world.chunk.UpgradeData;
import net.minecraft.world.gen.chunk.BlendingData;
import org.ladysnake.cca.api.v3.component.ComponentContainer;
Expand All @@ -45,7 +44,7 @@ public abstract class MixinChunk implements ComponentProvider {
private ComponentContainer components;

@Inject(method = "<init>", at = @At("RETURN"))
private void initComponents(ChunkPos pos, UpgradeData upgradeData, HeightLimitView heightLimitView, Registry<Biome> biome, long inhabitedTime, ChunkSection[] sectionArrayInitializer, BlendingData blendingData, CallbackInfo ci) {
private void initComponents(ChunkPos pos, UpgradeData upgradeData, HeightLimitView heightLimitView, PalettesFactory palettesFactory, long inhabitedTime, ChunkSection[] sectionArray, BlendingData blendingData, CallbackInfo ci) {
this.components = StaticChunkComponentPlugin.createContainer((Chunk) (Object) this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
package org.ladysnake.cca.mixin.chunk.common;

import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.storage.NbtReadView;
import net.minecraft.util.ErrorReporter;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.HeightLimitView;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.PalettesFactory;
import net.minecraft.world.chunk.ProtoChunk;
import net.minecraft.world.chunk.SerializedChunk;
import net.minecraft.world.chunk.WrapperProtoChunk;
Expand All @@ -50,7 +50,7 @@ public abstract class MixinSerializedChunk {
private @Nullable NbtCompound cca$serializedComponents;

@Inject(method = "fromNbt", at = @At("RETURN"))
private static void fromNbt(HeightLimitView world, DynamicRegistryManager registryManager, NbtCompound nbt, CallbackInfoReturnable<SerializedChunk> cir) {
private static void fromNbt(HeightLimitView world, PalettesFactory palettesFactory, NbtCompound nbt, CallbackInfoReturnable<SerializedChunk> cir) {
MixinSerializedChunk ret = (MixinSerializedChunk) (Object) cir.getReturnValue();
if (ret != null) {
ret.cca$serializedComponents = nbt.getCompound(AbstractComponentContainer.NBT_KEY).orElse(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@

import net.fabricmc.fabric.api.networking.v1.PlayerLookup;
import net.minecraft.network.RegistryByteBuf;
import net.minecraft.registry.Registry;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.HeightLimitView;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkSection;
import net.minecraft.world.chunk.PalettesFactory;
import net.minecraft.world.chunk.ProtoChunk;
import net.minecraft.world.chunk.UpgradeData;
import net.minecraft.world.chunk.WorldChunk;
Expand All @@ -53,8 +52,8 @@

@Mixin(WorldChunk.class)
public abstract class MixinWorldChunk extends Chunk implements ComponentProvider {
public MixinWorldChunk(ChunkPos pos, UpgradeData upgradeData, HeightLimitView heightLimitView, Registry<Biome> biome, long inhabitedTime, @Nullable ChunkSection[] sectionArrayInitializer, @Nullable BlendingData blendingData) {
super(pos, upgradeData, heightLimitView, biome, inhabitedTime, sectionArrayInitializer, blendingData);
public MixinWorldChunk(ChunkPos pos, UpgradeData upgradeData, HeightLimitView heightLimitView, PalettesFactory palettesFactory, long inhabitedTime, @Nullable ChunkSection[] sectionArray, @Nullable BlendingData blendingData) {
super(pos, upgradeData, heightLimitView, palettesFactory, inhabitedTime, sectionArray, blendingData);
}

@Shadow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void chunksSerialize(TestContext ctx) {
Chunk c = new WorldChunk(ctx.getWorld(), pos);
c.getComponent(Vita.KEY).setVitality(42);
NbtCompound nbt = SerializedChunk.fromChunk(ctx.getWorld(), c).serialize();
Chunk c1 = SerializedChunk.fromNbt(ctx.getWorld(), ctx.getWorld().getRegistryManager(), nbt)
Chunk c1 = SerializedChunk.fromNbt(ctx.getWorld(), ctx.getWorld().getPalettesFactory(), nbt)
.convert(ctx.getWorld(), ctx.getWorld().getPointOfInterestStorage(), new StorageKey("", ctx.getWorld().getRegistryKey(), ""), pos);
ctx.assertEquals(42, c1.getComponent(Vita.KEY).getVitality(), Text.literal("Chunk component data should survive deserialization -"));
ctx.complete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private static void copyData(LivingEntity original, LivingEntity clone, EntityCo
}

private static void copyData(ServerPlayerEntity original, ServerPlayerEntity clone, boolean lossless) {
boolean keepInventory = original.getWorld().getGameRules().getBoolean(GameRules.KEEP_INVENTORY) || clone.isSpectator();
boolean keepInventory = original.getEntityWorld().getGameRules().getBoolean(GameRules.KEEP_INVENTORY) || clone.isSpectator();
Set<ComponentKey<?>> keys = ((ComponentProvider) original).getComponentContainer().keys();

for (ComponentKey<?> key : keys) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import net.fabricmc.fabric.api.networking.v1.PlayerLookup;
import net.minecraft.entity.Entity;
import net.minecraft.network.RegistryByteBuf;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.storage.ReadView;
import net.minecraft.storage.WriteView;
Expand Down Expand Up @@ -59,8 +58,6 @@ public abstract class MixinEntity implements ComponentProvider {

@Shadow public abstract int getId();

@Shadow public abstract DynamicRegistryManager getRegistryManager();

@Inject(method = "<init>*", at = @At("RETURN"))
private void initDataTracker(CallbackInfo ci) {
this.components = CardinalEntityInternals.createEntityComponentContainer((Entity) (Object) this);
Expand All @@ -85,7 +82,7 @@ public ComponentContainer getComponentContainer() {
@Override
public Iterable<ServerPlayerEntity> getRecipientsForComponentSync() {
Entity holder = (Entity) (Object) this;
if (!this.world.isClient) {
if (!this.world.isClient()) {
Deque<ServerPlayerEntity> watchers = new ArrayDeque<>(PlayerLookup.tracking(holder));
if (holder instanceof ServerPlayerEntity player && player.networkHandler != null) {
watchers.addFirst(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
import net.minecraft.server.network.ServerPlayerEntity;
import org.ladysnake.cca.internal.entity.SwitchablePlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;

@Mixin(ServerPlayerEntity.class)
public abstract class MixinServerPlayerEntity implements SwitchablePlayerEntity {
private transient boolean switchingCharacter = false;
@Unique
private boolean switchingCharacter = false;

@Override
public void cca$markAsSwitchingCharacter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameMode;
import org.ladysnake.cca.test.base.LoadAwareTestComponent;
import org.ladysnake.cca.test.base.Vita;

public class CcaEntityTestSuite {
@GameTest
public void bucketableWorks(TestContext ctx) {
ServerPlayerEntity player = ctx.spawnServerPlayer(1, 0, 1);
player.interactionManager.changeGameMode(GameMode.SURVIVAL);
player.setStackInHand(Hand.MAIN_HAND, new ItemStack(Items.WATER_BUCKET));
BlockPos pos = new BlockPos(2, 0, 2);
var axolotl = ctx.spawnMob(EntityType.AXOLOTL, pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public EntityVita(LivingEntity owner, int baseVitality) {
@Override
public void setVitality(int value) {
super.setVitality(value);
if (!this.owner.getWorld().isClient) {
if (!this.owner.getEntityWorld().isClient()) {
if (this.getVitality() == 0) {
this.owner.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 4000));
} else if (this.getVitality() > 10) {
Expand Down
4 changes: 4 additions & 0 deletions cardinal-components-item/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
dependencies {
api(project(path = ":cardinal-components-base", configuration = "namedElements"))

// FIXME workaround for https://github.com/FabricMC/fabric-loom/issues/1334
val fabricApiVersion: String = providers.gradleProperty("fabric_api_version").get()
compileOnly(fabricApi.module("fabric-registry-sync-v0", fabricApiVersion))
}

loom {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.RegistryByteBuf;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.storage.NbtWriteView;
import net.minecraft.util.ErrorReporter;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.border.WorldBorder;
import net.minecraft.world.gen.GeneratorOptions;
import net.minecraft.world.level.LevelInfo;
import net.minecraft.world.level.LevelProperties;
Expand All @@ -55,6 +53,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import javax.annotation.Nonnull;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;

Expand All @@ -63,8 +62,8 @@ public abstract class MixinLevelProperties implements ServerWorldProperties, Com
@Unique
private ComponentContainer components;

@Inject(method = "<init>(Lnet/minecraft/nbt/NbtCompound;ZLnet/minecraft/util/math/BlockPos;FJJIIIZIZZZLnet/minecraft/world/border/WorldBorder$Properties;IILjava/util/UUID;Ljava/util/Set;Ljava/util/Set;Lnet/minecraft/world/timer/Timer;Lnet/minecraft/nbt/NbtCompound;Lnet/minecraft/entity/boss/dragon/EnderDragonFight$Data;Lnet/minecraft/world/level/LevelInfo;Lnet/minecraft/world/gen/GeneratorOptions;Lnet/minecraft/world/level/LevelProperties$SpecialProperty;Lcom/mojang/serialization/Lifecycle;)V", at = @At("RETURN"))
private void initComponents(NbtCompound playerData, boolean modded, BlockPos spawnPos, float spawnAngle, long time, long timeOfDay, int version, int clearWeatherTime, int rainTime, boolean raining, int thunderTime, boolean thundering, boolean initialized, boolean difficultyLocked, WorldBorder.Properties worldBorder, int wanderingTraderSpawnDelay, int wanderingTraderSpawnChance, UUID wanderingTraderId, Set<String> serverBrands, Set<String> removedFeatures, Timer<MinecraftServer> scheduledEvents, NbtCompound customBossEvents, EnderDragonFight.Data dragonFight, LevelInfo levelInfo, GeneratorOptions generatorOptions, LevelProperties.SpecialProperty specialProperty, Lifecycle lifecycle, CallbackInfo ci) {
@Inject(method = "<init>(Lnet/minecraft/nbt/NbtCompound;ZLnet/minecraft/util/math/BlockPos;FJJIIIZIZZZLjava/util/Optional;IILjava/util/UUID;Ljava/util/Set;Ljava/util/Set;Lnet/minecraft/world/timer/Timer;Lnet/minecraft/nbt/NbtCompound;Lnet/minecraft/entity/boss/dragon/EnderDragonFight$Data;Lnet/minecraft/world/level/LevelInfo;Lnet/minecraft/world/gen/GeneratorOptions;Lnet/minecraft/world/level/LevelProperties$SpecialProperty;Lcom/mojang/serialization/Lifecycle;)V", at = @At("RETURN"))
private void initComponents(NbtCompound playerData, boolean modded, BlockPos spawnPos, float spawnAngle, long time, long timeOfDay, int version, int clearWeatherTime, int rainTime, boolean raining, int thunderTime, boolean thundering, boolean initialized, boolean difficultyLocked, Optional worldBorder, int wanderingTraderSpawnDelay, int wanderingTraderSpawnChance, UUID wanderingTraderId, Set serverBrands, Set removedFeatures, Timer scheduledEvents, NbtCompound customBossEvents, EnderDragonFight.Data dragonFight, LevelInfo levelInfo, GeneratorOptions generatorOptions, LevelProperties.SpecialProperty specialProperty, Lifecycle lifecycle, CallbackInfo ci) {
this.components = StaticLevelComponentPlugin.createContainer(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public abstract class AmbientVita extends BaseVita implements AutoSyncedComponen
public void applySyncPacket(RegistryByteBuf buf) {
int vita = buf.readInt();
this.setVitality(vita);
World world = Objects.requireNonNull(MinecraftClient.getInstance().player).getWorld();
World world = Objects.requireNonNull(MinecraftClient.getInstance().player).getEntityWorld();
// Very bad shortcut to get a dimension's name
Text worldName = Text.literal(
Objects.requireNonNull(world.getRegistryKey() == World.OVERWORLD ? "Overworld" : "Alien World")
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ org.gradle.parallel=true
fabric.loom.multiProjectOptimisation=true

#see https://fabricmc.net/develop/
minecraft_version=1.21.6-rc1
yarn_mappings=1
loader_version=0.16.14
minecraft_version=25w36b
yarn_mappings=16
loader_version=0.17.2
#Fabric api
fabric_api_version=0.127.0+1.21.6
fabric_api_version=0.133.1+1.21.9

elmendorf_version=0.16.0

Expand All @@ -18,9 +18,9 @@ immersive_portals_version=v6.0.3-mc1.21.1
mod_version = 7.0.0-beta.1
curseforge_id = 318449
modrinth_id = K01OU20C
curseforge_versions = 1.21.6
modrinth_versions = 1.21.6
release_type = beta
curseforge_versions = 1.21.9-snapshot
modrinth_versions = 25w36b
release_type = alpha
display_name = Cardinal-Components-API
owners = Ladysnake

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion 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
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
6 changes: 3 additions & 3 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading