Skip to content

Commit

Permalink
Update for Minecraft 1.20.3 and 1.20.4.
Browse files Browse the repository at this point in the history
- Update for Minecraft 1.20.3 and 1.20.4
- Requires Fabric Loader version 0.15 or above
- Terraform API updates for better mod compatibility
- Update Cinderscapes mixins for better mod compatibility
  • Loading branch information
gniftygnome committed Dec 10, 2023
1 parent cbde1c0 commit af8c22c
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import java.util.concurrent.CompletableFuture;

@SuppressWarnings("UnstableApiUsage")
public class CinderscapesDynamicRegistryProvider extends FabricDynamicRegistryProvider {
protected CinderscapesDynamicRegistryProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(output, registriesFuture);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@
import java.util.stream.Stream;

public class CanopiedHugeFungusFeature extends Feature<CanopiedHugeFungusFeatureConfig> {
// TODO: Make the shapes API accept a Minecraft Special Snowflake Random
private static final java.util.Random localRandom = new java.util.Random();

public CanopiedHugeFungusFeature() {
super(CanopiedHugeFungusFeatureConfig.CODEC);
}

@Override
public boolean generate(FeatureContext<CanopiedHugeFungusFeatureConfig> context) {

CanopiedHugeFungusFeatureConfig config = context.getConfig();
StructureWorldAccess world = context.getWorld();
BlockPos pos = context.getOrigin();
Expand Down Expand Up @@ -112,10 +108,10 @@ public boolean generate(FeatureContext<CanopiedHugeFungusFeatureConfig> context)
if (baseClear && stemClear && canopyClear) {
// canopy
canopy.fill(new SimpleFiller(world, config.canopyBlock()));
canopyDripping.fill(new RandomSimpleFiller(world, config.canopyBlock(), localRandom, 0.5f));
canopyDripping.fill(new RandomSimpleFiller(world, config.canopyBlock(), random, 0.5f));
flesh.fill(new SimpleFiller(world, config.fleshBlock()));
fleshDripping.fill(new RandomSimpleFiller(world, config.fleshBlock(), localRandom, 0.5f));
detailBlocks.fill(new RandomSimpleFiller(world, config.decorationBlock(), localRandom, 0.2f));
fleshDripping.fill(new RandomSimpleFiller(world, config.fleshBlock(), random, 0.5f));
detailBlocks.fill(new RandomSimpleFiller(world, config.decorationBlock(), random, 0.2f));

// stem
stem.fill(new SimpleFiller(world, config.stemBlock()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import java.util.Map;

@SuppressWarnings("UnstableApiUsage")
public class CinderscapesArmorTrimMaterials {
public static final RegistryKey<ArmorTrimMaterial> ROSE_QUARTZ = CinderscapesArmorTrimMaterials.of("rose_quartz");
public static final RegistryKey<ArmorTrimMaterial> SMOKY_QUARTZ = CinderscapesArmorTrimMaterials.of("smoky_quartz");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import java.util.List;

@SuppressWarnings("UnstableApiUsage")
public class CinderscapesBiomes {
public static final RegistryKey<Biome> ASHY_SHOALS = RegistryKey.of(RegistryKeys.BIOME, Identifier.of(Cinderscapes.NAMESPACE, "ashy_shoals"));
public static final RegistryKey<Biome> BLACKSTONE_SHALES = RegistryKey.of(RegistryKeys.BIOME, Identifier.of(Cinderscapes.NAMESPACE, "blackstone_shales"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import java.util.List;

@SuppressWarnings("UnstableApiUsage")
public final class CinderscapesConfiguredFeatures {
/* ASHY SHOALS */
private static final RuleTest RULE_TEST_BASE_STONE_NETHER = new TagMatchRuleTest(BlockTags.BASE_STONE_NETHER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.minecraft.world.gen.stateprovider.WeightedBlockStateProvider;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

// TODO: Check
Expand Down Expand Up @@ -83,7 +84,7 @@ public static void init() {
.add(CinderscapesBlocks.TWILIGHT_FESCUES.getDefaultState(), 5)
.add(CinderscapesBlocks.TWILIGHT_TENDRILS.getDefaultState(), 5)
.add(CinderscapesBlocks.UMBRAL_FUNGUS.getDefaultState(), 2).build()),
Arrays.asList(
Collections.singletonList(
CinderscapesBlocks.UMBRAL_NYLIUM.getDefaultState()
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ private static void addCompostables() {
float BERRY_CHANCE = compostingRegistry.get(Items.SWEET_BERRIES);
float FLOWER_CHANCE = compostingRegistry.get(Items.POPPY);
float FUNGUS_CHANCE = compostingRegistry.get(Items.CRIMSON_FUNGUS);
float GRASS_CHANCE = compostingRegistry.get(Items.GRASS);
float GRASS_CHANCE = compostingRegistry.get(Items.SHORT_GRASS);
float WART_BLOCK_CHANCE = compostingRegistry.get(Items.NETHER_WART_BLOCK);

compostingRegistry.add(BRAMBLE_BERRIES, BERRY_CHANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("UnstableApiUsage")
public class CinderscapesPlacedFeatures {
/* ASHY SHOALS */
public static final RegistryKey<PlacedFeature> DEBRIS_ORE_LARGE = createRegistryKey("ashy_shoals/debris_ore_large");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,23 @@
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.LocalCapture;

@Mixin(AlterGroundTreeDecorator.class)
public class MixinAlterGroundTreeDecorator {
@Inject(method = "setColumn", at = @At(value = "TAIL"))
private void cinderscapes$setColumn(TreeDecorator.Generator generator, BlockPos origin, CallbackInfo callback) {
for(int i = 2; i >= -3; --i) {
BlockPos blockPos = origin.up(i);
if (generator.getWorld().testBlockState(blockPos, (state) -> state.isOf(Blocks.NETHERRACK))) {
generator.replace(blockPos, CinderscapesBlocks.NODZOL.getDefaultState());
break;
}

if (!generator.isAir(blockPos) && i < 0) {
break;
}
@Inject(method = "setColumn",
at = @At(
value = "INVOKE_ASSIGN",
target = "Lnet/minecraft/util/math/BlockPos;up(I)Lnet/minecraft/util/math/BlockPos;",
shift = At.Shift.AFTER
),
cancellable = true,
locals = LocalCapture.CAPTURE_FAILHARD
)
private void cinderscapes$netherrackConversion(TreeDecorator.Generator generator, BlockPos origin, CallbackInfo ci, int i, BlockPos pos) {
if (generator.getWorld().testBlockState(pos, (state) -> state.isOf(Blocks.NETHERRACK))) {
generator.replace(pos, CinderscapesBlocks.NODZOL.getDefaultState());
ci.cancel();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.terraformersmc.cinderscapes.mixin;

import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.NetherrackBlock;
import net.minecraft.block.NyliumBlock;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
Expand All @@ -16,19 +17,22 @@

@Mixin(NetherrackBlock.class)
public class MixinNetherrackBlock {
@Inject(method = "grow(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/random/Random;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V", at = @At("HEAD"), cancellable = true)
public void cinderscapes$grow(ServerWorld world, Random random, BlockPos pos, BlockState state, CallbackInfo callback) {

@Inject(method = "grow", at = @At("RETURN"))
private void cinderscapes$growNetherrackAction(ServerWorld world, Random random, BlockPos pos, BlockState state, CallbackInfo ci) {
BlockState vanillaState = world.getBlockState(pos);
List<BlockState> potentialStates = new ArrayList<>();

// Build a list of the default states of any surrounding Nylium variants.
for (BlockPos testPos : BlockPos.iterate(pos.add(-1, -1, -1), pos.add(1, 1, 1))) {
BlockState testState = world.getBlockState(testPos);
if (testState.getBlock() instanceof NyliumBlock && !potentialStates.contains(testState)) potentialStates.add(testState);
BlockState testState = world.getBlockState(testPos).getBlock().getDefaultState();
if (testState.isIn(BlockTags.NYLIUM) && !potentialStates.contains(testState)) {
potentialStates.add(testState);
}
}
if (potentialStates.size() > 0) {

// If another mod has changed the block state to something not a default Nylium state, leave it be.
if (potentialStates.size() > 0 && (vanillaState.isOf(Blocks.NETHERRACK) || potentialStates.contains(vanillaState))) {
world.setBlockState(pos, potentialStates.get(random.nextInt(potentialStates.size())), 3);
}

callback.cancel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
public class MixinPlantBlock {
@Inject(method = "canPlantOnTop", at = @At(value = "RETURN"), cancellable = true)
protected void cinderscapes$canPlantOnTop(BlockState floor, BlockView world, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
cir.setReturnValue(cir.getReturnValue() || floor.isOf(CinderscapesBlocks.NODZOL));
if (floor.isOf(CinderscapesBlocks.NODZOL)) {
cir.setReturnValue(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,42 +30,40 @@ protected MixinServerWorld(MutableWorldProperties properties, RegistryKey<World>
super(properties, registryRef, registryManager, dimensionEntry, profiler, isClient, debugWorld, biomeAccess, maxChainedNeighborUpdates);
}

// TODO: Revisit this and make it easier to read
// And fix having two calls to getBiome (maybe requires MixinExtras)
@Inject(method="tickIceAndSnow",
at = @At(value = "INVOKE_ASSIGN",
target = "Lnet/minecraft/server/world/ServerWorld;getBiome(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/registry/entry/RegistryEntry;",
ordinal = 0,
shift = At.Shift.AFTER
),
locals = LocalCapture.NO_CAPTURE
)
private void cinderscapes$tickAsh(boolean raining, BlockPos tickPos, CallbackInfo ci) {
/*
* NOTE: Unlike this mixin, vanilla evaluates the tick only at the surface Y level.
* This means there is no utility for us in reusing vanilla's calculations.
*/
@Inject(method="tickIceAndSnow", at = @At(value = "HEAD"), locals = LocalCapture.NO_CAPTURE)
private void cinderscapes$tickAsh(BlockPos tickPos, CallbackInfo ci) {
if (CinderscapesConfig.INSTANCE.enableAshFall) {
BlockPos pos = tickPos.mutableCopy();
BlockState state = getBlockState(pos);
RegistryEntry<Biome> biome = this.getBiome(pos);

while (!(
while (pos.getY() < 127 && !(
biome.matchesKey(CinderscapesBiomes.ASHY_SHOALS) &&
state.isSideSolidFullSquare(this, pos, Direction.UP) &&
blockAbove(pos).isIn(CinderscapesBlockTags.ASH_PERMEABLE) &&
this.getBlockState(pos.up()).isAir() &&
CinderscapesBlocks.ASH.getDefaultState().canPlaceAt(this, pos.up())) &&
pos.getY() < 127) {
state.isSideSolidFullSquare(this, pos, Direction.UP) &&
blockAbove(pos).isIn(CinderscapesBlockTags.ASH_PERMEABLE) &&
this.getBlockState(pos.up()).isAir() &&
CinderscapesBlocks.ASH.getDefaultState().canPlaceAt(this, pos.up()))) {
pos = pos.up();
state = getBlockState(pos);
biome = this.getBiome(pos);
}
if (pos.getY() < 127) this.setBlockState(pos.up(), CinderscapesBlocks.ASH.getDefaultState());

if (pos.getY() < 127) {
this.setBlockState(pos.up(), CinderscapesBlocks.ASH.getDefaultState());
}
}
}

private BlockState blockAbove(BlockPos pos) {
BlockPos iPos = pos.mutableCopy();
while(isAir(iPos.up()) && iPos.getY() < 127) {
iPos = iPos.up();
}
return getBlockState(iPos.up());
BlockPos iPos = pos.mutableCopy().up();

//noinspection StatementWithEmptyBody
for (; isAir(iPos) && iPos.getY() < 127; iPos = iPos.up());

return getBlockState(iPos);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

@Mixin(OverworldBiomeCreator.class)
public interface OverworldBiomeCreatorAccessor {

@Invoker("getSkyColor")
static int cinderscapes$callGetSkyColor(float temperature) {
throw new AssertionError("mixin");
Expand Down
26 changes: 13 additions & 13 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ fabric.loom.multiProjectOptimisation=true
maven_group=com.terraformersmc
archive_name=cinderscapes

minecraft_version=23w45a
yarn_mappings=23w45a+build.4
loader_version=0.14.24
fabric_version=0.90.8+1.20.3
minecraft_version=1.20.3
yarn_mappings=1.20.3+build.1
loader_version=0.15.1
fabric_version=0.91.1+1.20.3

# Terraform modules
terraform_biome_remapper_api_version=9.0.0-alpha.3
terraform_shapes_api_version=9.0.0-alpha.3
terraform_surfaces_api_version=9.0.0-alpha.3
terraform_wood_api_version=9.0.0-alpha.3
terraform_biome_remapper_api_version=9.0.0-beta.2
terraform_shapes_api_version=9.0.0-beta.2
terraform_surfaces_api_version=9.0.0-beta.2
terraform_wood_api_version=9.0.0-beta.2

# Biolith for worldgen module and testing
biolith_version=1.1.0-alpha.5

# TerraBlender for worldgen module and testing
terrablender_version=1.20.2-3.0.0.170
terrablender_version=1.20.3-3.3.0.2

# Other Things
clothconfig_version=12.0.109
modmenu_version=9.0.0-alpha.2
clothconfig_version=12.0.111
modmenu_version=9.0.0-pre.1
vistas_version=2.3.0

# Project Metadata
Expand All @@ -37,14 +37,14 @@ default_release_type=stable
# CurseForge Metadata
curseforge_slug=cinderscapes
curseforge_id=391429
curseforge_game_versions=1.20.2, Fabric, Quilt
curseforge_game_versions=1.20.3, 1.20.4, Fabric, Quilt
curseforge_required_dependencies=fabric-api
curseforge_optional_dependencies=

# Modrinth Metadata
modrinth_slug=cinderscapes
modrinth_id=QC4wcUXZ
modrinth_game_versions=1.20.2
modrinth_game_versions=1.20.3, 1.20.4
modrinth_mod_loaders=fabric, quilt
#modrinth_embedded_dependencies=biolith

Expand Down
7 changes: 3 additions & 4 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@
]
},
"depends": {
"fabricloader": ">=0.14.11",
"fabricloader": ">=0.15",
"fabric-api": ">=0.77.0",
"minecraft": ">=1.20.2 <1.21"
"minecraft": ">=1.20.3 <1.21"
},
"breaks": {
"bclib": "<3.0.8",
"modmenu": "<8.0.0-beta"
"bclib": "<3.0.8"
}
}

0 comments on commit af8c22c

Please sign in to comment.