Adapted to soem Fabric API changes
This commit is contained in:
parent
23bcbe1977
commit
e2ab77658b
11 changed files with 74 additions and 117 deletions
|
@ -6,9 +6,9 @@ loom_version=0.9-SNAPSHOT
|
|||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/versions.html
|
||||
minecraft_version= 21w37a
|
||||
minecraft_version= 21w38a
|
||||
loader_version= 0.11.7
|
||||
fabric_version = 0.40.1+1.17
|
||||
fabric_version = 0.40.4+1.18
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 0.4.1
|
||||
|
|
|
@ -3,7 +3,9 @@ package ru.bclib.api;
|
|||
import com.google.common.collect.Maps;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.impl.biome.InternalBiomeData;
|
||||
import net.fabricmc.fabric.api.biome.v1.NetherBiomes;
|
||||
import net.fabricmc.fabric.impl.biome.NetherBiomeData;
|
||||
import net.fabricmc.fabric.impl.biome.TheEndBiomeData;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
|
@ -11,8 +13,8 @@ import net.minecraft.resources.ResourceKey;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Climate;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
import net.minecraft.world.level.biome.Climate;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.util.MHelper;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
|
@ -106,7 +108,7 @@ public class BiomeAPI {
|
|||
random.nextFloat()
|
||||
);
|
||||
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).get();
|
||||
InternalBiomeData.addNetherBiome(key, parameters);
|
||||
NetherBiomeData.addNetherBiome(key, parameters);
|
||||
return biome;
|
||||
}
|
||||
|
||||
|
@ -135,8 +137,8 @@ public class BiomeAPI {
|
|||
END_LAND_BIOME_PICKER.addBiome(biome);
|
||||
float weight = biome.getGenChance();
|
||||
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).get();
|
||||
InternalBiomeData.addEndBiomeReplacement(Biomes.END_HIGHLANDS, key, weight);
|
||||
InternalBiomeData.addEndBiomeReplacement(Biomes.END_MIDLANDS, key, weight);
|
||||
TheEndBiomeData.addEndBiomeReplacement(Biomes.END_HIGHLANDS, key, weight);
|
||||
TheEndBiomeData.addEndBiomeReplacement(Biomes.END_MIDLANDS, key, weight);
|
||||
return biome;
|
||||
}
|
||||
|
||||
|
@ -180,7 +182,7 @@ public class BiomeAPI {
|
|||
END_VOID_BIOME_PICKER.addBiome(biome);
|
||||
float weight = biome.getGenChance();
|
||||
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).get();
|
||||
InternalBiomeData.addEndBiomeReplacement(Biomes.SMALL_END_ISLANDS, key, weight);
|
||||
TheEndBiomeData.addEndBiomeReplacement(Biomes.SMALL_END_ISLANDS, key, weight);
|
||||
return biome;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ public abstract class FeatureSaplingBlock extends SaplingBlock implements Render
|
|||
@Override
|
||||
public void advanceTree(ServerLevel world, BlockPos pos, BlockState blockState, Random random) {
|
||||
FeaturePlaceContext context = new FeaturePlaceContext(
|
||||
Optional.empty(),
|
||||
world,
|
||||
world.getChunkSource().getGenerator(),
|
||||
random,
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
package ru.bclib.blocks.properties;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@Deprecated
|
||||
public class StringProperty extends Property<String> {
|
||||
private final Set<String> values;
|
||||
|
||||
public static StringProperty create(String name, String... values) {
|
||||
return new StringProperty(name, values);
|
||||
}
|
||||
|
||||
protected StringProperty(String string, String... values) {
|
||||
super(string, String.class);
|
||||
this.values = Sets.newHashSet(values);
|
||||
}
|
||||
|
||||
public void addValue(String name) {
|
||||
values.add(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getPossibleValues() {
|
||||
return Collections.unmodifiableSet(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(String comparable) {
|
||||
return comparable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> getValue(String string) {
|
||||
if (values.contains(string)) {
|
||||
return Optional.of(string);
|
||||
}
|
||||
else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int generateHashCode() {
|
||||
return super.generateHashCode() + Objects.hashCode(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof StringProperty that)) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
return values.equals(that.values);
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import net.fabricmc.fabric.impl.biome.InternalBiomeData;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
import net.minecraft.world.level.biome.Climate;
|
||||
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.CallbackInfo;
|
||||
import ru.bclib.world.biomes.FabricBiomesData;
|
||||
|
||||
@Mixin(value = InternalBiomeData.class, remap = false)
|
||||
public class InternalBiomeDataMixin {
|
||||
@Inject(method = "addEndBiomeReplacement", at = @At(value = "HEAD"))
|
||||
private static void bclib_addEndBiomeReplacement(ResourceKey<Biome> replaced, ResourceKey<Biome> variant, double weight, CallbackInfo info) {
|
||||
if (replaced == Biomes.END_BARRENS || replaced == Biomes.SMALL_END_ISLANDS) {
|
||||
FabricBiomesData.END_VOID_BIOMES.put(variant, (float) weight);
|
||||
}
|
||||
else {
|
||||
FabricBiomesData.END_LAND_BIOMES.put(variant, (float) weight);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "addEndMidlandsReplacement", at = @At(value = "HEAD"))
|
||||
private static void bclib_addEndMidlandsReplacement(ResourceKey<Biome> highlands, ResourceKey<Biome> midlands, double weight, CallbackInfo info) {
|
||||
FabricBiomesData.END_LAND_BIOMES.put(midlands, (float) weight);
|
||||
}
|
||||
|
||||
@Inject(method = "addEndBarrensReplacement", at = @At(value = "HEAD"))
|
||||
private static void bclib_addEndBarrensReplacement(ResourceKey<Biome> highlands, ResourceKey<Biome> barrens, double weight, CallbackInfo info) {
|
||||
FabricBiomesData.END_LAND_BIOMES.put(barrens, (float) weight);
|
||||
FabricBiomesData.END_VOID_BIOMES.put(barrens, (float) weight);
|
||||
}
|
||||
|
||||
@Inject(method = "addNetherBiome", at = @At(value = "HEAD"))
|
||||
private static void bclib_addNetherBiome(ResourceKey<Biome> biome, Climate.ParameterPoint spawnNoisePoint, CallbackInfo info) {
|
||||
FabricBiomesData.NETHER_BIOMES.add(biome);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import net.fabricmc.fabric.impl.biome.NetherBiomeData;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Climate;
|
||||
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.CallbackInfo;
|
||||
import ru.bclib.world.biomes.FabricBiomesData;
|
||||
|
||||
@Mixin(value = NetherBiomeData.class, remap = false)
|
||||
public class NetherBiomeDataMixin {
|
||||
@Inject(method = "addNetherBiome", at = @At(value = "HEAD"))
|
||||
private static void bclib_addNetherBiome(ResourceKey<Biome> biome, Climate.ParameterPoint spawnNoisePoint, CallbackInfo info) {
|
||||
FabricBiomesData.NETHER_BIOMES.add(biome);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import net.fabricmc.fabric.impl.biome.TheEndBiomeData;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
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.CallbackInfo;
|
||||
import ru.bclib.world.biomes.FabricBiomesData;
|
||||
|
||||
@Mixin(value = TheEndBiomeData.class, remap = false)
|
||||
public class TheEndBiomeDataMixin {
|
||||
@Inject(method = "addEndBiomeReplacement", at = @At(value = "HEAD"))
|
||||
private static void bclib_addEndBiomeReplacement(ResourceKey<Biome> replaced, ResourceKey<Biome> variant, double weight, CallbackInfo info) {
|
||||
if (replaced == Biomes.END_BARRENS || replaced == Biomes.SMALL_END_ISLANDS) {
|
||||
FabricBiomesData.END_VOID_BIOMES.put(variant, (float) weight);
|
||||
}
|
||||
else {
|
||||
FabricBiomesData.END_LAND_BIOMES.put(variant, (float) weight);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "addEndMidlandsReplacement", at = @At(value = "HEAD"))
|
||||
private static void bclib_addEndMidlandsReplacement(ResourceKey<Biome> highlands, ResourceKey<Biome> midlands, double weight, CallbackInfo info) {
|
||||
FabricBiomesData.END_LAND_BIOMES.put(midlands, (float) weight);
|
||||
}
|
||||
|
||||
@Inject(method = "addEndBarrensReplacement", at = @At(value = "HEAD"))
|
||||
private static void bclib_addEndBarrensReplacement(ResourceKey<Biome> highlands, ResourceKey<Biome> barrens, double weight, CallbackInfo info) {
|
||||
FabricBiomesData.END_LAND_BIOMES.put(barrens, (float) weight);
|
||||
FabricBiomesData.END_VOID_BIOMES.put(barrens, (float) weight);
|
||||
}
|
||||
}
|
|
@ -321,6 +321,7 @@ public class BCLBiomeDef {
|
|||
});
|
||||
|
||||
generationSettings.surfaceBuilder(surface == null ? net.minecraft.data.worldgen.SurfaceBuilders.END : surface);
|
||||
//TODO: Removed now. Seems to part of a registry step per biome now
|
||||
structures.forEach((structure) -> generationSettings.addStructureStart(structure));
|
||||
features.forEach((info) -> generationSettings.addFeature(info.featureStep, info.feature));
|
||||
carvers.forEach((info) -> generationSettings.addCarver(info.carverStep, info.carver));
|
||||
|
|
|
@ -25,7 +25,7 @@ public class BCLStructureFeature {
|
|||
.register();
|
||||
this.featureConfigured = this.structure.configured(NoneFeatureConfiguration.NONE);
|
||||
BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE, id, this.featureConfigured);
|
||||
FlatChunkGeneratorConfigAccessor.getStructureToFeatures().put(this.structure, this.featureConfigured);
|
||||
FlatLevelGeneratorSettings.getStructureToFeatures().put(this.structure, this.featureConfigured);
|
||||
}
|
||||
|
||||
public StructureFeature<NoneFeatureConfiguration> getStructure() {
|
||||
|
|
|
@ -5,7 +5,7 @@ import net.minecraft.world.level.biome.Biome;
|
|||
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.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.BlockColumn;
|
||||
import net.minecraft.world.level.levelgen.surfacebuilders.ConfiguredSurfaceBuilder;
|
||||
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilder;
|
||||
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderBaseConfiguration;
|
||||
|
@ -45,11 +45,11 @@ public class DoubleBlockSurfaceBuilder extends SurfaceBuilder<SurfaceBuilderBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public void apply(Random random, ChunkAccess chunkAccess, Biome biome, int x, int z, int height, double noise, BlockState defaultBlock, BlockState defaultFluid, int l, int m, long seed, SurfaceBuilderBaseConfiguration surfaceBuilderConfiguration) {
|
||||
public void apply(Random random, BlockColumn blockColumn, Biome biome, int x, int z, int height, double noise, BlockState defaultBlock, BlockState defaultFluid, int l, int m, long seed, SurfaceBuilderBaseConfiguration surfaceBuilderConfiguration) {
|
||||
noise = NOISE.eval(x * 0.1, z * 0.1) + MHelper.randRange(-0.4, 0.4, random);
|
||||
SurfaceBuilder.DEFAULT.apply(
|
||||
random,
|
||||
chunkAccess,
|
||||
blockColumn,
|
||||
biome,
|
||||
x,
|
||||
z,
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
"compatibilityLevel": "JAVA_16",
|
||||
"mixins": [
|
||||
"SimpleReloadableResourceManagerMixin",
|
||||
"InternalBiomeDataMixin",
|
||||
"ComposterBlockAccessor",
|
||||
"PotionBrewingAccessor",
|
||||
"RecipeManagerAccessor",
|
||||
|
@ -20,7 +19,9 @@
|
|||
"AnvilMenuMixin",
|
||||
"TagLoaderMixin",
|
||||
"BiomeMixin",
|
||||
"MainMixin"
|
||||
"MainMixin",
|
||||
"TheEndBiomeDataMixin",
|
||||
"NetherBiomeDataMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue