Skip to content
Open
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
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
}

version = project.mod_version
Expand Down Expand Up @@ -41,8 +41,8 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
// Minecraft 1.20.6 upwards uses Java 21.
it.options.release = 21
}

java {
Expand All @@ -51,8 +51,8 @@ java {
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20
yarn_mappings=1.20+build.1
loader_version=0.14.21
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.5

# Dependencies
fabric_version=0.83.0+1.20
fabric_version=0.104.0+1.21.1

# Mod Properties
mod_version = 1.1.12
mod_version = 1.1.13
maven_group = protosky
archives_base_name = protosky
6 changes: 2 additions & 4 deletions src/main/java/protosky/WorldGenUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.*;
import net.minecraft.world.chunk.light.LightingProvider;
import protosky.mixins.ProtoChunkAccessor;

import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -82,12 +80,12 @@ public static void genSpawnPlatform(Chunk chunk, ServerWorld world) {

// Get structure for this dimension
if (world.getRegistryKey() == World.OVERWORLD) {
Optional<StructureTemplate> op = man.getTemplate(new Identifier("protosky:spawn_overworld"));
Optional<StructureTemplate> op = man.getTemplate(Identifier.of("protosky", "spawn_overworld"));
if (op.isPresent()) {
s = op.get();
}
} else if (world.getRegistryKey() == World.NETHER) {
Optional<StructureTemplate> op = man.getTemplate(new Identifier("protosky:spawn_nether"));
Optional<StructureTemplate> op = man.getTemplate(Identifier.of("protosky", "spawn_nether"));
if (op.isPresent()) {
s = op.get();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,38 @@
package protosky.mixins;

import com.mojang.datafixers.util.Either;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.server.world.ServerLightingProvider;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.structure.StructureStart;
import net.minecraft.structure.StructureTemplateManager;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.BoundedRegionArray;
import net.minecraft.world.ChunkRegion;
import net.minecraft.world.Heightmap;
import net.minecraft.world.World;
import net.minecraft.world.chunk.AbstractChunkHolder;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.chunk.ProtoChunk;
import net.minecraft.world.gen.chunk.Blender;
import net.minecraft.world.chunk.ChunkGenerating;
import net.minecraft.world.chunk.ChunkGenerationContext;
import net.minecraft.world.chunk.ChunkGenerationStep;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.structure.Structure;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import protosky.WorldGenUtils;
import protosky.stuctures.PillarHelper;
import protosky.stuctures.StructureHelper;

import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Function;

import static protosky.ProtoSkySettings.LOGGER;

@Mixin(ChunkStatus.class)
public abstract class ChunkStatusMixin {
@Inject(method = "method_51375", at = @At("HEAD"), cancellable = true)
//This is under ChunkStatus FEATURES. To find the inject method you need to read the bytecode. In Idea click View -> Show Bytecode
// In there search for "features" (you need the quotes).
@Mixin(ChunkGenerating.class)
public abstract class ChunkGeneratingMixin {
@Inject(method = "generateFeatures", at = @At("HEAD"), cancellable = true)
//This is where blocks structures should get placed, now it's where the structures ProtoSky needs get placed.
private static void FEATURES(ChunkStatus targetStatus, ServerWorld world, ChunkGenerator generator, List<Chunk> chunks, Chunk chunk, CallbackInfo ci) {
private static void onGenerateFeatures(ChunkGenerationContext context, ChunkGenerationStep step, BoundedRegionArray<AbstractChunkHolder> chunks, Chunk chunk, CallbackInfoReturnable<CompletableFuture<Chunk>> cir) {
ServerWorld world = context.world();
ChunkGenerator generator = context.generator();
Heightmap.populateHeightmaps(chunk, EnumSet.of(Heightmap.Type.MOTION_BLOCKING, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, Heightmap.Type.OCEAN_FLOOR, Heightmap.Type.WORLD_SURFACE));
ChunkRegion chunkRegion = new ChunkRegion(world, chunks, targetStatus, 1);
ChunkRegion chunkRegion = new ChunkRegion(world, chunks, step, chunk);
//This would normally generate structures, the blocks, not the bounding boxes.
//generator.generateFeatures(chunkRegion, chunk, world.getStructureAccessor().forRegion(chunkRegion));
//StructureHelper.handleStructures(chunkRegion, chunk, world.getStructureAccessor().forRegion(chunkRegion), generator, false);
//context.generator().generateFeatures(chunkRegion, chunk, world.getStructureAccessor().forRegion(chunkRegion));
//Blender.tickLeavesAndFluids(chunkRegion, chunk);

//Generate do the structures then delete blocks while in the end to remove the end cities
Expand All @@ -69,14 +53,13 @@ private static void FEATURES(ChunkStatus targetStatus, ServerWorld world, ChunkG
//This generates all the structures
StructureHelper.handleStructures(chunkRegion, chunk, world.getStructureAccessor().forRegion(chunkRegion), generator, false);
}
ci.cancel();
cir.setReturnValue(CompletableFuture.completedFuture(chunk));
}
@Inject(method = "method_20614", at = @At("HEAD"), cancellable = false)
//This is under ChunkStatus INITIALIZE_LIGHT. To find the inject method you need to read the bytecode. In Idea click View -> Show Bytecode
// In there search for "initialize_light" (you need the quotes).

@Inject(method = "initializeLight", at = @At("HEAD"), cancellable = false)
//We need to move the heightmaps down to y = 0 after structures have been generated because some rely on the heightmap to move.
//This used to be in the unused 'HEIGHTMAPS' status, but in 1.20 this was removed. Now we're using INITIALIZE_LIGHT.
private static void INITIALIZE_LIGHT(ChunkStatus targetStatus, Executor executor, ServerWorld world, ChunkGenerator generator, StructureTemplateManager structureTemplateManager, ServerLightingProvider lightingProvider, Function fullChunkConverter, List chunks, Chunk chunk, CallbackInfoReturnable<CompletableFuture> cir) {
private static void onInitializeLight(ChunkGenerationContext context, ChunkGenerationStep step, BoundedRegionArray<AbstractChunkHolder> chunks, Chunk chunk, CallbackInfoReturnable<CompletableFuture<Chunk>> cir) {
//Move the heightmaps down to y-64
//This gets done here not above in FEATURES because there are multiple threads that generate features. One thread
// may place a structure in a chunk then move the heightmap down to y=-64 when a second structure in the chunk on
Expand All @@ -88,13 +71,11 @@ private static void INITIALIZE_LIGHT(ChunkStatus targetStatus, Executor executor
//ci.cancel();
}

@Inject(method = "method_17033", at = @At("HEAD"), cancellable = true)
//This is under ChunkStatus SPAWN. To find the inject method you need to read the bytecode. In Idea click View -> Show Bytecode
// In there search for "spawn" (you need the quotes).
@Inject(method = "generateEntities", at = @At("HEAD"), cancellable = true)
//Spawning entities is skipped here. Even without this nothing would happen because entities from structures never
// get generated because that is skipped above and non-structure entities have no blocks to spawn on so they don't spawn.
// This is just an optimization
private static void SPAWN(ChunkStatus targetStatus, ServerWorld world, ChunkGenerator generator, List chunks, Chunk chunk, CallbackInfo ci) {
ci.cancel();
private static void onGenerateEntities(ChunkGenerationContext context, ChunkGenerationStep step, BoundedRegionArray<AbstractChunkHolder> chunks, Chunk chunk, CallbackInfoReturnable<CompletableFuture<Chunk>> cir) {
cir.setReturnValue(CompletableFuture.completedFuture(chunk));
}
}
8 changes: 4 additions & 4 deletions src/main/java/protosky/stuctures/StructureHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ private static synchronized void fixRaceCondition(WorldAccess world) {
StructurePieceInvoker pieceInvoker = (StructurePieceInvoker) structurePiece;


final Identifier TOP_TEMPLATE = new Identifier("igloo/top");
final Identifier MIDDLE_TEMPLATE = new Identifier("igloo/middle");
final Identifier BOTTOM_TEMPLATE = new Identifier("igloo/bottom");
final Identifier TOP_TEMPLATE = Identifier.ofVanilla("igloo/top");
final Identifier MIDDLE_TEMPLATE = Identifier.ofVanilla("igloo/middle");
final Identifier BOTTOM_TEMPLATE = Identifier.ofVanilla("igloo/bottom");
final Map<Identifier, BlockPos> OFFSETS_FROM_TOP = ImmutableMap.of(
TOP_TEMPLATE, BlockPos.ORIGIN, MIDDLE_TEMPLATE, new BlockPos(2, -3, 4), BOTTOM_TEMPLATE, new BlockPos(0, -3, -2)
);

Identifier identifier = new Identifier(simplePieceInvoker.getTemplateIdString());
Identifier identifier = Identifier.of(simplePieceInvoker.getTemplateIdString());
StructurePlacementData structurePlacementData = iglooGeneratorPieceInvoker.invokeCreatePlacementData(simplePieceInvoker.getPlacementData().getRotation(), identifier);

BlockPos blockPos = OFFSETS_FROM_TOP.get(identifier);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mixins.protosky.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"package": "protosky.mixins",
"compatibilityLevel": "JAVA_17",
"mixins": [
"ChunkStatusMixin",
"ChunkGeneratingMixin",
"EnderDragonFightMixin",
"ProtoChunkAccessor",
"StructurePieceAccessor",
Expand Down