Skip to content

Commit

Permalink
Initial 1.21 update
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Jun 16, 2024
1 parent a92ab0b commit 7aff6ce
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ repositories {
mavenContent {
includeModule("org.incendo", "cloud-sponge")
includeGroup("xyz.jpenilla")
includeModule("net.kyori", "adventure-platform-fabric") // TODO
snapshotsOnly()
}
}
Expand Down
4 changes: 4 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ minecraft {
accessWideners(layout.projectDirectory.file("src/main/resources/squaremap-common.accesswidener"))
}

configurations.all {
exclude("org.lwjgl", "lwjgl-freetype") // TODO: Don't care about running client :D (work around VG bug/Mojang repo weirdness?)
}

dependencies {
api(projects.squaremapApi)
api(libs.guice) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private void invisibleBlocks() {
"minecraft:short_grass",
"minecraft:large_fern"
)
).forEach(block -> this.invisibleBlocks.add(Util.requireEntry(BuiltInRegistries.BLOCK, new ResourceLocation(block))));
).forEach(block -> this.invisibleBlocks.add(Util.requireEntry(BuiltInRegistries.BLOCK, ResourceLocation.parse(block))));
}

public final Set<Block> iterateUpBaseBlocks = new HashSet<>();
Expand All @@ -59,7 +59,7 @@ private void iterateUpBaseBlocks() {
"minecraft:magma_block",
"minecraft:basalt"
)
).forEach(block -> this.iterateUpBaseBlocks.add(Util.requireEntry(BuiltInRegistries.BLOCK, new ResourceLocation(block))));
).forEach(block -> this.iterateUpBaseBlocks.add(Util.requireEntry(BuiltInRegistries.BLOCK, ResourceLocation.parse(block))));
}

