Skip to content

Commit

Permalink
Snowlogging now preserves the collision of the original block without…
Browse files Browse the repository at this point in the history
… modifying its selection shape & fragile ice in snowy biomes
  • Loading branch information
AViewFromTheTop committed Feb 28, 2025
1 parent 22b66fc commit 7c21917
Show file tree
Hide file tree
Showing 21 changed files with 147 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,4 @@ hi
- Mobs in the `wilderwild:fragile_ice_unwalkable_mobs` entity tag will crack, then shatter Fragile Ice when standing on it.
- Mobs not in the `wilderwild:fragile_ice_doesnt_crack_on_fall` entity tag will cause Fragile Ice to shatter when falling onto it.
- Revamped the Frozen Caves biome, removing snow patches and utilizing Fragile Ice and Icicles.
- Snowlogging now preserves the collision of the original block without modifying its selection shape.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"values": [
{
"id": "#minecraft:ice",
"required": false
}
"minecraft:ice"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"values": [
"minecraft:snowy_plains",
"minecraft:ice_spikes",
"minecraft:snowy_taiga",
"minecraft:snowy_beach",
"minecraft:frozen_ocean",
"minecraft:deep_frozen_ocean",
"minecraft:frozen_river",
{
"id": "wilderwild:snowy_old_growth_pine_taiga",
"required": false
},
{
"id": "wilderwild:snowy_dying_forest",
"required": false
},
{
"id": "wilderwild:snowy_dying_mixed_forest",
"required": false
}
]
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "frozenlib:fading_disk_feature",
"config": {
"fade_start_distance_percent": 0.8,
"fade_start_distance_percent": 0.7,
"heightmap": "MOTION_BLOCKING_NO_LEAVES",
"inner_chance": 0.925,
"inner_percent": 0.65,
Expand All @@ -25,7 +25,7 @@
}
}
},
"placement_chance": 0.95,
"placement_chance": 0.85,
"radius": {
"type": "minecraft:uniform",
"max_inclusive": 6,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"feature": "wilderwild:fragile_ice_disk_surface",
"placement": [
{
"type": "minecraft:rarity_filter",
"chance": 4
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:heightmap",
"heightmap": "MOTION_BLOCKING"
},
{
"type": "minecraft:biome"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"count": {
"type": "minecraft:uniform",
"max_inclusive": 30,
"min_inclusive": 18
"min_inclusive": 22
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"count": {
"type": "minecraft:uniform",
"max_inclusive": 30,
"min_inclusive": 18
"min_inclusive": 20
}
},
{
"type": "minecraft:rarity_filter",
"chance": 3
"chance": 2
},
{
"type": "minecraft:in_square"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1219,9 +1219,21 @@ private void generateFeatureTags() {
this.getOrCreateTagBuilder(WWBiomeTags.HAS_CHERRY_FLOWERS)
.add(Biomes.CHERRY_GROVE);

this.getOrCreateTagBuilder(WWBiomeTags.HAS_ICICLES)
this.getOrCreateTagBuilder(WWBiomeTags.HAS_SURFACE_ICICLES)
.add(Biomes.ICE_SPIKES);

this.getOrCreateTagBuilder(WWBiomeTags.HAS_SURFACE_FRAGILE_ICE)
.add(Biomes.SNOWY_PLAINS)
.add(Biomes.ICE_SPIKES)
.add(Biomes.SNOWY_TAIGA)
.add(Biomes.SNOWY_BEACH)
.add(Biomes.FROZEN_OCEAN)
.add(Biomes.DEEP_FROZEN_OCEAN)
.add(Biomes.FROZEN_RIVER)
.addOptional(WWBiomes.SNOWY_OLD_GROWTH_PINE_TAIGA)
.addOptional(WWBiomes.SNOWY_DYING_FOREST)
.addOptional(WWBiomes.SNOWY_DYING_MIXED_FOREST);

this.getOrCreateTagBuilder(WWBiomeTags.HAS_TUMBLEWEED_PLANT)
.add(Biomes.DESERT)
.add(Biomes.WINDSWEPT_SAVANNA)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ private void generateFeatures() {
.addOptionalTag(WWBlockTags.CAVE_ICE_REPLACEABLE);

this.getOrCreateTagBuilder(WWBlockTags.SURFACE_FRAGILE_ICE_REPLACEABLE)
.addOptionalTag(BlockTags.ICE);
.add(Blocks.ICE);

this.getOrCreateTagBuilder(WWBlockTags.DIORITE_ICE_REPLACEABLE)
.add(Blocks.GRAVEL)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright 2023-2025 FrozenBlock
* This file is part of Wilder Wild.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <https://www.gnu.org/licenses/>.
*/

package net.frozenblock.wilderwild.mixin.block.ice;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.frozenblock.wilderwild.registry.WWBlocks;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.HalfTransparentBlock;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(HalfTransparentBlock.class)
public class HalfTransparentBlockMixin {

@WrapOperation(
method = "skipRendering",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/block/state/BlockState;is(Lnet/minecraft/world/level/block/Block;)Z"
)
)
private boolean wilderWild$checkForIceAndFragileIce(
BlockState instance, Block block, Operation<Boolean> original
) {
if (instance.is(Blocks.ICE) && block == WWBlocks.FRAGILE_ICE) return true;
if (instance.is(WWBlocks.FRAGILE_ICE) && block == Blocks.ICE) return true;
return original.call(instance, block);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
@Mixin(Block.class)
public class BlockMixin {

@WrapOperation(method = "spawnDestroyParticles",
@WrapOperation(
method = "spawnDestroyParticles",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/block/Block;getId(Lnet/minecraft/world/level/block/state/BlockState;)I"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.EntityCollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -82,7 +83,10 @@ public abstract class BlockStateBaseMixin {
public VoxelShape wilderWild$getShape(VoxelShape original, BlockGetter level, BlockPos pos, CollisionContext context) {
BlockState blockState = this.asState();
if (SnowloggingUtils.isSnowlogged(blockState)) {
return SnowloggingUtils.getSnowEquivalent(blockState).getShape(level, pos, context);
VoxelShape snowShape = SnowloggingUtils.getSnowEquivalent(blockState).getShape(level, pos, context);
return !original.isEmpty() && (!(context instanceof EntityCollisionContext entityCollisionContext) || entityCollisionContext.getEntity() == null)
? Shapes.or(original, snowShape)
: snowShape;
}
return original;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
@Mixin(BlockBehaviour.BlockStateBase.Cache.class)
public class CacheMixin {

@WrapOperation(method = "<init>",
@WrapOperation(
method = "<init>",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/block/Block;propagatesSkylightDown(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Z"
)
)
public boolean wilderWild$init(Block instance, BlockState blockState, BlockGetter blockGetter, BlockPos pos, Operation<Boolean> original) {
public boolean wilderWild$propagatesSkylightDown(Block instance, BlockState blockState, BlockGetter blockGetter, BlockPos pos, Operation<Boolean> original) {
return original.call(instance, blockState, blockGetter, pos)
&& !(SnowloggingUtils.isSnowlogged(blockState)
&& SnowloggingUtils.getSnowLayers(blockState) >= SnowloggingUtils.MAX_LAYERS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public final class WWBiomeTags {
public static final TagKey<Biome> HAS_FROZEN_PLAIN_TALL_GRASS = bind("feature/has_frozen_plain_tall_grass");
public static final TagKey<Biome> HAS_FROZEN_LARGE_FERNS = bind("feature/has_frozen_large_ferns");

public static final TagKey<Biome> HAS_ICICLES = bind("feature/has_icicles");
public static final TagKey<Biome> HAS_SURFACE_ICICLES = bind("feature/has_surface_icicles");
public static final TagKey<Biome> HAS_SURFACE_FRAGILE_ICE = bind("feature/has_surface_fragile_ice");
public static final TagKey<Biome> HAS_TUMBLEWEED_PLANT = bind("feature/has_tumbleweed_plant");
public static final TagKey<Biome> NON_FROZEN_PLAINS = bind("non_frozen_plains");
public static final TagKey<Biome> SWAMP_TREES = bind("feature/swamp_trees");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1183,10 +1183,10 @@ public static void registerMiscConfigured() {
BlockStateProvider.simple(WWBlocks.FRAGILE_ICE),
BlockStateProvider.simple(WWBlocks.FRAGILE_ICE),
UniformInt.of(2, 6),
0.95F,
0.85F,
0.925F,
0.65F,
0.8F,
0.7F,
new HolderSet.Named<>(
BuiltInRegistries.BLOCK.holderOwner(),
WWBlockTags.SURFACE_FRAGILE_ICE_REPLACEABLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,8 @@ public static void registerCavePlaced(@NotNull BootstrapContext<PlacedFeature> e
);

ICICLES_SURFACE_WG.makeAndSetHolder(WWCaveConfigured.ICICLE.getHolder(),
CountPlacement.of(UniformInt.of(18, 30)),
RarityFilter.onAverageOnceEvery(3),
CountPlacement.of(UniformInt.of(20, 30)),
RarityFilter.onAverageOnceEvery(2),
InSquarePlacement.spread(),
PlacementUtils.HEIGHTMAP_WORLD_SURFACE,
HeightRangePlacement.uniform(VerticalAnchor.absolute(62), VerticalAnchor.absolute(127)),
Expand All @@ -524,7 +524,7 @@ public static void registerCavePlaced(@NotNull BootstrapContext<PlacedFeature> e
);

ICICLES_SURFACE.makeAndSetHolder(WWCaveConfigured.ICICLE.getHolder(),
CountPlacement.of(UniformInt.of(18, 30)),
CountPlacement.of(UniformInt.of(22, 30)),
RarityFilter.onAverageOnceEvery(3),
InSquarePlacement.spread(),
PlacementUtils.HEIGHTMAP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public final class WWMiscPlaced {
// SNOW
public static final FrozenLibPlacedFeature SNOW_BLANKET = WWPlacementUtils.register("snow_blanket");
public static final FrozenLibPlacedFeature SNOW_AND_ICE_TRANSITION = WWPlacementUtils.register("snow_and_freeze_transition");
public static final FrozenLibPlacedFeature FRAGILE_ICE_DISK_SURFACE = WWPlacementUtils.register("fragile_ice_disk_surface");

private WWMiscPlaced() {
throw new UnsupportedOperationException("WilderMiscPlaced contains only static declarations.");
Expand Down Expand Up @@ -626,6 +627,13 @@ public static void registerMiscPlaced(@NotNull BootstrapContext<PlacedFeature> e
InSquarePlacement.spread(),
BiomeFilter.biome()
);

FRAGILE_ICE_DISK_SURFACE.makeAndSetHolder(WWMiscConfigured.FRAGILE_ICE_DISK_SURFACE.getHolder(),
RarityFilter.onAverageOnceEvery(4),
InSquarePlacement.spread(),
PlacementUtils.HEIGHTMAP,
BiomeFilter.biome()
);
}

@Contract("_, _ -> new")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void generateMisc() {
}
});

BiomeModifications.create(WWConstants.id("termite_transitions"))
BiomeModifications.create(WWConstants.id("termite_generation"))
.add(ModificationPhase.ADDITIONS,
BiomeSelectors.all(),
(biomeSelectionContext, context) -> {
Expand Down Expand Up @@ -246,7 +246,7 @@ public static void generateMisc() {
generationSettings.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, WWPlacedFeatures.PATCH_PUMPKIN_COMMON.getKey());
}

if (biomeSelectionContext.hasTag(WWBiomeTags.HAS_ICICLES)) {
if (biomeSelectionContext.hasTag(WWBiomeTags.HAS_SURFACE_ICICLES)) {
generationSettings.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, WWCavePlaced.ICICLES_SURFACE_WG.getKey());
generationSettings.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, WWCavePlaced.ICICLES_SURFACE.getKey());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private static void replaceFeatures() {
BiomeModifications.create(WWConstants.id("add_new_snow"))
.add(ModificationPhase.POST_PROCESSING,
BiomeSelectors.all(),
context -> {
(biomeSelectionContext, context) -> {
BiomeModificationContext.GenerationSettingsContext generationSettings = context.getGenerationSettings();
if (generationSettings.removeFeature(MiscOverworldPlacements.FREEZE_TOP_LAYER)) {
generationSettings.addFeature(GenerationStep.Decoration.TOP_LAYER_MODIFICATION, MiscOverworldPlacements.FREEZE_TOP_LAYER);
Expand All @@ -127,6 +127,12 @@ private static void replaceFeatures() {
generationSettings.addFeature(GenerationStep.Decoration.TOP_LAYER_MODIFICATION, WWMiscPlaced.SNOW_AND_ICE_TRANSITION.getKey());
}
}

if (WWWorldgenConfig.get().surfaceTransitions) {
if (biomeSelectionContext.hasTag(WWBiomeTags.HAS_SURFACE_FRAGILE_ICE)) {
generationSettings.addFeature(GenerationStep.Decoration.TOP_LAYER_MODIFICATION, WWMiscPlaced.FRAGILE_ICE_DISK_SURFACE.getKey());
}
}
});

BiomeModifications.create(WWConstants.id("replace_forest_grass"))
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/wilderwild.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"block.frozen_vegetation.ShearsItemMixin",
"block.ice.EntityMixin",
"block.ice.FrostedIceBlockMixin",
"block.ice.HalfTransparentBlockMixin",
"block.ice.SpawnUtilStrategyMixin",
"block.ice.VibrationSystemTickerMixin",
"block.ice.WalkNodeEvaluatorMixin",
Expand Down

0 comments on commit 7c21917

Please sign in to comment.