Skip to content

Commit

Permalink
25w02a
Browse files Browse the repository at this point in the history
  • Loading branch information
Treetrain1 committed Jan 8, 2025
1 parent bdbf50a commit a60dad6
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 25 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@

# Fabric Properties
# Get new versions at https://fabricmc.net/develop and https://lambdaurora.dev/tools/import_quilt.html
minecraft_version=1.21.4
minecraft_version=25w02a
quilt_mappings=1.21+build.18
parchment_mappings=1.21:2024.07.28
loader_version=0.16.9
min_loader_version=0.16.9
loader_version=0.16.10
min_loader_version=0.16.10

# Mod Properties
mod_version = 1.9.11
maven_group = net.frozenblock
archives_base_name = FrozenLib

# Dependencies
fabric_api_version=0.113.0+1.21.4
fabric_api_version=0.114.1+1.21.5
fabric_kotlin_version=1.13.0+kotlin.2.1.0
toml4j_version=0.7.2
jankson_version=1.2.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand Down Expand Up @@ -58,7 +59,7 @@ public abstract class MultifaceClusterBlock extends MultifaceBlock implements Si
protected final VoxelShape downAabb;

private final Map<Direction, VoxelShape> shapeByDirection;
private final ImmutableMap<BlockState, VoxelShape> shapesCache;
private final Function<BlockState, VoxelShape> shapesCache;


