Simple WorldBlender crash fix, Pallidium blocks (WIP)

This commit is contained in:
paulevsGitch 2021-07-22 04:12:13 +03:00
parent 80590c1a7e
commit e32c6c76cb
18 changed files with 126 additions and 20 deletions

View file

@ -173,6 +173,10 @@ public class EndBlocks extends BlocksRegistry {
);
public static final Block SANGNUM = registerBlock("sangnum", new EndTerrainBlock(MaterialColor.COLOR_RED));
public static final Block RUTISCUS = registerBlock("rutiscus", new EndTerrainBlock(MaterialColor.COLOR_ORANGE));
public static final Block PALLIDIUM = registerBlock("pallidium", new EndTerrainBlock(MaterialColor.COLOR_LIGHT_GRAY));
public static final Block PALLIDIUM_TRANSITION_1 = registerBlock("pallidium_transition_1", new EndTerrainBlock(MaterialColor.COLOR_LIGHT_GRAY));
public static final Block PALLIDIUM_TRANSITION_2 = registerBlock("pallidium_transition_2", new EndTerrainBlock(MaterialColor.COLOR_LIGHT_GRAY));
public static final Block PALLIDIUM_TRANSITION_3 = registerBlock("pallidium_transition_3", new EndTerrainBlock(MaterialColor.COLOR_LIGHT_GRAY));
// Roads //
public static final Block END_MYCELIUM_PATH = registerBlock("end_mycelium_path", new BasePathBlock(END_MYCELIUM));

View file

@ -1,13 +1,17 @@
package ru.betterend.util;
import com.google.common.collect.Sets;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FallingBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.dimension.DimensionType;
import ru.bclib.blocks.BaseDoublePlantBlock;
import ru.bclib.blocks.BaseVineBlock;
import ru.bclib.blocks.StalactiteBlock;
@ -24,16 +28,23 @@ public class BlockFixer {
private static final BlockState WATER = Blocks.WATER.defaultBlockState();
public static void fixBlocks(LevelAccessor world, BlockPos start, BlockPos end) {
Set<BlockPos> doubleCheck = Sets.newConcurrentHashSet();
int dx = end.getX() - start.getX() + 1;
int dz = end.getZ() - start.getZ() + 1;
int count = dx * dz;
Registry<DimensionType> registry = world.registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
ResourceLocation dimKey = registry.getKey(world.dimensionType());
if (dimKey.getNamespace().equals("world_blender")) {
return;
}
final Set<BlockPos> doubleCheck = Sets.newConcurrentHashSet();
final int dx = end.getX() - start.getX() + 1;
final int dz = end.getZ() - start.getZ() + 1;
final int count = dx * dz;
final int minY = Math.max(start.getY(), world.getMinBuildHeight());
final int maxY = Math.min(end.getY(), world.getMaxBuildHeight());
IntStream.range(0, count).parallel().forEach(index -> {
MutableBlockPos POS = new MutableBlockPos();
POS.setX((index % dx) + start.getX());
POS.setZ((index / dx) + start.getZ());
BlockState state;
for (int y = start.getY(); y <= end.getY(); y++) {
for (int y = minY; y <= maxY; y++) {
POS.setY(y);
state = world.getBlockState(POS);

View file

@ -14,6 +14,10 @@ public class SurfaceBuilders {
public static final SurfaceBuilderBaseConfiguration BRIMSTONE_CONFIG = makeSimpleConfig(EndBlocks.BRIMSTONE);
public static final SurfaceBuilderBaseConfiguration SULFURIC_ROCK_CONFIG = makeSimpleConfig(EndBlocks.SULPHURIC_ROCK.stone);
public static final SurfaceBuilderBaseConfiguration UMBRA_SURFACE_CONFIG = makeSimpleConfig(EndBlocks.UMBRALITH.stone);
public static final SurfaceBuilderBaseConfiguration PALLIDIUM_SURFACE_CONFIG = makeSurfaceConfig(EndBlocks.PALLIDIUM, EndBlocks.UMBRALITH.stone);
public static final SurfaceBuilderBaseConfiguration PALLIDIUM_T1_SURFACE_CONFIG = makeSurfaceConfig(EndBlocks.PALLIDIUM_TRANSITION_1, EndBlocks.UMBRALITH.stone);
public static final SurfaceBuilderBaseConfiguration PALLIDIUM_T2_SURFACE_CONFIG = makeSurfaceConfig(EndBlocks.PALLIDIUM_TRANSITION_2, EndBlocks.UMBRALITH.stone);
public static final SurfaceBuilderBaseConfiguration PALLIDIUM_T3_SURFACE_CONFIG = makeSurfaceConfig(EndBlocks.PALLIDIUM_TRANSITION_3, EndBlocks.UMBRALITH.stone);
public static final SurfaceBuilder<SurfaceBuilderBaseConfiguration> SULPHURIC_SURFACE = register(
"sulphuric_surface",
@ -33,6 +37,14 @@ public class SurfaceBuilders {
return new SurfaceBuilderBaseConfiguration(state, state, state);
}
private static SurfaceBuilderBaseConfiguration makeSurfaceConfig(Block surface, Block under) {
return new SurfaceBuilderBaseConfiguration(
surface.defaultBlockState(),
under.defaultBlockState(),
under.defaultBlockState()
);
}
public static void register() {
}
}

View file

@ -19,20 +19,23 @@ public class UmbraSurfaceBuilder extends SurfaceBuilder<SurfaceBuilderBaseConfig
@Override
public void apply(Random random, ChunkAccess chunk, Biome biome, int x, int z, int height, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, int seed, long n, SurfaceBuilderBaseConfiguration surfaceBlocks) {
int depth = (int) (NOISE.eval(x * 0.1, z * 0.1) * 20 + NOISE.eval(x * 0.5, z * 0.5) * 10 + 60);
SurfaceBuilder.DEFAULT.apply(
random,
chunk,
biome,
x,
z,
height,
noise + depth,
defaultBlock,
defaultFluid,
seaLevel,
seed,
n,
SurfaceBuilders.UMBRA_SURFACE_CONFIG
);
float grass = ((float) NOISE.eval(x * 0.03, z * 0.03) + (float) NOISE.eval(x * 0.1, z * 0.1) * 0.6F + random.nextFloat() * 0.2F) - 0.05F;
SurfaceBuilderBaseConfiguration config = null;
if (grass > 0.3F) {
config = SurfaceBuilders.PALLIDIUM_SURFACE_CONFIG;
}
else if (grass > 0.1F) {
config = SurfaceBuilders.PALLIDIUM_T1_SURFACE_CONFIG;
}
else if (grass > -0.1) {
config = SurfaceBuilders.PALLIDIUM_T2_SURFACE_CONFIG;
}
else if (grass > -0.3F) {
config = SurfaceBuilders.PALLIDIUM_T3_SURFACE_CONFIG;
}
else {
config = SurfaceBuilders.UMBRA_SURFACE_CONFIG;
}
SurfaceBuilder.DEFAULT.apply(random, chunk, biome, x, z, height, noise + depth, defaultBlock, defaultFluid, seaLevel, seed, n, config);
}
}

View file

@ -0,0 +1,10 @@
{
"variants": {
"": [
{ "model": "betterend:block/pallidium" },
{ "model": "betterend:block/pallidium", "y": 90 },
{ "model": "betterend:block/pallidium", "y": 180 },
{ "model": "betterend:block/pallidium", "y": 270 }
]
}
}

View file

@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "betterend:block/pallidium_transition_1" }
}
}

View file

@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "betterend:block/pallidium_transition_2" }
}
}

