Fixed Compile Errors
This commit is contained in:
parent
4ba3a71a68
commit
05eac6f539
79 changed files with 979 additions and 844 deletions
|
@ -7,7 +7,7 @@ import net.minecraft.world.level.block.Block;
|
|||
import ru.bclib.util.WeightedList;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
import java.util.Set;
|
||||
|
||||
public class BonemealAPI {
|
||||
|
@ -111,7 +111,7 @@ public class BonemealAPI {
|
|||
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);
|
||||
WeightedList<Block> list = null;
|
||||
if (map != null) {
|
||||
|
@ -126,7 +126,7 @@ public class BonemealAPI {
|
|||
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);
|
||||
WeightedList<Block> list = null;
|
||||
if (map != null) {
|
||||
|
|
|
@ -50,9 +50,7 @@ public class LifeCycleAPI {
|
|||
LevelStorageSource.LevelStorageAccess levelStorageAccess,
|
||||
ServerLevelData serverLevelData,
|
||||
ResourceKey<Level> resourceKey,
|
||||
Holder<DimensionType> dimensionType,
|
||||
ChunkProgressListener chunkProgressListener,
|
||||
ChunkGenerator chunkGenerator,
|
||||
boolean bl,
|
||||
long l,
|
||||
List<CustomSpawner> list,
|
||||
|
@ -101,9 +99,7 @@ public class LifeCycleAPI {
|
|||
* @param levelStorageAccess
|
||||
* @param serverLevelData
|
||||
* @param resourceKey
|
||||
* @param dimensionType
|
||||
* @param chunkProgressListener
|
||||
* @param chunkGenerator
|
||||
* @param bl
|
||||
* @param l
|
||||
* @param list
|
||||
|
@ -115,9 +111,7 @@ public class LifeCycleAPI {
|
|||
LevelStorageSource.LevelStorageAccess levelStorageAccess,
|
||||
ServerLevelData serverLevelData,
|
||||
ResourceKey<Level> resourceKey,
|
||||
Holder<DimensionType> dimensionType,
|
||||
ChunkProgressListener chunkProgressListener,
|
||||
ChunkGenerator chunkGenerator,
|
||||
boolean bl,
|
||||
long l,
|
||||
List<CustomSpawner> list,
|
||||
|
@ -129,9 +123,7 @@ public class LifeCycleAPI {
|
|||
levelStorageAccess,
|
||||
serverLevelData,
|
||||
resourceKey,
|
||||
dimensionType,
|
||||
chunkProgressListener,
|
||||
chunkGenerator,
|
||||
bl,
|
||||
l,
|
||||
list,
|
||||
|
|
|
@ -19,7 +19,6 @@ import net.minecraft.world.level.biome.AmbientMoodSettings;
|
|||
import net.minecraft.world.level.biome.AmbientParticleSettings;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
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.BiomeGenerationSettings;
|
||||
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.BCLBiomeSettings;
|
||||
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.List;
|
||||
|
@ -67,7 +66,8 @@ public class BCLBiomeBuilder {
|
|||
private SurfaceRules.RuleSource surfaceRule;
|
||||
private Precipitation precipitation;
|
||||
private ResourceLocation biomeID;
|
||||
private BiomeCategory category;
|
||||
|
||||
//BiomeTags.IS_NETHER
|
||||
private float temperature;
|
||||
private float fogDensity;
|
||||
private float genChance;
|
||||
|
@ -86,7 +86,6 @@ public class BCLBiomeBuilder {
|
|||
public static BCLBiomeBuilder start(ResourceLocation biomeID) {
|
||||
INSTANCE.biomeID = biomeID;
|
||||
INSTANCE.precipitation = Precipitation.NONE;
|
||||
INSTANCE.category = BiomeCategory.NONE;
|
||||
INSTANCE.generationSettings = null;
|
||||
INSTANCE.effectsBuilder = null;
|
||||
INSTANCE.spawnSettings = null;
|
||||
|
@ -113,16 +112,6 @@ public class BCLBiomeBuilder {
|
|||
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.
|
||||
* @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.
|
||||
* @param structure {@link BCLStructureFeature} to add.
|
||||
* @param structure {@link BCLStructure} to add.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder structure(BCLStructureFeature structure) {
|
||||
public BCLBiomeBuilder structure(BCLStructure structure) {
|
||||
structure.addInternalBiome(biomeID);
|
||||
return structure(structure.biomeTag);
|
||||
}
|
||||
|
@ -685,7 +674,6 @@ public class BCLBiomeBuilder {
|
|||
public <T extends BCLBiome> T build(BiomeSupplier<T> biomeConstructor) {
|
||||
BiomeBuilder builder = new BiomeBuilder()
|
||||
.precipitation(precipitation)
|
||||
.biomeCategory(category)
|
||||
.temperature(temperature)
|
||||
.downfall(downfall);
|
||||
|
||||
|
|
|
@ -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.carver.ConfiguredWorldCarver;
|
||||
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.placement.PlacedFeature;
|
||||
import org.apache.commons.lang3.mutable.MutableInt;
|
||||
|
@ -72,7 +71,9 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
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.function.BiConsumer;
|
||||
import java.util.function.Supplier;
|
||||
|
@ -836,9 +837,9 @@ public class BiomeAPI {
|
|||
|
||||
static class StructureID {
|
||||
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.structure = structure;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.CommonComponents;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import ru.bclib.BCLib;
|
||||
import ru.bclib.api.dataexchange.DataExchangeAPI;
|
||||
|
|
|
@ -156,10 +156,21 @@ public class DataFixerAPI {
|
|||
*/
|
||||
public static void initializeWorldData(LevelStorageSource levelSource, String levelID, boolean newWorld) {
|
||||
wrapCall(levelSource, levelID, (levelStorageAccess) -> {
|
||||
initializeWorldData(levelStorageAccess.getLevelPath(LevelResource.ROOT).toFile(), newWorld);
|
||||
initializeWorldData(levelStorageAccess, newWorld);
|
||||
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
|
||||
|
|
|
@ -8,7 +8,7 @@ import net.minecraft.world.level.LevelAccessor;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
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> {
|
||||
private final SpawnRule rule;
|
||||
|
@ -19,7 +19,7 @@ public class SpawnRuleEntry<M extends Mob> implements Comparable<SpawnRuleEntry>
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.bclib.api.surface.rules;
|
|||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.util.KeyDispatchDataCodec;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.SurfaceRules.Context;
|
||||
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)
|
||||
).apply(instance, SwitchRuleSource::new));
|
||||
|
||||
private static final KeyDispatchDataCodec<? extends RuleSource> KEY_CODEC = KeyDispatchDataCodec.of(SwitchRuleSource.CODEC);
|
||||
|
||||
@Override
|
||||
public Codec<? extends RuleSource> codec() {
|
||||
return SwitchRuleSource.CODEC;
|
||||
public KeyDispatchDataCodec<? extends RuleSource> codec() {
|
||||
return KEY_CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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.ConditionSource;
|
||||
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;
|
||||
|
||||
public abstract class VolumeNoiseCondition implements NoiseCondition{
|
||||
public abstract Codec<? extends ConditionSource> codec();
|
||||
public abstract KeyDispatchDataCodec<? extends ConditionSource> codec();
|
||||
|
||||
@Override
|
||||
public final Condition apply(Context context2) {
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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 static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION;
|
||||
|
@ -118,7 +118,7 @@ public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelPro
|
|||
return 3;
|
||||
}
|
||||
|
||||
public BlockState damageAnvilUse(BlockState state, Random random) {
|
||||
public BlockState damageAnvilUse(BlockState state, RandomSource random) {
|
||||
IntegerProperty durability = getDurabilityProp();
|
||||
int value = state.getValue(durability);
|
||||
if (value < getMaxDurability() && random.nextInt(8) == 0) {
|
||||
|
|
|
@ -37,7 +37,7 @@ import ru.bclib.registry.BaseBlockEntities;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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 BaseBarrelBlock(Block source) {
|
||||
|
@ -79,7 +79,7 @@ public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
|||
}
|
||||
|
||||
@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);
|
||||
if (blockEntity instanceof BaseBarrelBlockEntity) {
|
||||
((BaseBarrelBlockEntity) blockEntity).tick();
|
||||
|
|
|
@ -27,7 +27,7 @@ import ru.bclib.util.MHelper;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
|
||||
public class BaseCropBlock extends BasePlantBlock {
|
||||
public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 3);
|
||||
|
@ -41,13 +41,14 @@ public class BaseCropBlock extends BasePlantBlock {
|
|||
FabricBlockSettings.of(Material.PLANT)
|
||||
.sound(SoundType.GRASS)
|
||||
.randomTicks()
|
||||
.noCollission(),
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.NONE),
|
||||
drop, terrain
|
||||
);
|
||||
}
|
||||
|
||||
public BaseCropBlock(BlockBehaviour.Properties properties, Item drop, Block... terrain) {
|
||||
super(properties);
|
||||
super(properties.offsetType(BlockBehaviour.OffsetType.NONE));
|
||||
this.drop = drop;
|
||||
this.terrain = terrain;
|
||||
this.registerDefaultState(defaultBlockState().setValue(AGE, 0));
|
||||
|
@ -88,15 +89,10 @@ public class BaseCropBlock extends BasePlantBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BlockBehaviour.OffsetType getOffsetType() {
|
||||
return BlockBehaviour.OffsetType.NONE;
|
||||
}
|
||||
|
||||
@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);
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
@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);
|
||||
if (isBonemealSuccess(world, random, pos, state) && random.nextInt(8) == 0) {
|
||||
performBonemeal(world, random, pos, state);
|
||||
|
|
|
@ -35,7 +35,7 @@ import ru.bclib.items.tool.BaseShearsItem;
|
|||
import ru.bclib.util.BlocksHelper;
|
||||
|
||||
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 {
|
||||
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)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -56,6 +57,7 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements R
|
|||
.sound(SoundType.GRASS)
|
||||
.lightLevel((state) -> state.getValue(TOP) ? light : 0)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -75,12 +77,7 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements R
|
|||
Vec3 vec3d = state.getOffset(view, pos);
|
||||
return SHAPE.move(vec3d.x, vec3d.y, vec3d.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBehaviour.OffsetType getOffsetType() {
|
||||
return BlockBehaviour.OffsetType.XZ;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
||||
|
@ -138,20 +135,20 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements R
|
|||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@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(
|
||||
world,
|
||||
level,
|
||||
pos.getX() + 0.5,
|
||||
pos.getY() + 0.5,
|
||||
pos.getZ() + 0.5,
|
||||
new ItemStack(this)
|
||||
);
|
||||
world.addFreshEntity(item);
|
||||
level.addFreshEntity(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,7 +11,7 @@ import net.minecraft.world.item.TieredItem;
|
|||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
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.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
|
@ -26,7 +26,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
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 int minCount;
|
||||
private final int maxCount;
|
||||
|
|
|
@ -39,7 +39,7 @@ import ru.bclib.items.tool.BaseShearsItem;
|
|||
|
||||
import java.util.List;
|
||||
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{
|
||||
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)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -68,11 +69,12 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL
|
|||
.luminance(light)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ)
|
||||
);
|
||||
}
|
||||
|
||||
public BasePlantBlock(Properties settings) {
|
||||
super(settings);
|
||||
super(settings.offsetType(BlockBehaviour.OffsetType.XZ));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBehaviour.OffsetType getOffsetType() {
|
||||
return BlockBehaviour.OffsetType.XZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
||||
|
@ -133,20 +130,20 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL
|
|||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@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(
|
||||
world,
|
||||
level,
|
||||
pos.getX() + 0.5,
|
||||
pos.getY() + 0.5,
|
||||
pos.getZ() + 0.5,
|
||||
new ItemStack(this)
|
||||
);
|
||||
world.addFreshEntity(item);
|
||||
level.addFreshEntity(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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.material.Material;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
|
||||
public abstract class BasePlantWithAgeBlock extends BasePlantBlock {
|
||||
public static final IntegerProperty AGE = BlockProperties.AGE;
|
||||
|
@ -35,27 +35,27 @@ public abstract class BasePlantWithAgeBlock extends BasePlantBlock {
|
|||
stateManager.add(AGE);
|
||||
}
|
||||
|
||||
public abstract void growAdult(WorldGenLevel world, Random random, BlockPos pos);
|
||||
public abstract void growAdult(WorldGenLevel world, RandomSource random, BlockPos pos);
|
||||
|
||||
@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);
|
||||
if (age < 3) {
|
||||
world.setBlockAndUpdate(pos, state.setValue(AGE, age + 1));
|
||||
level.setBlockAndUpdate(pos, state.setValue(AGE, age + 1));
|
||||
}
|
||||
else {
|
||||
growAdult(world, random, pos);
|
||||
growAdult(level, random, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Override
|
||||
@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);
|
||||
if (random.nextInt(8) == 0) {
|
||||
performBonemeal(world, random, pos, state);
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.minecraft.server.level.ServerLevel;
|
|||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -43,7 +44,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BaseTerrainBlock extends BaseBlock {
|
||||
|
@ -95,7 +96,7 @@ public class BaseTerrainBlock extends BaseBlock {
|
|||
}
|
||||
|
||||
@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)) {
|
||||
world.setBlockAndUpdate(pos, getBaseBlock().defaultBlockState());
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import ru.bclib.items.tool.BaseShearsItem;
|
|||
import ru.bclib.util.BlocksHelper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock {
|
||||
|
@ -56,11 +56,12 @@ public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvid
|
|||
.sound(SoundType.GRASS)
|
||||
.lightLevel((state) -> bottomOnly ? state.getValue(SHAPE) == TripleShape.BOTTOM ? light : 0 : light)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ)
|
||||
);
|
||||
}
|
||||
|
||||
public BaseVineBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
super(properties.offsetType(BlockBehaviour.OffsetType.XZ));
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBehaviour.OffsetType getOffsetType() {
|
||||
return BlockBehaviour.OffsetType.XZ;
|
||||
}
|
||||
|
||||
public boolean canGenerate(BlockState state, LevelReader world, BlockPos pos) {
|
||||
return isSupport(state, world, pos);
|
||||
}
|
||||
|
@ -134,19 +130,19 @@ public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvid
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
|
||||
while (world.getBlockState(pos).getBlock() == this) {
|
||||
public boolean isBonemealSuccess(Level level, RandomSource random, BlockPos pos, BlockState state) {
|
||||
while (level.getBlockState(pos).getBlock() == this) {
|
||||
pos = pos.below();
|
||||
}
|
||||
return world.isEmptyBlock(pos);
|
||||
return level.isEmptyBlock(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
|
||||
while (world.getBlockState(pos).getBlock() == this) {
|
||||
public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) {
|
||||
while (level.getBlockState(pos).getBlock() == this) {
|
||||
pos = pos.below();
|
||||
}
|
||||
world.setBlockAndUpdate(pos, defaultBlockState());
|
||||
BlocksHelper.setWithoutUpdate(world, pos, defaultBlockState());
|
||||
level.setBlockAndUpdate(pos, defaultBlockState());
|
||||
BlocksHelper.setWithoutUpdate(level, pos, defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ public abstract class BaseWallPlantBlock extends BasePlantBlock {
|
|||
.of(Material.PLANT)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission()
|
||||
.offsetType( BlockBehaviour.OffsetType.NONE)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -51,11 +52,12 @@ public abstract class BaseWallPlantBlock extends BasePlantBlock {
|
|||
.luminance(light)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission()
|
||||
.offsetType( BlockBehaviour.OffsetType.NONE)
|
||||
);
|
||||
}
|
||||
|
||||
public BaseWallPlantBlock(Properties settings) {
|
||||
super(settings);
|
||||
super(settings.offsetType( BlockBehaviour.OffsetType.NONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,11 +70,6 @@ public abstract class BaseWallPlantBlock extends BasePlantBlock {
|
|||
return SHAPES.get(state.getValue(FACING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBehaviour.OffsetType getOffsetType() {
|
||||
return BlockBehaviour.OffsetType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
||||
Direction direction = state.getValue(FACING);
|
||||
|
|
|
@ -35,7 +35,7 @@ import ru.bclib.interfaces.RenderLayerProvider;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class FeatureSaplingBlock extends SaplingBlock implements RenderLayerProvider, BlockModelProvider {
|
||||
|
@ -84,12 +84,12 @@ public class FeatureSaplingBlock extends SaplingBlock implements RenderLayerProv
|
|||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@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(
|
||||
Optional.empty(),
|
||||
world,
|
||||
|
@ -102,12 +102,12 @@ public class FeatureSaplingBlock extends SaplingBlock implements RenderLayerProv
|
|||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@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);
|
||||
if (isBonemealSuccess(world, random, pos, state)) {
|
||||
performBonemeal(world, random, pos, state);
|
||||
|
|
|
@ -35,7 +35,7 @@ import ru.bclib.client.models.PatternsHelper;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
|
||||
public class TripleTerrainBlock extends BaseTerrainBlock {
|
||||
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
||||
|
@ -72,7 +72,7 @@ public class TripleTerrainBlock extends BaseTerrainBlock {
|
|||
}
|
||||
|
||||
@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);
|
||||
if (shape == TripleShape.BOTTOM) {
|
||||
super.randomTick(state, world, pos, random);
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
|
@ -34,7 +35,7 @@ import ru.bclib.interfaces.RenderLayerProvider;
|
|||
import ru.bclib.items.tool.BaseShearsItem;
|
||||
|
||||
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 {
|
||||
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)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -55,6 +57,7 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
|
|||
.luminance(light)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBehaviour.OffsetType getOffsetType() {
|
||||
return BlockBehaviour.OffsetType.XZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
||||
|
@ -121,20 +119,20 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
|
|||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@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(
|
||||
world,
|
||||
level,
|
||||
pos.getX() + 0.5,
|
||||
pos.getY() + 0.5,
|
||||
pos.getZ() + 0.5,
|
||||
new ItemStack(this)
|
||||
);
|
||||
world.addFreshEntity(item);
|
||||
level.addFreshEntity(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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.material.Material;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
|
||||
public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock {
|
||||
public static final IntegerProperty AGE = BlockProperties.AGE;
|
||||
|
@ -31,10 +31,10 @@ public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock {
|
|||
stateManager.add(AGE);
|
||||
}
|
||||
|
||||
public abstract void grow(WorldGenLevel world, Random random, BlockPos pos);
|
||||
public abstract void grow(WorldGenLevel world, RandomSource random, BlockPos pos);
|
||||
|
||||
@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) {
|
||||
int age = state.getValue(AGE);
|
||||
if (age < 3) {
|
||||
|
@ -48,7 +48,7 @@ public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock {
|
|||
|
||||
@Override
|
||||
@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);
|
||||
if (isBonemealSuccess(world, random, pos, state)) {
|
||||
performBonemeal(world, random, pos, state);
|
||||
|
|
|
@ -41,11 +41,11 @@ public class CustomModelBakery {
|
|||
Registry.BLOCK.stream().parallel().filter(block -> block instanceof BlockModelProvider).forEach(block -> {
|
||||
ResourceLocation blockID = Registry.BLOCK.getKey(block);
|
||||
ResourceLocation storageID = new ResourceLocation(blockID.getNamespace(), "blockstates/" + blockID.getPath() + ".json");
|
||||
if (!resourceManager.hasResource(storageID)) {
|
||||
if (resourceManager.getResource(storageID).isEmpty()) {
|
||||
addBlockModel(blockID, block);
|
||||
}
|
||||
storageID = new ResourceLocation(blockID.getNamespace(), "models/item/" + blockID.getPath() + ".json");
|
||||
if (!resourceManager.hasResource(storageID)) {
|
||||
if (resourceManager.getResource(storageID).isEmpty()) {
|
||||
addItemModel(blockID, (ItemModelProvider) block);
|
||||
}
|
||||
});
|
||||
|
@ -53,7 +53,7 @@ public class CustomModelBakery {
|
|||
Registry.ITEM.stream().parallel().filter(item -> item instanceof ItemModelProvider).forEach(item -> {
|
||||
ResourceLocation registryID = Registry.ITEM.getKey(item);
|
||||
ResourceLocation storageID = new ResourceLocation(registryID.getNamespace(), "models/item/" + registryID.getPath() + ".json");
|
||||
if (!resourceManager.hasResource(storageID)) {
|
||||
if (resourceManager.getResource(storageID).isEmpty()) {
|
||||
addItemModel(registryID, (ItemModelProvider) item);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -22,6 +22,8 @@ import net.minecraft.resources.ResourceLocation;
|
|||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import ru.bclib.BCLib;
|
||||
import ru.bclib.util.BlocksHelper;
|
||||
import ru.bclib.util.MHelper;
|
||||
|
||||
|
@ -34,7 +36,7 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
@ -108,7 +110,7 @@ public class OBJBlockModel implements UnbakedModel, BakedModel {
|
|||
// Baked Model //
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
|
@ -148,23 +150,7 @@ public class OBJBlockModel implements UnbakedModel, BakedModel {
|
|||
}
|
||||
|
||||
private Resource getResource(ResourceLocation location) {
|
||||
Resource resource = 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;
|
||||
return Minecraft.getInstance().getResourceManager().getResource(location).orElse(null);
|
||||
}
|
||||
|
||||
private void loadModel(ResourceLocation location, Vector3f offset, byte maxIndex) {
|
||||
|
@ -172,8 +158,14 @@ public class OBJBlockModel implements UnbakedModel, BakedModel {
|
|||
if (resource == null) {
|
||||
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> uvs = new ArrayList<>(8);
|
||||
|
||||
|
@ -265,7 +257,6 @@ public class OBJBlockModel implements UnbakedModel, BakedModel {
|
|||
reader.close();
|
||||
streamReader.close();
|
||||
input.close();
|
||||
resource.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.bclib.client.models;
|
|||
import com.google.common.collect.Maps;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@ -53,7 +54,10 @@ public class PatternsHelper {
|
|||
|
||||
public static Optional<String> createJson(ResourceLocation patternId, Map<String, String> textures) {
|
||||
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);
|
||||
if (json == null) {
|
||||
json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines().collect(Collectors.joining());
|
||||
|
|
|
@ -2,6 +2,7 @@ package ru.bclib.gui.modmenu;
|
|||
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.CommonComponents;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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);
|
||||
}
|
||||
|
||||
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() );
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import net.fabricmc.api.EnvType;
|
|||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
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.GridLayout;
|
||||
|
@ -31,12 +31,12 @@ public class LevelFixErrorScreen extends BCLibScreen {
|
|||
row.addSpacer(10);
|
||||
GridColumn col = row.addColumn(300, GridLayout.GridValueType.CONSTANT);
|
||||
for (String error : errors){
|
||||
TextComponent dash = new TextComponent("-");
|
||||
Component dash = Component.literal("-");
|
||||
row = col.addRow();
|
||||
row.addString(dash, this);
|
||||
|
||||
row.addSpacer(4);
|
||||
row.addString(new TextComponent(error), this);
|
||||
row.addString(Component.literal(error), this);
|
||||
}
|
||||
|
||||
grid.addSpacerRow(8);
|
||||
|
|
|
@ -6,7 +6,6 @@ import net.fabricmc.loader.api.metadata.ModEnvironment;
|
|||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.CommonComponents;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import ru.bclib.api.dataexchange.handler.autosync.HelloClient;
|
||||
import ru.bclib.gui.gridlayout.GridColumn;
|
||||
import ru.bclib.gui.gridlayout.GridLayout;
|
||||
|
@ -177,14 +176,14 @@ public class ModListScreen extends BCLibScreen {
|
|||
color = GridLayout.COLOR_DARK_GREEN;
|
||||
typeText = "[OK]";
|
||||
}
|
||||
TextComponent dash = new TextComponent("-");
|
||||
TextComponent typeTextComponent = new TextComponent(typeText);
|
||||
Component dash = Component.literal("-");
|
||||
Component typeTextComponent = Component.literal(typeText);
|
||||
GridRow row = grid.addRow();
|
||||
|
||||
row.addString(dash, parent);
|
||||
|
||||
row.addSpacer(4);
|
||||
row.addString(new TextComponent(name), parent);
|
||||
row.addString(Component.literal(name), parent);
|
||||
|
||||
row.addSpacer(4);
|
||||
row.addString(typeTextComponent, color, parent);
|
||||
|
@ -192,7 +191,7 @@ public class ModListScreen extends BCLibScreen {
|
|||
if (!stateString.isEmpty()) {
|
||||
row = grid.addRow();
|
||||
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();
|
||||
|
|
|
@ -7,7 +7,6 @@ import net.minecraft.client.gui.GuiComponent;
|
|||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.ProgressListener;
|
||||
|
@ -161,7 +160,7 @@ public class ProgressScreen extends GridScreen implements ProgressListener, Atom
|
|||
|
||||
grid.addSpacerRow(20);
|
||||
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
|
||||
|
|
|
@ -6,9 +6,9 @@ import net.minecraft.world.entity.Mob;
|
|||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
|
||||
@FunctionalInterface
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import net.fabricmc.api.Environment;
|
|||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
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.block.state.BlockState;
|
||||
|
@ -46,7 +46,7 @@ public interface SurvivesOnSpecialGround {
|
|||
for (int i = 0; i < Math.min(lines.size(), MAX_LINES); i++) {
|
||||
String line = lines.get(i);
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.ItemCombinerScreen;
|
||||
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.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
|
@ -40,8 +40,8 @@ public class AnvilScreenMixin extends ItemCombinerScreen<AnvilMenu> {
|
|||
int x = (width - imageWidth) / 2;
|
||||
int y = (height - imageHeight) / 2;
|
||||
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 + 154, y + 45, 15, 20, new TextComponent(">"), b -> be_nextRecipe()));
|
||||
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, Component.literal(">"), b -> be_nextRecipe()));
|
||||
}
|
||||
|
||||
@Inject(method = "renderFg", at = @At("TAIL"))
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package ru.bclib.mixin.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Minecraft.ExperimentalDialogType;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@ public class MultiPackResourceManagerMixin {
|
|||
}
|
||||
|
||||
ResourceManager resourceManager = this.namespacedManagers.get(resourceLocation.getNamespace());
|
||||
if (resourceManager != null && !resourceManager.hasResource(resourceLocation)) {
|
||||
info.setReturnValue(resourceManager.getResource(bclib_alphaEmissionMaterial));
|
||||
if (resourceManager != null && resourceManager.getResource(resourceLocation).isEmpty()) {
|
||||
info.setReturnValue(resourceManager.getResource(bclib_alphaEmissionMaterial).get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import ru.bclib.BCLib;
|
|||
import ru.bclib.client.render.EmissiveTextureInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(TextureAtlas.class)
|
||||
public class TextureAtlasMixin {
|
||||
|
@ -47,7 +48,8 @@ public class TextureAtlasMixin {
|
|||
location.getNamespace(),
|
||||
"textures/" + location.getPath() + "_e.png"
|
||||
);
|
||||
if (resourceManager.hasResource(emissiveLocation)) {
|
||||
Optional<Resource> emissiveRes = resourceManager.getResource(emissiveLocation);
|
||||
if (emissiveRes.isPresent()) {
|
||||
NativeImage sprite = null;
|
||||
NativeImage emission = null;
|
||||
try {
|
||||
|
@ -55,13 +57,13 @@ public class TextureAtlasMixin {
|
|||
location.getNamespace(),
|
||||
"textures/" + location.getPath() + ".png"
|
||||
);
|
||||
Resource resource = resourceManager.getResource(spriteLocation);
|
||||
sprite = NativeImage.read(resource.getInputStream());
|
||||
resource.close();
|
||||
Resource resource = resourceManager.getResource(spriteLocation).orElse(null);
|
||||
sprite = NativeImage.read(resource.open());
|
||||
sprite.close();
|
||||
|
||||
resource = resourceManager.getResource(emissiveLocation);
|
||||
emission = NativeImage.read(resource.getInputStream());
|
||||
resource.close();
|
||||
resource = emissiveRes.get();
|
||||
emission = NativeImage.read(resource.open());
|
||||
emission.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
BCLib.LOGGER.warning(e.getMessage());
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
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.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
|
@ -26,7 +26,7 @@ public class ChunkGeneratorMixin implements ChunkGeneratorAccessor {
|
|||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,14 @@ import com.mojang.serialization.Lifecycle;
|
|||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
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.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||
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.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
@ -20,43 +24,44 @@ import java.util.OptionalInt;
|
|||
|
||||
@Mixin(DimensionType.class)
|
||||
public class DimensionTypeMixin {
|
||||
@Inject(
|
||||
method = "defaultDimensions(Lnet/minecraft/core/RegistryAccess;JZ)Lnet/minecraft/core/Registry;",
|
||||
locals = LocalCapture.CAPTURE_FAILHARD,
|
||||
at = @At("TAIL")
|
||||
)
|
||||
// @Inject(
|
||||
// method = "defaultDimensions(Lnet/minecraft/core/RegistryAccess;JZ)Lnet/minecraft/core/Registry;",
|
||||
// locals = LocalCapture.CAPTURE_FAILHARD,
|
||||
// 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) {
|
||||
int id = writableRegistry.getId(writableRegistry.get(LevelStem.NETHER));
|
||||
writableRegistry.registerOrOverride(
|
||||
OptionalInt.of(id),
|
||||
LevelStem.NETHER,
|
||||
new LevelStem(
|
||||
registry.getOrCreateHolder(DimensionType.NETHER_LOCATION),
|
||||
new NoiseBasedChunkGenerator(
|
||||
structureRegistry,
|
||||
noiseParamRegistry,
|
||||
new BCLibNetherBiomeSource(biomeRegistry, seed),
|
||||
seed,
|
||||
noiseSettingsRegistry.getOrCreateHolder(NoiseGeneratorSettings.NETHER))
|
||||
),
|
||||
Lifecycle.stable()
|
||||
);
|
||||
|
||||
|
||||
id = writableRegistry.getId(writableRegistry.get(LevelStem.END));
|
||||
writableRegistry.registerOrOverride(
|
||||
OptionalInt.of(id),
|
||||
LevelStem.END,
|
||||
new LevelStem(
|
||||
registry.getOrCreateHolder(DimensionType.END_LOCATION),
|
||||
new NoiseBasedChunkGenerator(
|
||||
structureRegistry,
|
||||
noiseParamRegistry,
|
||||
new BCLibEndBiomeSource(biomeRegistry, seed),
|
||||
seed,
|
||||
noiseSettingsRegistry.getOrCreateHolder(NoiseGeneratorSettings.END))
|
||||
),
|
||||
Lifecycle.stable()
|
||||
);
|
||||
//This probably moved to WorldPresets.bootstrap();
|
||||
// int id = writableRegistry.getId(writableRegistry.get(LevelStem.NETHER));
|
||||
// writableRegistry.registerOrOverride(
|
||||
// OptionalInt.of(id),
|
||||
// LevelStem.NETHER,
|
||||
// new LevelStem(
|
||||
// registry.getOrCreateHolder(BuiltinDimensionTypes.NETHER),
|
||||
// new NoiseBasedChunkGenerator(
|
||||
// structureRegistry,
|
||||
// noiseParamRegistry,
|
||||
// new BCLibNetherBiomeSource(biomeRegistry, seed),
|
||||
// seed,
|
||||
// noiseSettingsRegistry.getOrCreateHolder(NoiseGeneratorSettings.NETHER))
|
||||
// ),
|
||||
// Lifecycle.stable()
|
||||
// );
|
||||
//
|
||||
//
|
||||
// id = writableRegistry.getId(writableRegistry.get(LevelStem.END));
|
||||
// writableRegistry.registerOrOverride(
|
||||
// OptionalInt.of(id),
|
||||
// LevelStem.END,
|
||||
// new LevelStem(
|
||||
// registry.getOrCreateHolder(BuiltinDimensionTypes.END),
|
||||
// new NoiseBasedChunkGenerator(
|
||||
// structureRegistry,
|
||||
// noiseParamRegistry,
|
||||
// new BCLibEndBiomeSource(biomeRegistry, seed),
|
||||
// seed,
|
||||
// noiseSettingsRegistry.getOrCreateHolder(NoiseGeneratorSettings.END))
|
||||
// ),
|
||||
// Lifecycle.stable()
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,18 +3,14 @@ package ru.bclib.mixin.common;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
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.Climate;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.levelgen.Aquifer;
|
||||
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.*;
|
||||
import net.minecraft.world.level.levelgen.blending.Blender;
|
||||
import net.minecraft.world.level.levelgen.carver.CarvingContext;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
|
@ -29,12 +25,6 @@ import java.util.Optional;
|
|||
|
||||
@Mixin(NoiseBasedChunkGenerator.class)
|
||||
public abstract class NoiseBasedChunkGeneratorMixin implements SurfaceProvider, NoiseGeneratorSettingsProvider {
|
||||
@Final
|
||||
@Shadow
|
||||
private Climate.Sampler sampler;
|
||||
|
||||
@Shadow @Final private NoiseRouter router;
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
protected Holder<NoiseGeneratorSettings> settings;
|
||||
|
@ -50,33 +40,23 @@ public abstract class NoiseBasedChunkGeneratorMixin implements SurfaceProvider,
|
|||
public NoiseGeneratorSettings bclib_getNoiseGeneratorSettings(){
|
||||
return settings.value();
|
||||
}
|
||||
|
||||
|
||||
@Shadow protected abstract NoiseChunk createNoiseChunk(ChunkAccess chunkAccess,
|
||||
StructureManager structureManager,
|
||||
Blender blender,
|
||||
RandomState randomState);
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockState bclib_getSurface(BlockPos pos, Holder<Biome> biome, ServerLevel level) {
|
||||
ChunkAccess chunkAccess = level.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
||||
StructureFeatureManager structureFeatureManager = level.structureFeatureManager();
|
||||
StructureManager structureManager = level.structureManager();
|
||||
NoiseBasedChunkGenerator generator = NoiseBasedChunkGenerator.class.cast(this);
|
||||
if (bclib_constructor == null) {
|
||||
bclib_constructor = Beardifier.class.getConstructors()[0];
|
||||
bclib_constructor.setAccessible(true);
|
||||
}
|
||||
|
||||
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);
|
||||
RandomState randomState = level.getChunkSource().randomState();
|
||||
|
||||
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());
|
||||
Optional<BlockState> optional = carvingContext.topMaterial(bpos -> biome, chunkAccess, pos, false);
|
||||
return optional.isPresent() ? optional.get() : bclib_air;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import net.minecraft.util.profiling.ProfilerFiller;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
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.ServerLevelData;
|
||||
import net.minecraft.world.level.storage.WritableLevelData;
|
||||
|
@ -27,15 +29,34 @@ import java.util.function.Supplier;
|
|||
@Mixin(ServerLevel.class)
|
||||
public abstract class ServerLevelMixin extends Level {
|
||||
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) {
|
||||
super(writableLevelData, resourceKey, dimensionType, supplier, bl, bl2, l);
|
||||
|
||||
protected ServerLevelMixin(WritableLevelData writableLevelData,
|
||||
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"))
|
||||
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);
|
||||
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));
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
|
@ -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");
|
||||
}
|
||||
}
|
16
src/main/java/ru/bclib/mixin/common/StructuresAccessor.java
Normal file
16
src/main/java/ru/bclib/mixin/common/StructuresAccessor.java
Normal 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");
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
80
src/main/java/ru/bclib/mixin/common/WorldOpenFlowsMixin.java
Normal file
80
src/main/java/ru/bclib/mixin/common/WorldOpenFlowsMixin.java
Normal 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();
|
||||
}
|
||||
}
|
|
@ -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");
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ package ru.bclib.noise;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import ru.bclib.util.MHelper;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
|
||||
public class VoronoiNoise {
|
||||
private static final Random RANDOM = new Random();
|
||||
|
|
|
@ -37,7 +37,7 @@ public class BCLRecipeManager {
|
|||
});
|
||||
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) {
|
||||
|
|
|
@ -15,7 +15,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
|
||||
public class BlocksHelper {
|
||||
private static final Map<Block, Integer> COLOR_BY_BLOCK = Maps.newHashMap();
|
||||
|
|
|
@ -3,7 +3,7 @@ package ru.bclib.util;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
|
||||
public class ColorExtractor {
|
||||
private List<Center> centers = new ArrayList<>();
|
||||
|
|
|
@ -233,9 +233,10 @@ public class ColorUtil {
|
|||
public static NativeImage loadImage(ResourceLocation image, int w, int h) {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
ResourceManager resourceManager = minecraft.getResourceManager();
|
||||
if (resourceManager.hasResource(image)) {
|
||||
try (Resource resource = resourceManager.getResource(image)) {
|
||||
return NativeImage.read(resource.getInputStream());
|
||||
var imgResource = resourceManager.getResource(image);
|
||||
if (imgResource.isPresent()) {
|
||||
try {
|
||||
return NativeImage.read(imgResource.get().open());
|
||||
}
|
||||
catch (IOException e) {
|
||||
BCLib.LOGGER.warning("Can't load texture image: {}. Will be created empty image.", image);
|
||||
|
|
|
@ -67,9 +67,9 @@ public class JsonFactory {
|
|||
.getResourceManager();
|
||||
JsonObject obj = null;
|
||||
try {
|
||||
Resource resource = manager.getResource(location);
|
||||
Resource resource = manager.getResource(location).orElse(null);
|
||||
if (resource != null) {
|
||||
InputStream stream = resource.getInputStream();
|
||||
InputStream stream = resource.open();
|
||||
InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8);
|
||||
obj = JsonFactory.GSON.fromJson(reader, JsonObject.class);
|
||||
reader.close();
|
||||
|
|
|
@ -3,7 +3,7 @@ package ru.bclib.util;
|
|||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.core.Vec3i;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
|
||||
public class MHelper {
|
||||
private static final Vec3i[] RANDOM_OFFSETS = new Vec3i[3 * 3 * 3 - 1];
|
||||
|
@ -140,7 +140,7 @@ public class MHelper {
|
|||
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++) {
|
||||
int i2 = random.nextInt(array.length);
|
||||
T element = array[i];
|
||||
|
@ -202,7 +202,7 @@ public class MHelper {
|
|||
return new Vector3f(vx, 0, vz);
|
||||
}
|
||||
|
||||
public static Vec3i[] getOffsets(Random random) {
|
||||
public static Vec3i[] getOffsets(RandomSource random) {
|
||||
shuffle(RANDOM_OFFSETS, random);
|
||||
return RANDOM_OFFSETS;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import ru.bclib.sdf.primitive.SDFLine;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class SplineHelper {
|
||||
|
|
|
@ -17,7 +17,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
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.ZipFile;
|
||||
|
||||
|
@ -85,11 +85,11 @@ public class StructureHelper {
|
|||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation)
|
||||
.setMirror(mirror)
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package ru.bclib.util;
|
||||
|
||||
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> {
|
||||
private final float maxWeight;
|
||||
|
@ -18,7 +19,7 @@ public class WeighTree<T> {
|
|||
* @param random - {@link Random}.
|
||||
* @return {@link T} value.
|
||||
*/
|
||||
public T get(Random random) {
|
||||
public T get(WorldgenRandom random) {
|
||||
return root.get(random.nextFloat() * maxWeight);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ package ru.bclib.util;
|
|||
|
||||
import java.util.ArrayList;
|
||||
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;
|
||||
|
||||
public class WeightedList<T> {
|
||||
|
@ -28,7 +30,7 @@ public class WeightedList<T> {
|
|||
* @param random - {@link Random}.
|
||||
* @return {@link T} value.
|
||||
*/
|
||||
public T get(Random random) {
|
||||
public T get(RandomSource random) {
|
||||
if (maxWeight < 1) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@ import ru.bclib.util.WeightedList;
|
|||
|
||||
import java.util.List;
|
||||
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.function.Consumer;
|
||||
|
||||
|
@ -133,7 +135,7 @@ public class BCLBiome extends BCLBiomeSettings {
|
|||
* @param random {@link Random}.
|
||||
* @return {@link BCLBiome}.
|
||||
*/
|
||||
public BCLBiome getSubBiome(Random random) {
|
||||
public BCLBiome getSubBiome(WorldgenRandom random) {
|
||||
return subbiomes.get(random);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp
|
|||
import ru.bclib.util.StructureHelper;
|
||||
|
||||
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 StructureInfo selected;
|
||||
|
||||
|
@ -22,35 +22,35 @@ public class ListFeature extends NBTStructureFeature {
|
|||
}
|
||||
|
||||
@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()));
|
||||
return selected.getStructure();
|
||||
}
|
||||
|
||||
@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 cz = pos.getZ() >> 4;
|
||||
return ((cx + cz) & 1) == 0 && pos.getY() > 58;// && world.getBlockState(pos.below()).is(EndTags.GEN_TERRAIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Rotation getRotation(WorldGenLevel world, BlockPos pos, Random random) {
|
||||
protected Rotation getRotation(WorldGenLevel world, BlockPos pos, RandomSource random) {
|
||||
return Rotation.getRandom(random);
|
||||
}
|
||||
|
||||
@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)];
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TerrainMerge getTerrainMerge(WorldGenLevel world, BlockPos pos, Random random) {
|
||||
protected TerrainMerge getTerrainMerge(WorldGenLevel world, BlockPos pos, RandomSource random) {
|
||||
return selected.terrainMerge;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,234 +1,235 @@
|
|||
package ru.bclib.world.features;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Mirror;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
import ru.bclib.api.biomes.BiomeAPI;
|
||||
import ru.bclib.api.tag.CommonBlockTags;
|
||||
import ru.bclib.util.BlocksHelper;
|
||||
import ru.bclib.world.processors.DestructionStructureProcessor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class NBTStructureFeature extends DefaultFeature {
|
||||
private final BlockState defaultBlock;
|
||||
public NBTStructureFeature(BlockState defaultBlock){
|
||||
this.defaultBlock = defaultBlock;
|
||||
}
|
||||
|
||||
protected static final DestructionStructureProcessor DESTRUCTION = new DestructionStructureProcessor();
|
||||
|
||||
protected abstract StructureTemplate getStructure(WorldGenLevel world, BlockPos pos, Random random);
|
||||
|
||||
protected abstract boolean canSpawn(WorldGenLevel world, BlockPos pos, Random random);
|
||||
|
||||
protected abstract Rotation getRotation(WorldGenLevel world, BlockPos pos, Random random);
|
||||
|
||||
protected abstract Mirror getMirror(WorldGenLevel world, BlockPos pos, Random random);
|
||||
|
||||
protected abstract int getYOffset(StructureTemplate structure, WorldGenLevel world, BlockPos pos, Random random);
|
||||
|
||||
protected abstract TerrainMerge getTerrainMerge(WorldGenLevel world, BlockPos pos, Random random);
|
||||
|
||||
protected abstract void addStructureData(StructurePlaceSettings data);
|
||||
|
||||
protected BlockPos getGround(WorldGenLevel world, BlockPos center) {
|
||||
Holder<Biome> biome = world.getBiome(center);
|
||||
ResourceLocation id = BiomeAPI.getBiomeID(biome);
|
||||
if (id.getNamespace().contains("moutain") || id.getNamespace().contains("lake")) {
|
||||
int y = getAverageY(world, center);
|
||||
return new BlockPos(center.getX(), y, center.getZ());
|
||||
}
|
||||
else {
|
||||
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());
|
||||
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;
|
||||
}
|
||||
|
||||
protected int getAverageYWG(WorldGenLevel world, BlockPos center) {
|
||||
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);
|
||||
return y / 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {
|
||||
WorldGenLevel world = context.level();
|
||||
Random 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);
|
||||
|
||||
if (!canSpawn(world, center, random)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int posY = center.getY() + 1;
|
||||
StructureTemplate structure = getStructure(world, center, random);
|
||||
Rotation rotation = getRotation(world, center, random);
|
||||
Mirror mirror = getMirror(world, center, random);
|
||||
BlockPos offset = StructureTemplate.transform(
|
||||
new BlockPos(structure.getSize()),
|
||||
mirror,
|
||||
rotation,
|
||||
BlockPos.ZERO
|
||||
);
|
||||
center = center.offset(0, getYOffset(structure, world, center, random) + 0.5, 0);
|
||||
|
||||
BoundingBox bounds = makeBox(center);
|
||||
StructurePlaceSettings placementData = new StructurePlaceSettings()
|
||||
.setRotation(rotation)
|
||||
.setMirror(mirror)
|
||||
.setBoundingBox(bounds);
|
||||
addStructureData(placementData);
|
||||
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();
|
||||
int z1 = center.getZ();
|
||||
int x2 = x1 + offset.getX();
|
||||
int z2 = z1 + offset.getZ();
|
||||
if (merge != TerrainMerge.NONE) {
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
|
||||
if (x2 < x1) {
|
||||
int a = x1;
|
||||
x1 = x2;
|
||||
x2 = a;
|
||||
}
|
||||
|
||||
if (z2 < z1) {
|
||||
int a = z1;
|
||||
z1 = z2;
|
||||
z2 = a;
|
||||
}
|
||||
|
||||
int surfMax = posY - 1;
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
mut.setX(x);
|
||||
for (int z = z1; z <= z2; z++) {
|
||||
mut.setZ(z);
|
||||
mut.setY(surfMax);
|
||||
BlockState state = world.getBlockState(mut);
|
||||
if (!isTerrain(state) && state.isFaceSturdy(world, mut, Direction.DOWN)) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
mut.setY(mut.getY() - 1);
|
||||
BlockState stateSt = world.getBlockState(mut);
|
||||
if (!isTerrain(stateSt)) {
|
||||
if (merge == TerrainMerge.SURFACE) {
|
||||
boolean isTop = mut.getY() == surfMax && state.getMaterial().isSolidBlocking();
|
||||
Holder<Biome> b = world.getBiome(mut);
|
||||
BlockState top = (isTop ? BiomeAPI.findTopMaterial(b) : BiomeAPI.findUnderMaterial(b)).orElse(defaultBlock);
|
||||
BlocksHelper.setWithoutUpdate(world, mut, top);
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, state);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isTerrain(state) && state.getMaterial().isSolidBlocking()) {
|
||||
if (merge == TerrainMerge.SURFACE) {
|
||||
Holder<Biome> b = world.getBiome(mut);
|
||||
BlockState bottom = BiomeAPI.findUnderMaterial(b).orElse(defaultBlock);
|
||||
BlocksHelper.setWithoutUpdate(world, mut, bottom);
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, state);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//BlocksHelper.fixBlocks(world, new BlockPos(x1, center.getY(), z1), new BlockPos(x2, center.getY() + offset.getY(), z2));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
int sz = ((pos.getZ() >> 4) << 4) - 16;
|
||||
int ex = sx + 47;
|
||||
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();
|
||||
String nm = resource.getPath();
|
||||
|
||||
try {
|
||||
InputStream inputstream = MinecraftServer.class.getResourceAsStream("/data/" + ns + "/structures/" + nm + ".nbt");
|
||||
return readStructureFromStream(inputstream);
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static StructureTemplate readStructureFromStream(InputStream stream) throws IOException {
|
||||
CompoundTag nbttagcompound = NbtIo.readCompressed(stream);
|
||||
|
||||
StructureTemplate template = new StructureTemplate();
|
||||
template.load(nbttagcompound);
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
public enum TerrainMerge {
|
||||
NONE, SURFACE, OBJECT;
|
||||
|
||||
public static TerrainMerge getFromString(String type) {
|
||||
if (type.equals("surface")) {
|
||||
return SURFACE;
|
||||
}
|
||||
else if (type.equals("object")) {
|
||||
return OBJECT;
|
||||
}
|
||||
else {
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package ru.bclib.world.features;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Mirror;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
|
||||
import ru.bclib.api.biomes.BiomeAPI;
|
||||
import ru.bclib.api.tag.CommonBlockTags;
|
||||
import ru.bclib.util.BlocksHelper;
|
||||
import ru.bclib.world.processors.DestructionStructureProcessor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public abstract class NBTFeature extends DefaultFeature {
|
||||
private final BlockState defaultBlock;
|
||||
public NBTFeature(BlockState defaultBlock){
|
||||
this.defaultBlock = defaultBlock;
|
||||
}
|
||||
|
||||
protected static final DestructionStructureProcessor DESTRUCTION = new DestructionStructureProcessor();
|
||||
|
||||
protected abstract StructureTemplate getStructure(WorldGenLevel world, BlockPos pos, RandomSource random);
|
||||
|
||||
protected abstract boolean canSpawn(WorldGenLevel world, BlockPos pos, RandomSource random);
|
||||
|
||||
protected abstract Rotation getRotation(WorldGenLevel world, BlockPos pos, RandomSource random);
|
||||
|
||||
protected abstract Mirror getMirror(WorldGenLevel world, BlockPos pos, RandomSource random);
|
||||
|
||||
protected abstract int getYOffset(StructureTemplate structure, WorldGenLevel world, BlockPos pos, RandomSource random);
|
||||
|
||||
protected abstract TerrainMerge getTerrainMerge(WorldGenLevel world, BlockPos pos, RandomSource random);
|
||||
|
||||
protected abstract void addStructureData(StructurePlaceSettings data);
|
||||
|
||||
protected BlockPos getGround(WorldGenLevel world, BlockPos center) {
|
||||
Holder<Biome> biome = world.getBiome(center);
|
||||
ResourceLocation id = BiomeAPI.getBiomeID(biome);
|
||||
if (id.getNamespace().contains("moutain") || id.getNamespace().contains("lake")) {
|
||||
int y = getAverageY(world, center);
|
||||
return new BlockPos(center.getX(), y, center.getZ());
|
||||
}
|
||||
else {
|
||||
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());
|
||||
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;
|
||||
}
|
||||
|
||||
protected int getAverageYWG(WorldGenLevel world, BlockPos center) {
|
||||
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);
|
||||
return y / 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {
|
||||
WorldGenLevel world = context.level();
|
||||
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);
|
||||
|
||||
if (!canSpawn(world, center, random)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int posY = center.getY() + 1;
|
||||
StructureTemplate structure = getStructure(world, center, random);
|
||||
Rotation rotation = getRotation(world, center, random);
|
||||
Mirror mirror = getMirror(world, center, random);
|
||||
BlockPos offset = StructureTemplate.transform(
|
||||
new BlockPos(structure.getSize()),
|
||||
mirror,
|
||||
rotation,
|
||||
BlockPos.ZERO
|
||||
);
|
||||
center = center.offset(0, getYOffset(structure, world, center, random) + 0.5, 0);
|
||||
|
||||
BoundingBox bounds = makeBox(center);
|
||||
StructurePlaceSettings placementData = new StructurePlaceSettings()
|
||||
.setRotation(rotation)
|
||||
.setMirror(mirror)
|
||||
.setBoundingBox(bounds);
|
||||
addStructureData(placementData);
|
||||
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();
|
||||
int z1 = center.getZ();
|
||||
int x2 = x1 + offset.getX();
|
||||
int z2 = z1 + offset.getZ();
|
||||
if (merge != TerrainMerge.NONE) {
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
|
||||
if (x2 < x1) {
|
||||
int a = x1;
|
||||
x1 = x2;
|
||||
x2 = a;
|
||||
}
|
||||
|
||||
if (z2 < z1) {
|
||||
int a = z1;
|
||||
z1 = z2;
|
||||
z2 = a;
|
||||
}
|
||||
|
||||
int surfMax = posY - 1;
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
mut.setX(x);
|
||||
for (int z = z1; z <= z2; z++) {
|
||||
mut.setZ(z);
|
||||
mut.setY(surfMax);
|
||||
BlockState state = world.getBlockState(mut);
|
||||
if (!isTerrain(state) && state.isFaceSturdy(world, mut, Direction.DOWN)) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
mut.setY(mut.getY() - 1);
|
||||
BlockState stateSt = world.getBlockState(mut);
|
||||
if (!isTerrain(stateSt)) {
|
||||
if (merge == TerrainMerge.SURFACE) {
|
||||
boolean isTop = mut.getY() == surfMax && state.getMaterial().isSolidBlocking();
|
||||
Holder<Biome> b = world.getBiome(mut);
|
||||
BlockState top = (isTop ? BiomeAPI.findTopMaterial(b) : BiomeAPI.findUnderMaterial(b)).orElse(defaultBlock);
|
||||
BlocksHelper.setWithoutUpdate(world, mut, top);
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, state);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isTerrain(state) && state.getMaterial().isSolidBlocking()) {
|
||||
if (merge == TerrainMerge.SURFACE) {
|
||||
Holder<Biome> b = world.getBiome(mut);
|
||||
BlockState bottom = BiomeAPI.findUnderMaterial(b).orElse(defaultBlock);
|
||||
BlocksHelper.setWithoutUpdate(world, mut, bottom);
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, state);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//BlocksHelper.fixBlocks(world, new BlockPos(x1, center.getY(), z1), new BlockPos(x2, center.getY() + offset.getY(), z2));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
int sz = ((pos.getZ() >> 4) << 4) - 16;
|
||||
int ex = sx + 47;
|
||||
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();
|
||||
String nm = resource.getPath();
|
||||
|
||||
try {
|
||||
InputStream inputstream = MinecraftServer.class.getResourceAsStream("/data/" + ns + "/structures/" + nm + ".nbt");
|
||||
return readStructureFromStream(inputstream);
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static StructureTemplate readStructureFromStream(InputStream stream) throws IOException {
|
||||
CompoundTag nbttagcompound = NbtIo.readCompressed(stream);
|
||||
|
||||
StructureTemplate template = new StructureTemplate();
|
||||
template.load(nbttagcompound);
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
public enum TerrainMerge {
|
||||
NONE, SURFACE, OBJECT;
|
||||
|
||||
public static TerrainMerge getFromString(String type) {
|
||||
if (type.equals("surface")) {
|
||||
return SURFACE;
|
||||
}
|
||||
else if (type.equals("object")) {
|
||||
return OBJECT;
|
||||
}
|
||||
else {
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,19 +10,22 @@ import java.util.List;
|
|||
|
||||
public abstract class BCLBiomeSource extends BiomeSource {
|
||||
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){
|
||||
biomes.forEach(biome -> BiomeAPI.sortBiomeFeatures(biome));
|
||||
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));
|
||||
|
||||
this.seed = seed;
|
||||
this.biomeRegistry = biomeRegistry;
|
||||
|
||||
BiomeAPI.initRegistry(biomeRegistry);
|
||||
}
|
||||
|
||||
public void setSeed(long seed){
|
||||
this.currentSeed = seed;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,12 @@ import net.minecraft.core.Holder;
|
|||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
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.BiomeCategory;
|
||||
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.TheEndBiomeSource;
|
||||
import net.minecraft.world.level.levelgen.LegacyRandomSource;
|
||||
import net.minecraft.world.level.levelgen.WorldgenRandom;
|
||||
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.Configs;
|
||||
import ru.bclib.interfaces.BiomeMap;
|
||||
import ru.bclib.mixin.common.BiomeAccessor;
|
||||
import ru.bclib.noise.OpenSimplexNoise;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.generator.map.hex.HexBiomeMap;
|
||||
|
@ -31,19 +30,19 @@ import java.util.List;
|
|||
import java.util.function.Function;
|
||||
|
||||
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 Function<Point, Boolean> endLandFunction;
|
||||
|
||||
private final SimplexNoise noise;
|
||||
private SimplexNoise noise;
|
||||
private final Holder<Biome> centerBiome;
|
||||
private final Holder<Biome> barrens;
|
||||
private BiomeMap mapLand;
|
||||
private BiomeMap mapVoid;
|
||||
private final Point pos;
|
||||
|
||||
public BCLibEndBiomeSource(Registry<Biome> biomeRegistry, long seed) {
|
||||
super(biomeRegistry, seed, getBiomes(biomeRegistry));
|
||||
public BCLibEndBiomeSource(Registry<Biome> biomeRegistry) {
|
||||
super(biomeRegistry, getBiomes(biomeRegistry));
|
||||
|
||||
BiomeAPI.END_LAND_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_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()) {
|
||||
this.mapLand = new SquareBiomeMap(seed, GeneratorOptions.getBiomeSizeEndLand(), BiomeAPI.END_LAND_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.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));
|
||||
chunkRandom.consumeCount(17292);
|
||||
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) {
|
||||
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();
|
||||
|
@ -121,14 +129,9 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
|
|||
return true;
|
||||
}
|
||||
|
||||
final boolean isEndBiome;
|
||||
if ((Object)biome instanceof BiomeAccessor bacc) {
|
||||
isEndBiome = bacc.bclib_getBiomeCategory() == BiomeCategory.THEEND;
|
||||
if (GeneratorOptions.addEndBiomesByCategory() && isEndBiome) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
isEndBiome = false;
|
||||
final boolean isEndBiome = biome.is(BiomeTags.IS_END);
|
||||
if (GeneratorOptions.addEndBiomesByTag() && isEndBiome) {
|
||||
return true;
|
||||
}
|
||||
|
||||
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
||||
|
@ -144,6 +147,8 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
|
|||
|
||||
@Override
|
||||
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 posZ = biomeZ << 2;
|
||||
long farEndBiomes = GeneratorOptions.getFarEndBiomes();
|
||||
|
@ -156,7 +161,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
|
|||
|
||||
if (endLandFunction == null) {
|
||||
if (dist <= farEndBiomes) return centerBiome;
|
||||
float height = TheEndBiomeSource.getHeightValue(
|
||||
float height = getLegacyHeightValue(
|
||||
noise,
|
||||
(biomeX >> 1) + 1,
|
||||
(biomeZ >> 1) + 1
|
||||
|
@ -184,11 +189,29 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeSource withSeed(long seed) {
|
||||
return new BCLibEndBiomeSource(biomeRegistry, seed);
|
||||
public static float getLegacyHeightValue(SimplexNoise simplexNoise, int i, int j) {
|
||||
int k = i / 2;
|
||||
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
|
||||
protected Codec<? extends BiomeSource> codec() {
|
||||
return CODEC;
|
||||
|
|
|
@ -6,9 +6,10 @@ import net.minecraft.core.Holder;
|
|||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BiomeTags;
|
||||
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.Biomes;
|
||||
import net.minecraft.world.level.biome.Climate;
|
||||
import org.apache.commons.lang3.function.TriFunction;
|
||||
import ru.bclib.BCLib;
|
||||
|
@ -16,7 +17,6 @@ import ru.bclib.api.biomes.BiomeAPI;
|
|||
import ru.bclib.config.ConfigKeeper.StringArrayEntry;
|
||||
import ru.bclib.config.Configs;
|
||||
import ru.bclib.interfaces.BiomeMap;
|
||||
import ru.bclib.mixin.common.BiomeAccessor;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.generator.map.MapStack;
|
||||
import ru.bclib.world.generator.map.hex.HexBiomeMap;
|
||||
|
@ -31,12 +31,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
|
|||
.group(RegistryOps
|
||||
.retrieveRegistry(Registry.BIOME_REGISTRY)
|
||||
.forGetter(source -> source.biomeRegistry)
|
||||
,
|
||||
Codec
|
||||
.LONG
|
||||
.fieldOf("seed")
|
||||
.stable()
|
||||
.forGetter(source -> source.seed)
|
||||
|
||||
)
|
||||
.apply(instance, instance.stable(BCLibNetherBiomeSource::new))
|
||||
);
|
||||
|
@ -66,8 +61,8 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
|
|||
BCLibNetherBiomeSource.worldHeight = worldHeight;
|
||||
}
|
||||
|
||||
public BCLibNetherBiomeSource(Registry<Biome> biomeRegistry, long seed) {
|
||||
super(biomeRegistry, seed, getBiomes(biomeRegistry));
|
||||
public BCLibNetherBiomeSource(Registry<Biome> biomeRegistry) {
|
||||
super(biomeRegistry, getBiomes(biomeRegistry));
|
||||
|
||||
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.rebuild();
|
||||
|
||||
initMap();
|
||||
//initMap();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSeed(long seed) {
|
||||
super.setSeed(seed);
|
||||
initMap(seed);
|
||||
}
|
||||
|
||||
private static List<Holder<Biome>> getBiomes(Registry<Biome> biomeRegistry) {
|
||||
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;
|
||||
}
|
||||
|
||||
if (GeneratorOptions.addNetherBiomesByCategory() && (biome instanceof BiomeAccessor) && ((BiomeAccessor)(Object)biome).bclib_getBiomeCategory()== BiomeCategory.NETHER) {
|
||||
if (GeneratorOptions.addNetherBiomesByTag() && biome.is(BiomeTags.IS_NETHER)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -120,21 +121,19 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
|
|||
}
|
||||
key = bclBiome.getID();
|
||||
}
|
||||
final boolean isNetherBiome;
|
||||
if ((Object)biome instanceof BiomeAccessor bacc) {
|
||||
isNetherBiome = bacc.bclib_getBiomeCategory() == BiomeCategory.NETHER;
|
||||
} else {
|
||||
isNetherBiome = false;
|
||||
}
|
||||
final boolean isNetherBiome = biome.is(BiomeTags.IS_NETHER);
|
||||
return BiomeAPI.NETHER_BIOME_PICKER.containsImmutable(key) || (isNetherBiome && BiomeAPI.isDatapackBiome(key));
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
lastWorldHeight = worldHeight;
|
||||
initMap();
|
||||
initMap(this.currentSeed);
|
||||
}
|
||||
if ((biomeX & 63) == 0 && (biomeZ & 63) == 0) {
|
||||
biomeMap.clearCache();
|
||||
|
@ -142,11 +141,6 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
|
|||
return biomeMap.getBiome(biomeX << 2, biomeY << 2, biomeZ << 2).getActualBiome();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeSource withSeed(long seed) {
|
||||
return new BCLibNetherBiomeSource(biomeRegistry, seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Codec<? extends BiomeSource> codec() {
|
||||
return CODEC;
|
||||
|
@ -156,7 +150,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
|
|||
Registry.register(Registry.BIOME_SOURCE, BCLib.makeID("nether_biome_source"), CODEC);
|
||||
}
|
||||
|
||||
private void initMap() {
|
||||
private void initMap(long seed) {
|
||||
boolean useLegacy = GeneratorOptions.useOldBiomeGenerator() || forceLegacyGenerator;
|
||||
TriFunction<Long, Integer, BiomePicker, BiomeMap> mapConstructor = useLegacy ? SquareBiomeMap::new : HexBiomeMap::new;
|
||||
if (worldHeight > 128 && GeneratorOptions.useVerticalBiomes()) {
|
||||
|
|
|
@ -8,7 +8,9 @@ import ru.bclib.util.WeightedList;
|
|||
import ru.bclib.world.biomes.BCLBiome;
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ public class GeneratorOptions {
|
|||
private static Function<Point, Boolean> endLandFunction;
|
||||
private static boolean customNetherBiomeSource = true;
|
||||
private static boolean customEndBiomeSource = true;
|
||||
private static boolean addNetherBiomesByCategory = false;
|
||||
private static boolean addEndBiomesByCategory = false;
|
||||
private static boolean addNetherBiomesByTag = true;
|
||||
private static boolean addEndBiomesByTag = true;
|
||||
private static boolean useOldBiomeGenerator = false;
|
||||
private static boolean verticalBiomes = true;
|
||||
private static long farEndBiomesSqr = 1000000;
|
||||
|
@ -29,8 +29,8 @@ public class GeneratorOptions {
|
|||
biomeSizeEndVoid = Configs.GENERATOR_CONFIG.getInt("end.biomeMap", "biomeSizeVoid", 256);
|
||||
customNetherBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options", "customNetherBiomeSource", true);
|
||||
customEndBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options", "customEndBiomeSource", true);
|
||||
addNetherBiomesByCategory = Configs.GENERATOR_CONFIG.getBoolean("options", "addNetherBiomesByCategory", false);
|
||||
addEndBiomesByCategory = Configs.GENERATOR_CONFIG.getBoolean("options", "addEndBiomesByCategory", false);
|
||||
addNetherBiomesByTag = Configs.GENERATOR_CONFIG.getBoolean("options", "addNetherBiomesByTag", true);
|
||||
addEndBiomesByTag = Configs.GENERATOR_CONFIG.getBoolean("options", "addEndBiomesByTag", true);
|
||||
useOldBiomeGenerator = Configs.GENERATOR_CONFIG.useOldGenerator();
|
||||
verticalBiomes = Configs.GENERATOR_CONFIG.getBoolean("options", "verticalBiomesInTallNether", true);
|
||||
fixEndBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options.biomeSource", "fixEndBiomeSource", true);
|
||||
|
@ -89,12 +89,12 @@ public class GeneratorOptions {
|
|||
return customEndBiomeSource;
|
||||
}
|
||||
|
||||
public static boolean addNetherBiomesByCategory() {
|
||||
return addNetherBiomesByCategory;
|
||||
public static boolean addNetherBiomesByTag() {
|
||||
return addNetherBiomesByTag;
|
||||
}
|
||||
|
||||
public static boolean addEndBiomesByCategory() {
|
||||
return addEndBiomesByCategory;
|
||||
public static boolean addEndBiomesByTag() {
|
||||
return addEndBiomesByTag;
|
||||
}
|
||||
|
||||
public static boolean useOldBiomeGenerator() {
|
||||
|
|
|
@ -9,7 +9,7 @@ import ru.bclib.noise.OpenSimplexNoise;
|
|||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.generator.BiomePicker;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
|
||||
public class MapStack implements BiomeMap {
|
||||
private final OpenSimplexNoise noise;
|
||||
|
@ -35,7 +35,7 @@ public class MapStack implements BiomeMap {
|
|||
}
|
||||
noise = new OpenSimplexNoise(random.nextInt());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clearCache() {
|
||||
for (BiomeMap map: maps) {
|
||||
|
|
|
@ -5,7 +5,8 @@ import ru.bclib.world.biomes.BCLBiome;
|
|||
import ru.bclib.world.generator.BiomePicker;
|
||||
|
||||
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 {
|
||||
private static final short SIDE = 32;
|
||||
|
@ -22,7 +23,7 @@ public class HexBiomeChunk implements BiomeChunk {
|
|||
|
||||
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];
|
||||
|
||||
for (BCLBiome[] buffer: buffers) {
|
||||
|
|
|
@ -11,7 +11,8 @@ import ru.bclib.world.biomes.BCLBiome;
|
|||
import ru.bclib.world.generator.BiomePicker;
|
||||
|
||||
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 {
|
||||
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);
|
||||
this.seed = random.nextInt();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clearCache() {
|
||||
if (chunks.size() > 127) {
|
||||
|
@ -77,7 +78,7 @@ public class HexBiomeMap implements BiomeMap {
|
|||
final ChunkPos pos = new ChunkPos(cx, cz);
|
||||
HexBiomeChunk chunk = chunks.get(pos);
|
||||
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);
|
||||
if (update && processor != null) {
|
||||
processor.accept(cx, cz, chunk.getSide());
|
||||
|
|
|
@ -4,7 +4,8 @@ import ru.bclib.interfaces.BiomeChunk;
|
|||
import ru.bclib.world.biomes.BCLBiome;
|
||||
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 {
|
||||
private static final int BIT_OFFSET = 4;
|
||||
|
@ -19,7 +20,7 @@ public class SquareBiomeChunk implements BiomeChunk {
|
|||
|
||||
private final BCLBiome[] biomes;
|
||||
|
||||
public SquareBiomeChunk(Random random, BiomePicker picker) {
|
||||
public SquareBiomeChunk(WorldgenRandom random, BiomePicker picker) {
|
||||
BCLBiome[] PreBio = new BCLBiome[SM_CAPACITY];
|
||||
biomes = new BCLBiome[CAPACITY];
|
||||
|
||||
|
@ -53,7 +54,7 @@ public class SquareBiomeChunk implements BiomeChunk {
|
|||
return WIDTH;
|
||||
}
|
||||
|
||||
private int offsetXZ(int x, Random random) {
|
||||
private int offsetXZ(int x, WorldgenRandom random) {
|
||||
return ((x + random.nextInt(2)) >> 1) & MASK_OFFSET;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ public class SquareBiomeMap implements BiomeMap {
|
|||
private TriConsumer<Integer, Integer, Integer> processor;
|
||||
|
||||
public SquareBiomeMap(long seed, int size, BiomePicker picker) {
|
||||
maps.clear();
|
||||
random = new WorldgenRandom(new LegacyRandomSource(seed));
|
||||
noiseX = new OpenSimplexNoise(random.nextLong());
|
||||
noiseZ = new OpenSimplexNoise(random.nextLong());
|
||||
|
|
|
@ -1,131 +1,132 @@
|
|||
package ru.bclib.world.structures;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.QuartPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.worldgen.StructureSets;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
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 net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
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.RandomSpreadType;
|
||||
import ru.bclib.api.tag.TagAPI;
|
||||
import ru.bclib.mixin.common.StructureFeatureAccessor;
|
||||
import ru.bclib.mixin.common.StructureFeaturesAccessor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BCLStructureFeature {
|
||||
private static final Random RANDOM = new Random(354);
|
||||
private final StructureFeature<NoneFeatureConfiguration> structure;
|
||||
private final Holder<ConfiguredStructureFeature<?, ?>> featureConfigured;
|
||||
private final GenerationStep.Decoration featureStep;
|
||||
private final List<ResourceLocation> biomes = Lists.newArrayList();
|
||||
private final ResourceLocation id;
|
||||
public final TagKey<Biome> biomeTag;
|
||||
public final ResourceKey<ConfiguredStructureFeature<?, ?>> structureKey;
|
||||
public final ResourceKey<StructureSet> structureSetKey;
|
||||
public final RandomSpreadStructurePlacement spreadConfig;
|
||||
|
||||
public BCLStructureFeature(ResourceLocation id, StructureFeature<NoneFeatureConfiguration> 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, boolean adaptNoise) {
|
||||
this.id = id;
|
||||
this.featureStep = step;
|
||||
//parts from vanilla for Structure generation
|
||||
//public static final ResourceKey<ConfiguredStructureFeature<?, ?>> JUNGLE_TEMPLE =
|
||||
// BuiltinStructures.createKey("jungle_pyramid");
|
||||
//public static final Holder<ConfiguredStructureFeature<?, ?>> JUNGLE_TEMPLE =
|
||||
// StructureFeatures.register(BuiltinStructures.JUNGLE_TEMPLE, StructureFeature.JUNGLE_TEMPLE.configured(NoneFeatureConfiguration.INSTANCE, BiomeTags.HAS_JUNGLE_TEMPLE));
|
||||
//public static final Holder<StructureSet> JUNGLE_TEMPLES =
|
||||
// StructureSets.register(BuiltinStructureSets.JUNGLE_TEMPLES, StructureFeatures.JUNGLE_TEMPLE, new RandomSpreadStructurePlacement(32, 8, RandomSpreadType.LINEAR, 14357619));
|
||||
//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.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 = 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.
|
||||
*
|
||||
* @param context The context to test with.
|
||||
* @param <C> The FeatureConfiguration of the Context
|
||||
* @return true, if this feature can spawn in the current biome
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param context The context to test with.
|
||||
* @param yPos The Height to test for
|
||||
* @param <C> The FeatureConfiguration of the Context
|
||||
* @return true, if this feature can spawn in the current biome
|
||||
*/
|
||||
public static <C extends FeatureConfiguration> boolean isValidBiome(PieceGeneratorSupplier.Context<C> context, int yPos) {
|
||||
BlockPos blockPos = context.chunkPos().getMiddleBlockPosition(yPos);
|
||||
return context.validBiome().test(
|
||||
context.chunkGenerator().getNoiseBiome(QuartPos.fromBlock(blockPos.getX()), QuartPos.fromBlock(blockPos.getY()), QuartPos.fromBlock(blockPos.getZ()))
|
||||
);
|
||||
}
|
||||
|
||||
public StructureFeature<NoneFeatureConfiguration> getStructure() {
|
||||
return structure;
|
||||
}
|
||||
|
||||
public Holder<ConfiguredStructureFeature<?, ?>> getFeatureConfigured() {
|
||||
return featureConfigured;
|
||||
}
|
||||
|
||||
public GenerationStep.Decoration getFeatureStep() {
|
||||
return featureStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the structure ID;
|
||||
* @return {@link ResourceLocation} 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.
|
||||
*/
|
||||
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.
|
||||
* @return {@link List} of biome {@link ResourceLocation}.
|
||||
*/
|
||||
public List<ResourceLocation> getBiomes() {
|
||||
return biomes;
|
||||
}
|
||||
}
|
||||
package ru.bclib.world.structures;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.QuartPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.worldgen.StructureSets;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
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.RandomSpreadType;
|
||||
import ru.bclib.api.tag.TagAPI;
|
||||
import ru.bclib.mixin.common.StructuresAccessor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BCLStructure {
|
||||
private static final Random RANDOM = new Random(354);
|
||||
|
||||
private final Holder<Structure> structure;
|
||||
private final GenerationStep.Decoration featureStep;
|
||||
private final List<ResourceLocation> biomes = Lists.newArrayList();
|
||||
private final ResourceLocation id;
|
||||
public final TagKey<Biome> biomeTag;
|
||||
public final ResourceKey<Structure> structureKey;
|
||||
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 BCLStructure(ResourceLocation id, Structure structure, GenerationStep.Decoration step, int spacing, int separation, boolean adaptNoise) {
|
||||
this.id = id;
|
||||
this.featureStep = step;
|
||||
//parts from vanilla for Structure generation
|
||||
//public static final ResourceKey<ConfiguredStructure<?, ?>> JUNGLE_TEMPLE =
|
||||
// BuiltinStructures.createKey("jungle_pyramid");
|
||||
//public static final Holder<ConfiguredStructure<?, ?>> JUNGLE_TEMPLE =
|
||||
// Structures.register(BuiltinStructures.JUNGLE_TEMPLE, Structure.JUNGLE_TEMPLE.configured(NoneFeatureConfiguration.INSTANCE, BiomeTags.HAS_JUNGLE_TEMPLE));
|
||||
//public static final Holder<StructureSet> JUNGLE_TEMPLES =
|
||||
// StructureSets.register(BuiltinStructureSets.JUNGLE_TEMPLES, Structures.JUNGLE_TEMPLE, new RandomSpreadStructurePlacement(32, 8, RandomSpreadType.LINEAR, 14357619));
|
||||
//public static final Structure<NoneFeatureConfiguration> JUNGLE_TEMPLE =
|
||||
// Structure.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.structureSetKey = ResourceKey.create(Registry.STRUCTURE_SET_REGISTRY, id);
|
||||
|
||||
this.biomeTag = TagAPI.makeBiomeTag(id.getNamespace(), "has_structure/"+id.getPath());
|
||||
this.structure = StructuresAccessor.callRegister(structureKey, structure);
|
||||
StructureSets.register(structureSetKey, this.structure, spreadConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* runs the {@code PieceGeneratorSupplier.Context::validBiome} from the given context at
|
||||
* height=5 in the middle of the chunk.
|
||||
*
|
||||
* @param context The context to test with.
|
||||
* @param <C> The FeatureConfiguration of the Context
|
||||
* @return true, if this feature can spawn in the current biome
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param context The context to test with.
|
||||
* @param yPos The Height to test for
|
||||
* @param <C> The FeatureConfiguration of the Context
|
||||
* @return true, if this feature can spawn in the current biome
|
||||
*/
|
||||
public static <C extends FeatureConfiguration> boolean isValidBiome(PieceGeneratorSupplier.Context<C> context, int yPos) {
|
||||
BlockPos blockPos = context.chunkPos().getMiddleBlockPosition(yPos);
|
||||
return context.validBiome().test(
|
||||
context
|
||||
.chunkGenerator()
|
||||
.getBiomeSource()
|
||||
.getNoiseBiome(
|
||||
QuartPos.fromBlock(blockPos.getX()),
|
||||
QuartPos.fromBlock(blockPos.getY()),
|
||||
QuartPos.fromBlock(blockPos.getZ()),
|
||||
context.randomState().sampler()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public Holder<Structure> getStructure() {
|
||||
return structure;
|
||||
}
|
||||
|
||||
public GenerationStep.Decoration getFeatureStep() {
|
||||
return featureStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the structure ID;
|
||||
* @return {@link ResourceLocation} 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.
|
||||
*/
|
||||
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.
|
||||
* @return {@link List} of biome {@link ResourceLocation}.
|
||||
*/
|
||||
public List<ResourceLocation> getBiomes() {
|
||||
return biomes;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package ru.bclib.world.surface;
|
|||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.util.KeyDispatchDataCodec;
|
||||
import net.minecraft.world.level.levelgen.SurfaceRules;
|
||||
import ru.bclib.BCLib;
|
||||
import ru.bclib.api.surface.rules.SurfaceNoiseCondition;
|
||||
|
@ -12,14 +13,14 @@ import ru.bclib.util.MHelper;
|
|||
public class DoubleBlockSurfaceNoiseCondition extends SurfaceNoiseCondition {
|
||||
public static final DoubleBlockSurfaceNoiseCondition CONDITION = new DoubleBlockSurfaceNoiseCondition(0);
|
||||
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;
|
||||
public DoubleBlockSurfaceNoiseCondition(double threshold){
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Codec<? extends SurfaceRules.ConditionSource> codec() {
|
||||
public KeyDispatchDataCodec<? extends SurfaceRules.ConditionSource> codec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
|
@ -42,6 +43,6 @@ public class DoubleBlockSurfaceNoiseCondition extends SurfaceNoiseCondition {
|
|||
}
|
||||
|
||||
static {
|
||||
Registry.register(Registry.CONDITION , BCLib.makeID("doubleblock_surface"), DoubleBlockSurfaceNoiseCondition.CODEC);
|
||||
Registry.register(Registry.CONDITION , BCLib.makeID("doubleblock_surface"), DoubleBlockSurfaceNoiseCondition.CODEC.codec());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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$LazyCondition
|
||||
accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource
|
||||
accessible class net/minecraft/world/level/levelgen/presets/WorldPresets$Bootstrap
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"AnvilScreenMixin",
|
||||
"FogRendererMixin",
|
||||
"ModelBakeryMixin",
|
||||
"WorldPresetMixin",
|
||||
"CreateWorldScreenMixin",
|
||||
"MinecraftMixin",
|
||||
"BlockMixin",
|
||||
"GameMixin"
|
||||
|
|
|
@ -13,9 +13,8 @@
|
|||
"SurfaceRulesContextAccessor",
|
||||
"EnchantingTableBlockMixin",
|
||||
"shears.TripWireBlockMixin",
|
||||
"StructureFeaturesAccessor",
|
||||
"StructuresAccessor",
|
||||
"MobSpawnSettingsAccessor",
|
||||
"StructureFeatureAccessor",
|
||||
"shears.BeehiveBlockMixin",
|
||||
"shears.PumpkinBlockMixin",
|
||||
"shears.MushroomCowMixin",
|
||||
|
@ -31,7 +30,6 @@
|
|||
"ChunkGeneratorMixin",
|
||||
"WorldGenRegionMixin",
|
||||
"DiggerItemAccessor",
|
||||
"DimensionTypeMixin",
|
||||
"RecipeManagerMixin",
|
||||
"RecipeManagerMixin",
|
||||
"ShovelItemAccessor",
|
||||
|
@ -45,8 +43,11 @@
|
|||
"AnvilMenuMixin",
|
||||
"ItemStackMixin",
|
||||
"TagLoaderMixin",
|
||||
"BiomeAccessor",
|
||||
"MainMixin"
|
||||
"MainMixin",
|
||||
"WorldPresetsAccessor",
|
||||
"WorldPresetsBootstrapMixin",
|
||||
"WorldOpenFlowsMixin",
|
||||
"WorldGenPropertiesMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Reference in a new issue