Skip to content

Commit

Permalink
Update to 1.20.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Nov 28, 2023
1 parent 3c2c524 commit 03b5a37
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,28 +91,29 @@ public void canQueryThroughLookup(TestContext ctx) {

@GameTest(templateName = EMPTY_STRUCTURE)
public void beComponentsTick(TestContext ctx) {
ctx.setBlockState(BlockPos.ORIGIN, Blocks.END_PORTAL);
ctx.waitAndRun(5, () -> {
int ticks = Objects.requireNonNull(ctx.getBlockEntity(BlockPos.ORIGIN)).getComponent(TickingTestComponent.KEY).serverTicks();
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();
GameTestUtil.assertTrue("Component should tick 5 times", ticks == 5);
ctx.complete();
});
}

@GameTest(templateName = EMPTY_STRUCTURE)
public void beComponentsLoadUnload(TestContext ctx) {
BlockEntity firstCommandBlock = new CommandBlockBlockEntity(ctx.getAbsolutePos(BlockPos.ORIGIN), Blocks.CHAIN_COMMAND_BLOCK.getDefaultState());
BlockPos pos = new BlockPos(1, 1, 1);
BlockEntity firstCommandBlock = new CommandBlockBlockEntity(ctx.getAbsolutePos(pos), Blocks.CHAIN_COMMAND_BLOCK.getDefaultState());
GameTestUtil.assertTrue(
"Load counter should not be incremented until the block entity joins the world",
LoadAwareTestComponent.KEY.get(firstCommandBlock).getLoadCounter() == 0
);
ctx.setBlockState(BlockPos.ORIGIN, Blocks.CHAIN_COMMAND_BLOCK);
BlockEntity commandBlock = Objects.requireNonNull(ctx.getBlockEntity(BlockPos.ORIGIN));
ctx.setBlockState(pos, Blocks.CHAIN_COMMAND_BLOCK);
BlockEntity commandBlock = Objects.requireNonNull(ctx.getBlockEntity(pos));
GameTestUtil.assertTrue(
"Load counter should be incremented once when the block entity joins the world",
LoadAwareTestComponent.KEY.get(commandBlock).getLoadCounter() == 1
);
ctx.setBlockState(BlockPos.ORIGIN, Blocks.AIR);
ctx.setBlockState(pos, Blocks.AIR);
ctx.waitAndRun(1, () -> {
GameTestUtil.assertTrue(
"Load counter should be decremented when the block entity leaves the world",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/
package dev.onyxstudios.cca.mixin.level.common;

import com.mojang.datafixers.DataFixer;
import com.mojang.serialization.Dynamic;
import com.mojang.serialization.Lifecycle;
import dev.onyxstudios.cca.api.v3.component.ComponentContainer;
Expand All @@ -36,18 +35,15 @@
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.entity.boss.dragon.EnderDragonFight;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.world.border.WorldBorder;
import net.minecraft.world.gen.GeneratorOptions;
import net.minecraft.world.level.LevelInfo;
import net.minecraft.world.level.LevelProperties;
import net.minecraft.world.level.ServerWorldProperties;
import net.minecraft.world.level.storage.SaveVersionInfo;
import net.minecraft.world.timer.Timer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
Expand All @@ -66,13 +62,13 @@ public abstract class MixinLevelProperties implements ServerWorldProperties, Com
@Unique
private ComponentContainer components;

@Inject(method = "Lnet/minecraft/world/level/LevelProperties;<init>(Lcom/mojang/datafixers/DataFixer;ILnet/minecraft/nbt/NbtCompound;ZIIIFJJIIIZIZZZLnet/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(DataFixer dataFixer, int dataVersion, NbtCompound playerData, boolean modded, int spawnX, int spawnY, int spawnZ, 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;ZIIIFJJIIIZIZZZLnet/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, int spawnX, int spawnY, int spawnZ, 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<?> 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);
}

@Inject(method = "readProperties", at = @At("RETURN"))
private static void readComponents(Dynamic<NbtElement> dynamic, DataFixer dataFixer, int dataVersion, NbtCompound playerData, LevelInfo levelInfo, SaveVersionInfo saveVersionInfo, LevelProperties.SpecialProperty specialProperty, GeneratorOptions generatorOptions, Lifecycle lifecycle, CallbackInfoReturnable<LevelProperties> cir) {
private static <T> void readComponents(Dynamic<T> dynamic, LevelInfo info, LevelProperties.SpecialProperty specialProperty, GeneratorOptions generatorOptions, Lifecycle lifecycle, CallbackInfoReturnable<LevelProperties> cir) {
((ComponentProvider) cir.getReturnValue()).getComponentContainer().fromDynamic(dynamic);
}

Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
------------------------------------------------------
Version 5.4.0
------------------------------------------------------
Updated to 1.20.3

------------------------------------------------------
Version 5.3.0
------------------------------------------------------
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ org.gradle.parallel=true
fabric.loom.multiProjectOptimisation=true

#see https://fabricmc.net/develop/
minecraft_version=1.20.2-pre2
yarn_mappings=5
loader_version=0.14.22
minecraft_version=1.20.3-pre4
yarn_mappings=2
loader_version=0.14.25
#Fabric api
fabric_api_version=0.88.3+1.20.2
fabric_api_version=0.91.1+1.20.3

elmendorf_version=0.12.0

#Publishing
mod_version = 5.3.0
mod_version = 5.4.0
curseforge_id = 318449
modrinth_id = K01OU20C
curseforge_versions = 1.20.2-Snapshot
modrinth_versions = 1.20.2-pre2
curseforge_versions = 1.20.3-Snapshot
modrinth_versions = 1.20.3-pre4
release_type = release
display_name = Cardinal-Components-API
owners = Ladysnake
Expand Down

0 comments on commit 03b5a37

Please sign in to comment.