diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 5f8020a..2a6fa73 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -9,10 +9,10 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Set up JDK 16 + - name: Set up JDK 17 uses: actions/setup-java@v1 with: - java-version: 16 + java-version: 17 - name: Build with Gradle run: ./gradlew build - name: Upload JARs diff --git a/build.gradle b/build.gradle index 3328c83..930f2bb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,12 @@ import java.text.SimpleDateFormat plugins { - id 'fabric-loom' version '0.9-SNAPSHOT' + id 'fabric-loom' version '0.10-SNAPSHOT' + id 'io.github.juuxel.loom-quiltflower-mini' version '1.2.1' } -sourceCompatibility = JavaVersion.VERSION_16 -targetCompatibility = JavaVersion.VERSION_16 +sourceCompatibility = JavaVersion.VERSION_17 +targetCompatibility = JavaVersion.VERSION_17 def buildDate = new Date() def branch = GitHelper.getBranch(rootDir) @@ -85,7 +86,7 @@ processResources { tasks.withType(JavaCompile) { options.encoding = "UTF-8" - it.options.release = 16 + it.options.release = 17 } // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task diff --git a/gradle.properties b/gradle.properties index 11dee61..8544e4e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,14 +4,14 @@ org.gradle.jvmargs=-Xmx1G # Mod Properties -mod_version = 3.1.0 +mod_version = 3.2.0 maven_group = quickcarpet archives_base_name = skyblock -minecraft_version=1.17.1 -yarn_mappings=1.17.1+build.61:v2 -loader_version=0.11.3 +minecraft_version=1.18.1 +yarn_mappings=1.18.1+build.18:v2 +loader_version=0.12.12 -fabric_resource_loader_v0_version=0.4.8+a00e834b18 +fabric_resource_loader_v0_version=0.4.11+3ac43d95c8 quickcarpet_api_version=1.0.0 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0f80bbf..2e6e589 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index f981ed1..5d753a7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,10 +1,13 @@ pluginManagement { repositories { - jcenter() maven { name = 'Fabric' url = 'https://maven.fabricmc.net/' } + maven { + name = 'Cotton' + url = 'https://server.bbkr.space/artifactory/libs-release/' + } gradlePluginPortal() } } diff --git a/src/main/java/skyblock/SkyBlockUtils.java b/src/main/java/skyblock/SkyBlockUtils.java index 396404c..2f8c225 100644 --- a/src/main/java/skyblock/SkyBlockUtils.java +++ b/src/main/java/skyblock/SkyBlockUtils.java @@ -1,8 +1,9 @@ package skyblock; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.EndPortalFrameBlock; +import net.minecraft.block.*; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.block.entity.MobSpawnerBlockEntity; +import net.minecraft.entity.EntityType; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtList; import net.minecraft.server.world.ServerLightingProvider; @@ -15,8 +16,11 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.Direction; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.registry.Registry; import net.minecraft.world.Heightmap; import net.minecraft.world.WorldAccess; +import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.ChunkSection; import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.chunk.ProtoChunk; @@ -33,13 +37,17 @@ public class SkyBlockUtils { public static void deleteBlocks(ProtoChunk chunk, WorldAccess world) { + Registry biomes = world.getRegistryManager().get(Registry.BIOME_KEY); ChunkSection[] sections = chunk.getSectionArray(); - Arrays.fill(sections, WorldChunk.EMPTY_SECTION); + for (int i = 0; i < sections.length; i++) { + sections[i] = new ChunkSection(world.sectionIndexToCoord(i), biomes); + } for (BlockPos bePos : chunk.getBlockEntityPositions()) { chunk.removeBlockEntity(bePos); } ((ProtoChunkAccessor) chunk).getLightSources().clear(); - long[] emptyHeightmap = new PackedIntegerArray(9, 256).getStorage(); + int bits = MathHelper.ceilLog2(chunk.getHeight() + 1); + long[] emptyHeightmap = new PackedIntegerArray(bits, 256).getData(); for (Map.Entry heightmapEntry : chunk.getHeightmaps()) { heightmapEntry.getValue().setTo(chunk, heightmapEntry.getKey(), emptyHeightmap); } @@ -53,7 +61,7 @@ private static void processStronghold(ProtoChunk chunk, WorldAccess world) { ProtoChunk startChunk = (ProtoChunk) world.getChunk(startPos.x, startPos.z, ChunkStatus.STRUCTURE_STARTS); StructureStart stronghold = startChunk.getStructureStart(StructureFeature.STRONGHOLD); ChunkPos pos = chunk.getPos(); - if (stronghold != null && stronghold.setBoundingBoxFromChildren().intersectsXZ(pos.getStartX(), pos.getStartZ(), pos.getEndX(), pos.getEndZ())) { + if (stronghold != null && stronghold.getBoundingBox().intersectsXZ(pos.getStartX(), pos.getStartZ(), pos.getEndX(), pos.getEndZ())) { for (StructurePiece piece : stronghold.getChildren()) { if (piece instanceof StrongholdGenerator.PortalRoom) { if (piece.getBoundingBox().intersectsXZ(pos.getStartX(), pos.getStartZ(), pos.getEndX(), pos.getEndZ())) { @@ -135,19 +143,13 @@ private static void generateStrongholdPortal(ProtoChunk chunk, StrongholdGenerat setBlockInStructure(room, chunk, portal, 6, 3, 11); } BlockPos spawnerPos = getBlockInStructurePiece(room, 5, 3, 6); - setBlockInChunk(chunk, spawnerPos, Blocks.SPAWNER.getDefaultState()); - NbtCompound spawnerTag = new NbtCompound(); - spawnerTag.putString("id", "minecraft:mob_spawner"); - NbtList spawnPotentials = new NbtList(); - spawnerTag.put("SpawnPotentials", spawnPotentials); - NbtCompound spawnEntry = new NbtCompound(); - spawnPotentials.add(0, spawnEntry); - NbtCompound entity = new NbtCompound(); - spawnEntry.put("Entity", entity); - entity.putString("id", "minecraft:silverfish"); - spawnEntry.putInt("Weight", 1); - spawnerTag.put("SpawnData", entity.copy()); - setBlockEntityInChunk(chunk, spawnerPos, spawnerTag); + BlockState spawnerState = Blocks.SPAWNER.getDefaultState(); + setBlockInChunk(chunk, spawnerPos, spawnerState); + BlockEntity blockEntity = ((BlockEntityProvider) spawnerState.getBlock()).createBlockEntity(spawnerPos, spawnerState); + if (blockEntity instanceof MobSpawnerBlockEntity) { + ((MobSpawnerBlockEntity)blockEntity).getLogic().setEntityId(EntityType.SILVERFISH); + } + chunk.setBlockEntity(blockEntity); } private static void clearChunk(ProtoChunk chunk, WorldAccess world) { diff --git a/src/main/java/skyblock/mixin/ChunkStatusMixin.java b/src/main/java/skyblock/mixin/ChunkStatusMixin.java index 3d1d70a..4434081 100644 --- a/src/main/java/skyblock/mixin/ChunkStatusMixin.java +++ b/src/main/java/skyblock/mixin/ChunkStatusMixin.java @@ -24,14 +24,14 @@ @Mixin(ChunkStatus.class) public class ChunkStatusMixin { // LIGHT - @Inject(method = "method_20613", at = @At("HEAD")) - private static void onLighting(ChunkStatus chunkStatus, Executor executor, ServerWorld world, ChunkGenerator generator, StructureManager manager, ServerLightingProvider lightingProvider, Function>> function, List list, Chunk chunk, CallbackInfoReturnable>> info) { + @Inject(method = "method_20614", at = @At("HEAD")) + private static void onLighting(ChunkStatus chunkStatus, Executor executor, ServerWorld world, ChunkGenerator generator, StructureManager manager, ServerLightingProvider lightingProvider, Function>> function, List list, Chunk chunk, boolean bl, CallbackInfoReturnable>> info) { if(!chunk.getStatus().isAtLeast(chunkStatus)) SkyBlockUtils.deleteBlocks((ProtoChunk) chunk, world); } // SPAWN -> populateEntities - @Inject(method = "method_16566", at = @At("RETURN")) + @Inject(method = "method_17033", at = @At("RETURN")) private static void afterPopulation(ChunkStatus chunkStatus, ServerWorld world, ChunkGenerator generator, List list, Chunk chunk, CallbackInfo info) { ((ProtoChunk) chunk).getEntities().clear(); } -} +} \ No newline at end of file diff --git a/src/main/java/skyblock/mixin/DaylightDetectorBlockEntityMixin.java b/src/main/java/skyblock/mixin/DaylightDetectorBlockEntityMixin.java index 9b18f38..1a17d1c 100644 --- a/src/main/java/skyblock/mixin/DaylightDetectorBlockEntityMixin.java +++ b/src/main/java/skyblock/mixin/DaylightDetectorBlockEntityMixin.java @@ -31,20 +31,19 @@ public void toggleBlockLightDetection() { } @Override - public void readNbt(NbtCompound compoundTag_1) { - super.readNbt(compoundTag_1); + public void readNbt(NbtCompound nbt) { + super.readNbt(nbt); - if (SkyBlockSettings.blockLightDetector && compoundTag_1.contains("blockLightMode", 99 /* NUMBER */)) { - this.detectsBlockLight = compoundTag_1.getInt("blockLightMode") > 0; + if (SkyBlockSettings.blockLightDetector && nbt.contains("blockLightMode", 99 /* NUMBER */)) { + this.detectsBlockLight = nbt.getInt("blockLightMode") > 0; } } @Override - public NbtCompound writeNbt(NbtCompound compoundTag_1) { - compoundTag_1 = super.writeNbt(compoundTag_1); + public void writeNbt(NbtCompound nbt) { + super.writeNbt(nbt); if (SkyBlockSettings.blockLightDetector) { - compoundTag_1.putInt("blockLightMode", this.detectsBlockLight ? 1 : 0); + nbt.putInt("blockLightMode", this.detectsBlockLight ? 1 : 0); } - return compoundTag_1; } }