From 958e35955c19eb0641530fcef591022729eac342 Mon Sep 17 00:00:00 2001 From: Jack Sorrell Date: Mon, 14 Feb 2022 16:04:04 -0500 Subject: [PATCH] Update to 1.18 --- README.md | 17 ---- .../advancements/skyblock/go_down.json | 4 +- gradle.properties | 12 +-- .../jsorrell/skyblock/SkyBlockSettings.java | 34 +------ .../skyblock/gen/SkyBlockChunkGenerator.java | 97 ++++++++++--------- .../gen/SkyBlockGenerationSettings.java | 29 +++--- .../skyblock/gen/SkyBlockGeneratorTypes.java | 20 ++-- .../skyblock/helpers/UsefulComposter.java | 80 --------------- .../skyblock/mixin/ComposterBlockMixin.java | 71 -------------- .../skyblock/mixin/EndIslandFeatureMixin.java | 23 +++-- .../skyblock/mixin/GeneratorOptionsMixin.java | 20 ++-- src/main/resources/pack.mcmeta | 4 +- src/main/resources/skyblock.mixins.json | 1 - 13 files changed, 108 insertions(+), 304 deletions(-) delete mode 100644 src/main/java/com/jsorrell/skyblock/helpers/UsefulComposter.java delete mode 100644 src/main/java/com/jsorrell/skyblock/mixin/ComposterBlockMixin.java diff --git a/README.md b/README.md index ba784123..6a32ed7a 100644 --- a/README.md +++ b/README.md @@ -188,23 +188,6 @@ The fox will eat them soon after spawning, so be quick. --- -#### Useful Composters (disabled by default) #### -Provides additional *Sand*, *Red Sand*, and *Dirt* - -Enable with ```/skyblock setDefault usefulComposters true``` or ```/skyblock setDefault usefulComposters redstone``` - -Provides an easier way to get sand/red sand than the 64/24 you can get at a time from a wandering trader. - -The datapack now makes it so Husks drop Sand and Red Sand has a crafting recipe, so this is disabled by default. -Additionally, Dirt farming is nicer since 1.17. - -Compost result depends on the biome. -Get sand in deserts, beaches, warm oceans etc, red sand from badlands, and dirt elsewhere. - -When set to ```redstone```, the composter outputs Bonemeal without a redstone signal. - ---- - ### Additional Datapack Features ### The included datapack provides additional recipes, and advancements. diff --git a/datapack/data/skyblock/advancements/skyblock/go_down.json b/datapack/data/skyblock/advancements/skyblock/go_down.json index 8ad587e0..1bb08152 100644 --- a/datapack/data/skyblock/advancements/skyblock/go_down.json +++ b/datapack/data/skyblock/advancements/skyblock/go_down.json @@ -22,7 +22,7 @@ "predicate": { "position": { "y": { - "max": 10 + "max": -54 } } }, @@ -32,4 +32,4 @@ } } } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index 045c4d15..37e98aa2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -# Done to increase the memory available to gradle. +# Increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G # Mod Properties @@ -7,10 +7,10 @@ archives_base_name=skyblock # Fabric Properties # see https://modmuss50.me/fabric.html -minecraft_version=1.17.1 -yarn_mappings=1.17.1+build.65 -loader_version=0.13.1 -fabric_api_version=0.46.0+1.17 +minecraft_version=1.18.1 +yarn_mappings=1.18.1+build.22 +loader_version=0.13.2 +fabric_api_version=0.46.4+1.18 # see https://masa.dy.fi/maven/carpet/fabric-carpet/ -carpet_core_version=1.17.1-1.4.57+v220119 +carpet_core_version=1.18.1-1.4.57+v220119 diff --git a/src/main/java/com/jsorrell/skyblock/SkyBlockSettings.java b/src/main/java/com/jsorrell/skyblock/SkyBlockSettings.java index aa9ed28b..70201a63 100644 --- a/src/main/java/com/jsorrell/skyblock/SkyBlockSettings.java +++ b/src/main/java/com/jsorrell/skyblock/SkyBlockSettings.java @@ -1,14 +1,8 @@ package com.jsorrell.skyblock; -import static carpet.settings.RuleCategory.FEATURE; - -import java.util.Locale; - -import carpet.settings.ParsedRule; import carpet.settings.Rule; -import carpet.settings.Validator; -import net.minecraft.server.command.ServerCommandSource; +import static carpet.settings.RuleCategory.FEATURE; public class SkyBlockSettings { public static final String SKYBLOCK = "skyblock"; @@ -72,30 +66,4 @@ public class SkyBlockSettings { desc = "A spawned fox has a chance to hold berries", category = {SKYBLOCK, FEATURE}) public static boolean foxesSpawnWithBerries = false; - - /* Useful Composters */ - public static boolean doUsefulComposters = false; - public static boolean usefulCompostersNeedRedstone = false; - - private static class UsefulCompostersSetting extends Validator { - @Override - public String validate( - ServerCommandSource source, - ParsedRule currentRule, - String newValue, - String string) { - doUsefulComposters = !newValue.toLowerCase(Locale.ROOT).equals("false"); - usefulCompostersNeedRedstone = newValue.toLowerCase(Locale.ROOT).equals("redstone"); - - return newValue; - } - } - - @Rule( - desc = "Composters create sand, red sand, and dirt depending on biome", - category = {SKYBLOCK, FEATURE}, - options = {"true", "false", "redstone"}, - validate = UsefulCompostersSetting.class) - @SuppressWarnings("unused") - public static String usefulComposters = "false"; } diff --git a/src/main/java/com/jsorrell/skyblock/gen/SkyBlockChunkGenerator.java b/src/main/java/com/jsorrell/skyblock/gen/SkyBlockChunkGenerator.java index e9f0d3e9..1350fb47 100644 --- a/src/main/java/com/jsorrell/skyblock/gen/SkyBlockChunkGenerator.java +++ b/src/main/java/com/jsorrell/skyblock/gen/SkyBlockChunkGenerator.java @@ -1,17 +1,7 @@ package com.jsorrell.skyblock.gen; -import java.util.Arrays; -import java.util.Objects; -import java.util.Random; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; -import java.util.function.Supplier; - import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; - import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.EndPortalFrameBlock; @@ -22,36 +12,40 @@ import net.minecraft.structure.StructurePiece; import net.minecraft.structure.StructurePieceType; import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.math.ChunkSectionPos; -import net.minecraft.util.math.Direction; +import net.minecraft.util.dynamic.RegistryLookupCodec; +import net.minecraft.util.math.*; import net.minecraft.util.math.Direction.Axis; -import net.minecraft.util.math.Vec3i; +import net.minecraft.util.math.noise.DoublePerlinNoiseSampler; import net.minecraft.util.registry.Registry; -import net.minecraft.world.ChunkRegion; -import net.minecraft.world.ServerWorldAccess; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.*; import net.minecraft.world.biome.source.BiomeAccess; import net.minecraft.world.biome.source.BiomeSource; import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.WorldChunk; -import net.minecraft.world.gen.ChunkRandom; import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.StructureAccessor; -import net.minecraft.world.gen.chunk.ChunkGenerator; -import net.minecraft.world.gen.chunk.ChunkGeneratorSettings; -import net.minecraft.world.gen.chunk.NoiseChunkGenerator; +import net.minecraft.world.gen.chunk.*; +import net.minecraft.world.gen.random.ChunkRandom; +import net.minecraft.world.gen.random.RandomSeed; +import net.minecraft.world.gen.random.Xoroshiro128PlusPlusRandom; + +import java.util.Objects; +import java.util.Random; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import java.util.function.Supplier; public class SkyBlockChunkGenerator extends NoiseChunkGenerator { private final long seed; + private final Registry noiseRegistry; public static final Codec CODEC = RecordCodecBuilder.create( (instance) -> instance .group( + RegistryLookupCodec + .of(Registry.NOISE_WORLDGEN) + .forGetter(skyblockChunkGenerator -> skyblockChunkGenerator.noiseRegistry), BiomeSource.CODEC .fieldOf("biome_source") .forGetter(SkyBlockChunkGenerator::getBiomeSource), @@ -64,10 +58,12 @@ public class SkyBlockChunkGenerator extends NoiseChunkGenerator { .forGetter(SkyBlockChunkGenerator::getSettings)) .apply(instance, instance.stable(SkyBlockChunkGenerator::new))); - public SkyBlockChunkGenerator( - BiomeSource biomeSource, long seed, Supplier settings) { - super(biomeSource, seed, settings); + public SkyBlockChunkGenerator(Registry noiseRegistry, + BiomeSource biomeSource, long seed, Supplier settings) { + super(noiseRegistry, biomeSource, seed, settings); this.seed = seed; + // Need noise registry kept so features generate in identical places to vanilla + this.noiseRegistry = noiseRegistry; } public long getSeed() { @@ -84,15 +80,17 @@ protected Codec getCodec() { } @Override - @Environment(EnvType.CLIENT) public ChunkGenerator withSeed(long seed) { - return new SkyBlockChunkGenerator(this.biomeSource.withSeed(seed), seed, this.settings); + return new SkyBlockChunkGenerator(this.noiseRegistry, this.biomeSource.withSeed(seed), seed, this.settings); } @Override - public void buildSurface(ChunkRegion region, Chunk chunk) { - Arrays.fill(chunk.getSectionArray(), WorldChunk.EMPTY_SECTION); + public VerticalBlockSample getColumnSample(int x, int z, HeightLimitView world) { + return new VerticalBlockSample(world.getBottomY(), new BlockState[0]); + } + @Override + public void buildSurface(ChunkRegion region, StructureAccessor structures, Chunk chunk) { if (region.getDimension().isNatural()) { BlockPos spawn = new BlockPos( @@ -108,10 +106,10 @@ public void buildSurface(ChunkRegion region, Chunk chunk) { spawn, new BlockBox( chunk.getPos().getStartX(), - 0, + chunk.getBottomY(), chunk.getPos().getStartZ(), chunk.getPos().getStartX() + 15, - region.getHeight(), + chunk.getTopY(), chunk.getPos().getStartZ() + 15)); } } @@ -120,23 +118,24 @@ public void buildSurface(ChunkRegion region, Chunk chunk) { // TODO: Does this hurt something @Override public CompletableFuture populateNoise( - Executor executor, StructureAccessor accessor, Chunk chunk) { + Executor executor, Blender blender, StructureAccessor accessor, Chunk chunk) { return CompletableFuture.completedFuture(chunk); } @Override - public void carve(long seed, BiomeAccess access, Chunk chunk, GenerationStep.Carver carver) {} + public void carve(ChunkRegion chunkRegion, long seed, BiomeAccess access, StructureAccessor structureAccessor, Chunk chunk, GenerationStep.Carver carver) { + } @Override - public void generateFeatures(ChunkRegion region, StructureAccessor accessor) { - ChunkPos chunkPos = region.getCenterPos(); - BlockPos pos = new BlockPos(chunkPos.getStartX(), region.getBottomY(), chunkPos.getStartZ()); + public void generateFeatures(StructureWorldAccess world, Chunk chunk, StructureAccessor accessor) { + ChunkPos chunkPos = chunk.getPos(); + BlockPos pos = new BlockPos(chunkPos.getStartX(), chunk.getBottomY(), chunkPos.getStartZ()); int startX = chunkPos.getStartX(); int startZ = chunkPos.getStartZ(); - BlockBox box = new BlockBox(startX, 0, startZ, startX + 15, region.getHeight(), startZ + 15); + BlockBox chunkBoundary = new BlockBox(startX, chunk.getBottomY(), startZ, startX + 15, chunk.getTopY(), startZ + 15); accessor - .getStructuresWithChildren( + .getStructureStarts( ChunkSectionPos.from(pos), Registry.STRUCTURE_FEATURE.get(new Identifier("minecraft:stronghold"))) .forEach( @@ -149,10 +148,10 @@ public void generateFeatures(ChunkRegion region, StructureAccessor accessor) { piece.getBoundingBox().getMinY(), piece.getBoundingBox().getMinZ()); if (piece.intersectsChunk(chunkPos, 0)) { - ChunkRandom random = new ChunkRandom(); + ChunkRandom random = new ChunkRandom(new Xoroshiro128PlusPlusRandom(RandomSeed.getSeed())); random.setCarverSeed(seed, chunkPos.x, chunkPos.z); generateStrongholdPortalInBox( - region, portalPos, random, Objects.requireNonNull(piece.getFacing()), box); + world, portalPos, random, Objects.requireNonNull(piece.getFacing()), chunkBoundary); } } } @@ -160,7 +159,8 @@ public void generateFeatures(ChunkRegion region, StructureAccessor accessor) { } @Override - public void populateEntities(ChunkRegion region) {} + public void populateEntities(ChunkRegion region) { + } protected static void placeRelativeBlockInBox( WorldAccess world, @@ -227,6 +227,7 @@ private static void generateStrongholdPortalInBox( Direction facing, BlockBox box) { + // TODO switch this to pattern matching when it is no longer a preview BlockPos portalCenterPosition; switch (facing) { case EAST: @@ -256,10 +257,12 @@ private static void generateStrongholdPortalInBox( } BlockPos spawnerPos = portalCenterPosition.subtract(facing.getVector().multiply(4)); - world.setBlockState(spawnerPos, Blocks.SPAWNER.getDefaultState(), 2); - BlockEntity spawnerEntity = world.getBlockEntity(spawnerPos); - if (spawnerEntity instanceof MobSpawnerBlockEntity) { - ((MobSpawnerBlockEntity) spawnerEntity).getLogic().setEntityId(EntityType.SILVERFISH); + if (box.contains(spawnerPos)) { + world.setBlockState(spawnerPos, Blocks.SPAWNER.getDefaultState(), 2); + BlockEntity spawnerEntity = world.getBlockEntity(spawnerPos); + if (spawnerEntity instanceof MobSpawnerBlockEntity) { + ((MobSpawnerBlockEntity) spawnerEntity).getLogic().setEntityId(EntityType.SILVERFISH); + } } } diff --git a/src/main/java/com/jsorrell/skyblock/gen/SkyBlockGenerationSettings.java b/src/main/java/com/jsorrell/skyblock/gen/SkyBlockGenerationSettings.java index 52614d62..b8ee1ff5 100644 --- a/src/main/java/com/jsorrell/skyblock/gen/SkyBlockGenerationSettings.java +++ b/src/main/java/com/jsorrell/skyblock/gen/SkyBlockGenerationSettings.java @@ -1,13 +1,12 @@ package com.jsorrell.skyblock.gen; import com.mojang.serialization.Lifecycle; - +import net.minecraft.util.math.noise.DoublePerlinNoiseSampler; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.SimpleRegistry; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.source.MultiNoiseBiomeSource; import net.minecraft.world.biome.source.TheEndBiomeSource; -import net.minecraft.world.biome.source.VanillaLayeredBiomeSource; import net.minecraft.world.dimension.DimensionOptions; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.gen.chunk.ChunkGenerator; @@ -19,6 +18,7 @@ public class SkyBlockGenerationSettings { public static SimpleRegistry getSkyBlockDimensionOptions( Registry dimensionTypeRegistry, + Registry noiseRegistry, Registry biomeRegistry, Registry settingsRegistry, long seed) { @@ -28,42 +28,45 @@ public static SimpleRegistry getSkyBlockDimensionOptions( DimensionOptions.OVERWORLD, new DimensionOptions( () -> dimensionTypeRegistry.get(DimensionType.OVERWORLD_REGISTRY_KEY), - createOverworldGenerator(biomeRegistry, settingsRegistry, seed)), + createOverworldGenerator(noiseRegistry, biomeRegistry, settingsRegistry, seed)), Lifecycle.stable()); simpleRegistry.add( DimensionOptions.NETHER, new DimensionOptions( () -> dimensionTypeRegistry.get(DimensionType.THE_NETHER_REGISTRY_KEY), - createNetherGenerator(biomeRegistry, settingsRegistry, seed)), + createNetherGenerator(noiseRegistry, biomeRegistry, settingsRegistry, seed)), Lifecycle.stable()); simpleRegistry.add( DimensionOptions.END, new DimensionOptions( () -> dimensionTypeRegistry.get(DimensionType.THE_END_REGISTRY_KEY), - createEndGenerator(biomeRegistry, settingsRegistry, seed)), + createEndGenerator(noiseRegistry, biomeRegistry, settingsRegistry, seed)), Lifecycle.stable()); return simpleRegistry; } - public static ChunkGenerator createOverworldGenerator( - Registry biomeRegistry, Registry settingsRegistry, long seed) { + public static ChunkGenerator createOverworldGenerator(Registry noiseRegistry, + Registry biomeRegistry, Registry settingsRegistry, long seed) { return new SkyBlockChunkGenerator( - new VanillaLayeredBiomeSource(seed, false, false, biomeRegistry), + noiseRegistry, + MultiNoiseBiomeSource.Preset.OVERWORLD.getBiomeSource(biomeRegistry).withSeed(seed), seed, () -> settingsRegistry.getOrThrow(ChunkGeneratorSettings.OVERWORLD)); } - public static ChunkGenerator createNetherGenerator( - Registry biomeRegistry, Registry settingsRegistry, long seed) { + public static ChunkGenerator createNetherGenerator(Registry noiseRegistry, + Registry biomeRegistry, Registry settingsRegistry, long seed) { return new SkyBlockChunkGenerator( - MultiNoiseBiomeSource.Preset.NETHER.getBiomeSource(biomeRegistry, seed), + noiseRegistry, + MultiNoiseBiomeSource.Preset.NETHER.getBiomeSource(biomeRegistry).withSeed(seed), seed, () -> settingsRegistry.getOrThrow(ChunkGeneratorSettings.NETHER)); } - public static ChunkGenerator createEndGenerator( - Registry biomeRegistry, Registry settingsRegistry, long seed) { + public static ChunkGenerator createEndGenerator(Registry noiseRegistry, + Registry biomeRegistry, Registry settingsRegistry, long seed) { return new SkyBlockChunkGenerator( + noiseRegistry, new TheEndBiomeSource(biomeRegistry, seed), seed, () -> settingsRegistry.getOrThrow(ChunkGeneratorSettings.END)); diff --git a/src/main/java/com/jsorrell/skyblock/gen/SkyBlockGeneratorTypes.java b/src/main/java/com/jsorrell/skyblock/gen/SkyBlockGeneratorTypes.java index 10271ed9..6c0fbbc2 100644 --- a/src/main/java/com/jsorrell/skyblock/gen/SkyBlockGeneratorTypes.java +++ b/src/main/java/com/jsorrell/skyblock/gen/SkyBlockGeneratorTypes.java @@ -2,8 +2,8 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; - import net.minecraft.client.world.GeneratorType; +import net.minecraft.util.math.noise.DoublePerlinNoiseSampler; import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.SimpleRegistry; @@ -19,12 +19,12 @@ public class SkyBlockGeneratorTypes { public static final GeneratorType SKYBLOCK = new GeneratorType("skyblock") { @Override - protected ChunkGenerator getChunkGenerator( - Registry biomeRegistry, - Registry chunkGeneratorSettingsRegistry, - long seed) { - return SkyBlockGenerationSettings.createOverworldGenerator( - biomeRegistry, chunkGeneratorSettingsRegistry, seed); + protected ChunkGenerator getChunkGenerator(DynamicRegistryManager registryManager, long seed) { + Registry noiseRegistry = registryManager.get(Registry.NOISE_WORLDGEN); + Registry biomeRegistry = registryManager.get(Registry.BIOME_KEY); + Registry settingsRegistry = + registryManager.get(Registry.CHUNK_GENERATOR_SETTINGS_KEY); + return SkyBlockGenerationSettings.createOverworldGenerator(noiseRegistry, biomeRegistry, settingsRegistry, seed); } @Override @@ -33,14 +33,16 @@ public GeneratorOptions createDefaultOptions( long seed, boolean generateStructures, boolean bonusChest) { - Registry biomeRegistry = registryManager.get(Registry.BIOME_KEY); Registry dimensionTypeRegistry = registryManager.get(Registry.DIMENSION_TYPE_KEY); + Registry noiseRegistry = registryManager.get(Registry.NOISE_WORLDGEN); + Registry biomeRegistry = registryManager.get(Registry.BIOME_KEY); Registry settingsRegistry = registryManager.get(Registry.CHUNK_GENERATOR_SETTINGS_KEY); + SimpleRegistry dimensionOptionsRegistry = SkyBlockGenerationSettings.getSkyBlockDimensionOptions( - dimensionTypeRegistry, biomeRegistry, settingsRegistry, seed); + dimensionTypeRegistry, noiseRegistry, biomeRegistry, settingsRegistry, seed); return new GeneratorOptions( seed, generateStructures, bonusChest, dimensionOptionsRegistry); } diff --git a/src/main/java/com/jsorrell/skyblock/helpers/UsefulComposter.java b/src/main/java/com/jsorrell/skyblock/helpers/UsefulComposter.java deleted file mode 100644 index 45608acf..00000000 --- a/src/main/java/com/jsorrell/skyblock/helpers/UsefulComposter.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.jsorrell.skyblock.helpers; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.jetbrains.annotations.Nullable; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ComposterBlock; -import net.minecraft.inventory.SidedInventory; -import net.minecraft.inventory.SimpleInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.WorldAccess; -import net.minecraft.world.biome.Biome; - -public class UsefulComposter { - protected static final List possibleSurfaceDrops = - new ArrayList<>(Arrays.asList(Blocks.SAND, Blocks.RED_SAND, Blocks.DIRT)); - - public static Item getComposterProduct(Biome biome) { - Block dropBlock = Blocks.DIRT; - - Block surfaceBlock = - biome.getGenerationSettings().getSurfaceConfig().getTopMaterial().getBlock(); - if (possibleSurfaceDrops.contains(surfaceBlock)) { - dropBlock = surfaceBlock; - } - - return dropBlock.asItem(); - } - - // Provides a simple, single-item inventory for the full composter - public static class FullComposterInventory extends SimpleInventory implements SidedInventory { - private final BlockState state; - private final WorldAccess world; - private final BlockPos pos; - private boolean dirty; - - public FullComposterInventory(BlockState state, WorldAccess world, BlockPos pos) { - super(new ItemStack(getComposterProduct(world.getBiome(pos)))); - this.state = state; - this.world = world; - this.pos = pos; - } - - public int getMaxCountPerStack() { - return 1; - } - - public int[] getAvailableSlots(Direction side) { - return side == Direction.DOWN ? new int[] {0} : new int[0]; - } - - public boolean canInsert(int slot, ItemStack stack, @Nullable Direction dir) { - return false; - } - - public boolean canExtract(int slot, ItemStack stack, Direction dir) { - return !this.dirty - && dir == Direction.DOWN - && stack.getItem() == getComposterProduct(world.getBiome(pos)); - } - - public void markDirty() { - emptyComposter(this.state, this.world, this.pos); - this.dirty = true; - } - - private static void emptyComposter(BlockState state, WorldAccess world, BlockPos pos) { - BlockState blockState = state.with(ComposterBlock.LEVEL, 0); - world.setBlockState(pos, blockState, 3); - } - } -} diff --git a/src/main/java/com/jsorrell/skyblock/mixin/ComposterBlockMixin.java b/src/main/java/com/jsorrell/skyblock/mixin/ComposterBlockMixin.java deleted file mode 100644 index 8445f0b8..00000000 --- a/src/main/java/com/jsorrell/skyblock/mixin/ComposterBlockMixin.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.jsorrell.skyblock.mixin; - -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.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import net.minecraft.block.BlockState; -import net.minecraft.block.ComposterBlock; -import net.minecraft.entity.ItemEntity; -import net.minecraft.inventory.SidedInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; -import net.minecraft.world.biome.Biome; - -import com.jsorrell.skyblock.SkyBlockSettings; -import com.jsorrell.skyblock.helpers.UsefulComposter; -import com.jsorrell.skyblock.helpers.UsefulComposter.FullComposterInventory; - -@Mixin(ComposterBlock.class) -public class ComposterBlockMixin { - - @Inject( - method = "emptyFullComposter", - locals = LocalCapture.CAPTURE_FAILSOFT, - at = - @At( - value = "INVOKE", - target = "Lnet/minecraft/entity/ItemEntity;setToDefaultPickupDelay()V")) - private static void setItemDroppedFromComposter( - BlockState arg0, - World world, - BlockPos pos, - CallbackInfoReturnable cir, - float f, - double d, - double e, - double g, - ItemEntity droppedItem) { - if (SkyBlockSettings.doUsefulComposters) { - if (!SkyBlockSettings.usefulCompostersNeedRedstone || world.isReceivingRedstonePower(pos)) { - Biome biome = world.getBiome(pos); - Item composterProduct = UsefulComposter.getComposterProduct(biome); - droppedItem.setStack(new ItemStack(composterProduct)); - } - } - } - - @Inject( - method = "getInventory", - locals = LocalCapture.CAPTURE_FAILSOFT, - cancellable = true, - at = @At(value = "RETURN", ordinal = 0)) - private void setFullComposterInventory( - BlockState state, - WorldAccess world, - BlockPos pos, - CallbackInfoReturnable cir) { - if (SkyBlockSettings.doUsefulComposters) { - if (!SkyBlockSettings.usefulCompostersNeedRedstone - || ((World) world).isReceivingRedstonePower(pos)) { - SidedInventory inventory = new FullComposterInventory(state, world, pos); - cir.setReturnValue(inventory); - } - } - } -} diff --git a/src/main/java/com/jsorrell/skyblock/mixin/EndIslandFeatureMixin.java b/src/main/java/com/jsorrell/skyblock/mixin/EndIslandFeatureMixin.java index 8f8f0ad6..a62a6706 100644 --- a/src/main/java/com/jsorrell/skyblock/mixin/EndIslandFeatureMixin.java +++ b/src/main/java/com/jsorrell/skyblock/mixin/EndIslandFeatureMixin.java @@ -1,25 +1,24 @@ package com.jsorrell.skyblock.mixin; -import java.util.Random; - +import com.jsorrell.skyblock.SkyBlockSettings; import com.mojang.serialization.Codec; -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.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.StructureWorldAccess; -import net.minecraft.world.gen.ChunkRandom; import net.minecraft.world.gen.feature.DefaultFeatureConfig; import net.minecraft.world.gen.feature.EndIslandFeature; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.util.FeatureContext; +import net.minecraft.world.gen.random.AtomicSimpleRandom; +import net.minecraft.world.gen.random.ChunkRandom; +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.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import com.jsorrell.skyblock.SkyBlockSettings; +import java.util.Random; @Mixin(EndIslandFeature.class) public abstract class EndIslandFeatureMixin extends Feature { @@ -42,7 +41,7 @@ private void generateChorus( int level) { if (SkyBlockSettings.gatewaysSpawnChorus) { if (level == 0) { - ChunkRandom randomChorus = new ChunkRandom(); + ChunkRandom randomChorus = new ChunkRandom(new AtomicSimpleRandom(0L)); ChunkPos chunkPos = new ChunkPos(blockPos); randomChorus.setPopulationSeed(world.getSeed(), chunkPos.getStartX(), chunkPos.getStartZ()); int islandRadius = MathHelper.ceil(islandSizeF); @@ -52,7 +51,7 @@ private void generateChorus( int zOffset = randomChorus.nextInt(2 * farthestZ) - farthestZ; BlockPos chorusPos = blockPos.add(xOffset, 1, zOffset); Feature.CHORUS_PLANT.generate( - new FeatureContext<>(world, null, randomChorus, chorusPos, null)); + new FeatureContext<>(null, world, null, randomChorus, chorusPos, null)); } } } diff --git a/src/main/java/com/jsorrell/skyblock/mixin/GeneratorOptionsMixin.java b/src/main/java/com/jsorrell/skyblock/mixin/GeneratorOptionsMixin.java index 1829e3be..2dc721ca 100644 --- a/src/main/java/com/jsorrell/skyblock/mixin/GeneratorOptionsMixin.java +++ b/src/main/java/com/jsorrell/skyblock/mixin/GeneratorOptionsMixin.java @@ -1,13 +1,6 @@ package com.jsorrell.skyblock.mixin; -import java.util.Properties; - -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.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - +import com.jsorrell.skyblock.gen.SkyBlockGenerationSettings; import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.SimpleRegistry; @@ -16,8 +9,13 @@ import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.gen.GeneratorOptions; import net.minecraft.world.gen.chunk.ChunkGeneratorSettings; +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.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import com.jsorrell.skyblock.gen.SkyBlockGenerationSettings; +import java.util.Properties; @Mixin(GeneratorOptions.class) public class GeneratorOptionsMixin { @@ -39,11 +37,11 @@ private static void addSkyBlockGeneratorOptionWhenLoadingProperties( long seed, Registry dimensionTypeRegistry, Registry biomeRegistry, - Registry settingsRegistry) { + SimpleRegistry settingsRegistry) { if (SkyBlockGenerationSettings.NAME.equals(generatorSettingsName)) { SimpleRegistry dimensionOptions = SkyBlockGenerationSettings.getSkyBlockDimensionOptions( - dimensionTypeRegistry, biomeRegistry, settingsRegistry, seed); + dimensionTypeRegistry, drm.get(Registry.NOISE_WORLDGEN), biomeRegistry, settingsRegistry, seed); GeneratorOptions generatorOptions = new GeneratorOptions(seed, generateStructures, false, dimensionOptions); cir.setReturnValue(generatorOptions); diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index 76319383..1fe5ed87 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "SkyBlock Resources", - "pack_format": 7 + "pack_format": 8 } -} \ No newline at end of file +} diff --git a/src/main/resources/skyblock.mixins.json b/src/main/resources/skyblock.mixins.json index d0581536..3d464bc4 100644 --- a/src/main/resources/skyblock.mixins.json +++ b/src/main/resources/skyblock.mixins.json @@ -3,7 +3,6 @@ "package": "com.jsorrell.skyblock.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ - "ComposterBlockMixin", "CriteriaAccessor", "DolphinEntityLeadToNearbyTreasureGoalMixin", "EnderDragonEntityMixin",