Fixed Compile Errors

This commit is contained in:
Frank 2022-05-13 00:05:05 +02:00
parent 4ba3a71a68
commit 05eac6f539
79 changed files with 979 additions and 844 deletions

View file

@ -7,7 +7,7 @@ import net.minecraft.world.level.block.Block;
import ru.bclib.util.WeightedList; import ru.bclib.util.WeightedList;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
import java.util.Set; import java.util.Set;
public class BonemealAPI { public class BonemealAPI {
@ -111,7 +111,7 @@ public class BonemealAPI {
list.add(plant, chance); list.add(plant, chance);
} }
public static Block getLandGrass(ResourceLocation biomeID, Block terrain, Random random) { public static Block getLandGrass(ResourceLocation biomeID, Block terrain, RandomSource random) {
Map<Block, WeightedList<Block>> map = LAND_GRASS_BIOMES.get(biomeID); Map<Block, WeightedList<Block>> map = LAND_GRASS_BIOMES.get(biomeID);
WeightedList<Block> list = null; WeightedList<Block> list = null;
if (map != null) { if (map != null) {
@ -126,7 +126,7 @@ public class BonemealAPI {
return list == null ? null : list.get(random); return list == null ? null : list.get(random);
} }
public static Block getWaterGrass(ResourceLocation biomeID, Block terrain, Random random) { public static Block getWaterGrass(ResourceLocation biomeID, Block terrain, RandomSource random) {
Map<Block, WeightedList<Block>> map = WATER_GRASS_BIOMES.get(biomeID); Map<Block, WeightedList<Block>> map = WATER_GRASS_BIOMES.get(biomeID);
WeightedList<Block> list = null; WeightedList<Block> list = null;
if (map != null) { if (map != null) {

View file

@ -50,9 +50,7 @@ public class LifeCycleAPI {
LevelStorageSource.LevelStorageAccess levelStorageAccess, LevelStorageSource.LevelStorageAccess levelStorageAccess,
ServerLevelData serverLevelData, ServerLevelData serverLevelData,
ResourceKey<Level> resourceKey, ResourceKey<Level> resourceKey,
Holder<DimensionType> dimensionType,
ChunkProgressListener chunkProgressListener, ChunkProgressListener chunkProgressListener,
ChunkGenerator chunkGenerator,
boolean bl, boolean bl,
long l, long l,
List<CustomSpawner> list, List<CustomSpawner> list,
@ -101,9 +99,7 @@ public class LifeCycleAPI {
* @param levelStorageAccess * @param levelStorageAccess
* @param serverLevelData * @param serverLevelData
* @param resourceKey * @param resourceKey
* @param dimensionType
* @param chunkProgressListener * @param chunkProgressListener
* @param chunkGenerator
* @param bl * @param bl
* @param l * @param l
* @param list * @param list
@ -115,9 +111,7 @@ public class LifeCycleAPI {
LevelStorageSource.LevelStorageAccess levelStorageAccess, LevelStorageSource.LevelStorageAccess levelStorageAccess,
ServerLevelData serverLevelData, ServerLevelData serverLevelData,
ResourceKey<Level> resourceKey, ResourceKey<Level> resourceKey,
Holder<DimensionType> dimensionType,
ChunkProgressListener chunkProgressListener, ChunkProgressListener chunkProgressListener,
ChunkGenerator chunkGenerator,
boolean bl, boolean bl,
long l, long l,
List<CustomSpawner> list, List<CustomSpawner> list,
@ -129,9 +123,7 @@ public class LifeCycleAPI {
levelStorageAccess, levelStorageAccess,
serverLevelData, serverLevelData,
resourceKey, resourceKey,
dimensionType,
chunkProgressListener, chunkProgressListener,
chunkGenerator,
bl, bl,
l, l,
list, list,

View file

@ -19,7 +19,6 @@ import net.minecraft.world.level.biome.AmbientMoodSettings;
import net.minecraft.world.level.biome.AmbientParticleSettings; import net.minecraft.world.level.biome.AmbientParticleSettings;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.Biome.BiomeBuilder; import net.minecraft.world.level.biome.Biome.BiomeBuilder;
import net.minecraft.world.level.biome.Biome.BiomeCategory;
import net.minecraft.world.level.biome.Biome.Precipitation; import net.minecraft.world.level.biome.Biome.Precipitation;
import net.minecraft.world.level.biome.BiomeGenerationSettings; import net.minecraft.world.level.biome.BiomeGenerationSettings;
import net.minecraft.world.level.biome.BiomeSpecialEffects; import net.minecraft.world.level.biome.BiomeSpecialEffects;
@ -43,7 +42,7 @@ import ru.bclib.util.TriFunction;
import ru.bclib.world.biomes.BCLBiome; import ru.bclib.world.biomes.BCLBiome;
import ru.bclib.world.biomes.BCLBiomeSettings; import ru.bclib.world.biomes.BCLBiomeSettings;
import ru.bclib.world.features.BCLFeature; import ru.bclib.world.features.BCLFeature;
import ru.bclib.world.structures.BCLStructureFeature; import ru.bclib.world.structures.BCLStructure;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -67,7 +66,8 @@ public class BCLBiomeBuilder {
private SurfaceRules.RuleSource surfaceRule; private SurfaceRules.RuleSource surfaceRule;
private Precipitation precipitation; private Precipitation precipitation;
private ResourceLocation biomeID; private ResourceLocation biomeID;
private BiomeCategory category;
//BiomeTags.IS_NETHER
private float temperature; private float temperature;
private float fogDensity; private float fogDensity;
private float genChance; private float genChance;
@ -86,7 +86,6 @@ public class BCLBiomeBuilder {
public static BCLBiomeBuilder start(ResourceLocation biomeID) { public static BCLBiomeBuilder start(ResourceLocation biomeID) {
INSTANCE.biomeID = biomeID; INSTANCE.biomeID = biomeID;
INSTANCE.precipitation = Precipitation.NONE; INSTANCE.precipitation = Precipitation.NONE;
INSTANCE.category = BiomeCategory.NONE;
INSTANCE.generationSettings = null; INSTANCE.generationSettings = null;
INSTANCE.effectsBuilder = null; INSTANCE.effectsBuilder = null;
INSTANCE.spawnSettings = null; INSTANCE.spawnSettings = null;
@ -113,16 +112,6 @@ public class BCLBiomeBuilder {
return this; return this;
} }
/**
* Set biome category. Doesn't affect biome worldgen, but Fabric biome modifications can target biome by it.
* @param category {@link BiomeCategory}
* @return same {@link BCLBiomeBuilder} instance.
*/
public BCLBiomeBuilder category(BiomeCategory category) {
this.category = category;
return this;
}
/** /**
* Set biome temperature, affect plant color, biome generation and ice formation. * Set biome temperature, affect plant color, biome generation and ice formation.
* @param temperature biome temperature. * @param temperature biome temperature.
@ -556,10 +545,10 @@ public class BCLBiomeBuilder {
/** /**
* Adds new structure feature into thr biome. Will add building biome into the structure list. * Adds new structure feature into thr biome. Will add building biome into the structure list.
* @param structure {@link BCLStructureFeature} to add. * @param structure {@link BCLStructure} to add.
* @return same {@link BCLBiomeBuilder} instance. * @return same {@link BCLBiomeBuilder} instance.
*/ */
public BCLBiomeBuilder structure(BCLStructureFeature structure) { public BCLBiomeBuilder structure(BCLStructure structure) {
structure.addInternalBiome(biomeID); structure.addInternalBiome(biomeID);
return structure(structure.biomeTag); return structure(structure.biomeTag);
} }
@ -685,7 +674,6 @@ public class BCLBiomeBuilder {
public <T extends BCLBiome> T build(BiomeSupplier<T> biomeConstructor) { public <T extends BCLBiome> T build(BiomeSupplier<T> biomeConstructor) {
BiomeBuilder builder = new BiomeBuilder() BiomeBuilder builder = new BiomeBuilder()
.precipitation(precipitation) .precipitation(precipitation)
.biomeCategory(category)
.temperature(temperature) .temperature(temperature)
.downfall(downfall); .downfall(downfall);

View file

@ -44,7 +44,6 @@ import net.minecraft.world.level.levelgen.SurfaceRules;
import net.minecraft.world.level.levelgen.SurfaceRules.RuleSource; import net.minecraft.world.level.levelgen.SurfaceRules.RuleSource;
import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.placement.PlacedFeature; import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableInt;
@ -72,7 +71,9 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
import net.minecraft.world.level.levelgen.structure.Structure;
import java.util.Set; import java.util.Set;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -836,9 +837,9 @@ public class BiomeAPI {
static class StructureID { static class StructureID {
public final ResourceLocation biomeID; public final ResourceLocation biomeID;
public final ConfiguredStructureFeature structure; public final Holder<Structure> structure;
StructureID(ResourceLocation biomeID, ConfiguredStructureFeature structure){ StructureID(ResourceLocation biomeID, Holder<Structure> structure){
this.biomeID = biomeID; this.biomeID = biomeID;
this.structure = structure; this.structure = structure;
} }

View file

@ -8,6 +8,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import ru.bclib.BCLib; import ru.bclib.BCLib;
import ru.bclib.api.dataexchange.DataExchangeAPI; import ru.bclib.api.dataexchange.DataExchangeAPI;

View file

@ -156,10 +156,21 @@ public class DataFixerAPI {
*/ */
public static void initializeWorldData(LevelStorageSource levelSource, String levelID, boolean newWorld) { public static void initializeWorldData(LevelStorageSource levelSource, String levelID, boolean newWorld) {
wrapCall(levelSource, levelID, (levelStorageAccess) -> { wrapCall(levelSource, levelID, (levelStorageAccess) -> {
initializeWorldData(levelStorageAccess.getLevelPath(LevelResource.ROOT).toFile(), newWorld); initializeWorldData(levelStorageAccess, newWorld);
return true; return true;
}); });
} }
/**
* Initializes the DataStorage for this world. If the world is new, the patch registry is initialized to the
* current versions of the plugins.
* @param access levelAccess for the worldd
* @param newWorld {@code true} if this is a fresh world
*
*/
public static void initializeWorldData(LevelStorageAccess access, boolean newWorld){
initializeWorldData(access.getLevelPath(LevelResource.ROOT).toFile(), newWorld);
}
/** /**
* Initializes the DataStorage for this world. If the world is new, the patch registry is initialized to the * Initializes the DataStorage for this world. If the world is new, the patch registry is initialized to the

View file

@ -8,7 +8,7 @@ import net.minecraft.world.level.LevelAccessor;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import ru.bclib.interfaces.SpawnRule; import ru.bclib.interfaces.SpawnRule;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
public class SpawnRuleEntry<M extends Mob> implements Comparable<SpawnRuleEntry> { public class SpawnRuleEntry<M extends Mob> implements Comparable<SpawnRuleEntry> {
private final SpawnRule rule; private final SpawnRule rule;
@ -19,7 +19,7 @@ public class SpawnRuleEntry<M extends Mob> implements Comparable<SpawnRuleEntry>
this.rule = rule; this.rule = rule;
} }
protected boolean canSpawn(EntityType<M> type, LevelAccessor world, MobSpawnType spawnReason, BlockPos pos, Random random) { protected boolean canSpawn(EntityType<M> type, LevelAccessor world, MobSpawnType spawnReason, BlockPos pos, RandomSource random) {
return rule.canSpawn(type, world, spawnReason, pos, random); return rule.canSpawn(type, world, spawnReason, pos, random);
} }

View file

@ -3,6 +3,7 @@ package ru.bclib.api.surface.rules;
import com.mojang.serialization.Codec; import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder; import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.util.KeyDispatchDataCodec;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.SurfaceRules.Context; import net.minecraft.world.level.levelgen.SurfaceRules.Context;
import net.minecraft.world.level.levelgen.SurfaceRules.RuleSource; import net.minecraft.world.level.levelgen.SurfaceRules.RuleSource;
@ -20,9 +21,11 @@ public record SwitchRuleSource(NumericProvider selector, List<RuleSource> collec
RuleSource.CODEC.listOf().fieldOf("collection").forGetter(SwitchRuleSource::collection) RuleSource.CODEC.listOf().fieldOf("collection").forGetter(SwitchRuleSource::collection)
).apply(instance, SwitchRuleSource::new)); ).apply(instance, SwitchRuleSource::new));
private static final KeyDispatchDataCodec<? extends RuleSource> KEY_CODEC = KeyDispatchDataCodec.of(SwitchRuleSource.CODEC);
@Override @Override
public Codec<? extends RuleSource> codec() { public KeyDispatchDataCodec<? extends RuleSource> codec() {
return SwitchRuleSource.CODEC; return KEY_CODEC;
} }
@Override @Override

View file

@ -1,6 +1,6 @@
package ru.bclib.api.surface.rules; package ru.bclib.api.surface.rules;
import com.mojang.serialization.Codec; import net.minecraft.util.KeyDispatchDataCodec;
import net.minecraft.world.level.levelgen.SurfaceRules.Condition; import net.minecraft.world.level.levelgen.SurfaceRules.Condition;
import net.minecraft.world.level.levelgen.SurfaceRules.ConditionSource; import net.minecraft.world.level.levelgen.SurfaceRules.ConditionSource;
import net.minecraft.world.level.levelgen.SurfaceRules.Context; import net.minecraft.world.level.levelgen.SurfaceRules.Context;
@ -8,7 +8,7 @@ import net.minecraft.world.level.levelgen.SurfaceRules.LazyCondition;
import ru.bclib.mixin.common.SurfaceRulesContextAccessor; import ru.bclib.mixin.common.SurfaceRulesContextAccessor;
public abstract class VolumeNoiseCondition implements NoiseCondition{ public abstract class VolumeNoiseCondition implements NoiseCondition{
public abstract Codec<? extends ConditionSource> codec(); public abstract KeyDispatchDataCodec<? extends ConditionSource> codec();
@Override @Override
public final Condition apply(Context context2) { public final Condition apply(Context context2) {

View file

@ -34,7 +34,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelProvider, CustomItemProvider { public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelProvider, CustomItemProvider {
public static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION; public static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION;
@ -118,7 +118,7 @@ public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelPro
return 3; return 3;
} }
public BlockState damageAnvilUse(BlockState state, Random random) { public BlockState damageAnvilUse(BlockState state, RandomSource random) {
IntegerProperty durability = getDurabilityProp(); IntegerProperty durability = getDurabilityProp();
int value = state.getValue(durability); int value = state.getValue(durability);
if (value < getMaxDurability() && random.nextInt(8) == 0) { if (value < getMaxDurability() && random.nextInt(8) == 0) {

View file

@ -37,7 +37,7 @@ import ru.bclib.registry.BaseBlockEntities;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider { public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider {
public BaseBarrelBlock(Block source) { public BaseBarrelBlock(Block source) {
@ -79,7 +79,7 @@ public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider {
} }
@Override @Override
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
BlockEntity blockEntity = world.getBlockEntity(pos); BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof BaseBarrelBlockEntity) { if (blockEntity instanceof BaseBarrelBlockEntity) {
((BaseBarrelBlockEntity) blockEntity).tick(); ((BaseBarrelBlockEntity) blockEntity).tick();

View file

@ -27,7 +27,7 @@ import ru.bclib.util.MHelper;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
public class BaseCropBlock extends BasePlantBlock { public class BaseCropBlock extends BasePlantBlock {
public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 3); public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 3);
@ -41,13 +41,14 @@ public class BaseCropBlock extends BasePlantBlock {
FabricBlockSettings.of(Material.PLANT) FabricBlockSettings.of(Material.PLANT)
.sound(SoundType.GRASS) .sound(SoundType.GRASS)
.randomTicks() .randomTicks()
.noCollission(), .noCollission()
.offsetType(BlockBehaviour.OffsetType.NONE),
drop, terrain drop, terrain
); );
} }
public BaseCropBlock(BlockBehaviour.Properties properties, Item drop, Block... terrain) { public BaseCropBlock(BlockBehaviour.Properties properties, Item drop, Block... terrain) {
super(properties); super(properties.offsetType(BlockBehaviour.OffsetType.NONE));
this.drop = drop; this.drop = drop;
this.terrain = terrain; this.terrain = terrain;
this.registerDefaultState(defaultBlockState().setValue(AGE, 0)); this.registerDefaultState(defaultBlockState().setValue(AGE, 0));
@ -88,15 +89,10 @@ public class BaseCropBlock extends BasePlantBlock {
} }
@Override @Override
public BlockBehaviour.OffsetType getOffsetType() { public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) {
return BlockBehaviour.OffsetType.NONE;
}
@Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
int age = state.getValue(AGE); int age = state.getValue(AGE);
if (age < 3) { if (age < 3) {
BlocksHelper.setWithUpdate(world, pos, state.setValue(AGE, age + 1)); BlocksHelper.setWithUpdate(level, pos, state.setValue(AGE, age + 1));
} }
} }
@ -106,13 +102,13 @@ public class BaseCropBlock extends BasePlantBlock {
} }
@Override @Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) { public boolean isBonemealSuccess(Level level, RandomSource random, BlockPos pos, BlockState state) {
return state.getValue(AGE) < 3; return state.getValue(AGE) < 3;
} }
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
super.tick(state, world, pos, random); super.tick(state, world, pos, random);
if (isBonemealSuccess(world, random, pos, state) && random.nextInt(8) == 0) { if (isBonemealSuccess(world, random, pos, state) && random.nextInt(8) == 0) {
performBonemeal(world, random, pos, state); performBonemeal(world, random, pos, state);

View file

@ -35,7 +35,7 @@ import ru.bclib.items.tool.BaseShearsItem;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock { public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock {
private static final VoxelShape SHAPE = Block.box(4, 2, 4, 12, 16, 12); private static final VoxelShape SHAPE = Block.box(4, 2, 4, 12, 16, 12);
@ -47,6 +47,7 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements R
FabricBlockSettings.of(Material.PLANT) FabricBlockSettings.of(Material.PLANT)
.sound(SoundType.GRASS) .sound(SoundType.GRASS)
.noCollission() .noCollission()
.offsetType(BlockBehaviour.OffsetType.XZ)
); );
} }
@ -56,6 +57,7 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements R
.sound(SoundType.GRASS) .sound(SoundType.GRASS)
.lightLevel((state) -> state.getValue(TOP) ? light : 0) .lightLevel((state) -> state.getValue(TOP) ? light : 0)
.noCollission() .noCollission()
.offsetType(BlockBehaviour.OffsetType.XZ)
); );
} }
@ -75,12 +77,7 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements R
Vec3 vec3d = state.getOffset(view, pos); Vec3 vec3d = state.getOffset(view, pos);
return SHAPE.move(vec3d.x, vec3d.y, vec3d.z); return SHAPE.move(vec3d.x, vec3d.y, vec3d.z);
} }
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.XZ;
}
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
@ -138,20 +135,20 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements R
} }
@Override @Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) { public boolean isBonemealSuccess(Level level, RandomSource random, BlockPos pos, BlockState state) {
return true; return true;
} }
@Override @Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) { public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) {
ItemEntity item = new ItemEntity( ItemEntity item = new ItemEntity(
world, level,
pos.getX() + 0.5, pos.getX() + 0.5,
pos.getY() + 0.5, pos.getY() + 0.5,
pos.getZ() + 0.5, pos.getZ() + 0.5,
new ItemStack(this) new ItemStack(this)
); );
world.addFreshEntity(item); level.addFreshEntity(item);
} }
@Override @Override

View file

@ -11,7 +11,7 @@ import net.minecraft.world.item.TieredItem;
import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.OreBlock; import net.minecraft.world.level.block.DropExperienceBlock;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
@ -26,7 +26,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.Supplier; import java.util.function.Supplier;
public class BaseOreBlock extends OreBlock implements BlockModelProvider { public class BaseOreBlock extends DropExperienceBlock implements BlockModelProvider {
private final Supplier<Item> dropItem; private final Supplier<Item> dropItem;
private final int minCount; private final int minCount;
private final int maxCount; private final int maxCount;

View file

@ -39,7 +39,7 @@ import ru.bclib.items.tool.BaseShearsItem;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock{ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock{
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12); private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
@ -58,6 +58,7 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL
.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT) .of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
.sound(SoundType.GRASS) .sound(SoundType.GRASS)
.noCollission() .noCollission()
.offsetType(BlockBehaviour.OffsetType.XZ)
); );
} }
@ -68,11 +69,12 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL
.luminance(light) .luminance(light)
.sound(SoundType.GRASS) .sound(SoundType.GRASS)
.noCollission() .noCollission()
.offsetType(BlockBehaviour.OffsetType.XZ)
); );
} }
public BasePlantBlock(Properties settings) { public BasePlantBlock(Properties settings) {
super(settings); super(settings.offsetType(BlockBehaviour.OffsetType.XZ));
} }
protected abstract boolean isTerrain(BlockState state); protected abstract boolean isTerrain(BlockState state);
@ -84,11 +86,6 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL
return SHAPE.move(vec3d.x, vec3d.y, vec3d.z); return SHAPE.move(vec3d.x, vec3d.y, vec3d.z);
} }
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.XZ;
}
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
@ -133,20 +130,20 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL
} }
@Override @Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) { public boolean isBonemealSuccess(Level level, RandomSource random, BlockPos pos, BlockState state) {
return true; return true;
} }
@Override @Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) { public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) {
ItemEntity item = new ItemEntity( ItemEntity item = new ItemEntity(
world, level,
pos.getX() + 0.5, pos.getX() + 0.5,
pos.getY() + 0.5, pos.getY() + 0.5,
pos.getZ() + 0.5, pos.getZ() + 0.5,
new ItemStack(this) new ItemStack(this)
); );
world.addFreshEntity(item); level.addFreshEntity(item);
} }
@Override @Override

View file

@ -12,7 +12,7 @@ import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty; import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
public abstract class BasePlantWithAgeBlock extends BasePlantBlock { public abstract class BasePlantWithAgeBlock extends BasePlantBlock {
public static final IntegerProperty AGE = BlockProperties.AGE; public static final IntegerProperty AGE = BlockProperties.AGE;
@ -35,27 +35,27 @@ public abstract class BasePlantWithAgeBlock extends BasePlantBlock {
stateManager.add(AGE); stateManager.add(AGE);
} }
public abstract void growAdult(WorldGenLevel world, Random random, BlockPos pos); public abstract void growAdult(WorldGenLevel world, RandomSource random, BlockPos pos);
@Override @Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) { public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) {
int age = state.getValue(AGE); int age = state.getValue(AGE);
if (age < 3) { if (age < 3) {
world.setBlockAndUpdate(pos, state.setValue(AGE, age + 1)); level.setBlockAndUpdate(pos, state.setValue(AGE, age + 1));
} }
else { else {
growAdult(world, random, pos); growAdult(level, random, pos);
} }
} }
@Override @Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) { public boolean isBonemealSuccess(Level level, RandomSource random, BlockPos pos, BlockState state) {
return true; return true;
} }
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
super.tick(state, world, pos, random); super.tick(state, world, pos, random);
if (random.nextInt(8) == 0) { if (random.nextInt(8) == 0) {
performBonemeal(world, random, pos, state); performBonemeal(world, random, pos, state);

View file

@ -14,6 +14,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@ -43,7 +44,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class BaseTerrainBlock extends BaseBlock { public class BaseTerrainBlock extends BaseBlock {
@ -95,7 +96,7 @@ public class BaseTerrainBlock extends BaseBlock {
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
if (random.nextInt(16) == 0 && !canStay(state, world, pos)) { if (random.nextInt(16) == 0 && !canStay(state, world, pos)) {
world.setBlockAndUpdate(pos, getBaseBlock().defaultBlockState()); world.setBlockAndUpdate(pos, getBaseBlock().defaultBlockState());
} }

View file

@ -34,7 +34,7 @@ import ru.bclib.items.tool.BaseShearsItem;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock { public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock {
@ -56,11 +56,12 @@ public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvid
.sound(SoundType.GRASS) .sound(SoundType.GRASS)
.lightLevel((state) -> bottomOnly ? state.getValue(SHAPE) == TripleShape.BOTTOM ? light : 0 : light) .lightLevel((state) -> bottomOnly ? state.getValue(SHAPE) == TripleShape.BOTTOM ? light : 0 : light)
.noCollission() .noCollission()
.offsetType(BlockBehaviour.OffsetType.XZ)
); );
} }
public BaseVineBlock(BlockBehaviour.Properties properties) { public BaseVineBlock(BlockBehaviour.Properties properties) {
super(properties); super(properties.offsetType(BlockBehaviour.OffsetType.XZ));
this.registerDefaultState(this.stateDefinition.any().setValue(SHAPE, TripleShape.BOTTOM)); this.registerDefaultState(this.stateDefinition.any().setValue(SHAPE, TripleShape.BOTTOM));
} }
@ -75,11 +76,6 @@ public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvid
return VOXEL_SHAPE.move(vec3d.x, vec3d.y, vec3d.z); return VOXEL_SHAPE.move(vec3d.x, vec3d.y, vec3d.z);
} }
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.XZ;
}
public boolean canGenerate(BlockState state, LevelReader world, BlockPos pos) { public boolean canGenerate(BlockState state, LevelReader world, BlockPos pos) {
return isSupport(state, world, pos); return isSupport(state, world, pos);
} }
@ -134,19 +130,19 @@ public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvid
} }
@Override @Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) { public boolean isBonemealSuccess(Level level, RandomSource random, BlockPos pos, BlockState state) {
while (world.getBlockState(pos).getBlock() == this) { while (level.getBlockState(pos).getBlock() == this) {
pos = pos.below(); pos = pos.below();
} }
return world.isEmptyBlock(pos); return level.isEmptyBlock(pos);
} }
@Override @Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) { public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) {
while (world.getBlockState(pos).getBlock() == this) { while (level.getBlockState(pos).getBlock() == this) {
pos = pos.below(); pos = pos.below();
} }
world.setBlockAndUpdate(pos, defaultBlockState()); level.setBlockAndUpdate(pos, defaultBlockState());
BlocksHelper.setWithoutUpdate(world, pos, defaultBlockState()); BlocksHelper.setWithoutUpdate(level, pos, defaultBlockState());
} }
} }

View file

@ -41,6 +41,7 @@ public abstract class BaseWallPlantBlock extends BasePlantBlock {
.of(Material.PLANT) .of(Material.PLANT)
.sound(SoundType.GRASS) .sound(SoundType.GRASS)
.noCollission() .noCollission()
.offsetType( BlockBehaviour.OffsetType.NONE)
); );
} }
@ -51,11 +52,12 @@ public abstract class BaseWallPlantBlock extends BasePlantBlock {
.luminance(light) .luminance(light)
.sound(SoundType.GRASS) .sound(SoundType.GRASS)
.noCollission() .noCollission()
.offsetType( BlockBehaviour.OffsetType.NONE)
); );
} }
public BaseWallPlantBlock(Properties settings) { public BaseWallPlantBlock(Properties settings) {
super(settings); super(settings.offsetType( BlockBehaviour.OffsetType.NONE));
} }
@Override @Override
@ -68,11 +70,6 @@ public abstract class BaseWallPlantBlock extends BasePlantBlock {
return SHAPES.get(state.getValue(FACING)); return SHAPES.get(state.getValue(FACING));
} }
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = state.getValue(FACING); Direction direction = state.getValue(FACING);

View file

@ -35,7 +35,7 @@ import ru.bclib.interfaces.RenderLayerProvider;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
import java.util.function.Function; import java.util.function.Function;
public class FeatureSaplingBlock extends SaplingBlock implements RenderLayerProvider, BlockModelProvider { public class FeatureSaplingBlock extends SaplingBlock implements RenderLayerProvider, BlockModelProvider {
@ -84,12 +84,12 @@ public class FeatureSaplingBlock extends SaplingBlock implements RenderLayerProv
} }
@Override @Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) { public boolean isBonemealSuccess(Level level, RandomSource random, BlockPos pos, BlockState state) {
return random.nextInt(16) == 0; return random.nextInt(16) == 0;
} }
@Override @Override
public void advanceTree(ServerLevel world, BlockPos pos, BlockState blockState, Random random) { public void advanceTree(ServerLevel world, BlockPos pos, BlockState blockState, RandomSource random) {
FeaturePlaceContext context = new FeaturePlaceContext( FeaturePlaceContext context = new FeaturePlaceContext(
Optional.empty(), Optional.empty(),
world, world,
@ -102,12 +102,12 @@ public class FeatureSaplingBlock extends SaplingBlock implements RenderLayerProv
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
this.tick(state, world, pos, random); this.tick(state, world, pos, random);
} }
@Override @Override
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
super.tick(state, world, pos, random); super.tick(state, world, pos, random);
if (isBonemealSuccess(world, random, pos, state)) { if (isBonemealSuccess(world, random, pos, state)) {
performBonemeal(world, random, pos, state); performBonemeal(world, random, pos, state);

View file

@ -35,7 +35,7 @@ import ru.bclib.client.models.PatternsHelper;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
public class TripleTerrainBlock extends BaseTerrainBlock { public class TripleTerrainBlock extends BaseTerrainBlock {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE; public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
@ -72,7 +72,7 @@ public class TripleTerrainBlock extends BaseTerrainBlock {
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
TripleShape shape = state.getValue(SHAPE); TripleShape shape = state.getValue(SHAPE);
if (shape == TripleShape.BOTTOM) { if (shape == TripleShape.BOTTOM) {
super.randomTick(state, world, pos, random); super.randomTick(state, world, pos, random);

View file

@ -5,6 +5,7 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.EnchantmentHelper;
@ -34,7 +35,7 @@ import ru.bclib.interfaces.RenderLayerProvider;
import ru.bclib.items.tool.BaseShearsItem; import ru.bclib.items.tool.BaseShearsItem;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock, LiquidBlockContainer { public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock, LiquidBlockContainer {
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12); private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
@ -45,6 +46,7 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
.of(Material.WATER_PLANT) .of(Material.WATER_PLANT)
.sound(SoundType.WET_GRASS) .sound(SoundType.WET_GRASS)
.noCollission() .noCollission()
.offsetType(BlockBehaviour.OffsetType.XZ)
); );
} }
@ -55,6 +57,7 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
.luminance(light) .luminance(light)
.sound(SoundType.WET_GRASS) .sound(SoundType.WET_GRASS)
.noCollission() .noCollission()
.offsetType(BlockBehaviour.OffsetType.XZ)
); );
} }
@ -69,11 +72,6 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
return SHAPE.move(vec3d.x, vec3d.y, vec3d.z); return SHAPE.move(vec3d.x, vec3d.y, vec3d.z);
} }
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.XZ;
}
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
@ -121,20 +119,20 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
} }
@Override @Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) { public boolean isBonemealSuccess(Level level, RandomSource random, BlockPos pos, BlockState state) {
return true; return true;
} }
@Override @Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) { public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) {
ItemEntity item = new ItemEntity( ItemEntity item = new ItemEntity(
world, level,
pos.getX() + 0.5, pos.getX() + 0.5,
pos.getY() + 0.5, pos.getY() + 0.5,
pos.getZ() + 0.5, pos.getZ() + 0.5,
new ItemStack(this) new ItemStack(this)
); );
world.addFreshEntity(item); level.addFreshEntity(item);
} }
@Override @Override

View file

@ -11,7 +11,7 @@ import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty; import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock { public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock {
public static final IntegerProperty AGE = BlockProperties.AGE; public static final IntegerProperty AGE = BlockProperties.AGE;
@ -31,10 +31,10 @@ public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock {
stateManager.add(AGE); stateManager.add(AGE);
} }
public abstract void grow(WorldGenLevel world, Random random, BlockPos pos); public abstract void grow(WorldGenLevel world, RandomSource random, BlockPos pos);
@Override @Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) { public void performBonemeal(ServerLevel world, RandomSource random, BlockPos pos, BlockState state) {
if (random.nextInt(4) == 0) { if (random.nextInt(4) == 0) {
int age = state.getValue(AGE); int age = state.getValue(AGE);
if (age < 3) { if (age < 3) {
@ -48,7 +48,7 @@ public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock {
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
super.tick(state, world, pos, random); super.tick(state, world, pos, random);
if (isBonemealSuccess(world, random, pos, state)) { if (isBonemealSuccess(world, random, pos, state)) {
performBonemeal(world, random, pos, state); performBonemeal(world, random, pos, state);

View file

@ -41,11 +41,11 @@ public class CustomModelBakery {
Registry.BLOCK.stream().parallel().filter(block -> block instanceof BlockModelProvider).forEach(block -> { Registry.BLOCK.stream().parallel().filter(block -> block instanceof BlockModelProvider).forEach(block -> {
ResourceLocation blockID = Registry.BLOCK.getKey(block); ResourceLocation blockID = Registry.BLOCK.getKey(block);
ResourceLocation storageID = new ResourceLocation(blockID.getNamespace(), "blockstates/" + blockID.getPath() + ".json"); ResourceLocation storageID = new ResourceLocation(blockID.getNamespace(), "blockstates/" + blockID.getPath() + ".json");
if (!resourceManager.hasResource(storageID)) { if (resourceManager.getResource(storageID).isEmpty()) {
addBlockModel(blockID, block); addBlockModel(blockID, block);
} }
storageID = new ResourceLocation(blockID.getNamespace(), "models/item/" + blockID.getPath() + ".json"); storageID = new ResourceLocation(blockID.getNamespace(), "models/item/" + blockID.getPath() + ".json");
if (!resourceManager.hasResource(storageID)) { if (resourceManager.getResource(storageID).isEmpty()) {
addItemModel(blockID, (ItemModelProvider) block); addItemModel(blockID, (ItemModelProvider) block);
} }
}); });
@ -53,7 +53,7 @@ public class CustomModelBakery {
Registry.ITEM.stream().parallel().filter(item -> item instanceof ItemModelProvider).forEach(item -> { Registry.ITEM.stream().parallel().filter(item -> item instanceof ItemModelProvider).forEach(item -> {
ResourceLocation registryID = Registry.ITEM.getKey(item); ResourceLocation registryID = Registry.ITEM.getKey(item);
ResourceLocation storageID = new ResourceLocation(registryID.getNamespace(), "models/item/" + registryID.getPath() + ".json"); ResourceLocation storageID = new ResourceLocation(registryID.getNamespace(), "models/item/" + registryID.getPath() + ".json");
if (!resourceManager.hasResource(storageID)) { if (resourceManager.getResource(storageID).isEmpty()) {
addItemModel(registryID, (ItemModelProvider) item); addItemModel(registryID, (ItemModelProvider) item);
} }
}); });

View file

@ -22,6 +22,8 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource; import net.minecraft.server.packs.resources.Resource;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.BCLib;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper; import ru.bclib.util.MHelper;
@ -34,7 +36,7 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
@ -108,7 +110,7 @@ public class OBJBlockModel implements UnbakedModel, BakedModel {
// Baked Model // // Baked Model //
@Override @Override
public List<BakedQuad> getQuads(@Nullable BlockState blockState, @Nullable Direction direction, Random random) { public List<BakedQuad> getQuads(@Nullable BlockState blockState, @Nullable Direction direction, RandomSource random) {
return direction == null ? quadsBaked : quadsBakedMap.get(direction); return direction == null ? quadsBaked : quadsBakedMap.get(direction);
} }
@ -148,23 +150,7 @@ public class OBJBlockModel implements UnbakedModel, BakedModel {
} }
private Resource getResource(ResourceLocation location) { private Resource getResource(ResourceLocation location) {
Resource resource = null; return Minecraft.getInstance().getResourceManager().getResource(location).orElse(null);
try {
resource = Minecraft.getInstance().getResourceManager().getResource(location);
}
catch (IOException e) {
e.printStackTrace();
if (resource != null) {
try {
resource.close();
}
catch (IOException ioException) {
ioException.printStackTrace();
}
resource = null;
}
}
return resource;
} }
private void loadModel(ResourceLocation location, Vector3f offset, byte maxIndex) { private void loadModel(ResourceLocation location, Vector3f offset, byte maxIndex) {
@ -172,8 +158,14 @@ public class OBJBlockModel implements UnbakedModel, BakedModel {
if (resource == null) { if (resource == null) {
return; return;
} }
InputStream input = resource.getInputStream(); InputStream input = null;
try {
input = resource.open();
} catch (IOException e) {
BCLib.LOGGER.error("Unable to load Model", e);
throw new RuntimeException(e);
}
List<Float> vertecies = new ArrayList<>(12); List<Float> vertecies = new ArrayList<>(12);
List<Float> uvs = new ArrayList<>(8); List<Float> uvs = new ArrayList<>(8);
@ -265,7 +257,6 @@ public class OBJBlockModel implements UnbakedModel, BakedModel {
reader.close(); reader.close();
streamReader.close(); streamReader.close();
input.close(); input.close();
resource.close();
} }
catch (IOException e) { catch (IOException e) {
e.printStackTrace(); e.printStackTrace();

View file

@ -3,6 +3,7 @@ package ru.bclib.client.models;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManager;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -53,7 +54,10 @@ public class PatternsHelper {
public static Optional<String> createJson(ResourceLocation patternId, Map<String, String> textures) { public static Optional<String> createJson(ResourceLocation patternId, Map<String, String> textures) {
ResourceManager resourceManager = Minecraft.getInstance().getResourceManager(); ResourceManager resourceManager = Minecraft.getInstance().getResourceManager();
try (InputStream input = resourceManager.getResource(patternId).getInputStream()) { Optional<Resource> patternRes = resourceManager.getResource(patternId);
if (patternRes.isEmpty()) return Optional.empty();
try (InputStream input = patternRes.get().open()) {
String json = JSON_CACHE.get(patternId); String json = JSON_CACHE.get(patternId);
if (json == null) { if (json == null) {
json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines().collect(Collectors.joining()); json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines().collect(Collectors.joining());

View file

@ -2,6 +2,7 @@ package ru.bclib.gui.modmenu;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.config.ConfigKeeper.BooleanEntry; import ru.bclib.config.ConfigKeeper.BooleanEntry;
@ -25,7 +26,7 @@ public class MainScreen extends GridScreen{
super(parent, Component.translatable("title.bclib.modmenu.main"), 10, false); super(parent, Component.translatable("title.bclib.modmenu.main"), 10, false);
} }
protected <T> TranslatableComponent getComponent(NamedPathConfig config, ConfigTokenDescription<T> option, String type){ protected <T> Component getComponent(NamedPathConfig config, ConfigTokenDescription<T> option, String type){
return Component.translatable(type + ".config." + config.configID + option.getPath() ); return Component.translatable(type + ".config." + config.configID + option.getPath() );
} }

View file

@ -4,7 +4,7 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.Component;
import ru.bclib.gui.gridlayout.GridColumn; import ru.bclib.gui.gridlayout.GridColumn;
import ru.bclib.gui.gridlayout.GridLayout; import ru.bclib.gui.gridlayout.GridLayout;
@ -31,12 +31,12 @@ public class LevelFixErrorScreen extends BCLibScreen {
row.addSpacer(10); row.addSpacer(10);
GridColumn col = row.addColumn(300, GridLayout.GridValueType.CONSTANT); GridColumn col = row.addColumn(300, GridLayout.GridValueType.CONSTANT);
for (String error : errors){ for (String error : errors){
TextComponent dash = new TextComponent("-"); Component dash = Component.literal("-");
row = col.addRow(); row = col.addRow();
row.addString(dash, this); row.addString(dash, this);
row.addSpacer(4); row.addSpacer(4);
row.addString(new TextComponent(error), this); row.addString(Component.literal(error), this);
} }
grid.addSpacerRow(8); grid.addSpacerRow(8);

View file

@ -6,7 +6,6 @@ import net.fabricmc.loader.api.metadata.ModEnvironment;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import ru.bclib.api.dataexchange.handler.autosync.HelloClient; import ru.bclib.api.dataexchange.handler.autosync.HelloClient;
import ru.bclib.gui.gridlayout.GridColumn; import ru.bclib.gui.gridlayout.GridColumn;
import ru.bclib.gui.gridlayout.GridLayout; import ru.bclib.gui.gridlayout.GridLayout;
@ -177,14 +176,14 @@ public class ModListScreen extends BCLibScreen {
color = GridLayout.COLOR_DARK_GREEN; color = GridLayout.COLOR_DARK_GREEN;
typeText = "[OK]"; typeText = "[OK]";
} }
TextComponent dash = new TextComponent("-"); Component dash = Component.literal("-");
TextComponent typeTextComponent = new TextComponent(typeText); Component typeTextComponent = Component.literal(typeText);
GridRow row = grid.addRow(); GridRow row = grid.addRow();
row.addString(dash, parent); row.addString(dash, parent);
row.addSpacer(4); row.addSpacer(4);
row.addString(new TextComponent(name), parent); row.addString(Component.literal(name), parent);
row.addSpacer(4); row.addSpacer(4);
row.addString(typeTextComponent, color, parent); row.addString(typeTextComponent, color, parent);
@ -192,7 +191,7 @@ public class ModListScreen extends BCLibScreen {
if (!stateString.isEmpty()) { if (!stateString.isEmpty()) {
row = grid.addRow(); row = grid.addRow();
row.addSpacer(4 + parent.getWidth(dash)); row.addSpacer(4 + parent.getWidth(dash));
row.addString(new TextComponent(stateString), GridLayout.COLOR_GRAY, parent); row.addString(Component.literal(stateString), GridLayout.COLOR_GRAY, parent);
} }
grid.addSpacerRow(); grid.addSpacerRow();

View file

@ -7,7 +7,6 @@ import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ProgressListener; import net.minecraft.util.ProgressListener;
@ -161,7 +160,7 @@ public class ProgressScreen extends GridScreen implements ProgressListener, Atom
grid.addSpacerRow(20); grid.addSpacerRow(20);
row = grid.addRow(); row = grid.addRow();
stage = row.addMessage(stageComponent!=null?stageComponent:new TextComponent(""), font, Alignment.CENTER); stage = row.addMessage(stageComponent!=null?stageComponent:Component.literal(""), font, Alignment.CENTER);
} }
@Override @Override

View file

@ -6,9 +6,9 @@ import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelAccessor;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
@FunctionalInterface @FunctionalInterface
public interface SpawnRule<M extends Mob> { public interface SpawnRule<M extends Mob> {
boolean canSpawn(EntityType<M> type, LevelAccessor world, MobSpawnType spawnReason, BlockPos pos, Random random); boolean canSpawn(EntityType<M> type, LevelAccessor world, MobSpawnType spawnReason, BlockPos pos, RandomSource random);
} }

View file

@ -6,7 +6,7 @@ import net.fabricmc.api.Environment;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.Component;
import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
@ -46,7 +46,7 @@ public interface SurvivesOnSpecialGround {
for (int i = 0; i < Math.min(lines.size(), MAX_LINES); i++) { for (int i = 0; i < Math.min(lines.size(), MAX_LINES); i++) {
String line = lines.get(i); String line = lines.get(i);
if (i == MAX_LINES - 1 && i < lines.size() - 1) line += " ..."; if (i == MAX_LINES - 1 && i < lines.size() - 1) line += " ...";
list.add(new TextComponent(" " + line).withStyle(ChatFormatting.GREEN)); list.add(Component.literal(" " + line).withStyle(ChatFormatting.GREEN));
} }
} }
} }

View file

@ -8,7 +8,7 @@ import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.screens.inventory.AnvilScreen; import net.minecraft.client.gui.screens.inventory.AnvilScreen;
import net.minecraft.client.gui.screens.inventory.ItemCombinerScreen; import net.minecraft.client.gui.screens.inventory.ItemCombinerScreen;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.AbstractContainerMenu;
@ -40,8 +40,8 @@ public class AnvilScreenMixin extends ItemCombinerScreen<AnvilMenu> {
int x = (width - imageWidth) / 2; int x = (width - imageWidth) / 2;
int y = (height - imageHeight) / 2; int y = (height - imageHeight) / 2;
be_buttons.clear(); be_buttons.clear();
be_buttons.add(new Button(x + 8, y + 45, 15, 20, new TextComponent("<"), b -> be_previousRecipe())); be_buttons.add(new Button(x + 8, y + 45, 15, 20, Component.literal("<"), b -> be_previousRecipe()));
be_buttons.add(new Button(x + 154, y + 45, 15, 20, new TextComponent(">"), b -> be_nextRecipe())); be_buttons.add(new Button(x + 154, y + 45, 15, 20, Component.literal(">"), b -> be_nextRecipe()));
} }
@Inject(method = "renderFg", at = @At("TAIL")) @Inject(method = "renderFg", at = @At("TAIL"))

View file

@ -0,0 +1,24 @@
package ru.bclib.mixin.client;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
import net.minecraft.client.gui.screens.worldselection.WorldGenSettingsComponent;
import net.minecraft.core.Registry;
import net.minecraft.world.level.DataPackConfig;
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.api.biomes.BiomeAPI;
@Mixin(CreateWorldScreen.class)
public class CreateWorldScreenMixin {
@Inject(method = "<init>", at = @At("HEAD"))
private static void bcl_init(Screen screen,
DataPackConfig dataPackConfig,
WorldGenSettingsComponent worldGenSettingsComponent,
CallbackInfo ci) {
BiomeAPI.initRegistry(worldGenSettingsComponent.registryHolder().registryOrThrow(Registry.BIOME_REGISTRY));
}
}

View file

@ -1,7 +1,6 @@
package ru.bclib.mixin.client; package ru.bclib.mixin.client;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.Minecraft.ExperimentalDialogType;
import net.minecraft.client.color.block.BlockColors; import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.color.item.ItemColors; import net.minecraft.client.color.item.ItemColors;
import net.minecraft.client.main.GameConfig; import net.minecraft.client.main.GameConfig;
@ -46,41 +45,4 @@ public abstract class MinecraftMixin {
} }
}); });
} }
@Shadow protected abstract void doLoadLevel(String string, Function<LevelStorageAccess, WorldStem.DataPackConfigSupplier> function, Function<LevelStorageAccess, WorldStem.WorldDataSupplier> function2, boolean bl, ExperimentalDialogType experimentalDialogType);
@Shadow
@Final
private LevelStorageSource levelSource;
@Inject(method = "loadLevel", cancellable = true, at = @At("HEAD"))
private void bclib_callFixerOnLoad(String levelID, CallbackInfo ci) {
DataExchangeAPI.prepareServerside();
BiomeAPI.prepareNewLevel();
if (DataFixerAPI.fixData(this.levelSource, levelID, true, (appliedFixes) -> {
LifeCycleAPI._runBeforeLevelLoad();
this.doLoadLevel(levelID, WorldStem.DataPackConfigSupplier::loadFromWorld, WorldStem.WorldDataSupplier::loadFromWorld, false, appliedFixes ? ExperimentalDialogType.NONE : ExperimentalDialogType.BACKUP);
})) {
//cancle call when fix-screen is presented
ci.cancel();
}
else {
LifeCycleAPI._runBeforeLevelLoad();
if (Configs.CLIENT_CONFIG.suppressExperimentalDialog()) {
this.doLoadLevel(levelID, WorldStem.DataPackConfigSupplier::loadFromWorld, WorldStem.WorldDataSupplier::loadFromWorld, false, ExperimentalDialogType.NONE);
//cancle call as we manually start the level load here
ci.cancel();
}
}
}
@Inject(method = "createLevel", at = @At("HEAD"))
private void bclib_initPatchData(String levelID, LevelSettings levelSettings, RegistryAccess registryAccess, WorldGenSettings worldGenSettings, CallbackInfo ci) {
DataExchangeAPI.prepareServerside();
BiomeAPI.prepareNewLevel();
DataFixerAPI.initializeWorldData(this.levelSource, levelID, true);
LifeCycleAPI._runBeforeLevelLoad();
}
} }

View file

@ -46,8 +46,8 @@ public class MultiPackResourceManagerMixin {
} }
ResourceManager resourceManager = this.namespacedManagers.get(resourceLocation.getNamespace()); ResourceManager resourceManager = this.namespacedManagers.get(resourceLocation.getNamespace());
if (resourceManager != null && !resourceManager.hasResource(resourceLocation)) { if (resourceManager != null && resourceManager.getResource(resourceLocation).isEmpty()) {
info.setReturnValue(resourceManager.getResource(bclib_alphaEmissionMaterial)); info.setReturnValue(resourceManager.getResource(bclib_alphaEmissionMaterial).get());
} }
} }
} }

View file

@ -17,6 +17,7 @@ import ru.bclib.BCLib;
import ru.bclib.client.render.EmissiveTextureInfo; import ru.bclib.client.render.EmissiveTextureInfo;
import java.io.IOException; import java.io.IOException;
import java.util.Optional;
@Mixin(TextureAtlas.class) @Mixin(TextureAtlas.class)
public class TextureAtlasMixin { public class TextureAtlasMixin {
@ -47,7 +48,8 @@ public class TextureAtlasMixin {
location.getNamespace(), location.getNamespace(),
"textures/" + location.getPath() + "_e.png" "textures/" + location.getPath() + "_e.png"
); );
if (resourceManager.hasResource(emissiveLocation)) { Optional<Resource> emissiveRes = resourceManager.getResource(emissiveLocation);
if (emissiveRes.isPresent()) {
NativeImage sprite = null; NativeImage sprite = null;
NativeImage emission = null; NativeImage emission = null;
try { try {
@ -55,13 +57,13 @@ public class TextureAtlasMixin {
location.getNamespace(), location.getNamespace(),
"textures/" + location.getPath() + ".png" "textures/" + location.getPath() + ".png"
); );
Resource resource = resourceManager.getResource(spriteLocation); Resource resource = resourceManager.getResource(spriteLocation).orElse(null);
sprite = NativeImage.read(resource.getInputStream()); sprite = NativeImage.read(resource.open());
resource.close(); sprite.close();
resource = resourceManager.getResource(emissiveLocation); resource = emissiveRes.get();
emission = NativeImage.read(resource.getInputStream()); emission = NativeImage.read(resource.open());
resource.close(); emission.close();
} }
catch (IOException e) { catch (IOException e) {
BCLib.LOGGER.warning(e.getMessage()); BCLib.LOGGER.warning(e.getMessage());

View file

@ -1,19 +0,0 @@
package ru.bclib.mixin.client;
import net.minecraft.client.gui.screens.worldselection.WorldPreset;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.world.level.levelgen.WorldGenSettings;
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.CallbackInfoReturnable;
import ru.bclib.api.biomes.BiomeAPI;
@Mixin(WorldPreset.class)
public class WorldPresetMixin {
@Inject(method = "create", at = @At("HEAD"))
private void bclib_create(RegistryAccess registryAccess, long l, boolean bl, boolean bl2, CallbackInfoReturnable<WorldGenSettings> info) {
BiomeAPI.initRegistry(registryAccess.registryOrThrow(Registry.BIOME_REGISTRY));
}
}

View file

@ -1,13 +0,0 @@
package ru.bclib.mixin.common;
import net.minecraft.world.level.biome.Biome;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(Biome.class)
public interface BiomeAccessor {
@Accessor("biomeCategory")
@Mutable
Biome.BiomeCategory bclib_getBiomeCategory();
}

View file

@ -1,7 +1,7 @@
package ru.bclib.mixin.common; package ru.bclib.mixin.common;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.world.level.StructureFeatureManager; import net.minecraft.world.level.StructureManager;
import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.ChunkGenerator;
@ -26,7 +26,7 @@ public class ChunkGeneratorMixin implements ChunkGeneratorAccessor {
} }
@Inject(method = "applyBiomeDecoration", at = @At("HEAD")) @Inject(method = "applyBiomeDecoration", at = @At("HEAD"))
private void bclib_obBiomeGenerate(WorldGenLevel worldGenLevel, ChunkAccess chunkAccess, StructureFeatureManager structureFeatureManager, CallbackInfo ci) { private void bclib_obBiomeGenerate(WorldGenLevel worldGenLevel, ChunkAccess chunkAccess, StructureManager structureFeatureManager, CallbackInfo ci) {
bclib_featureIteratorSeed = 0; bclib_featureIteratorSeed = 0;
} }

View file

@ -4,10 +4,14 @@ import com.mojang.serialization.Lifecycle;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.core.WritableRegistry; import net.minecraft.core.WritableRegistry;
import net.minecraft.data.worldgen.DimensionTypes;
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.levelgen.presets.WorldPresets;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
@ -20,43 +24,44 @@ import java.util.OptionalInt;
@Mixin(DimensionType.class) @Mixin(DimensionType.class)
public class DimensionTypeMixin { public class DimensionTypeMixin {
@Inject( // @Inject(
method = "defaultDimensions(Lnet/minecraft/core/RegistryAccess;JZ)Lnet/minecraft/core/Registry;", // method = "defaultDimensions(Lnet/minecraft/core/RegistryAccess;JZ)Lnet/minecraft/core/Registry;",
locals = LocalCapture.CAPTURE_FAILHARD, // locals = LocalCapture.CAPTURE_FAILHARD,
at = @At("TAIL") // at = @At("TAIL")
) // )
private static void bclib_updateDimensions(RegistryAccess registryAccess, long seed, boolean bl, CallbackInfoReturnable<Registry> info, WritableRegistry writableRegistry, Registry registry, Registry biomeRegistry, Registry structureRegistry, Registry noiseSettingsRegistry, Registry noiseParamRegistry) { private static void bclib_updateDimensions(RegistryAccess registryAccess, long seed, boolean bl, CallbackInfoReturnable<Registry> info, WritableRegistry writableRegistry, Registry registry, Registry biomeRegistry, Registry structureRegistry, Registry noiseSettingsRegistry, Registry noiseParamRegistry) {
int id = writableRegistry.getId(writableRegistry.get(LevelStem.NETHER)); //This probably moved to WorldPresets.bootstrap();
writableRegistry.registerOrOverride( // int id = writableRegistry.getId(writableRegistry.get(LevelStem.NETHER));
OptionalInt.of(id), // writableRegistry.registerOrOverride(
LevelStem.NETHER, // OptionalInt.of(id),
new LevelStem( // LevelStem.NETHER,
registry.getOrCreateHolder(DimensionType.NETHER_LOCATION), // new LevelStem(
new NoiseBasedChunkGenerator( // registry.getOrCreateHolder(BuiltinDimensionTypes.NETHER),
structureRegistry, // new NoiseBasedChunkGenerator(
noiseParamRegistry, // structureRegistry,
new BCLibNetherBiomeSource(biomeRegistry, seed), // noiseParamRegistry,
seed, // new BCLibNetherBiomeSource(biomeRegistry, seed),
noiseSettingsRegistry.getOrCreateHolder(NoiseGeneratorSettings.NETHER)) // seed,
), // noiseSettingsRegistry.getOrCreateHolder(NoiseGeneratorSettings.NETHER))
Lifecycle.stable() // ),
); // Lifecycle.stable()
// );
//
id = writableRegistry.getId(writableRegistry.get(LevelStem.END)); //
writableRegistry.registerOrOverride( // id = writableRegistry.getId(writableRegistry.get(LevelStem.END));
OptionalInt.of(id), // writableRegistry.registerOrOverride(
LevelStem.END, // OptionalInt.of(id),
new LevelStem( // LevelStem.END,
registry.getOrCreateHolder(DimensionType.END_LOCATION), // new LevelStem(
new NoiseBasedChunkGenerator( // registry.getOrCreateHolder(BuiltinDimensionTypes.END),
structureRegistry, // new NoiseBasedChunkGenerator(
noiseParamRegistry, // structureRegistry,
new BCLibEndBiomeSource(biomeRegistry, seed), // noiseParamRegistry,
seed, // new BCLibEndBiomeSource(biomeRegistry, seed),
noiseSettingsRegistry.getOrCreateHolder(NoiseGeneratorSettings.END)) // seed,
), // noiseSettingsRegistry.getOrCreateHolder(NoiseGeneratorSettings.END))
Lifecycle.stable() // ),
); // Lifecycle.stable()
// );
} }
} }

View file

@ -3,18 +3,14 @@ package ru.bclib.mixin.common;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.StructureFeatureManager; import net.minecraft.util.RandomSource;
import net.minecraft.world.level.StructureManager;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.Climate; import net.minecraft.world.level.biome.Climate;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.levelgen.Aquifer; import net.minecraft.world.level.levelgen.*;
import net.minecraft.world.level.levelgen.Beardifier;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.world.level.levelgen.NoiseChunk;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.levelgen.NoiseRouter;
import net.minecraft.world.level.levelgen.blending.Blender; import net.minecraft.world.level.levelgen.blending.Blender;
import net.minecraft.world.level.levelgen.carver.CarvingContext; import net.minecraft.world.level.levelgen.carver.CarvingContext;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
@ -29,12 +25,6 @@ import java.util.Optional;
@Mixin(NoiseBasedChunkGenerator.class) @Mixin(NoiseBasedChunkGenerator.class)
public abstract class NoiseBasedChunkGeneratorMixin implements SurfaceProvider, NoiseGeneratorSettingsProvider { public abstract class NoiseBasedChunkGeneratorMixin implements SurfaceProvider, NoiseGeneratorSettingsProvider {
@Final
@Shadow
private Climate.Sampler sampler;
@Shadow @Final private NoiseRouter router;
@Final @Final
@Shadow @Shadow
protected Holder<NoiseGeneratorSettings> settings; protected Holder<NoiseGeneratorSettings> settings;
@ -50,33 +40,23 @@ public abstract class NoiseBasedChunkGeneratorMixin implements SurfaceProvider,
public NoiseGeneratorSettings bclib_getNoiseGeneratorSettings(){ public NoiseGeneratorSettings bclib_getNoiseGeneratorSettings(){
return settings.value(); return settings.value();
} }
@Shadow protected abstract NoiseChunk createNoiseChunk(ChunkAccess chunkAccess,
StructureManager structureManager,
Blender blender,
RandomState randomState);
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public BlockState bclib_getSurface(BlockPos pos, Holder<Biome> biome, ServerLevel level) { public BlockState bclib_getSurface(BlockPos pos, Holder<Biome> biome, ServerLevel level) {
ChunkAccess chunkAccess = level.getChunk(pos.getX() >> 4, pos.getZ() >> 4); ChunkAccess chunkAccess = level.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
StructureFeatureManager structureFeatureManager = level.structureFeatureManager(); StructureManager structureManager = level.structureManager();
NoiseBasedChunkGenerator generator = NoiseBasedChunkGenerator.class.cast(this); NoiseBasedChunkGenerator generator = NoiseBasedChunkGenerator.class.cast(this);
if (bclib_constructor == null) { RandomState randomState = level.getChunkSource().randomState();
bclib_constructor = Beardifier.class.getConstructors()[0];
bclib_constructor.setAccessible(true); NoiseChunk noiseChunk = chunkAccess.getOrCreateNoiseChunk(ca -> this.createNoiseChunk(ca, structureManager, Blender.empty(), randomState));
}
CarvingContext carvingContext = new CarvingContext(generator, level.registryAccess(), chunkAccess.getHeightAccessorForGeneration(), noiseChunk, randomState, this.settings.value().surfaceRule());
Beardifier beardifier = null;
try {
beardifier = (Beardifier) bclib_constructor.newInstance(structureFeatureManager, chunkAccess);
}
catch (Exception e) {
BCLib.LOGGER.error(e.getLocalizedMessage());
}
if (beardifier == null) {
return bclib_air;
}
Beardifier finalBeardifier = beardifier;
NoiseChunk noiseChunk = chunkAccess.getOrCreateNoiseChunk(router, () -> finalBeardifier, this.settings.value(), this.globalFluidPicker, Blender.empty());
CarvingContext carvingContext = new CarvingContext(generator, level.registryAccess(), chunkAccess.getHeightAccessorForGeneration(), noiseChunk);
Optional<BlockState> optional = carvingContext.topMaterial(bpos -> biome, chunkAccess, pos, false); Optional<BlockState> optional = carvingContext.topMaterial(bpos -> biome, chunkAccess, pos, false);
return optional.isPresent() ? optional.get() : bclib_air; return optional.isPresent() ? optional.get() : bclib_air;
} }

View file

@ -9,6 +9,8 @@ import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.storage.LevelStorageSource;
import net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess; import net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess;
import net.minecraft.world.level.storage.ServerLevelData; import net.minecraft.world.level.storage.ServerLevelData;
import net.minecraft.world.level.storage.WritableLevelData; import net.minecraft.world.level.storage.WritableLevelData;
@ -27,15 +29,34 @@ import java.util.function.Supplier;
@Mixin(ServerLevel.class) @Mixin(ServerLevel.class)
public abstract class ServerLevelMixin extends Level { public abstract class ServerLevelMixin extends Level {
private static String bclib_lastWorld = null; private static String bclib_lastWorld = null;
protected ServerLevelMixin(WritableLevelData writableLevelData, ResourceKey<Level> resourceKey, Holder<DimensionType> dimensionType, Supplier<ProfilerFiller> supplier, boolean bl, boolean bl2, long l) { protected ServerLevelMixin(WritableLevelData writableLevelData,
super(writableLevelData, resourceKey, dimensionType, supplier, bl, bl2, l); ResourceKey<Level> resourceKey,
Holder<DimensionType> holder,
Supplier<ProfilerFiller> supplier,
boolean bl,
boolean bl2,
long l,
int i) {
super(writableLevelData, resourceKey, holder, supplier, bl, bl2, l, i);
} }
@Inject(method = "<init>*", at = @At("TAIL")) @Inject(method = "<init>*", at = @At("TAIL"))
private void bclib_onServerWorldInit(MinecraftServer server, Executor executor, LevelStorageAccess levelStorageAccess, ServerLevelData serverLevelData, ResourceKey resourceKey, Holder<DimensionType> dimensionType, ChunkProgressListener chunkProgressListener, ChunkGenerator chunkGenerator, boolean bl, long l, List list, boolean bl2, CallbackInfo ci) { private void bclib_onServerWorldInit(MinecraftServer server,
Executor executor,
LevelStorageAccess levelStorageAccess,
ServerLevelData serverLevelData,
ResourceKey resourceKey,
LevelStem levelStem,
ChunkProgressListener chunkProgressListener,
boolean bl,
long l,
List list,
boolean bl2,
CallbackInfo ci) {
ServerLevel level = ServerLevel.class.cast(this); ServerLevel level = ServerLevel.class.cast(this);
LifeCycleAPI._runLevelLoad(level, server, executor, levelStorageAccess, serverLevelData, resourceKey, dimensionType, chunkProgressListener, chunkGenerator, bl, l, list, bl2); LifeCycleAPI._runLevelLoad(level, server, executor, levelStorageAccess, serverLevelData, resourceKey, chunkProgressListener, bl, l, list, bl2);
BiomeAPI.applyModifications(ServerLevel.class.cast(this)); BiomeAPI.applyModifications(ServerLevel.class.cast(this));

View file

@ -1,14 +0,0 @@
package ru.bclib.mixin.common;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(StructureFeature.class)
public interface StructureFeatureAccessor {
@Invoker
static <F extends StructureFeature<?>> F callRegister(String name, F structureFeature, GenerationStep.Decoration step) {
throw new RuntimeException("Unexpected call");
}
}

View file

@ -1,18 +0,0 @@
package ru.bclib.mixin.common;
import net.minecraft.core.Holder;
import net.minecraft.data.worldgen.StructureFeatures;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(StructureFeatures.class)
public interface StructureFeaturesAccessor {
@Invoker
static <FC extends FeatureConfiguration, F extends StructureFeature<FC>> Holder<ConfiguredStructureFeature<?, ?>> callRegister(ResourceKey<ConfiguredStructureFeature<?, ?>> resourceKey, ConfiguredStructureFeature<FC, F> configuredStructureFeature) {
throw new RuntimeException("Unexpected call");
}
}

View file

@ -0,0 +1,16 @@
package ru.bclib.mixin.common;
import net.minecraft.core.Holder;
import net.minecraft.data.worldgen.Structures;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.levelgen.structure.Structure;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(Structures.class)
public interface StructuresAccessor {
@Invoker
static Holder<Structure> callRegister(ResourceKey<Structure> resourceKey, Structure structure) {
throw new RuntimeException("Unexpected call");
}
}

View file

@ -0,0 +1,15 @@
package ru.bclib.mixin.common;
import net.minecraft.server.dedicated.DedicatedServerProperties;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
@Mixin(DedicatedServerProperties.WorldGenProperties.class)
public class WorldGenPropertiesMixin {
@ModifyArg(method = "create", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/levelgen/presets/WorldPreset;createWorldGenSettings(JZZ)Lnet/minecraft/world/level/levelgen/WorldGenSettings;"))
public long bcl_create(long seed) {
return seed;
}
}

View file

@ -0,0 +1,80 @@
package ru.bclib.mixin.common;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.worldselection.WorldOpenFlows;
import net.minecraft.core.RegistryAccess;
import net.minecraft.server.ReloadableServerResources;
import net.minecraft.server.WorldStem;
import net.minecraft.world.level.LevelSettings;
import net.minecraft.world.level.levelgen.WorldGenSettings;
import net.minecraft.world.level.storage.LevelStorageSource;
import net.minecraft.world.level.storage.WorldData;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
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.api.LifeCycleAPI;
import ru.bclib.api.biomes.BiomeAPI;
import ru.bclib.api.dataexchange.DataExchangeAPI;
import ru.bclib.api.datafixer.DataFixerAPI;
import ru.bclib.config.Configs;
@Mixin(WorldOpenFlows.class)
public abstract class WorldOpenFlowsMixin {
@Shadow @Final private LevelStorageSource levelSource;
@Shadow protected abstract void doLoadLevel(Screen screen, String levelID, boolean safeMode, boolean canAskForBackup);
@Inject(method = "loadLevel", cancellable = true, at = @At("HEAD"))
private void bcl_callFixerOnLoad(Screen screen, String levelID, CallbackInfo ci) {
DataExchangeAPI.prepareServerside();
BiomeAPI.prepareNewLevel();
if (DataFixerAPI.fixData(this.levelSource, levelID, true, (appliedFixes) -> {
LifeCycleAPI._runBeforeLevelLoad();
this.doLoadLevel(screen, levelID, false, false);
})) {
//cancel call when fix-screen is presented
ci.cancel();
}
else {
LifeCycleAPI._runBeforeLevelLoad();
if (Configs.CLIENT_CONFIG.suppressExperimentalDialog()) {
this.doLoadLevel(screen, levelID, false, false);
//cancel call as we manually start the level load here
ci.cancel();
}
}
}
@Inject(method="createFreshLevel", at=@At("HEAD"))
public void bcl_createFreshLevel(String levelID,
LevelSettings levelSettings,
RegistryAccess registryAccess,
WorldGenSettings worldGenSettings,
CallbackInfo ci){
DataExchangeAPI.prepareServerside();
BiomeAPI.prepareNewLevel();
DataFixerAPI.initializeWorldData(this.levelSource, levelID, true);
LifeCycleAPI._runBeforeLevelLoad();
}
@Inject(method="createLevelFromExistingSettings", at=@At("HEAD"))
public void bcl_createLevelFromExistingSettings(LevelStorageSource.LevelStorageAccess levelStorageAccess,
ReloadableServerResources reloadableServerResources,
RegistryAccess.Frozen frozen,
WorldData worldData,
CallbackInfo ci){
DataExchangeAPI.prepareServerside();
BiomeAPI.prepareNewLevel();
DataFixerAPI.initializeWorldData(levelStorageAccess, true);
LifeCycleAPI._runBeforeLevelLoad();
}
}

View file

@ -0,0 +1,16 @@
package ru.bclib.mixin.common;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.levelgen.presets.WorldPreset;
import net.minecraft.world.level.levelgen.presets.WorldPresets;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(WorldPresets.class)
public interface WorldPresetsAccessor {
@Invoker("register")
public static ResourceKey<WorldPreset> callRegister(String string) {
throw new RuntimeException("Not Implemented");
}
}

View file

@ -0,0 +1,70 @@
package ru.bclib.mixin.common;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.MultiNoiseBiomeSource;
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.FlatLevelSource;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings;
import net.minecraft.world.level.levelgen.presets.WorldPreset;
import net.minecraft.world.level.levelgen.presets.WorldPresets;
import net.minecraft.world.level.levelgen.structure.StructureSet;
import net.minecraft.world.level.levelgen.synth.NormalNoise;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.bclib.world.generator.BCLibEndBiomeSource;
import ru.bclib.world.generator.BCLibNetherBiomeSource;
import java.util.Map;
@Mixin(WorldPresets.Bootstrap.class)
public abstract class WorldPresetsBootstrapMixin {
private static final ResourceKey<WorldPreset> BCL_NORMAL = WorldPresetsAccessor.callRegister("normal");
@Shadow @Final private Registry<WorldPreset> presets;
@Shadow @Final private Registry<Biome> biomes;
@Shadow @Final private Registry<StructureSet> structureSets;
@Shadow @Final private Registry<NormalNoise.NoiseParameters> noises;
@Shadow @Final private Holder<DimensionType> netherDimensionType;
@Shadow @Final private Holder<NoiseGeneratorSettings> netherNoiseSettings;
@Shadow @Final private Holder<DimensionType> endDimensionType;
@Shadow @Final private Holder<NoiseGeneratorSettings> endNoiseSettings;
@ModifyArg(method="run", at=@At(value="INVOKE", ordinal = 0, target="Lnet/minecraft/world/level/levelgen/presets/WorldPresets$Bootstrap;registerCustomOverworldPreset(Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/dimension/LevelStem;)Lnet/minecraft/core/Holder;"))
private LevelStem bcl_getOverworldStem(LevelStem overworldStem){
LevelStem bclNether = new LevelStem(
this.netherDimensionType,
new NoiseBasedChunkGenerator(
this.structureSets,
this.noises,
new BCLibNetherBiomeSource(this.biomes),
this.netherNoiseSettings)
);
LevelStem bclEnd = new LevelStem(
this.endDimensionType,
new NoiseBasedChunkGenerator(
this.structureSets,
this.noises,
new BCLibEndBiomeSource(this.biomes),
this.endNoiseSettings)
);
WorldPreset preset = new WorldPreset(Map.of(LevelStem.OVERWORLD, overworldStem, LevelStem.NETHER, bclNether, LevelStem.END, bclEnd));
BuiltinRegistries.register(this.presets, BCL_NORMAL, preset);
return overworldStem;
}
}

View file

@ -3,7 +3,7 @@ package ru.bclib.noise;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import ru.bclib.util.MHelper; import ru.bclib.util.MHelper;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
public class VoronoiNoise { public class VoronoiNoise {
private static final Random RANDOM = new Random(); private static final Random RANDOM = new Random();

View file

@ -37,7 +37,7 @@ public class BCLRecipeManager {
}); });
return ImmutableList.copyOf(list); return ImmutableList.copyOf(list);
}); });
return recipes.stream().flatMap(recipe -> type.tryMatch(recipe, level, inventory).stream()).findFirst(); return (Optional<T>)recipes.stream().filter(recipe -> recipe.matches(inventory, level)).findFirst();
} }
public static void addRecipe(RecipeType<?> type, Recipe<?> recipe) { public static void addRecipe(RecipeType<?> type, Recipe<?> recipe) {

View file

@ -15,7 +15,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property; import net.minecraft.world.level.block.state.properties.Property;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
public class BlocksHelper { public class BlocksHelper {
private static final Map<Block, Integer> COLOR_BY_BLOCK = Maps.newHashMap(); private static final Map<Block, Integer> COLOR_BY_BLOCK = Maps.newHashMap();

View file

@ -3,7 +3,7 @@ package ru.bclib.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
public class ColorExtractor { public class ColorExtractor {
private List<Center> centers = new ArrayList<>(); private List<Center> centers = new ArrayList<>();

View file

@ -233,9 +233,10 @@ public class ColorUtil {
public static NativeImage loadImage(ResourceLocation image, int w, int h) { public static NativeImage loadImage(ResourceLocation image, int w, int h) {
Minecraft minecraft = Minecraft.getInstance(); Minecraft minecraft = Minecraft.getInstance();
ResourceManager resourceManager = minecraft.getResourceManager(); ResourceManager resourceManager = minecraft.getResourceManager();
if (resourceManager.hasResource(image)) { var imgResource = resourceManager.getResource(image);
try (Resource resource = resourceManager.getResource(image)) { if (imgResource.isPresent()) {
return NativeImage.read(resource.getInputStream()); try {
return NativeImage.read(imgResource.get().open());
} }
catch (IOException e) { catch (IOException e) {
BCLib.LOGGER.warning("Can't load texture image: {}. Will be created empty image.", image); BCLib.LOGGER.warning("Can't load texture image: {}. Will be created empty image.", image);

View file

@ -67,9 +67,9 @@ public class JsonFactory {
.getResourceManager(); .getResourceManager();
JsonObject obj = null; JsonObject obj = null;
try { try {
Resource resource = manager.getResource(location); Resource resource = manager.getResource(location).orElse(null);
if (resource != null) { if (resource != null) {
InputStream stream = resource.getInputStream(); InputStream stream = resource.open();
InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8); InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8);
obj = JsonFactory.GSON.fromJson(reader, JsonObject.class); obj = JsonFactory.GSON.fromJson(reader, JsonObject.class);
reader.close(); reader.close();

View file

@ -3,7 +3,7 @@ package ru.bclib.util;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
import net.minecraft.core.Vec3i; import net.minecraft.core.Vec3i;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
public class MHelper { public class MHelper {
private static final Vec3i[] RANDOM_OFFSETS = new Vec3i[3 * 3 * 3 - 1]; private static final Vec3i[] RANDOM_OFFSETS = new Vec3i[3 * 3 * 3 - 1];
@ -140,7 +140,7 @@ public class MHelper {
return h ^ (h >> 16); return h ^ (h >> 16);
} }
public static <T> void shuffle(T[] array, Random random) { public static <T> void shuffle(T[] array, RandomSource random) {
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
int i2 = random.nextInt(array.length); int i2 = random.nextInt(array.length);
T element = array[i]; T element = array[i];
@ -202,7 +202,7 @@ public class MHelper {
return new Vector3f(vx, 0, vz); return new Vector3f(vx, 0, vz);
} }
public static Vec3i[] getOffsets(Random random) { public static Vec3i[] getOffsets(RandomSource random) {
shuffle(RANDOM_OFFSETS, random); shuffle(RANDOM_OFFSETS, random);
return RANDOM_OFFSETS; return RANDOM_OFFSETS;
} }

View file

@ -13,7 +13,7 @@ import ru.bclib.sdf.primitive.SDFLine;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
import java.util.function.Function; import java.util.function.Function;
public class SplineHelper { public class SplineHelper {

View file

@ -17,7 +17,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
@ -85,11 +85,11 @@ public class StructureHelper {
return pos.offset(-offset.x * 0.5, 0, -offset.z * 0.5); return pos.offset(-offset.x * 0.5, 0, -offset.z * 0.5);
} }
public static void placeCenteredBottom(WorldGenLevel world, BlockPos pos, StructureTemplate structure, Rotation rotation, Mirror mirror, Random random) { public static void placeCenteredBottom(WorldGenLevel world, BlockPos pos, StructureTemplate structure, Rotation rotation, Mirror mirror, RandomSource random) {
placeCenteredBottom(world, pos, structure, rotation, mirror, makeBox(pos), random); placeCenteredBottom(world, pos, structure, rotation, mirror, makeBox(pos), random);
} }
public static void placeCenteredBottom(WorldGenLevel world, BlockPos pos, StructureTemplate structure, Rotation rotation, Mirror mirror, BoundingBox bounds, Random random) { public static void placeCenteredBottom(WorldGenLevel world, BlockPos pos, StructureTemplate structure, Rotation rotation, Mirror mirror, BoundingBox bounds, RandomSource random) {
BlockPos offset = offsetPos(pos, structure, rotation, mirror); BlockPos offset = offsetPos(pos, structure, rotation, mirror);
StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation) StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation)
.setMirror(mirror) .setMirror(mirror)

View file

@ -1,7 +1,8 @@
package ru.bclib.util; package ru.bclib.util;
import java.util.Locale; import java.util.Locale;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
import net.minecraft.world.level.levelgen.WorldgenRandom;
public class WeighTree<T> { public class WeighTree<T> {
private final float maxWeight; private final float maxWeight;
@ -18,7 +19,7 @@ public class WeighTree<T> {
* @param random - {@link Random}. * @param random - {@link Random}.
* @return {@link T} value. * @return {@link T} value.
*/ */
public T get(Random random) { public T get(WorldgenRandom random) {
return root.get(random.nextFloat() * maxWeight); return root.get(random.nextFloat() * maxWeight);
} }

View file

@ -2,7 +2,9 @@ package ru.bclib.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
import net.minecraft.world.level.levelgen.WorldgenRandom;
import java.util.function.Consumer; import java.util.function.Consumer;
public class WeightedList<T> { public class WeightedList<T> {
@ -28,7 +30,7 @@ public class WeightedList<T> {
* @param random - {@link Random}. * @param random - {@link Random}.
* @return {@link T} value. * @return {@link T} value.
*/ */
public T get(Random random) { public T get(RandomSource random) {
if (maxWeight < 1) { if (maxWeight < 1) {
return null; return null;
} }

View file

@ -19,7 +19,9 @@ import ru.bclib.util.WeightedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
import net.minecraft.world.level.levelgen.WorldgenRandom;
import java.util.Set; import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -133,7 +135,7 @@ public class BCLBiome extends BCLBiomeSettings {
* @param random {@link Random}. * @param random {@link Random}.
* @return {@link BCLBiome}. * @return {@link BCLBiome}.
*/ */
public BCLBiome getSubBiome(Random random) { public BCLBiome getSubBiome(WorldgenRandom random) {
return subbiomes.get(random); return subbiomes.get(random);
} }

View file

@ -10,9 +10,9 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp
import ru.bclib.util.StructureHelper; import ru.bclib.util.StructureHelper;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
public class ListFeature extends NBTStructureFeature { public class ListFeature extends NBTFeature {
private final List<StructureInfo> list; private final List<StructureInfo> list;
private StructureInfo selected; private StructureInfo selected;
@ -22,35 +22,35 @@ public class ListFeature extends NBTStructureFeature {
} }
@Override @Override
protected StructureTemplate getStructure(WorldGenLevel world, BlockPos pos, Random random) { protected StructureTemplate getStructure(WorldGenLevel world, BlockPos pos, RandomSource random) {
selected = list.get(random.nextInt(list.size())); selected = list.get(random.nextInt(list.size()));
return selected.getStructure(); return selected.getStructure();
} }
@Override @Override
protected boolean canSpawn(WorldGenLevel world, BlockPos pos, Random random) { protected boolean canSpawn(WorldGenLevel world, BlockPos pos, RandomSource random) {
int cx = pos.getX() >> 4; int cx = pos.getX() >> 4;
int cz = pos.getZ() >> 4; int cz = pos.getZ() >> 4;
return ((cx + cz) & 1) == 0 && pos.getY() > 58;// && world.getBlockState(pos.below()).is(EndTags.GEN_TERRAIN); return ((cx + cz) & 1) == 0 && pos.getY() > 58;// && world.getBlockState(pos.below()).is(EndTags.GEN_TERRAIN);
} }
@Override @Override
protected Rotation getRotation(WorldGenLevel world, BlockPos pos, Random random) { protected Rotation getRotation(WorldGenLevel world, BlockPos pos, RandomSource random) {
return Rotation.getRandom(random); return Rotation.getRandom(random);
} }
@Override @Override
protected Mirror getMirror(WorldGenLevel world, BlockPos pos, Random random) { protected Mirror getMirror(WorldGenLevel world, BlockPos pos, RandomSource random) {
return Mirror.values()[random.nextInt(3)]; return Mirror.values()[random.nextInt(3)];
} }
@Override @Override
protected int getYOffset(StructureTemplate structure, WorldGenLevel world, BlockPos pos, Random random) { protected int getYOffset(StructureTemplate structure, WorldGenLevel world, BlockPos pos, RandomSource random) {
return selected.offsetY; return selected.offsetY;
} }
@Override @Override
protected TerrainMerge getTerrainMerge(WorldGenLevel world, BlockPos pos, Random random) { protected TerrainMerge getTerrainMerge(WorldGenLevel world, BlockPos pos, RandomSource random) {
return selected.terrainMerge; return selected.terrainMerge;
} }

View file

@ -1,234 +1,235 @@
package ru.bclib.world.features; package ru.bclib.world.features;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.core.Vec3i; import net.minecraft.core.Vec3i;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.NbtIo;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.WorldGenLevel; import net.minecraft.util.RandomSource;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Mirror; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.structure.BoundingBox; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import ru.bclib.api.biomes.BiomeAPI; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import ru.bclib.api.tag.CommonBlockTags;
import ru.bclib.util.BlocksHelper; import ru.bclib.api.biomes.BiomeAPI;
import ru.bclib.world.processors.DestructionStructureProcessor; import ru.bclib.api.tag.CommonBlockTags;
import ru.bclib.util.BlocksHelper;
import java.io.IOException; import ru.bclib.world.processors.DestructionStructureProcessor;
import java.io.InputStream;
import java.util.Random; import java.io.IOException;
import java.io.InputStream;
public abstract class NBTStructureFeature extends DefaultFeature {
private final BlockState defaultBlock; public abstract class NBTFeature extends DefaultFeature {
public NBTStructureFeature(BlockState defaultBlock){ private final BlockState defaultBlock;
this.defaultBlock = defaultBlock; public NBTFeature(BlockState defaultBlock){
} this.defaultBlock = defaultBlock;
}
protected static final DestructionStructureProcessor DESTRUCTION = new DestructionStructureProcessor();
protected static final DestructionStructureProcessor DESTRUCTION = new DestructionStructureProcessor();
protected abstract StructureTemplate getStructure(WorldGenLevel world, BlockPos pos, Random random);
protected abstract StructureTemplate getStructure(WorldGenLevel world, BlockPos pos, RandomSource random);
protected abstract boolean canSpawn(WorldGenLevel world, BlockPos pos, Random random);
protected abstract boolean canSpawn(WorldGenLevel world, BlockPos pos, RandomSource random);
protected abstract Rotation getRotation(WorldGenLevel world, BlockPos pos, Random random);
protected abstract Rotation getRotation(WorldGenLevel world, BlockPos pos, RandomSource random);
protected abstract Mirror getMirror(WorldGenLevel world, BlockPos pos, Random random);
protected abstract Mirror getMirror(WorldGenLevel world, BlockPos pos, RandomSource random);
protected abstract int getYOffset(StructureTemplate structure, WorldGenLevel world, BlockPos pos, Random random);
protected abstract int getYOffset(StructureTemplate structure, WorldGenLevel world, BlockPos pos, RandomSource random);
protected abstract TerrainMerge getTerrainMerge(WorldGenLevel world, BlockPos pos, Random random);
protected abstract TerrainMerge getTerrainMerge(WorldGenLevel world, BlockPos pos, RandomSource random);
protected abstract void addStructureData(StructurePlaceSettings data);
protected abstract void addStructureData(StructurePlaceSettings data);
protected BlockPos getGround(WorldGenLevel world, BlockPos center) {
Holder<Biome> biome = world.getBiome(center); protected BlockPos getGround(WorldGenLevel world, BlockPos center) {
ResourceLocation id = BiomeAPI.getBiomeID(biome); Holder<Biome> biome = world.getBiome(center);
if (id.getNamespace().contains("moutain") || id.getNamespace().contains("lake")) { ResourceLocation id = BiomeAPI.getBiomeID(biome);
int y = getAverageY(world, center); if (id.getNamespace().contains("moutain") || id.getNamespace().contains("lake")) {
return new BlockPos(center.getX(), y, center.getZ()); int y = getAverageY(world, center);
} return new BlockPos(center.getX(), y, center.getZ());
else { }
int y = getAverageYWG(world, center); else {
return new BlockPos(center.getX(), y, center.getZ()); int y = getAverageYWG(world, center);
} return new BlockPos(center.getX(), y, center.getZ());
} }
}
protected int getAverageY(WorldGenLevel world, BlockPos center) {
int y = getYOnSurface(world, center.getX(), center.getZ()); protected int getAverageY(WorldGenLevel world, BlockPos center) {
y += getYOnSurface(world, center.getX() - 2, center.getZ() - 2); int y = getYOnSurface(world, center.getX(), center.getZ());
y += getYOnSurface(world, center.getX() + 2, center.getZ() - 2); y += getYOnSurface(world, center.getX() - 2, center.getZ() - 2);
y += getYOnSurface(world, center.getX() - 2, center.getZ() + 2); y += getYOnSurface(world, center.getX() + 2, center.getZ() - 2);
y += getYOnSurface(world, center.getX() + 2, center.getZ() + 2); y += getYOnSurface(world, center.getX() - 2, center.getZ() + 2);
return y / 5; y += getYOnSurface(world, center.getX() + 2, center.getZ() + 2);
} return y / 5;
}
protected int getAverageYWG(WorldGenLevel world, BlockPos center) {
int y = getYOnSurfaceWG(world, center.getX(), center.getZ()); protected int getAverageYWG(WorldGenLevel world, BlockPos center) {
y += getYOnSurfaceWG(world, center.getX() - 2, center.getZ() - 2); int y = getYOnSurfaceWG(world, center.getX(), center.getZ());
y += getYOnSurfaceWG(world, center.getX() + 2, center.getZ() - 2); y += getYOnSurfaceWG(world, center.getX() - 2, center.getZ() - 2);
y += getYOnSurfaceWG(world, center.getX() - 2, center.getZ() + 2); y += getYOnSurfaceWG(world, center.getX() + 2, center.getZ() - 2);
y += getYOnSurfaceWG(world, center.getX() + 2, center.getZ() + 2); y += getYOnSurfaceWG(world, center.getX() - 2, center.getZ() + 2);
return y / 5; y += getYOnSurfaceWG(world, center.getX() + 2, center.getZ() + 2);
} return y / 5;
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) { @Override
WorldGenLevel world = context.level(); public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {
Random random = context.random(); WorldGenLevel world = context.level();
BlockPos center = context.origin(); RandomSource random = context.random();
BlockPos center = context.origin();
center = new BlockPos(((center.getX() >> 4) << 4) | 8, 128, ((center.getZ() >> 4) << 4) | 8);
center = getGround(world, center); center = new BlockPos(((center.getX() >> 4) << 4) | 8, 128, ((center.getZ() >> 4) << 4) | 8);
center = getGround(world, center);
if (!canSpawn(world, center, random)) {
return false; if (!canSpawn(world, center, random)) {
} return false;
}
int posY = center.getY() + 1;
StructureTemplate structure = getStructure(world, center, random); int posY = center.getY() + 1;
Rotation rotation = getRotation(world, center, random); StructureTemplate structure = getStructure(world, center, random);
Mirror mirror = getMirror(world, center, random); Rotation rotation = getRotation(world, center, random);
BlockPos offset = StructureTemplate.transform( Mirror mirror = getMirror(world, center, random);
new BlockPos(structure.getSize()), BlockPos offset = StructureTemplate.transform(
mirror, new BlockPos(structure.getSize()),
rotation, mirror,
BlockPos.ZERO rotation,
); BlockPos.ZERO
center = center.offset(0, getYOffset(structure, world, center, random) + 0.5, 0); );
center = center.offset(0, getYOffset(structure, world, center, random) + 0.5, 0);
BoundingBox bounds = makeBox(center);
StructurePlaceSettings placementData = new StructurePlaceSettings() BoundingBox bounds = makeBox(center);
.setRotation(rotation) StructurePlaceSettings placementData = new StructurePlaceSettings()
.setMirror(mirror) .setRotation(rotation)
.setBoundingBox(bounds); .setMirror(mirror)
addStructureData(placementData); .setBoundingBox(bounds);
center = center.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5); addStructureData(placementData);
structure.placeInWorld(world, center, center, placementData, random, 4); center = center.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
structure.placeInWorld(world, center, center, placementData, random, 4);
TerrainMerge merge = getTerrainMerge(world, center, random);
int x1 = center.getX(); TerrainMerge merge = getTerrainMerge(world, center, random);
int z1 = center.getZ(); int x1 = center.getX();
int x2 = x1 + offset.getX(); int z1 = center.getZ();
int z2 = z1 + offset.getZ(); int x2 = x1 + offset.getX();
if (merge != TerrainMerge.NONE) { int z2 = z1 + offset.getZ();
MutableBlockPos mut = new MutableBlockPos(); if (merge != TerrainMerge.NONE) {
MutableBlockPos mut = new MutableBlockPos();
if (x2 < x1) {
int a = x1; if (x2 < x1) {
x1 = x2; int a = x1;
x2 = a; x1 = x2;
} x2 = a;
}
if (z2 < z1) {
int a = z1; if (z2 < z1) {
z1 = z2; int a = z1;
z2 = a; z1 = z2;
} z2 = a;
}
int surfMax = posY - 1;
for (int x = x1; x <= x2; x++) { int surfMax = posY - 1;
mut.setX(x); for (int x = x1; x <= x2; x++) {
for (int z = z1; z <= z2; z++) { mut.setX(x);
mut.setZ(z); for (int z = z1; z <= z2; z++) {
mut.setY(surfMax); mut.setZ(z);
BlockState state = world.getBlockState(mut); mut.setY(surfMax);
if (!isTerrain(state) && state.isFaceSturdy(world, mut, Direction.DOWN)) { BlockState state = world.getBlockState(mut);
for (int i = 0; i < 10; i++) { if (!isTerrain(state) && state.isFaceSturdy(world, mut, Direction.DOWN)) {
mut.setY(mut.getY() - 1); for (int i = 0; i < 10; i++) {
BlockState stateSt = world.getBlockState(mut); mut.setY(mut.getY() - 1);
if (!isTerrain(stateSt)) { BlockState stateSt = world.getBlockState(mut);
if (merge == TerrainMerge.SURFACE) { if (!isTerrain(stateSt)) {
boolean isTop = mut.getY() == surfMax && state.getMaterial().isSolidBlocking(); if (merge == TerrainMerge.SURFACE) {
Holder<Biome> b = world.getBiome(mut); boolean isTop = mut.getY() == surfMax && state.getMaterial().isSolidBlocking();
BlockState top = (isTop ? BiomeAPI.findTopMaterial(b) : BiomeAPI.findUnderMaterial(b)).orElse(defaultBlock); Holder<Biome> b = world.getBiome(mut);
BlocksHelper.setWithoutUpdate(world, mut, top); BlockState top = (isTop ? BiomeAPI.findTopMaterial(b) : BiomeAPI.findUnderMaterial(b)).orElse(defaultBlock);
} BlocksHelper.setWithoutUpdate(world, mut, top);
else { }
BlocksHelper.setWithoutUpdate(world, mut, state); else {
} BlocksHelper.setWithoutUpdate(world, mut, state);
} }
else { }
if (isTerrain(state) && state.getMaterial().isSolidBlocking()) { else {
if (merge == TerrainMerge.SURFACE) { if (isTerrain(state) && state.getMaterial().isSolidBlocking()) {
Holder<Biome> b = world.getBiome(mut); if (merge == TerrainMerge.SURFACE) {
BlockState bottom = BiomeAPI.findUnderMaterial(b).orElse(defaultBlock); Holder<Biome> b = world.getBiome(mut);
BlocksHelper.setWithoutUpdate(world, mut, bottom); BlockState bottom = BiomeAPI.findUnderMaterial(b).orElse(defaultBlock);
} BlocksHelper.setWithoutUpdate(world, mut, bottom);
else { }
BlocksHelper.setWithoutUpdate(world, mut, state); else {
} BlocksHelper.setWithoutUpdate(world, mut, state);
} }
break; }
} break;
} }
} }
} }
} }
} }
//BlocksHelper.fixBlocks(world, new BlockPos(x1, center.getY(), z1), new BlockPos(x2, center.getY() + offset.getY(), z2)); }
//BlocksHelper.fixBlocks(world, new BlockPos(x1, center.getY(), z1), new BlockPos(x2, center.getY() + offset.getY(), z2));
return true;
} return true;
}
private boolean isTerrain(BlockState state) {
return state.is(CommonBlockTags.END_STONES) || state.is(CommonBlockTags.NETHER_STONES); private boolean isTerrain(BlockState state) {
} return state.is(CommonBlockTags.END_STONES) || state.is(CommonBlockTags.NETHER_STONES);
}
protected BoundingBox makeBox(BlockPos pos) {
int sx = ((pos.getX() >> 4) << 4) - 16; protected BoundingBox makeBox(BlockPos pos) {
int sz = ((pos.getZ() >> 4) << 4) - 16; int sx = ((pos.getX() >> 4) << 4) - 16;
int ex = sx + 47; int sz = ((pos.getZ() >> 4) << 4) - 16;
int ez = sz + 47; int ex = sx + 47;
return BoundingBox.fromCorners(new Vec3i(sx, 0, sz), new Vec3i(ex, 255, ez)); int ez = sz + 47;
} return BoundingBox.fromCorners(new Vec3i(sx, 0, sz), new Vec3i(ex, 255, ez));
}
protected static StructureTemplate readStructure(ResourceLocation resource) {
String ns = resource.getNamespace(); protected static StructureTemplate readStructure(ResourceLocation resource) {
String nm = resource.getPath(); String ns = resource.getNamespace();
String nm = resource.getPath();
try {
InputStream inputstream = MinecraftServer.class.getResourceAsStream("/data/" + ns + "/structures/" + nm + ".nbt"); try {
return readStructureFromStream(inputstream); InputStream inputstream = MinecraftServer.class.getResourceAsStream("/data/" + ns + "/structures/" + nm + ".nbt");
} return readStructureFromStream(inputstream);
catch (IOException e) { }
e.printStackTrace(); catch (IOException e) {
} e.printStackTrace();
}
return null;
} return null;
}
private static StructureTemplate readStructureFromStream(InputStream stream) throws IOException {
CompoundTag nbttagcompound = NbtIo.readCompressed(stream); private static StructureTemplate readStructureFromStream(InputStream stream) throws IOException {
CompoundTag nbttagcompound = NbtIo.readCompressed(stream);
StructureTemplate template = new StructureTemplate();
template.load(nbttagcompound); StructureTemplate template = new StructureTemplate();
template.load(nbttagcompound);
return template;
} return template;
}
public enum TerrainMerge {
NONE, SURFACE, OBJECT; public enum TerrainMerge {
NONE, SURFACE, OBJECT;
public static TerrainMerge getFromString(String type) {
if (type.equals("surface")) { public static TerrainMerge getFromString(String type) {
return SURFACE; if (type.equals("surface")) {
} return SURFACE;
else if (type.equals("object")) { }
return OBJECT; else if (type.equals("object")) {
} return OBJECT;
else { }
return NONE; else {
} return NONE;
} }
} }
} }
}

View file

@ -10,19 +10,22 @@ import java.util.List;
public abstract class BCLBiomeSource extends BiomeSource { public abstract class BCLBiomeSource extends BiomeSource {
protected final Registry<Biome> biomeRegistry; protected final Registry<Biome> biomeRegistry;
protected final long seed; protected long currentSeed;
private static List<Holder<Biome>> preInit(Registry<Biome> biomeRegistry, List<Holder<Biome>> biomes){ private static List<Holder<Biome>> preInit(Registry<Biome> biomeRegistry, List<Holder<Biome>> biomes){
biomes.forEach(biome -> BiomeAPI.sortBiomeFeatures(biome)); biomes.forEach(biome -> BiomeAPI.sortBiomeFeatures(biome));
return biomes; return biomes;
} }
protected BCLBiomeSource(Registry<Biome> biomeRegistry, long seed, List<Holder<Biome>> list) { protected BCLBiomeSource(Registry<Biome> biomeRegistry, List<Holder<Biome>> list) {
super(preInit(biomeRegistry, list)); super(preInit(biomeRegistry, list));
this.seed = seed;
this.biomeRegistry = biomeRegistry; this.biomeRegistry = biomeRegistry;
BiomeAPI.initRegistry(biomeRegistry); BiomeAPI.initRegistry(biomeRegistry);
} }
public void setSeed(long seed){
this.currentSeed = seed;
}
} }

View file

@ -6,12 +6,12 @@ import net.minecraft.core.Holder;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.resources.RegistryOps; import net.minecraft.resources.RegistryOps;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BiomeTags;
import net.minecraft.util.Mth;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.Biome.BiomeCategory;
import net.minecraft.world.level.biome.BiomeSource; import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.biome.Biomes; import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.biome.Climate; import net.minecraft.world.level.biome.Climate;
import net.minecraft.world.level.biome.TheEndBiomeSource;
import net.minecraft.world.level.levelgen.LegacyRandomSource; import net.minecraft.world.level.levelgen.LegacyRandomSource;
import net.minecraft.world.level.levelgen.WorldgenRandom; import net.minecraft.world.level.levelgen.WorldgenRandom;
import net.minecraft.world.level.levelgen.synth.SimplexNoise; import net.minecraft.world.level.levelgen.synth.SimplexNoise;
@ -20,7 +20,6 @@ import ru.bclib.api.biomes.BiomeAPI;
import ru.bclib.config.ConfigKeeper.StringArrayEntry; import ru.bclib.config.ConfigKeeper.StringArrayEntry;
import ru.bclib.config.Configs; import ru.bclib.config.Configs;
import ru.bclib.interfaces.BiomeMap; import ru.bclib.interfaces.BiomeMap;
import ru.bclib.mixin.common.BiomeAccessor;
import ru.bclib.noise.OpenSimplexNoise; import ru.bclib.noise.OpenSimplexNoise;
import ru.bclib.world.biomes.BCLBiome; import ru.bclib.world.biomes.BCLBiome;
import ru.bclib.world.generator.map.hex.HexBiomeMap; import ru.bclib.world.generator.map.hex.HexBiomeMap;
@ -31,19 +30,19 @@ import java.util.List;
import java.util.function.Function; import java.util.function.Function;
public class BCLibEndBiomeSource extends BCLBiomeSource { public class BCLibEndBiomeSource extends BCLBiomeSource {
public static Codec<BCLibEndBiomeSource> CODEC = RecordCodecBuilder.create((instance) -> instance.group(RegistryOps.retrieveRegistry(Registry.BIOME_REGISTRY).forGetter((theEndBiomeSource) -> null), Codec.LONG.fieldOf("seed").stable().forGetter((theEndBiomeSource) -> theEndBiomeSource.seed)).apply(instance, instance.stable(BCLibEndBiomeSource::new))); public static Codec<BCLibEndBiomeSource> CODEC = RecordCodecBuilder.create((instance) -> instance.group(RegistryOps.retrieveRegistry(Registry.BIOME_REGISTRY).forGetter((theEndBiomeSource) -> null)).apply(instance, instance.stable(BCLibEndBiomeSource::new)));
private static final OpenSimplexNoise SMALL_NOISE = new OpenSimplexNoise(8324); private static final OpenSimplexNoise SMALL_NOISE = new OpenSimplexNoise(8324);
private Function<Point, Boolean> endLandFunction; private Function<Point, Boolean> endLandFunction;
private final SimplexNoise noise; private SimplexNoise noise;
private final Holder<Biome> centerBiome; private final Holder<Biome> centerBiome;
private final Holder<Biome> barrens; private final Holder<Biome> barrens;
private BiomeMap mapLand; private BiomeMap mapLand;
private BiomeMap mapVoid; private BiomeMap mapVoid;
private final Point pos; private final Point pos;
public BCLibEndBiomeSource(Registry<Biome> biomeRegistry, long seed) { public BCLibEndBiomeSource(Registry<Biome> biomeRegistry) {
super(biomeRegistry, seed, getBiomes(biomeRegistry)); super(biomeRegistry, getBiomes(biomeRegistry));
BiomeAPI.END_LAND_BIOME_PICKER.clearMutables(); BiomeAPI.END_LAND_BIOME_PICKER.clearMutables();
BiomeAPI.END_VOID_BIOME_PICKER.clearMutables(); BiomeAPI.END_VOID_BIOME_PICKER.clearMutables();
@ -86,6 +85,15 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
BiomeAPI.END_LAND_BIOME_PICKER.rebuild(); BiomeAPI.END_LAND_BIOME_PICKER.rebuild();
BiomeAPI.END_VOID_BIOME_PICKER.rebuild(); BiomeAPI.END_VOID_BIOME_PICKER.rebuild();
this.centerBiome = biomeRegistry.getOrCreateHolder(Biomes.THE_END);
this.barrens = biomeRegistry.getOrCreateHolder(Biomes.END_BARRENS);
this.endLandFunction = GeneratorOptions.getEndLandFunction();
this.pos = new Point();
}
private void initMap(long seed){
if (GeneratorOptions.useOldBiomeGenerator()) { if (GeneratorOptions.useOldBiomeGenerator()) {
this.mapLand = new SquareBiomeMap(seed, GeneratorOptions.getBiomeSizeEndLand(), BiomeAPI.END_LAND_BIOME_PICKER); this.mapLand = new SquareBiomeMap(seed, GeneratorOptions.getBiomeSizeEndLand(), BiomeAPI.END_LAND_BIOME_PICKER);
this.mapVoid = new SquareBiomeMap(seed, GeneratorOptions.getBiomeSizeEndVoid(), BiomeAPI.END_VOID_BIOME_PICKER); this.mapVoid = new SquareBiomeMap(seed, GeneratorOptions.getBiomeSizeEndVoid(), BiomeAPI.END_VOID_BIOME_PICKER);
@ -94,18 +102,18 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
this.mapLand = new HexBiomeMap(seed, GeneratorOptions.getBiomeSizeEndLand(), BiomeAPI.END_LAND_BIOME_PICKER); this.mapLand = new HexBiomeMap(seed, GeneratorOptions.getBiomeSizeEndLand(), BiomeAPI.END_LAND_BIOME_PICKER);
this.mapVoid = new HexBiomeMap(seed, GeneratorOptions.getBiomeSizeEndVoid(), BiomeAPI.END_VOID_BIOME_PICKER); this.mapVoid = new HexBiomeMap(seed, GeneratorOptions.getBiomeSizeEndVoid(), BiomeAPI.END_VOID_BIOME_PICKER);
} }
this.centerBiome = biomeRegistry.getOrCreateHolder(Biomes.THE_END);
this.barrens = biomeRegistry.getOrCreateHolder(Biomes.END_BARRENS);
WorldgenRandom chunkRandom = new WorldgenRandom(new LegacyRandomSource(seed)); WorldgenRandom chunkRandom = new WorldgenRandom(new LegacyRandomSource(seed));
chunkRandom.consumeCount(17292); chunkRandom.consumeCount(17292);
this.noise = new SimplexNoise(chunkRandom); this.noise = new SimplexNoise(chunkRandom);
this.endLandFunction = GeneratorOptions.getEndLandFunction();
this.pos = new Point();
} }
@Override
public void setSeed(long seed) {
super.setSeed(seed);
initMap(seed);
}
private static List<Holder<Biome>> getBiomes(Registry<Biome> biomeRegistry) { private static List<Holder<Biome>> getBiomes(Registry<Biome> biomeRegistry) {
List<String> includeLand = Configs.BIOMES_CONFIG.getEntry("force_include", "end_land_biomes", StringArrayEntry.class).getValue(); List<String> includeLand = Configs.BIOMES_CONFIG.getEntry("force_include", "end_land_biomes", StringArrayEntry.class).getValue();
List<String> includeVoid = Configs.BIOMES_CONFIG.getEntry("force_include", "end_void_biomes", StringArrayEntry.class).getValue(); List<String> includeVoid = Configs.BIOMES_CONFIG.getEntry("force_include", "end_void_biomes", StringArrayEntry.class).getValue();
@ -121,14 +129,9 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
return true; return true;
} }
final boolean isEndBiome; final boolean isEndBiome = biome.is(BiomeTags.IS_END);
if ((Object)biome instanceof BiomeAccessor bacc) { if (GeneratorOptions.addEndBiomesByTag() && isEndBiome) {
isEndBiome = bacc.bclib_getBiomeCategory() == BiomeCategory.THEEND; return true;
if (GeneratorOptions.addEndBiomesByCategory() && isEndBiome) {
return true;
}
} else {
isEndBiome = false;
} }
BCLBiome bclBiome = BiomeAPI.getBiome(key); BCLBiome bclBiome = BiomeAPI.getBiome(key);
@ -144,6 +147,8 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
@Override @Override
public Holder<Biome> getNoiseBiome(int biomeX, int biomeY, int biomeZ, Climate.Sampler sampler) { public Holder<Biome> getNoiseBiome(int biomeX, int biomeY, int biomeZ, Climate.Sampler sampler) {
if (mapLand==null || mapVoid==null)
return this.possibleBiomes().stream().findFirst().get();
long posX = biomeX << 2; long posX = biomeX << 2;
long posZ = biomeZ << 2; long posZ = biomeZ << 2;
long farEndBiomes = GeneratorOptions.getFarEndBiomes(); long farEndBiomes = GeneratorOptions.getFarEndBiomes();
@ -156,7 +161,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
if (endLandFunction == null) { if (endLandFunction == null) {
if (dist <= farEndBiomes) return centerBiome; if (dist <= farEndBiomes) return centerBiome;
float height = TheEndBiomeSource.getHeightValue( float height = getLegacyHeightValue(
noise, noise,
(biomeX >> 1) + 1, (biomeX >> 1) + 1,
(biomeZ >> 1) + 1 (biomeZ >> 1) + 1
@ -184,11 +189,29 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
} }
} }
@Override public static float getLegacyHeightValue(SimplexNoise simplexNoise, int i, int j) {
public BiomeSource withSeed(long seed) { int k = i / 2;
return new BCLibEndBiomeSource(biomeRegistry, seed); int l = j / 2;
int m = i % 2;
int n = j % 2;
float f = 100.0f - Mth.sqrt(i * i + j * j) * 8.0f;
f = Mth.clamp(f, -100.0f, 80.0f);
for (int o = -12; o <= 12; ++o) {
for (int p = -12; p <= 12; ++p) {
long q = k + o;
long r = l + p;
if (q * q + r * r <= 4096L || !(simplexNoise.getValue(q, r) < (double)-0.9f)) continue;
float g = (Mth.abs(q) * 3439.0f + Mth.abs(r) * 147.0f) % 13.0f + 9.0f;
float h = m - o * 2;
float s = n - p * 2;
float t = 100.0f - Mth.sqrt(h * h + s * s) * g;
t = Mth.clamp(t, -100.0f, 80.0f);
f = Math.max(f, t);
}
}
return f;
} }
@Override @Override
protected Codec<? extends BiomeSource> codec() { protected Codec<? extends BiomeSource> codec() {
return CODEC; return CODEC;

View file

@ -6,9 +6,10 @@ import net.minecraft.core.Holder;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.resources.RegistryOps; import net.minecraft.resources.RegistryOps;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BiomeTags;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.Biome.BiomeCategory;
import net.minecraft.world.level.biome.BiomeSource; import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.biome.Climate; import net.minecraft.world.level.biome.Climate;
import org.apache.commons.lang3.function.TriFunction; import org.apache.commons.lang3.function.TriFunction;
import ru.bclib.BCLib; import ru.bclib.BCLib;
@ -16,7 +17,6 @@ import ru.bclib.api.biomes.BiomeAPI;
import ru.bclib.config.ConfigKeeper.StringArrayEntry; import ru.bclib.config.ConfigKeeper.StringArrayEntry;
import ru.bclib.config.Configs; import ru.bclib.config.Configs;
import ru.bclib.interfaces.BiomeMap; import ru.bclib.interfaces.BiomeMap;
import ru.bclib.mixin.common.BiomeAccessor;
import ru.bclib.world.biomes.BCLBiome; import ru.bclib.world.biomes.BCLBiome;
import ru.bclib.world.generator.map.MapStack; import ru.bclib.world.generator.map.MapStack;
import ru.bclib.world.generator.map.hex.HexBiomeMap; import ru.bclib.world.generator.map.hex.HexBiomeMap;
@ -31,12 +31,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
.group(RegistryOps .group(RegistryOps
.retrieveRegistry(Registry.BIOME_REGISTRY) .retrieveRegistry(Registry.BIOME_REGISTRY)
.forGetter(source -> source.biomeRegistry) .forGetter(source -> source.biomeRegistry)
,
Codec
.LONG
.fieldOf("seed")
.stable()
.forGetter(source -> source.seed)
) )
.apply(instance, instance.stable(BCLibNetherBiomeSource::new)) .apply(instance, instance.stable(BCLibNetherBiomeSource::new))
); );
@ -66,8 +61,8 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
BCLibNetherBiomeSource.worldHeight = worldHeight; BCLibNetherBiomeSource.worldHeight = worldHeight;
} }
public BCLibNetherBiomeSource(Registry<Biome> biomeRegistry, long seed) { public BCLibNetherBiomeSource(Registry<Biome> biomeRegistry) {
super(biomeRegistry, seed, getBiomes(biomeRegistry)); super(biomeRegistry, getBiomes(biomeRegistry));
BiomeAPI.NETHER_BIOME_PICKER.clearMutables(); BiomeAPI.NETHER_BIOME_PICKER.clearMutables();
@ -93,9 +88,15 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
BiomeAPI.NETHER_BIOME_PICKER.getBiomes().forEach(biome -> biome.updateActualBiomes(biomeRegistry)); BiomeAPI.NETHER_BIOME_PICKER.getBiomes().forEach(biome -> biome.updateActualBiomes(biomeRegistry));
BiomeAPI.NETHER_BIOME_PICKER.rebuild(); BiomeAPI.NETHER_BIOME_PICKER.rebuild();
initMap(); //initMap();
} }
@Override
public void setSeed(long seed) {
super.setSeed(seed);
initMap(seed);
}
private static List<Holder<Biome>> getBiomes(Registry<Biome> biomeRegistry) { private static List<Holder<Biome>> getBiomes(Registry<Biome> biomeRegistry) {
List<String> include = Configs.BIOMES_CONFIG.getEntry("force_include", "nether_biomes", StringArrayEntry.class).getValue(); List<String> include = Configs.BIOMES_CONFIG.getEntry("force_include", "nether_biomes", StringArrayEntry.class).getValue();
@ -109,7 +110,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
return true; return true;
} }
if (GeneratorOptions.addNetherBiomesByCategory() && (biome instanceof BiomeAccessor) && ((BiomeAccessor)(Object)biome).bclib_getBiomeCategory()== BiomeCategory.NETHER) { if (GeneratorOptions.addNetherBiomesByTag() && biome.is(BiomeTags.IS_NETHER)) {
return true; return true;
} }
@ -120,21 +121,19 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
} }
key = bclBiome.getID(); key = bclBiome.getID();
} }
final boolean isNetherBiome; final boolean isNetherBiome = biome.is(BiomeTags.IS_NETHER);
if ((Object)biome instanceof BiomeAccessor bacc) {
isNetherBiome = bacc.bclib_getBiomeCategory() == BiomeCategory.NETHER;
} else {
isNetherBiome = false;
}
return BiomeAPI.NETHER_BIOME_PICKER.containsImmutable(key) || (isNetherBiome && BiomeAPI.isDatapackBiome(key)); return BiomeAPI.NETHER_BIOME_PICKER.containsImmutable(key) || (isNetherBiome && BiomeAPI.isDatapackBiome(key));
}).toList(); }).toList();
} }
@Override @Override
public Holder<Biome> getNoiseBiome(int biomeX, int biomeY, int biomeZ, Climate.Sampler var4) { public Holder<Biome> getNoiseBiome(int biomeX, int biomeY, int biomeZ, Climate.Sampler var4) {
if (biomeMap==null)
return this.possibleBiomes().stream().findFirst().get();
if (lastWorldHeight != worldHeight) { if (lastWorldHeight != worldHeight) {
lastWorldHeight = worldHeight; lastWorldHeight = worldHeight;
initMap(); initMap(this.currentSeed);
} }
if ((biomeX & 63) == 0 && (biomeZ & 63) == 0) { if ((biomeX & 63) == 0 && (biomeZ & 63) == 0) {
biomeMap.clearCache(); biomeMap.clearCache();
@ -142,11 +141,6 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
return biomeMap.getBiome(biomeX << 2, biomeY << 2, biomeZ << 2).getActualBiome(); return biomeMap.getBiome(biomeX << 2, biomeY << 2, biomeZ << 2).getActualBiome();
} }
@Override
public BiomeSource withSeed(long seed) {
return new BCLibNetherBiomeSource(biomeRegistry, seed);
}
@Override @Override
protected Codec<? extends BiomeSource> codec() { protected Codec<? extends BiomeSource> codec() {
return CODEC; return CODEC;
@ -156,7 +150,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
Registry.register(Registry.BIOME_SOURCE, BCLib.makeID("nether_biome_source"), CODEC); Registry.register(Registry.BIOME_SOURCE, BCLib.makeID("nether_biome_source"), CODEC);
} }
private void initMap() { private void initMap(long seed) {
boolean useLegacy = GeneratorOptions.useOldBiomeGenerator() || forceLegacyGenerator; boolean useLegacy = GeneratorOptions.useOldBiomeGenerator() || forceLegacyGenerator;
TriFunction<Long, Integer, BiomePicker, BiomeMap> mapConstructor = useLegacy ? SquareBiomeMap::new : HexBiomeMap::new; TriFunction<Long, Integer, BiomePicker, BiomeMap> mapConstructor = useLegacy ? SquareBiomeMap::new : HexBiomeMap::new;
if (worldHeight > 128 && GeneratorOptions.useVerticalBiomes()) { if (worldHeight > 128 && GeneratorOptions.useVerticalBiomes()) {

View file

@ -8,7 +8,9 @@ import ru.bclib.util.WeightedList;
import ru.bclib.world.biomes.BCLBiome; import ru.bclib.world.biomes.BCLBiome;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
import net.minecraft.world.level.levelgen.WorldgenRandom;
import java.util.Set; import java.util.Set;
public class BiomePicker { public class BiomePicker {
@ -39,7 +41,7 @@ public class BiomePicker {
} }
} }
public BCLBiome getBiome(Random random) { public BCLBiome getBiome(WorldgenRandom random) {
return biomes.isEmpty() ? null : tree.get(random); return biomes.isEmpty() ? null : tree.get(random);
} }

View file

@ -14,8 +14,8 @@ public class GeneratorOptions {
private static Function<Point, Boolean> endLandFunction; private static Function<Point, Boolean> endLandFunction;
private static boolean customNetherBiomeSource = true; private static boolean customNetherBiomeSource = true;
private static boolean customEndBiomeSource = true; private static boolean customEndBiomeSource = true;
private static boolean addNetherBiomesByCategory = false; private static boolean addNetherBiomesByTag = true;
private static boolean addEndBiomesByCategory = false; private static boolean addEndBiomesByTag = true;
private static boolean useOldBiomeGenerator = false; private static boolean useOldBiomeGenerator = false;
private static boolean verticalBiomes = true; private static boolean verticalBiomes = true;
private static long farEndBiomesSqr = 1000000; private static long farEndBiomesSqr = 1000000;
@ -29,8 +29,8 @@ public class GeneratorOptions {
biomeSizeEndVoid = Configs.GENERATOR_CONFIG.getInt("end.biomeMap", "biomeSizeVoid", 256); biomeSizeEndVoid = Configs.GENERATOR_CONFIG.getInt("end.biomeMap", "biomeSizeVoid", 256);
customNetherBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options", "customNetherBiomeSource", true); customNetherBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options", "customNetherBiomeSource", true);
customEndBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options", "customEndBiomeSource", true); customEndBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options", "customEndBiomeSource", true);
addNetherBiomesByCategory = Configs.GENERATOR_CONFIG.getBoolean("options", "addNetherBiomesByCategory", false); addNetherBiomesByTag = Configs.GENERATOR_CONFIG.getBoolean("options", "addNetherBiomesByTag", true);
addEndBiomesByCategory = Configs.GENERATOR_CONFIG.getBoolean("options", "addEndBiomesByCategory", false); addEndBiomesByTag = Configs.GENERATOR_CONFIG.getBoolean("options", "addEndBiomesByTag", true);
useOldBiomeGenerator = Configs.GENERATOR_CONFIG.useOldGenerator(); useOldBiomeGenerator = Configs.GENERATOR_CONFIG.useOldGenerator();
verticalBiomes = Configs.GENERATOR_CONFIG.getBoolean("options", "verticalBiomesInTallNether", true); verticalBiomes = Configs.GENERATOR_CONFIG.getBoolean("options", "verticalBiomesInTallNether", true);
fixEndBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options.biomeSource", "fixEndBiomeSource", true); fixEndBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options.biomeSource", "fixEndBiomeSource", true);
@ -89,12 +89,12 @@ public class GeneratorOptions {
return customEndBiomeSource; return customEndBiomeSource;
} }
public static boolean addNetherBiomesByCategory() { public static boolean addNetherBiomesByTag() {
return addNetherBiomesByCategory; return addNetherBiomesByTag;
} }
public static boolean addEndBiomesByCategory() { public static boolean addEndBiomesByTag() {
return addEndBiomesByCategory; return addEndBiomesByTag;
} }
public static boolean useOldBiomeGenerator() { public static boolean useOldBiomeGenerator() {

View file

@ -9,7 +9,7 @@ import ru.bclib.noise.OpenSimplexNoise;
import ru.bclib.world.biomes.BCLBiome; import ru.bclib.world.biomes.BCLBiome;
import ru.bclib.world.generator.BiomePicker; import ru.bclib.world.generator.BiomePicker;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
public class MapStack implements BiomeMap { public class MapStack implements BiomeMap {
private final OpenSimplexNoise noise; private final OpenSimplexNoise noise;
@ -35,7 +35,7 @@ public class MapStack implements BiomeMap {
} }
noise = new OpenSimplexNoise(random.nextInt()); noise = new OpenSimplexNoise(random.nextInt());
} }
@Override @Override
public void clearCache() { public void clearCache() {
for (BiomeMap map: maps) { for (BiomeMap map: maps) {

View file

@ -5,7 +5,8 @@ import ru.bclib.world.biomes.BCLBiome;
import ru.bclib.world.generator.BiomePicker; import ru.bclib.world.generator.BiomePicker;
import java.util.Arrays; import java.util.Arrays;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
import net.minecraft.world.level.levelgen.WorldgenRandom;
public class HexBiomeChunk implements BiomeChunk { public class HexBiomeChunk implements BiomeChunk {
private static final short SIDE = 32; private static final short SIDE = 32;
@ -22,7 +23,7 @@ public class HexBiomeChunk implements BiomeChunk {
private final BCLBiome[] biomes = new BCLBiome[SIZE]; private final BCLBiome[] biomes = new BCLBiome[SIZE];
public HexBiomeChunk(Random random, BiomePicker picker) { public HexBiomeChunk(WorldgenRandom random, BiomePicker picker) {
BCLBiome[][] buffers = new BCLBiome[2][SIZE]; BCLBiome[][] buffers = new BCLBiome[2][SIZE];
for (BCLBiome[] buffer: buffers) { for (BCLBiome[] buffer: buffers) {

View file

@ -11,7 +11,8 @@ import ru.bclib.world.biomes.BCLBiome;
import ru.bclib.world.generator.BiomePicker; import ru.bclib.world.generator.BiomePicker;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
import net.minecraft.world.level.levelgen.WorldgenRandom;
public class HexBiomeMap implements BiomeMap { public class HexBiomeMap implements BiomeMap {
private static final float RAD_INNER = (float) Math.sqrt(3.0) * 0.5F; private static final float RAD_INNER = (float) Math.sqrt(3.0) * 0.5F;
@ -40,7 +41,7 @@ public class HexBiomeMap implements BiomeMap {
noiseIterations = (byte) Math.min(Math.ceil(Math.log(scale) / Math.log(2)), 5); noiseIterations = (byte) Math.min(Math.ceil(Math.log(scale) / Math.log(2)), 5);
this.seed = random.nextInt(); this.seed = random.nextInt();
} }
@Override @Override
public void clearCache() { public void clearCache() {
if (chunks.size() > 127) { if (chunks.size() > 127) {
@ -77,7 +78,7 @@ public class HexBiomeMap implements BiomeMap {
final ChunkPos pos = new ChunkPos(cx, cz); final ChunkPos pos = new ChunkPos(cx, cz);
HexBiomeChunk chunk = chunks.get(pos); HexBiomeChunk chunk = chunks.get(pos);
if (chunk == null) { if (chunk == null) {
Random random = new Random(MHelper.getSeed(seed, cx, cz)); WorldgenRandom random = new WorldgenRandom(RandomSource.create(MHelper.getSeed(seed, cx, cz)));
chunk = new HexBiomeChunk(random, picker); chunk = new HexBiomeChunk(random, picker);
if (update && processor != null) { if (update && processor != null) {
processor.accept(cx, cz, chunk.getSide()); processor.accept(cx, cz, chunk.getSide());

View file

@ -4,7 +4,8 @@ import ru.bclib.interfaces.BiomeChunk;
import ru.bclib.world.biomes.BCLBiome; import ru.bclib.world.biomes.BCLBiome;
import ru.bclib.world.generator.BiomePicker; import ru.bclib.world.generator.BiomePicker;
import java.util.Random; import java.util.Random;import net.minecraft.util.RandomSource;
import net.minecraft.world.level.levelgen.WorldgenRandom;
public class SquareBiomeChunk implements BiomeChunk { public class SquareBiomeChunk implements BiomeChunk {
private static final int BIT_OFFSET = 4; private static final int BIT_OFFSET = 4;
@ -19,7 +20,7 @@ public class SquareBiomeChunk implements BiomeChunk {
private final BCLBiome[] biomes; private final BCLBiome[] biomes;
public SquareBiomeChunk(Random random, BiomePicker picker) { public SquareBiomeChunk(WorldgenRandom random, BiomePicker picker) {
BCLBiome[] PreBio = new BCLBiome[SM_CAPACITY]; BCLBiome[] PreBio = new BCLBiome[SM_CAPACITY];
biomes = new BCLBiome[CAPACITY]; biomes = new BCLBiome[CAPACITY];
@ -53,7 +54,7 @@ public class SquareBiomeChunk implements BiomeChunk {
return WIDTH; return WIDTH;
} }
private int offsetXZ(int x, Random random) { private int offsetXZ(int x, WorldgenRandom random) {
return ((x + random.nextInt(2)) >> 1) & MASK_OFFSET; return ((x + random.nextInt(2)) >> 1) & MASK_OFFSET;
} }

View file

@ -28,7 +28,6 @@ public class SquareBiomeMap implements BiomeMap {
private TriConsumer<Integer, Integer, Integer> processor; private TriConsumer<Integer, Integer, Integer> processor;
public SquareBiomeMap(long seed, int size, BiomePicker picker) { public SquareBiomeMap(long seed, int size, BiomePicker picker) {
maps.clear();
random = new WorldgenRandom(new LegacyRandomSource(seed)); random = new WorldgenRandom(new LegacyRandomSource(seed));
noiseX = new OpenSimplexNoise(random.nextLong()); noiseX = new OpenSimplexNoise(random.nextLong());
noiseZ = new OpenSimplexNoise(random.nextLong()); noiseZ = new OpenSimplexNoise(random.nextLong());

View file

@ -1,131 +1,132 @@
package ru.bclib.world.structures; package ru.bclib.world.structures;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.core.QuartPos; import net.minecraft.core.QuartPos;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.data.worldgen.StructureSets; import net.minecraft.data.worldgen.StructureSets;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.GenerationStep; import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; import net.minecraft.world.level.levelgen.structure.Structure;
import net.minecraft.world.level.levelgen.feature.StructureFeature; import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
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.configurations.NoneFeatureConfiguration; import net.minecraft.world.level.levelgen.structure.StructureSet;
import net.minecraft.world.level.levelgen.structure.StructureSet; import net.minecraft.world.level.levelgen.structure.pieces.PieceGeneratorSupplier;
import net.minecraft.world.level.levelgen.structure.pieces.PieceGeneratorSupplier; import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement;
import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement; import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadType;
import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadType; import ru.bclib.api.tag.TagAPI;
import ru.bclib.api.tag.TagAPI; import ru.bclib.mixin.common.StructuresAccessor;
import ru.bclib.mixin.common.StructureFeatureAccessor;
import ru.bclib.mixin.common.StructureFeaturesAccessor; import java.util.List;
import java.util.Random;
import java.util.List;
import java.util.Random; public class BCLStructure {
private static final Random RANDOM = new Random(354);
public class BCLStructureFeature {
private static final Random RANDOM = new Random(354); private final Holder<Structure> structure;
private final StructureFeature<NoneFeatureConfiguration> structure; private final GenerationStep.Decoration featureStep;
private final Holder<ConfiguredStructureFeature<?, ?>> featureConfigured; private final List<ResourceLocation> biomes = Lists.newArrayList();
private final GenerationStep.Decoration featureStep; private final ResourceLocation id;
private final List<ResourceLocation> biomes = Lists.newArrayList(); public final TagKey<Biome> biomeTag;
private final ResourceLocation id; public final ResourceKey<Structure> structureKey;
public final TagKey<Biome> biomeTag; public final ResourceKey<StructureSet> structureSetKey;
public final ResourceKey<ConfiguredStructureFeature<?, ?>> structureKey; public final RandomSpreadStructurePlacement spreadConfig;
public final ResourceKey<StructureSet> structureSetKey;
public final RandomSpreadStructurePlacement spreadConfig; public BCLStructure(ResourceLocation id, Structure structure, GenerationStep.Decoration step, int spacing, int separation) {
this(id, structure, step, spacing, separation, false);
public BCLStructureFeature(ResourceLocation id, StructureFeature<NoneFeatureConfiguration> structure, GenerationStep.Decoration step, int spacing, int separation) { }
this(id, structure, step, spacing, separation, false); public BCLStructure(ResourceLocation id, Structure structure, GenerationStep.Decoration step, int spacing, int separation, boolean adaptNoise) {
} this.id = id;
public BCLStructureFeature(ResourceLocation id, StructureFeature<NoneFeatureConfiguration> structure, GenerationStep.Decoration step, int spacing, int separation, boolean adaptNoise) { this.featureStep = step;
this.id = id; //parts from vanilla for Structure generation
this.featureStep = step; //public static final ResourceKey<ConfiguredStructure<?, ?>> JUNGLE_TEMPLE =
//parts from vanilla for Structure generation // BuiltinStructures.createKey("jungle_pyramid");
//public static final ResourceKey<ConfiguredStructureFeature<?, ?>> JUNGLE_TEMPLE = //public static final Holder<ConfiguredStructure<?, ?>> JUNGLE_TEMPLE =
// BuiltinStructures.createKey("jungle_pyramid"); // Structures.register(BuiltinStructures.JUNGLE_TEMPLE, Structure.JUNGLE_TEMPLE.configured(NoneFeatureConfiguration.INSTANCE, BiomeTags.HAS_JUNGLE_TEMPLE));
//public static final Holder<ConfiguredStructureFeature<?, ?>> JUNGLE_TEMPLE = //public static final Holder<StructureSet> JUNGLE_TEMPLES =
// StructureFeatures.register(BuiltinStructures.JUNGLE_TEMPLE, StructureFeature.JUNGLE_TEMPLE.configured(NoneFeatureConfiguration.INSTANCE, BiomeTags.HAS_JUNGLE_TEMPLE)); // StructureSets.register(BuiltinStructureSets.JUNGLE_TEMPLES, Structures.JUNGLE_TEMPLE, new RandomSpreadStructurePlacement(32, 8, RandomSpreadType.LINEAR, 14357619));
//public static final Holder<StructureSet> JUNGLE_TEMPLES = //public static final Structure<NoneFeatureConfiguration> JUNGLE_TEMPLE =
// StructureSets.register(BuiltinStructureSets.JUNGLE_TEMPLES, StructureFeatures.JUNGLE_TEMPLE, new RandomSpreadStructurePlacement(32, 8, RandomSpreadType.LINEAR, 14357619)); // Structure.register("jungle_pyramid", new JunglePyramidFeature(NoneFeatureConfiguration.CODEC), GenerationStep.Decoration.SURFACE_STRUCTURES);
//public static final StructureFeature<NoneFeatureConfiguration> JUNGLE_TEMPLE = //
// StructureFeature.register("jungle_pyramid", new JunglePyramidFeature(NoneFeatureConfiguration.CODEC), GenerationStep.Decoration.SURFACE_STRUCTURES);
// this.spreadConfig = new RandomSpreadStructurePlacement(spacing, separation, RandomSpreadType.LINEAR, RANDOM.nextInt(8192));
this.structureKey = ResourceKey.create(Registry.STRUCTURE_REGISTRY, id);
this.spreadConfig = new RandomSpreadStructurePlacement(spacing, separation, RandomSpreadType.LINEAR, RANDOM.nextInt(8192)); this.structureSetKey = ResourceKey.create(Registry.STRUCTURE_SET_REGISTRY, id);
this.structureKey = ResourceKey.create(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY, id);
this.structureSetKey = ResourceKey.create(Registry.STRUCTURE_SET_REGISTRY, id); this.biomeTag = TagAPI.makeBiomeTag(id.getNamespace(), "has_structure/"+id.getPath());
this.structure = StructuresAccessor.callRegister(structureKey, structure);
this.biomeTag = TagAPI.makeBiomeTag(id.getNamespace(), "has_structure/"+id.getPath()); StructureSets.register(structureSetKey, this.structure, spreadConfig);
this.structure = StructureFeatureAccessor.callRegister(id.toString(), structure, step); }
this.featureConfigured = StructureFeaturesAccessor.callRegister(structureKey, this.structure.configured(NoneFeatureConfiguration.NONE, biomeTag, adaptNoise));
StructureSets.register(structureSetKey, featureConfigured, spreadConfig); /**
} * runs the {@code PieceGeneratorSupplier.Context::validBiome} from the given context at
* height=5 in the middle of the chunk.
/** *
* runs the {@code PieceGeneratorSupplier.Context::validBiome} from the given context at * @param context The context to test with.
* height=5 in the middle of the chunk. * @param <C> The FeatureConfiguration of the Context
* * @return true, if this feature can spawn in the current biome
* @param context The context to test with. */
* @param <C> The FeatureConfiguration of the Context public static <C extends FeatureConfiguration> boolean isValidBiome(PieceGeneratorSupplier.Context<C> context) {
* @return true, if this feature can spawn in the current biome return isValidBiome(context, 5);
*/ }
public static <C extends FeatureConfiguration> boolean isValidBiome(PieceGeneratorSupplier.Context<C> context) { /**
return isValidBiome(context, 5); * runs the {@code PieceGeneratorSupplier.Context::validBiome} from the given context at the
} * given height in the middle of the chunk.
/** *
* runs the {@code PieceGeneratorSupplier.Context::validBiome} from the given context at the * @param context The context to test with.
* given height in the middle of the chunk. * @param yPos The Height to test for
* * @param <C> The FeatureConfiguration of the Context
* @param context The context to test with. * @return true, if this feature can spawn in the current biome
* @param yPos The Height to test for */
* @param <C> The FeatureConfiguration of the Context public static <C extends FeatureConfiguration> boolean isValidBiome(PieceGeneratorSupplier.Context<C> context, int yPos) {
* @return true, if this feature can spawn in the current biome BlockPos blockPos = context.chunkPos().getMiddleBlockPosition(yPos);
*/ return context.validBiome().test(
public static <C extends FeatureConfiguration> boolean isValidBiome(PieceGeneratorSupplier.Context<C> context, int yPos) { context
BlockPos blockPos = context.chunkPos().getMiddleBlockPosition(yPos); .chunkGenerator()
return context.validBiome().test( .getBiomeSource()
context.chunkGenerator().getNoiseBiome(QuartPos.fromBlock(blockPos.getX()), QuartPos.fromBlock(blockPos.getY()), QuartPos.fromBlock(blockPos.getZ())) .getNoiseBiome(
); QuartPos.fromBlock(blockPos.getX()),
} QuartPos.fromBlock(blockPos.getY()),
QuartPos.fromBlock(blockPos.getZ()),
public StructureFeature<NoneFeatureConfiguration> getStructure() { context.randomState().sampler()
return structure; )
} );
}
public Holder<ConfiguredStructureFeature<?, ?>> getFeatureConfigured() {
return featureConfigured; public Holder<Structure> getStructure() {
} return structure;
}
public GenerationStep.Decoration getFeatureStep() {
return featureStep; public GenerationStep.Decoration getFeatureStep() {
} return featureStep;
}
/**
* Get the structure ID; /**
* @return {@link ResourceLocation} id. * Get the structure ID;
*/ * @return {@link ResourceLocation} id.
public ResourceLocation getID() { */
return id; public ResourceLocation getID() {
} return id;
}
/**
* Adds biome into internal biome list, used in {@link ru.bclib.api.biomes.BCLBiomeBuilder}. /**
* @param biome {@link ResourceLocation} biome ID. * Adds biome into internal biome list, used in {@link ru.bclib.api.biomes.BCLBiomeBuilder}.
*/ * @param biome {@link ResourceLocation} biome ID.
public void addInternalBiome(ResourceLocation biome) { */
biomes.add(biome); public void addInternalBiome(ResourceLocation biome) {
} biomes.add(biome);
}
/**
* Get biome list where this structure feature can generate. Only represents biomes made with {@link ru.bclib.api.biomes.BCLBiomeBuilder} and only /**
* if structure was added during building process. Modification of this list will not affect structure generation. * Get biome list where this structure feature can generate. Only represents biomes made with {@link ru.bclib.api.biomes.BCLBiomeBuilder} and only
* @return {@link List} of biome {@link ResourceLocation}. * if structure was added during building process. Modification of this list will not affect structure generation.
*/ * @return {@link List} of biome {@link ResourceLocation}.
public List<ResourceLocation> getBiomes() { */
return biomes; public List<ResourceLocation> getBiomes() {
} return biomes;
} }
}

View file

@ -2,6 +2,7 @@ package ru.bclib.world.surface;
import com.mojang.serialization.Codec; import com.mojang.serialization.Codec;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.util.KeyDispatchDataCodec;
import net.minecraft.world.level.levelgen.SurfaceRules; import net.minecraft.world.level.levelgen.SurfaceRules;
import ru.bclib.BCLib; import ru.bclib.BCLib;
import ru.bclib.api.surface.rules.SurfaceNoiseCondition; import ru.bclib.api.surface.rules.SurfaceNoiseCondition;
@ -12,14 +13,14 @@ import ru.bclib.util.MHelper;
public class DoubleBlockSurfaceNoiseCondition extends SurfaceNoiseCondition { public class DoubleBlockSurfaceNoiseCondition extends SurfaceNoiseCondition {
public static final DoubleBlockSurfaceNoiseCondition CONDITION = new DoubleBlockSurfaceNoiseCondition(0); public static final DoubleBlockSurfaceNoiseCondition CONDITION = new DoubleBlockSurfaceNoiseCondition(0);
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(4141); private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(4141);
public static final Codec<DoubleBlockSurfaceNoiseCondition> CODEC = Codec.DOUBLE.fieldOf("threshold").xmap(DoubleBlockSurfaceNoiseCondition::new, obj -> obj.threshold).codec(); public static final KeyDispatchDataCodec<DoubleBlockSurfaceNoiseCondition> CODEC = KeyDispatchDataCodec.of(Codec.DOUBLE.fieldOf("threshold").xmap(DoubleBlockSurfaceNoiseCondition::new, obj -> obj.threshold).codec());
private final double threshold; private final double threshold;
public DoubleBlockSurfaceNoiseCondition(double threshold){ public DoubleBlockSurfaceNoiseCondition(double threshold){
this.threshold = threshold; this.threshold = threshold;
} }
@Override @Override
public Codec<? extends SurfaceRules.ConditionSource> codec() { public KeyDispatchDataCodec<? extends SurfaceRules.ConditionSource> codec() {
return CODEC; return CODEC;
} }
@ -42,6 +43,6 @@ public class DoubleBlockSurfaceNoiseCondition extends SurfaceNoiseCondition {
} }
static { static {
Registry.register(Registry.CONDITION , BCLib.makeID("doubleblock_surface"), DoubleBlockSurfaceNoiseCondition.CODEC); Registry.register(Registry.CONDITION , BCLib.makeID("doubleblock_surface"), DoubleBlockSurfaceNoiseCondition.CODEC.codec());
} }
} }

View file

@ -9,3 +9,5 @@ accessible class net/minecraft/world/level/levelgen/SurfaceRules$SurfaceRule
accessible class net/minecraft/world/level/levelgen/SurfaceRules$LazyXZCondition accessible class net/minecraft/world/level/levelgen/SurfaceRules$LazyXZCondition
accessible class net/minecraft/world/level/levelgen/SurfaceRules$LazyCondition accessible class net/minecraft/world/level/levelgen/SurfaceRules$LazyCondition
accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource
accessible class net/minecraft/world/level/levelgen/presets/WorldPresets$Bootstrap

View file

@ -11,7 +11,7 @@
"AnvilScreenMixin", "AnvilScreenMixin",
"FogRendererMixin", "FogRendererMixin",
"ModelBakeryMixin", "ModelBakeryMixin",
"WorldPresetMixin", "CreateWorldScreenMixin",
"MinecraftMixin", "MinecraftMixin",
"BlockMixin", "BlockMixin",
"GameMixin" "GameMixin"

View file

@ -13,9 +13,8 @@
"SurfaceRulesContextAccessor", "SurfaceRulesContextAccessor",
"EnchantingTableBlockMixin", "EnchantingTableBlockMixin",
"shears.TripWireBlockMixin", "shears.TripWireBlockMixin",
"StructureFeaturesAccessor", "StructuresAccessor",
"MobSpawnSettingsAccessor", "MobSpawnSettingsAccessor",
"StructureFeatureAccessor",
"shears.BeehiveBlockMixin", "shears.BeehiveBlockMixin",
"shears.PumpkinBlockMixin", "shears.PumpkinBlockMixin",
"shears.MushroomCowMixin", "shears.MushroomCowMixin",
@ -31,7 +30,6 @@
"ChunkGeneratorMixin", "ChunkGeneratorMixin",
"WorldGenRegionMixin", "WorldGenRegionMixin",
"DiggerItemAccessor", "DiggerItemAccessor",
"DimensionTypeMixin",
"RecipeManagerMixin", "RecipeManagerMixin",
"RecipeManagerMixin", "RecipeManagerMixin",
"ShovelItemAccessor", "ShovelItemAccessor",
@ -45,8 +43,11 @@
"AnvilMenuMixin", "AnvilMenuMixin",
"ItemStackMixin", "ItemStackMixin",
"TagLoaderMixin", "TagLoaderMixin",
"BiomeAccessor", "MainMixin",
"MainMixin" "WorldPresetsAccessor",
"WorldPresetsBootstrapMixin",
"WorldOpenFlowsMixin",
"WorldGenPropertiesMixin"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1