public final Reference2IntMap<Biome> COLOR_OVERRIDES_BIOME_FOLIAGE = new Reference2IntOpenHashMap<>();
Expand All @@ -79,7 +79,7 @@ private void colorOverrideBiomeFoliageSettings() {
Map.entry("minecraft:mangrove_swamp", "#6f9623")
)
).forEach((key, color) -> {
final Biome biome = Util.requireEntry(registry, new ResourceLocation(key));
final Biome biome = Util.requireEntry(registry, ResourceLocation.parse(key));
this.COLOR_OVERRIDES_BIOME_FOLIAGE.put(biome, Colors.parseHex(color));
});
}
Expand All @@ -95,7 +95,7 @@ private void colorOverrideBiomeGrassSettings() {
"color-overrides.biomes.grass",
Map.of()
).forEach((key, color) -> {
final Biome biome = Util.requireEntry(registry, new ResourceLocation(key));
final Biome biome = Util.requireEntry(registry, ResourceLocation.parse(key));
this.COLOR_OVERRIDES_BIOME_GRASS.put(biome, Colors.parseHex(color));
});
}
Expand All @@ -111,7 +111,7 @@ private void colorOverrideBiomeWaterSettings() {
"color-overrides.biomes.water",
Map.of()
).forEach((key, color) -> {
final Biome biome = Util.requireEntry(registry, new ResourceLocation(key));
final Biome biome = Util.requireEntry(registry, ResourceLocation.parse(key));
this.COLOR_OVERRIDES_BIOME_WATER.put(biome, Colors.parseHex(color));
});
}
Expand Down Expand Up @@ -154,7 +154,7 @@ private void colorOverrideBlocksSettings() {
Map.entry("minecraft:glass", "#FFFFFF")
)
).forEach((key, color) -> {
final Block block = Util.requireEntry(BuiltInRegistries.BLOCK, new ResourceLocation(key));
final Block block = Util.requireEntry(BuiltInRegistries.BLOCK, ResourceLocation.parse(key));
if (block != Blocks.AIR) {
this.COLOR_OVERRIDES_BLOCKS.put(block, Colors.parseHex(color));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
@DefaultQualifier(NonNull.class)
public final class NetworkingHandler {
public static final ResourceLocation CHANNEL = new ResourceLocation("squaremap:client");
public static final ResourceLocation CHANNEL = ResourceLocation.parse("squaremap:client");

private final WorldManager worldManager;
private final ServerAccess serverAccess;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static boolean isFullStatus(final CompoundTag chunkTag) {
}

private static @Nullable ChunkAccess fullIfPresent(final ChunkHolder chunkHolder) {
return unwrap(chunkHolder.getLastAvailable());
return unwrap(chunkHolder.getLatestChunk());
}

private static @Nullable ChunkAccess unwrap(@Nullable ChunkAccess chunk) {
Expand All @@ -80,7 +80,7 @@ private static boolean isFullStatus(final CompoundTag chunkTag) {
if (chunk instanceof ImposterProtoChunk imposter) {
chunk = imposter.getWrapped();
}
if (!chunk.getStatus().isOrAfter(ChunkStatus.FULL) && !preHeightChangeFullChunk(chunk)) {
if (!chunk.getPersistedStatus().isOrAfter(ChunkStatus.FULL) && !preHeightChangeFullChunk(chunk)) {
return null;
}
return chunk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@DefaultQualifier(NonNull.class)
public class SquaremapComponentInitializer implements EntityComponentInitializer {
public static final ComponentKey<PlayerComponent> SQUAREMAP_PLAYER_COMPONENT =
ComponentRegistryV3.INSTANCE.getOrCreate(new ResourceLocation("squaremap:player_component"), PlayerComponent.class);
ComponentRegistryV3.INSTANCE.getOrCreate(ResourceLocation.parse("squaremap:player_component"), PlayerComponent.class);

@Override
public void registerEntityComponentFactories(final EntityComponentFactoryRegistry registry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private void registerLifecycleListeners() {
ServerLifecycleEvents.SERVER_STARTED.register($ -> this.common.updateCheck());
}

final ResourceLocation early = new ResourceLocation("squaremap:early");
final ResourceLocation early = ResourceLocation.parse("squaremap:early");
ServerWorldEvents.LOAD.register(early, (server, level) -> this.worldManager.initWorld(level));
ServerWorldEvents.LOAD.addPhaseOrdering(early, Event.DEFAULT_PHASE);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package xyz.jpenilla.squaremap.fabric.mixin;

import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.GenerationChunkHolder;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.chunk.ImposterProtoChunk;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -9,8 +9,8 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import xyz.jpenilla.squaremap.fabric.event.MapUpdateEvents;

@Mixin(ChunkHolder.class)
abstract class ChunkHolderMixin {
@Mixin(GenerationChunkHolder.class)
abstract class GenerationChunkHolderMixin {
@Inject(
method = "replaceProtoChunk(Lnet/minecraft/world/level/chunk/ImposterProtoChunk;)V",
at = @At("TAIL")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.PlayerList;
import net.minecraft.world.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -14,18 +15,18 @@ abstract class PlayerListMixin {
private final ThreadLocal<ServerLevel> preRespawnLevel = new ThreadLocal<>();

@Inject(
method = "respawn(Lnet/minecraft/server/level/ServerPlayer;Z)Lnet/minecraft/server/level/ServerPlayer;",
method = "Lnet/minecraft/server/players/PlayerList;respawn(Lnet/minecraft/server/level/ServerPlayer;ZLnet/minecraft/world/entity/Entity$RemovalReason;)Lnet/minecraft/server/level/ServerPlayer;",
at = @At("HEAD")
)
void injectRespawnHead(ServerPlayer serverPlayer, boolean bl, CallbackInfoReturnable<ServerPlayer> cir) {
void injectRespawnHead(ServerPlayer serverPlayer, boolean bl, Entity.RemovalReason removalReason, CallbackInfoReturnable<ServerPlayer> cir) {
this.preRespawnLevel.set((ServerLevel) serverPlayer.level());
}

@Inject(
method = "respawn(Lnet/minecraft/server/level/ServerPlayer;Z)Lnet/minecraft/server/level/ServerPlayer;",
method = "Lnet/minecraft/server/players/PlayerList;respawn(Lnet/minecraft/server/level/ServerPlayer;ZLnet/minecraft/world/entity/Entity$RemovalReason;)Lnet/minecraft/server/level/ServerPlayer;",
at = @At("RETURN")
)
void injectRespawnReturn(ServerPlayer oldPlayer, boolean bl, CallbackInfoReturnable<ServerPlayer> cir) {
void injectRespawnReturn(ServerPlayer serverPlayer, boolean bl, Entity.RemovalReason removalReason, CallbackInfoReturnable<ServerPlayer> cir) {
final ServerLevel oldLevel = this.preRespawnLevel.get();
this.preRespawnLevel.remove();
final ServerPlayer player = cir.getReturnValue();
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"depends": {
"fabric": "*",
"fabricloader": ">=0.15.11",
"minecraft": "~1.20.6",
"minecraft": "~1.21",
"cloud": "*",
"adventure-platform-fabric": "*"
}
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/resources/squaremap-fabric.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"BlockItemMixin",
"ChunkHolderMixin",
"GenerationChunkHolderMixin",
"ChunkMapAccess",
"CommandSourceStackAccess",
"PlayerListMixin",
Expand Down
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ hangar-publish = { id = "io.papermc.hangar-publish-plugin", version = "0.1.2" }
javadoc-links = { id = "org.incendo.cloud-build-logic.javadoc-links", version = "0.0.15" }

[versions]
minecraft = "1.20.6"
minecraft = "1.21"
checkerQual = "3.44.0"
cloud = "2.0.0-rc.2"
cloudMinecraft = "2.0.0-beta.8"
cloudMinecraft = "2.0.0-SNAPSHOT"
cloudProcessors = "1.0.0-beta.3"
cloudModded = "2.0.0-beta.7"
cloudSponge = "2.0.0-SNAPSHOT"
configurate = "4.1.2"
adventure = "4.17.0"
examination = "1.3.0"
option = "1.0.0"
adventurePlatformFabric = "5.13.0"
adventurePlatformFabric = "5.14.0-SNAPSHOT"
paperApi = "1.20.2-R0.1-SNAPSHOT"
bStats = "3.0.2"
fabricApi = "0.99.0+1.20.6"
fabricApi = "0.100.1+1.21"
fabricLoader = "0.15.11"
cardinalComponents = "6.0.0"
cardinalComponents = "6.1.0"
guice = "7.0.0"
neoforge = "20.6.98-beta"
neoforge = "21.0.11-beta"
htmlSanitizer = "20240325.1"

# buildSrc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.minecraft.world.level.material.Fluid;
import net.neoforged.neoforge.client.extensions.common.IClientFluidTypeExtensions;
import net.neoforged.neoforge.fluids.FluidType;
import net.neoforged.neoforge.fluids.IFluidBlock;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier;
Expand All @@ -27,9 +26,7 @@ private ForgeFluidColorExporter(final DirectoryProvider directoryProvider) {

@Override
protected @Nullable Fluid fluid(final Block block) {
if (block instanceof IFluidBlock fluidBlock) {
return fluidBlock.getFluid();
} else if (block instanceof LiquidBlock liquidBlock) {
if (block instanceof LiquidBlock liquidBlock) {
return liquidBlock.fluid;
}
return null;
Expand Down
4 changes: 2 additions & 2 deletions neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ displayTest = "IGNORE_ALL_VERSION"
[[dependencies.squaremap]]
modId = "neoforge"
type = "required"
versionRange = "[20.6,)"
versionRange = "[21.0,)"
ordering = "NONE"
side = "BOTH"

[[dependencies.squaremap]]
modId = "minecraft"
type = "required"
versionRange = "[1.20.6,1.21)"
versionRange = "[1.21,1.22)"
ordering = "NONE"
side = "BOTH"

Expand Down
9 changes: 7 additions & 2 deletions paper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ plugins {

val minecraftVersion = libs.versions.minecraft

configurations.mojangMappedServer {
exclude("io.papermc.paper", "paper-api")
}

dependencies {
paperweight.foliaDevBundle(minecraftVersion.map { "$it-R0.1-SNAPSHOT" })
paperweight.paperDevBundle(minecraftVersion.map { "$it-R0.1-SNAPSHOT" })
compileOnly("dev.folia:folia-api:1.20.6-R0.1-SNAPSHOT")

implementation(projects.squaremapCommon)

Expand Down Expand Up @@ -44,7 +49,7 @@ tasks {
"version" to project.version,
"website" to providers.gradleProperty("githubUrl").get(),
"description" to project.description,
"apiVersion" to minecraftVersion.get().take(4),
"apiVersion" to minecraftVersion.get(),
))
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package xyz.jpenilla.squaremap.paper.util.chunksnapshot;

import ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor;
import io.papermc.paper.chunk.system.ChunkSystem;
import ca.spottedleaf.moonrise.patches.chunk_system.ChunkSystem;
import io.papermc.paper.util.TickThread;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
Expand All @@ -28,7 +28,7 @@ record PaperChunkSnapshotProvider(
public CompletableFuture<@Nullable ChunkSnapshot> asyncSnapshot(final int x, final int z) {
return CompletableFuture.supplyAsync(() -> {
final @Nullable ChunkAccess existing = this.level.getChunkIfLoadedImmediately(x, z);
if (existing != null && existing.getStatus().isOrAfter(ChunkStatus.FULL)) {
if (existing != null && existing.getPersistedStatus().isOrAfter(ChunkStatus.FULL)) {
return CompletableFuture.completedFuture(existing);
} else if (existing != null) {
return CompletableFuture.<@Nullable ChunkAccess>completedFuture(null);
Expand All @@ -51,7 +51,7 @@ record PaperChunkSnapshotProvider(
if (chunk instanceof ImposterProtoChunk imposter) {
chunk = imposter.getWrapped();
}
if (!chunk.getStatus().isOrAfter(ChunkStatus.FULL)) {
if (!chunk.getPersistedStatus().isOrAfter(ChunkStatus.FULL)) {
if (chunk.getBelowZeroRetrogen() == null || !chunk.getBelowZeroRetrogen().targetStatus().isOrAfter(ChunkStatus.SPAWN)) {
return null;
}
Expand Down
8 changes: 7 additions & 1 deletion sponge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ plugins {

val minecraftVersion = libs.versions.minecraft

configurations.all {
exclude("org.lwjgl", "lwjgl-freetype") // TODO: Don't care about running client :D (work around VG bug/Mojang repo weirdness?)
}

minecraft {
version().set(minecraftVersion)
accessWideners(project(":squaremap-common").layout.projectDirectory.file("src/main/resources/squaremap-common.accesswidener"))
Expand All @@ -28,6 +32,7 @@ dependencies {
}

// https://github.com/SpongePowered/SpongeGradle/issues/70
/*
configurations.spongeRuntime {
resolutionStrategy {
eachDependency {
Expand All @@ -37,9 +42,10 @@ configurations.spongeRuntime {
}
}
}
*/

sponge {
apiVersion("11.0.0-SNAPSHOT")
apiVersion("12.0.0-SNAPSHOT")
plugin("squaremap") {
loader {
name(PluginLoaders.JAVA_PLAIN)
Expand Down

0 comments on commit 7aff6ce

Please sign in to comment.