public MultifaceClusterBlock(int height, int xzOffset, @NotNull Properties properties) {
Expand All @@ -84,7 +85,7 @@ public MultifaceClusterBlock(int height, int xzOffset, @NotNull Properties prope
@Override
@NotNull
public VoxelShape getShape(@NotNull BlockState state, @NotNull BlockGetter world, @NotNull BlockPos pos, @NotNull CollisionContext context) {
return Objects.requireNonNull(this.shapesCache.get(state));
return Objects.requireNonNull(this.shapesCache.apply(state));
}

public VoxelShape calculateMultifaceShape(BlockState state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.jetbrains.annotations.NotNull;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;

/**
* A block that combines an amethyst cluster-type block with a multiface spreadable block.
Expand All @@ -57,7 +58,7 @@ public abstract class MultifaceClusterSpreadableBlock extends MultifaceSpreadeab
protected final VoxelShape downAabb;

private final Map<Direction, VoxelShape> shapeByDirection;
private final ImmutableMap<BlockState, VoxelShape> shapesCache;
private final Function<BlockState, VoxelShape> shapesCache;

public MultifaceClusterSpreadableBlock(int height, int xzOffset, @NotNull Properties properties) {
super(properties.pushReaction(PushReaction.DESTROY));
Expand All @@ -82,7 +83,7 @@ public MultifaceClusterSpreadableBlock(int height, int xzOffset, @NotNull Proper
@Override
@NotNull
public VoxelShape getShape(@NotNull BlockState state, @NotNull BlockGetter world, @NotNull BlockPos pos, @NotNull CollisionContext context) {
return Objects.requireNonNull(this.shapesCache.get(state));
return Objects.requireNonNull(this.shapesCache.apply(state));
}

public VoxelShape calculateMultifaceShape(BlockState state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private static boolean isFaceOccludedByState(BlockGetter level, Direction face,
if (neighborState.getBlock() == state.getBlock() && state.canOcclude()) {
VoxelShape voxelShape = Shapes.box(0.0, 0.0, 0.0, 1.0, height, 1.0);
VoxelShape voxelShape2 = state.getOcclusionShape();
return Shapes.blockOccudes(voxelShape, voxelShape2, face);
return Shapes.blockOccludes(voxelShape, voxelShape2, face);
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ public class LevelRendererMixin {
ResourceHandle resourceHandle,
ResourceHandle resourceHandle2,
ResourceHandle resourceHandle3,
ResourceHandle resourceHandle4,
boolean bl,
Frustum frustum,
ResourceHandle resourceHandle5,
ResourceHandle resourceHandle4,
CallbackInfo info,
@Local(ordinal = 0) float deltaTime,
@Local PoseStack poseStack,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.BlockPos;
import net.minecraft.util.RandomSource;
import net.minecraft.util.random.WeightedEntry;
import net.minecraft.util.random.WeightedRandomList;
import net.minecraft.util.random.Weighted;
import net.minecraft.util.random.WeightedList;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.structure.templatesystem.PosAlwaysTrueTest;
import net.minecraft.world.level.levelgen.structure.templatesystem.PosRuleTest;
Expand All @@ -34,21 +34,21 @@ public class WeightedProcessorRule {
RuleTest.CODEC.fieldOf("input_predicate").forGetter(rule -> rule.inputPredicate),
RuleTest.CODEC.fieldOf("location_predicate").forGetter(rule -> rule.locPredicate),
PosRuleTest.CODEC.lenientOptionalFieldOf("position_predicate", PosAlwaysTrueTest.INSTANCE).forGetter(rule -> rule.posPredicate),
WeightedRandomList.codec(WeightedEntry.Wrapper.codec(BlockState.CODEC)).fieldOf("output_states").forGetter(rule -> rule.outputStates)
WeightedList.codec(Weighted.codec(BlockState.CODEC)).fieldOf("output_states").forGetter(rule -> rule.outputStates)
)
.apply(instance, WeightedProcessorRule::new)
);
private final RuleTest inputPredicate;
private final RuleTest locPredicate;
private final PosRuleTest posPredicate;
private final WeightedRandomList<WeightedEntry.Wrapper<BlockState>> outputStates;
private final WeightedList<Weighted<BlockState>> outputStates;

public WeightedProcessorRule(RuleTest inputPredicate, RuleTest locationPredicate, WeightedRandomList<WeightedEntry.Wrapper<BlockState>> states) {
public WeightedProcessorRule(RuleTest inputPredicate, RuleTest locationPredicate, WeightedList<Weighted<BlockState>> states) {
this(inputPredicate, locationPredicate, PosAlwaysTrueTest.INSTANCE, states);
}

public WeightedProcessorRule(
RuleTest inputPredicate, RuleTest locationPredicate, PosRuleTest positionPredicate, WeightedRandomList<WeightedEntry.Wrapper<BlockState>> states
RuleTest inputPredicate, RuleTest locationPredicate, PosRuleTest positionPredicate, WeightedList<Weighted<BlockState>> states
) {
this.inputPredicate = inputPredicate;
this.locPredicate = locationPredicate;
Expand All @@ -61,6 +61,6 @@ public boolean test(BlockState input, BlockState location, BlockPos localPos, Bl
}

public BlockState getOutputState(RandomSource random) {
return this.outputStates.getRandom(random).orElseThrow().data();
return this.outputStates.getRandom(random).orElseThrow().value();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.random.SimpleWeightedRandomList;
import net.minecraft.util.random.WeightedEntry;
import net.minecraft.util.random.Weighted;
import net.minecraft.util.random.WeightedList;
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
import net.minecraft.world.level.levelgen.structure.pools.alias.Random;
import org.spongepowered.asm.mixin.Final;
Expand All @@ -41,17 +41,17 @@ public class RandomMixin {
@Shadow
@Final
@Mutable
private SimpleWeightedRandomList<ResourceKey<StructureTemplatePool>> targets;
private WeightedList<ResourceKey<StructureTemplatePool>> targets;

@Inject(method = "<init>", at = @At("TAIL"))
public void frozenLib$addRandomPoolAliasTargets(ResourceKey<StructureTemplatePool> alias, SimpleWeightedRandomList<ResourceKey<StructureTemplatePool>> targets, CallbackInfo info) {
public void frozenLib$addRandomPoolAliasTargets(ResourceKey<StructureTemplatePool> alias, WeightedList<ResourceKey<StructureTemplatePool>> targets, CallbackInfo info) {
ResourceLocation aliasLocation = alias.location();
List<Pair<ResourceLocation, Integer>> additions = RandomPoolAliasApi.getAdditionalTargets(aliasLocation);

SimpleWeightedRandomList.Builder<ResourceKey<StructureTemplatePool>> builder = SimpleWeightedRandomList.builder();
WeightedList.Builder<ResourceKey<StructureTemplatePool>> builder = WeightedList.builder();

for (WeightedEntry.Wrapper<ResourceKey<StructureTemplatePool>> wrapper : this.targets.unwrap()) {
builder.add(wrapper.data(), wrapper.weight().asInt());
for (Weighted<ResourceKey<StructureTemplatePool>> wrapper : this.targets.unwrap()) {
builder.add(wrapper.value(), wrapper.weight());
}

for (Pair<ResourceLocation, Integer> additionalTargets : additions) {
Expand Down

0 comments on commit a60dad6

Please sign in to comment.