Cave related changes
This commit is contained in:
parent
3d93b8607b
commit
60e7489fa4
4 changed files with 43 additions and 27 deletions
|
@ -10,6 +10,7 @@ import net.minecraft.client.renderer.block.model.BlockModel;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
|
@ -24,6 +25,7 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.LegacyRandomSource;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import ru.bclib.api.tag.CommonBlockTags;
|
||||
import ru.bclib.api.tag.NamedCommonItemTags;
|
||||
|
@ -31,12 +33,13 @@ import ru.bclib.api.tag.TagAPI.TagLocation;
|
|||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.interfaces.ItemModelProvider;
|
||||
import ru.bclib.interfaces.TagProvider;
|
||||
import ru.bclib.util.MHelper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class EndHammerItem extends DiggerItem implements ItemModelProvider, TagProvider {
|
||||
public final static UUID ATTACK_KNOCKBACK_MODIFIER_ID = Mth.createInsecureUUID(ThreadLocalRandom.current());
|
||||
public final static UUID ATTACK_KNOCKBACK_MODIFIER_ID = Mth.createInsecureUUID(MHelper.RANDOM_SOURCE);
|
||||
|
||||
private final Multimap<Attribute, AttributeModifier> attributeModifiers;
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ import ru.betterend.world.generator.BiomeType;
|
|||
import ru.betterend.world.generator.GeneratorOptions;
|
||||
|
||||
public class EndBiomes {
|
||||
public static final BiomePicker CAVE_BIOMES = new BiomePicker();
|
||||
public static BiomePicker CAVE_BIOMES = null;
|
||||
private static HexBiomeMap caveBiomeMap;
|
||||
private static long lastSeed;
|
||||
|
||||
|
@ -81,8 +81,20 @@ public class EndBiomes {
|
|||
}
|
||||
|
||||
private static void onWorldLoad(ServerLevel level, long seed, Registry<Biome> registry) {
|
||||
CAVE_BIOMES.getBiomes().forEach(biome -> biome.updateActualBiomes(registry));
|
||||
CAVE_BIOMES.rebuild();
|
||||
if (CAVE_BIOMES.biomeRegistry != registry) {
|
||||
CAVE_BIOMES = new BiomePicker(registry);
|
||||
registry.stream()
|
||||
.filter(biome -> registry.getResourceKey(biome).isPresent())
|
||||
.map(biome -> registry.getOrCreateHolder(registry.getResourceKey(biome).get()))
|
||||
.map(biome -> biome.unwrapKey().orElseThrow().location())
|
||||
.filter(id -> BiomeAPI.wasRegisteredAs(id, END_CAVE))
|
||||
.map(id -> BiomeAPI.getBiome(id))
|
||||
.filter(bcl -> bcl != null)
|
||||
.forEach(bcl -> CAVE_BIOMES.addBiome(bcl));
|
||||
|
||||
caveBiomeMap = null;
|
||||
}
|
||||
|
||||
if (caveBiomeMap == null || lastSeed != seed) {
|
||||
caveBiomeMap = new HexBiomeMap(seed, GeneratorOptions.getBiomeSizeCaves(), CAVE_BIOMES);
|
||||
lastSeed = seed;
|
||||
|
@ -134,7 +146,7 @@ public class EndBiomes {
|
|||
public static EndBiome registerSubBiomeIntegration(EndBiome.Config biomeConfig) {
|
||||
EndBiome biome = EndBiome.create(biomeConfig);
|
||||
if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) {
|
||||
BiomeAPI.registerBiome(biome);
|
||||
BiomeAPI.registerBiome(biome, BiomeAPI.Dimension.END);
|
||||
}
|
||||
return biome;
|
||||
}
|
||||
|
@ -153,17 +165,16 @@ public class EndBiomes {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final BiomeAPI.Dimension END_CAVE = new BiomeAPI.Dimension(BiomeAPI.Dimension.END);
|
||||
public static EndCaveBiome registerCaveBiome(EndCaveBiome.Config biomeConfig) {
|
||||
final EndCaveBiome biome = EndCaveBiome.create(biomeConfig);
|
||||
if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) {
|
||||
BiomeAPI.registerBiome(biome);
|
||||
CAVE_BIOMES.addBiome(biome);
|
||||
BiomeAPI.registerBiome(biome, END_CAVE);
|
||||
}
|
||||
return biome;
|
||||
}
|
||||
|
||||
public static EndCaveBiome getCaveBiome(int x, int z) {
|
||||
return (EndCaveBiome) caveBiomeMap.getBiome(x, 5, z);
|
||||
public static BiomePicker.Entry getCaveBiome(int x, int z) {
|
||||
return caveBiomeMap.getBiome(x, 5, z);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import ru.bclib.util.BlocksHelper;
|
|||
import ru.bclib.util.MHelper;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.features.DefaultFeature;
|
||||
import ru.bclib.world.generator.BiomePicker;
|
||||
import ru.betterend.registry.EndBiomes;
|
||||
import ru.betterend.util.BlockFixer;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
|
@ -58,7 +59,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
return false;
|
||||
}
|
||||
|
||||
EndCaveBiome biome = EndBiomes.getCaveBiome(pos.getX(), pos.getZ());
|
||||
BiomePicker.Entry biome = EndBiomes.getCaveBiome(pos.getX(), pos.getZ());
|
||||
Set<BlockPos> caveBlocks = generate(world, center, radius, random);
|
||||
if (!caveBlocks.isEmpty()) {
|
||||
if (biome != null) {
|
||||
|
@ -78,10 +79,10 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
}
|
||||
});
|
||||
|
||||
BlockState surfaceBlock = EndBiome.findTopMaterial(biome);
|
||||
placeFloor(world, biome, floorPositions, random, surfaceBlock);
|
||||
placeCeil(world, biome, ceilPositions, random);
|
||||
placeWalls(world, biome, caveBlocks, random);
|
||||
BlockState surfaceBlock = EndBiome.findTopMaterial(biome.bclBiome);
|
||||
placeFloor(world, (EndCaveBiome) biome.bclBiome, floorPositions, random, surfaceBlock);
|
||||
placeCeil(world, (EndCaveBiome) biome.bclBiome, ceilPositions, random);
|
||||
placeWalls(world, (EndCaveBiome) biome.bclBiome, caveBlocks, random);
|
||||
}
|
||||
fixBlocks(world, caveBlocks);
|
||||
}
|
||||
|
@ -150,12 +151,12 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
return false;
|
||||
}
|
||||
|
||||
protected void setBiomes(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> blocks) {
|
||||
protected void setBiomes(WorldGenLevel world, BiomePicker.Entry biome, Set<BlockPos> blocks) {
|
||||
blocks.forEach((pos) -> setBiome(world, pos, biome));
|
||||
}
|
||||
|
||||
protected void setBiome(WorldGenLevel world, BlockPos pos, EndCaveBiome biome) {
|
||||
BiomeAPI.setBiome(world, pos, biome.getActualBiome());
|
||||
protected void setBiome(WorldGenLevel world, BlockPos pos, BiomePicker.Entry biome) {
|
||||
BiomeAPI.setBiome(world, pos, biome.actual);
|
||||
}
|
||||
|
||||
private BlockPos findPos(WorldGenLevel world, BlockPos pos, int radius, RandomSource random) {
|
||||
|
@ -232,7 +233,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
Holder<Biome> biome = world.getBiome(pos.offset(x << 4, 0, z << 4));
|
||||
BCLBiome endBiome = BiomeAPI.getFromBiome(biome);
|
||||
boolean hasCaves = endBiome.getCustomData("has_caves", true);
|
||||
if (!hasCaves && BiomeAPI.END_LAND_BIOME_PICKER.containsImmutable(endBiome.getID())) {
|
||||
if (!hasCaves && BiomeAPI.wasRegisteredAsEndLandBiome(endBiome.getID())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import ru.bclib.api.biomes.BiomeAPI;
|
|||
import ru.bclib.api.tag.CommonBlockTags;
|
||||
import ru.bclib.util.BlocksHelper;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.generator.BiomePicker;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.EndBiomes;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
|
@ -131,13 +132,13 @@ public class TunelCaveFeature extends EndCaveFeature {
|
|||
return false;
|
||||
}
|
||||
|
||||
Map<EndCaveBiome, Set<BlockPos>> floorSets = Maps.newHashMap();
|
||||
Map<EndCaveBiome, Set<BlockPos>> ceilSets = Maps.newHashMap();
|
||||
Map<BiomePicker.Entry, Set<BlockPos>> floorSets = Maps.newHashMap();
|
||||
Map<BiomePicker.Entry, Set<BlockPos>> ceilSets = Maps.newHashMap();
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
Set<BlockPos> remove = Sets.newHashSet();
|
||||
caveBlocks.forEach((bpos) -> {
|
||||
mut.set(bpos);
|
||||
EndCaveBiome bio = EndBiomes.getCaveBiome(bpos.getX(), bpos.getZ());
|
||||
BiomePicker.Entry bio = EndBiomes.getCaveBiome(bpos.getX(), bpos.getZ());
|
||||
int height = world.getHeight(Types.WORLD_SURFACE, bpos.getX(), bpos.getZ());
|
||||
if (mut.getY() >= height) {
|
||||
remove.add(bpos);
|
||||
|
@ -171,14 +172,14 @@ public class TunelCaveFeature extends EndCaveFeature {
|
|||
}
|
||||
|
||||
floorSets.forEach((biome, floorPositions) -> {
|
||||
BlockState surfaceBlock = EndBiome.findTopMaterial(biome);
|
||||
placeFloor(world, biome, floorPositions, random, surfaceBlock);
|
||||
BlockState surfaceBlock = EndBiome.findTopMaterial(biome.bclBiome);
|
||||
placeFloor(world, (EndCaveBiome) biome.bclBiome, floorPositions, random, surfaceBlock);
|
||||
});
|
||||
ceilSets.forEach((biome, ceilPositions) -> {
|
||||
placeCeil(world, biome, ceilPositions, random);
|
||||
placeCeil(world, (EndCaveBiome) biome.bclBiome, ceilPositions, random);
|
||||
});
|
||||
EndCaveBiome biome = EndBiomes.getCaveBiome(pos.getX(), pos.getZ());
|
||||
placeWalls(world, biome, caveBlocks, random);
|
||||
BiomePicker.Entry biome = EndBiomes.getCaveBiome(pos.getX(), pos.getZ());
|
||||
placeWalls(world, (EndCaveBiome) biome.bclBiome, caveBlocks, random);
|
||||
fixBlocks(world, caveBlocks);
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue