Skip to content

Commit

Permalink
Update to 1.19.
Browse files Browse the repository at this point in the history
  • Loading branch information
alcatrazEscapee committed Nov 30, 2022
1 parent 0133e8a commit 56a72d4
Show file tree
Hide file tree
Showing 20 changed files with 102 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;
import com.google.common.collect.ImmutableMap;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
Expand All @@ -25,7 +23,6 @@
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;

import com.alcatrazescapee.primalwinter.PrimalWinter;
import com.alcatrazescapee.primalwinter.mixin.AxeItemAccessor;
import com.alcatrazescapee.primalwinter.platform.RegistryHolder;
import com.alcatrazescapee.primalwinter.platform.RegistryInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import net.minecraft.core.Registry;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;

import com.alcatrazescapee.primalwinter.PrimalWinter;
import com.alcatrazescapee.primalwinter.platform.RegistryHolder;
import com.alcatrazescapee.primalwinter.platform.RegistryInterface;
import com.alcatrazescapee.primalwinter.platform.XPlatform;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ private void addExtraSnowParticlesAndSounds(Camera camera, CallbackInfo ci)
final BlockPos cameraPos = new BlockPos(camera.getPosition());
BlockPos pos = null;

final int particleCount = (int) (100.0F * rain * rain) / (minecraft.options.particles == ParticleStatus.DECREASED ? 2 : 1);
final int particleCount = (int) (100.0F * rain * rain) / (minecraft.options.particles().get() == ParticleStatus.DECREASED ? 2 : 1);
for (int i = 0; i < particleCount; ++i)
{
final BlockPos randomPos = level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, cameraPos.offset(random.nextInt(21) - 10, 0, random.nextInt(21) - 10));
final Biome biome = level.getBiome(randomPos).value();
if (randomPos.getY() > level.getMinBuildHeight() && randomPos.getY() <= cameraPos.getY() + 10 && randomPos.getY() >= cameraPos.getY() - 10 && biome.getPrecipitation() == Biome.Precipitation.SNOW && biome.coldEnoughToSnow(randomPos)) // Change: use SNOW and coldEnoughToSnow() instead
{
pos = randomPos.below();
if (minecraft.options.particles == ParticleStatus.MINIMAL)
if (minecraft.options.particles().get() == ParticleStatus.MINIMAL)
{
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ default ResourceKey<T> key()

default Holder<T> holder()
{
return registry().getOrCreateHolder(key());
return registry().getOrCreateHolderOrThrow(key());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@ public enum Config
{
final SpecBuilder builder = Spec.builder();

builder.push("general");
builder
.comment(
"This is the config file for the Primal Winter mod",
"In order to reload these settings in-game, you must run /primalwinterReloadConfig"
)
.push("general");

// Common
enableWeatherCommand = builder
.comment("Should the vanilla /weather be disabled? Any changes require a world restart to take effect.")
.define("enableWeatherCommand", false);
Expand Down Expand Up @@ -115,7 +119,6 @@ public enum Config

builder.swap("client");

// Client
fogDensity = builder
.comment("How dense the fog effect during a snowstorm is.")
.define("fogDensity", 0.1f, 0f, 1f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.LevelAccessor;
Expand Down Expand Up @@ -36,7 +36,7 @@ public static void registerCommands(CommandDispatcher<CommandSourceStack> dispat
// Vanilla weather command... NOT ALLOWED
dispatcher.getRoot().getChildren().removeIf(node -> node.getName().equals("weather"));
dispatcher.register(Commands.literal("weather").executes(source -> {
source.getSource().sendSuccess(new TextComponent("Not even a command can overcome this storm... (This command is disabled by Primal Winter)"), false);
source.getSource().sendSuccess(Component.literal("Not even a command can overcome this storm... (This command is disabled by Primal Winter)"), false);
return 0;
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -137,7 +138,7 @@ private void extendSkyLights(int[] skyLights, int startX, int startZ)
}
}

private void placeSnowAndIce(WorldGenLevel level, BlockPos pos, BlockState state, Random random, int skyLight)
private void placeSnowAndIce(WorldGenLevel level, BlockPos pos, BlockState state, RandomSource random, int skyLight)
{
final Biome biome = level.getBiome(pos).value();
if (!biome.coldEnoughToSnow(pos) || biome.getPrecipitation() != Biome.Precipitation.SNOW)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.BaseDiskFeature;
import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.DiskFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.DiskConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.stateproviders.RuleBasedBlockStateProvider;
import net.minecraft.world.level.levelgen.placement.BiomeFilter;
import net.minecraft.world.level.levelgen.placement.InSquarePlacement;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
Expand All @@ -39,7 +41,7 @@ public static final class Features

public static final RegistryHolder<ImprovedFreezeTopLayerFeature> FREEZE_TOP_LAYER = register("freeze_top_layer", ImprovedFreezeTopLayerFeature::new, NoneFeatureConfiguration.CODEC);
public static final RegistryHolder<ImprovedIceSpikeFeature> ICE_SPIKES = register("ice_spikes", ImprovedIceSpikeFeature::new, NoneFeatureConfiguration.CODEC);
public static final RegistryHolder<BaseDiskFeature> DISK = register("disk", BaseDiskFeature::new, DiskConfiguration.CODEC);
public static final RegistryHolder<DiskFeature> DISK = register("disk", DiskFeature::new, DiskConfiguration.CODEC);

private static <C extends FeatureConfiguration, F extends Feature<C>> RegistryHolder<F> register(String name, Function<Codec<C>, F> feature, Codec<C> codec)
{
Expand All @@ -54,20 +56,31 @@ public static final class Configured
public static final RegistryHolder<ConfiguredFeature<?, ?>> FREEZE_TOP_LAYER = register("freeze_top_layer", Features.FREEZE_TOP_LAYER, () -> NoneFeatureConfiguration.INSTANCE);
public static final RegistryHolder<ConfiguredFeature<?, ?>> ICE_SPIKES = register("ice_spikes", Features.ICE_SPIKES, () -> NoneFeatureConfiguration.INSTANCE);

public static final RegistryHolder<ConfiguredFeature<?, ?>> ICE_PATCH = register("ice_patch", Features.DISK, () -> new DiskConfiguration(Blocks.PACKED_ICE.defaultBlockState(), UniformInt.of(2, 3), 1, snowyReplaceableBlocks()));
public static final RegistryHolder<ConfiguredFeature<?, ?>> SNOW_PATCH = register("snow_patch", Features.DISK, () -> new DiskConfiguration(Blocks.SNOW_BLOCK.defaultBlockState(), UniformInt.of(2, 3), 1, snowyReplaceableBlocks()));
public static final RegistryHolder<ConfiguredFeature<?, ?>> POWDER_SNOW_PATCH = register("powder_snow_patch", Features.DISK, () -> new DiskConfiguration(Blocks.POWDER_SNOW.defaultBlockState(), UniformInt.of(2, 3), 1, snowyReplaceableBlocks()));
public static final RegistryHolder<ConfiguredFeature<?, ?>> ICE_PATCH = register("ice_patch", Features.DISK, () -> new DiskConfiguration(RuleBasedBlockStateProvider.simple(Blocks.PACKED_ICE), snowyReplaceableBlocks(), UniformInt.of(2, 3), 1));
public static final RegistryHolder<ConfiguredFeature<?, ?>> SNOW_PATCH = register("snow_patch", Features.DISK, () -> new DiskConfiguration(RuleBasedBlockStateProvider.simple(Blocks.SNOW_BLOCK), snowyReplaceableBlocks(), UniformInt.of(2, 3), 1));
public static final RegistryHolder<ConfiguredFeature<?, ?>> POWDER_SNOW_PATCH = register("powder_snow_patch", Features.DISK, () -> new DiskConfiguration(RuleBasedBlockStateProvider.simple(Blocks.POWDER_SNOW), snowyReplaceableBlocks(), UniformInt.of(2, 3), 1));

private static <C extends FeatureConfiguration, F extends Feature<C>> RegistryHolder<ConfiguredFeature<?, ?>> register(String name, Supplier<F> feature, Supplier<C> config)
{
return CONFIGURED_FEATURES.register(name, () -> new ConfiguredFeature<>(feature.get(), config.get()));
}

private static List<BlockState> snowyReplaceableBlocks()
private static BlockPredicate snowyReplaceableBlocks()
{
return Stream.of(Blocks.DIRT, Blocks.GRASS_BLOCK, Blocks.PODZOL, Blocks.COARSE_DIRT, Blocks.MYCELIUM, Blocks.SNOW_BLOCK, Blocks.ICE, Blocks.SAND, Blocks.RED_SAND, PrimalWinterBlocks.SNOWY_DIRT.get(), PrimalWinterBlocks.SNOWY_COARSE_DIRT.get(), PrimalWinterBlocks.SNOWY_SAND.get(), PrimalWinterBlocks.SNOWY_RED_SAND.get())
.map(Block::defaultBlockState)
.toList();
return BlockPredicate.matchesBlocks(
Blocks.DIRT,
Blocks.GRASS_BLOCK,
Blocks.PODZOL,
Blocks.COARSE_DIRT,
Blocks.MYCELIUM,
Blocks.SNOW_BLOCK,
Blocks.ICE,
Blocks.SAND,
Blocks.RED_SAND,
PrimalWinterBlocks.SNOWY_DIRT.get(),
PrimalWinterBlocks.SNOWY_COARSE_DIRT.get(),
PrimalWinterBlocks.SNOWY_SAND.get(),
PrimalWinterBlocks.SNOWY_RED_SAND.get());
}
}

Expand Down
Binary file modified Common/src/main/resources/assets/primalwinter/sounds/wind.ogg
Binary file not shown.
3 changes: 3 additions & 0 deletions Data/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ def main():

common.block_tag('minecraft:animals_spawnable_on', 'minecraft:snow_block', 'minecraft:snow', 'primalwinter:snowy_dirt', 'primalwinter:snowy_sand')

# Forge biome modifier
forge.data(('forge', 'biome_modifier', 'instance'), {'type': 'primalwinter:instance'})

# Only flush common
common.flush()

Expand Down
2 changes: 1 addition & 1 deletion Fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "idea"
id "fabric-loom" version "0.12-SNAPSHOT"
id "io.github.juuxel.loom-quiltflower" version "1.7.2"
id "idea"
id "com.github.johnrengelman.shadow" version "7.1.2"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.biome.v1.BiomeModificationContext;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.fabricmc.fabric.api.biome.v1.ModificationPhase;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;

public final class FabricPrimalWinter implements ModInitializer
{
Expand All @@ -29,7 +28,7 @@ public void onInitialize()
PrimalWinter.earlySetup();
PrimalWinter.lateSetup();

CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> EventHandler.registerCommands(dispatcher));
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, dedicated) -> EventHandler.registerCommands(dispatcher));
ServerWorldEvents.LOAD.register((server, level) -> EventHandler.setLevelToThunder(level));

BiomeModifications.create(Helpers.identifier("winterize")).add(ModificationPhase.REPLACEMENTS, context -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private static void modifyFogColor(Camera camera, float partialTick, ClientLevel
}

@Inject(method = "setupFog", at = @At("TAIL"))
private static void modifyFogDensity(Camera camera, FogRenderer.FogMode mode, float unused1, boolean unused2, CallbackInfo ci)
private static void modifyFogDensity(Camera camera, FogRenderer.FogMode mode, float unused1, boolean unused2, float unused3, CallbackInfo ci)
{
ClientEventHandler.renderFogDensity(camera, (nearPlane, farPlane) -> {
RenderSystem.setShaderFogStart(nearPlane * RenderSystem.getShaderFogStart());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;

import com.alcatrazescapee.primalwinter.util.Config;
import net.fabricmc.api.EnvType;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.loader.api.FabricLoader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;

import com.alcatrazescapee.primalwinter.PrimalWinter;
import com.alcatrazescapee.primalwinter.util.Helpers;
import org.jetbrains.annotations.Nullable;

Expand Down
Loading

0 comments on commit 56a72d4

Please sign in to comment.