View file

@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "betterend:block/pallidium_transition_3" }
}
}

View file

@ -0,0 +1,12 @@
{
"parent": "block/cube",
"textures": {
"down": "betterend:block/umbralith",
"east": "betterend:block/pallidium_side",
"north": "betterend:block/pallidium_side",
"particle": "betterend:block/pallidium_side",
"south": "betterend:block/pallidium_side",
"up": "betterend:block/pallidium_top",
"west": "betterend:block/pallidium_side"
}
}

View file

@ -0,0 +1,12 @@
{
"parent": "block/cube",
"textures": {
"down": "betterend:block/umbralith",
"east": "betterend:block/pallidium_side",
"north": "betterend:block/pallidium_side",
"particle": "betterend:block/pallidium_side",
"south": "betterend:block/pallidium_side",
"up": "betterend:block/pallidium_transition_1_top",
"west": "betterend:block/pallidium_side"
}
}

View file

@ -0,0 +1,12 @@
{
"parent": "block/cube",
"textures": {
"down": "betterend:block/umbralith",
"east": "betterend:block/pallidium_side",
"north": "betterend:block/pallidium_side",
"particle": "betterend:block/pallidium_side",
"south": "betterend:block/pallidium_side",
"up": "betterend:block/pallidium_transition_2_top",
"west": "betterend:block/pallidium_side"
}
}

View file

@ -0,0 +1,12 @@
{
"parent": "block/cube",
"textures": {
"down": "betterend:block/umbralith",
"east": "betterend:block/pallidium_side",
"north": "betterend:block/pallidium_side",
"particle": "betterend:block/pallidium_side",
"south": "betterend:block/pallidium_side",
"up": "betterend:block/pallidium_transition_3_top",
"west": "betterend:block/pallidium_side"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "betterend:block/pallidium"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 796 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 795 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 B