From 9504432cdd953e5c8c8fef46b31052ed31a555f4 Mon Sep 17 00:00:00 2001 From: paulevsGitch Date: Fri, 4 Dec 2020 13:50:13 +0300 Subject: [PATCH 1/3] Sulphuric caves & fixes --- .../betterend/blocks/BlockSulphurCrystal.java | 8 +++ .../ru/betterend/registry/EndFeatures.java | 2 +- .../betterend/world/features/EndFeature.java | 5 ++ .../world/features/terrain/GeyserFeature.java | 52 +++++++------- .../terrain/SulphuricCaveFeature.java | 67 +++++++++++++++---- 5 files changed, 91 insertions(+), 43 deletions(-) diff --git a/src/main/java/ru/betterend/blocks/BlockSulphurCrystal.java b/src/main/java/ru/betterend/blocks/BlockSulphurCrystal.java index c37a5b3d..bfa5f4d8 100644 --- a/src/main/java/ru/betterend/blocks/BlockSulphurCrystal.java +++ b/src/main/java/ru/betterend/blocks/BlockSulphurCrystal.java @@ -37,6 +37,7 @@ import net.minecraft.world.WorldView; import ru.betterend.blocks.basis.BlockAttached; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; +import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndItems; import ru.betterend.util.MHelper; @@ -102,6 +103,13 @@ public class BlockSulphurCrystal extends BlockAttached implements IRenderTypeabl return BOUNDING_SHAPES.get(state.get(FACING)); } + @Override + public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { + Direction direction = (Direction) state.get(FACING); + BlockPos blockPos = pos.offset(direction.getOpposite()); + return world.getBlockState(blockPos).isOf(EndBlocks.BRIMSTONE); + } + static { BOUNDING_SHAPES.put(Direction.UP, VoxelShapes.cuboid(0.125, 0.0, 0.125, 0.875F, 0.5, 0.875F)); BOUNDING_SHAPES.put(Direction.DOWN, VoxelShapes.cuboid(0.125, 0.5, 0.125, 0.875F, 1.0, 0.875F)); diff --git a/src/main/java/ru/betterend/registry/EndFeatures.java b/src/main/java/ru/betterend/registry/EndFeatures.java index fa96dd93..e081cf7a 100644 --- a/src/main/java/ru/betterend/registry/EndFeatures.java +++ b/src/main/java/ru/betterend/registry/EndFeatures.java @@ -97,7 +97,7 @@ public class EndFeatures { public static final EndFeature FLOATING_SPIRE = EndFeature.makeRawGenFeature("floating_spire", new FloatingSpireFeature(), 8); public static final EndFeature GEYSER = EndFeature.makeRawGenFeature("geyser", new GeyserFeature(), 8); public static final EndFeature SULPHURIC_LAKE = EndFeature.makeLakeFeature("sulphuric_lake", new SulphuricLakeFeature(), 8); - public static final EndFeature SULPHURIC_CAVE = EndFeature.makeRawGenFeature("sulphuric_cave", new SulphuricCaveFeature(), 1); + public static final EndFeature SULPHURIC_CAVE = EndFeature.makeCountRawFeature("sulphuric_cave", new SulphuricCaveFeature(), 2); // Ores // public static final EndFeature ENDER_ORE = EndFeature.makeOreFeature("ender_ore", EndBlocks.ENDER_ORE, 6, 3, 0, 4, 96); diff --git a/src/main/java/ru/betterend/world/features/EndFeature.java b/src/main/java/ru/betterend/world/features/EndFeature.java index 5847e5bc..653933a3 100644 --- a/src/main/java/ru/betterend/world/features/EndFeature.java +++ b/src/main/java/ru/betterend/world/features/EndFeature.java @@ -103,6 +103,11 @@ public class EndFeature { return new EndFeature(name, feature, GenerationStep.Feature.SURFACE_STRUCTURES, configured); } + public static EndFeature makeCountRawFeature(String name, Feature feature, int chance) { + ConfiguredFeature configured = feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.COUNT.configure(new CountConfig(chance))); + return new EndFeature(name, feature, GenerationStep.Feature.RAW_GENERATION, configured); + } + public Feature getFeature() { return feature; } diff --git a/src/main/java/ru/betterend/world/features/terrain/GeyserFeature.java b/src/main/java/ru/betterend/world/features/terrain/GeyserFeature.java index 7146f815..af1ea389 100644 --- a/src/main/java/ru/betterend/world/features/terrain/GeyserFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/GeyserFeature.java @@ -38,6 +38,7 @@ import ru.betterend.world.features.DefaultFeature; public class GeyserFeature extends DefaultFeature { protected static final Function REPLACE1; protected static final Function REPLACE2; + private static final Function IGNORE; @Override public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { @@ -56,19 +57,6 @@ public class GeyserFeature extends DefaultFeature { float delta = (float) i / (float) (count - 1); float radius = MathHelper.lerp(delta, radius1, radius2) * 1.3F; - /*SDF bowl = new SDFCapedCone().setHeight(radius).setRadius1(0).setRadius2(radius).setBlock(EndBlocks.SULFURIC_ROCK.stone); - SDF cut = new SDFTranslate().setTranslate(0, 2, 0).setSource(bowl); - bowl = new SDFSubtraction().setSourceA(bowl).setSourceB(cut); - - SDF inner = new SDFCapedCone().setHeight(radius - 2).setRadius1(0).setRadius2(radius - 1).setBlock(EndBlocks.BRIMSTONE); - cut = new SDFTranslate().setTranslate(0, 4, 0).setSource(inner); - inner = new SDFSubtraction().setSourceA(inner).setSourceB(cut); - inner = new SDFTranslate().setTranslate(0, 1.99F, 0).setSource(inner); - bowl = new SDFUnion().setSourceA(inner).setSourceB(bowl); - - SDF water = new SDFCapedCone().setHeight(radius - 4).setRadius1(0).setRadius2(radius - 3).setBlock(Blocks.WATER); - bowl = new SDFUnion().setSourceA(water).setSourceB(bowl);*/ - SDF bowl = new SDFCapedCone().setHeight(radius).setRadius1(0).setRadius2(radius).setBlock(EndBlocks.SULPHURIC_ROCK.stone); SDF brimstone = new SDFCapedCone().setHeight(radius).setRadius1(0).setRadius2(radius).setBlock(EndBlocks.BRIMSTONE); @@ -83,9 +71,7 @@ public class GeyserFeature extends DefaultFeature { final OpenSimplexNoise noise1 = new OpenSimplexNoise(random.nextLong()); final OpenSimplexNoise noise2 = new OpenSimplexNoise(random.nextLong()); - /*bowl = new SDFDisplacement().setFunction((vec) -> { - return (float) noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1); - }).setSource(bowl);*/ + bowl = new SDFCoordModify().setFunction((vec) -> { float dx = (float) noise1.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1); float dz = (float) noise2.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1); @@ -99,7 +85,7 @@ public class GeyserFeature extends DefaultFeature { bowl = new SDFTranslate().setTranslate(radius, py - radius, 0).setSource(bowl); bowl = new SDFRotation().setRotation(Vector3f.POSITIVE_Y, i * 4F).setSource(bowl); - sdf = /*new SDFSmoothUnion()*/new SDFUnion()/*.setRadius(3)*/.setSourceA(sdf).setSourceB(bowl); + sdf = new SDFUnion().setSourceA(sdf).setSourceB(bowl); } sdf.setReplaceFunction(REPLACE2).fillRecursive(world, pos); @@ -127,22 +113,28 @@ public class GeyserFeature extends DefaultFeature { sdf = new SDFSmoothUnion().setRadius(5).setSourceA(cave).setSourceB(sdf); - obj1.setBlock(EndBlocks.SULPHURIC_ROCK.stone); - obj2.setBlock(EndBlocks.SULPHURIC_ROCK.stone); - new SDFDisplacement().setFunction((vec) -> { - return -4F; - }).setSource(sdf).setReplaceFunction(REPLACE1).fillRecursive(world, pos); + obj1.setBlock(WATER); + obj2.setBlock(WATER); + sdf.setReplaceFunction(REPLACE2); + sdf.fillRecursive(world, pos); obj1.setBlock(EndBlocks.BRIMSTONE); obj2.setBlock(EndBlocks.BRIMSTONE); new SDFDisplacement().setFunction((vec) -> { return -2F; - }).setSource(sdf).setReplaceFunction(REPLACE1).fillRecursive(world, pos); + }).setSource(sdf).setReplaceFunction(REPLACE1).fillRecursiveIgnore(world, pos, IGNORE); - obj1.setBlock(WATER); - obj2.setBlock(WATER); - sdf.setReplaceFunction(REPLACE2); - sdf.fillRecursive(world, pos); + obj1.setBlock(EndBlocks.SULPHURIC_ROCK.stone); + obj2.setBlock(EndBlocks.SULPHURIC_ROCK.stone); + new SDFDisplacement().setFunction((vec) -> { + return -4F; + }).setSource(sdf).setReplaceFunction(REPLACE1).fillRecursiveIgnore(world, pos, IGNORE); + + obj1.setBlock(Blocks.END_STONE); + obj2.setBlock(Blocks.END_STONE); + new SDFDisplacement().setFunction((vec) -> { + return -6F; + }).setSource(sdf).setReplaceFunction(REPLACE1).fillRecursiveIgnore(world, pos, IGNORE); Mutable mut = new Mutable().set(pos); for (int i = 0; i < halfHeight + 5; i++) { @@ -164,7 +156,7 @@ public class GeyserFeature extends DefaultFeature { static { REPLACE1 = (state) -> { - return state.isAir() || (state.isIn(EndTags.GEN_TERRAIN) && !state.isOf(EndBlocks.SULPHURIC_ROCK.stone) && !state.isOf(EndBlocks.BRIMSTONE)); + return state.isAir() || (state.isIn(EndTags.GEN_TERRAIN)); }; REPLACE2 = (state) -> { @@ -179,5 +171,9 @@ public class GeyserFeature extends DefaultFeature { } return state.getMaterial().isReplaceable(); }; + + IGNORE = (state) -> { + return state.isOf(Blocks.WATER) || state.isOf(Blocks.CAVE_AIR) || state.isOf(EndBlocks.SULPHURIC_ROCK.stone) || state.isOf(EndBlocks.BRIMSTONE); + }; } } diff --git a/src/main/java/ru/betterend/world/features/terrain/SulphuricCaveFeature.java b/src/main/java/ru/betterend/world/features/terrain/SulphuricCaveFeature.java index 16e02c3e..2d5b5576 100644 --- a/src/main/java/ru/betterend/world/features/terrain/SulphuricCaveFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/SulphuricCaveFeature.java @@ -1,16 +1,22 @@ package ru.betterend.world.features.terrain; import java.util.Random; +import java.util.Set; + +import com.google.common.collect.Sets; + import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.Material; -import net.minecraft.fluid.Fluids; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import net.minecraft.util.math.BlockPos.Mutable; import net.minecraft.world.Heightmap; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; +import ru.betterend.blocks.BlockProperties; +import ru.betterend.blocks.BlockSulphurCrystal; import ru.betterend.noise.OpenSimplexNoise; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndTags; @@ -24,7 +30,7 @@ public class SulphuricCaveFeature extends DefaultFeature { @Override public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - int radius = MHelper.randRange(20, 40, random); + int radius = MHelper.randRange(10, 30, random); int bottom = BlocksHelper.upRay(world, new BlockPos(pos.getX(), 0, pos.getZ()), 32) + radius + 5; int top = world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ()) - radius - 5; @@ -47,10 +53,9 @@ public class SulphuricCaveFeature extends DefaultFeature { double hr = radius * 0.75; double nr = radius * 0.25; - BlockState terrain = EndBlocks.BRIMSTONE.getDefaultState(); + Set brimstone = Sets.newHashSet(); BlockState rock = EndBlocks.SULPHURIC_ROCK.stone.getDefaultState(); - int waterLevel = random.nextBoolean() ? -200 : MHelper.floor(pos.getY() - radius * 0.3F); - + int waterLevel = pos.getY() + MHelper.randRange(MHelper.floor(radius * 0.8), radius, random); for (int x = x1; x <= x2; x++) { int xsq = x - pos.getX(); xsq *= xsq; @@ -71,32 +76,66 @@ public class SulphuricCaveFeature extends DefaultFeature { BlockState state = world.getBlockState(bpos); if (isReplaceable(state)) { BlocksHelper.setWithoutUpdate(world, bpos, y < waterLevel ? WATER : CAVE_AIR); - world.getFluidTickScheduler().schedule(bpos, Fluids.WATER, random.nextInt(16)); - } - int depth = MHelper.randRange(2, 4, random); - for (int i = 0; i < depth; i++) { - bpos.setY(y - 1); - if (world.getBlockState(bpos).isIn(EndTags.GEN_TERRAIN)) { - BlocksHelper.setWithoutUpdate(world, bpos, terrain); - } } } else if (dist < r2 * r2) { if (world.getBlockState(bpos).isIn(EndTags.GEN_TERRAIN)) { - BlocksHelper.setWithoutUpdate(world, bpos, rock); + double v = noise.eval(x * 0.1, y * 0.1, z * 0.1) + noise.eval(x * 0.03, y * 0.03, z * 0.03) * 0.5; + if (v < 0) { + brimstone.add(bpos.toImmutable()); + } + else { + BlocksHelper.setWithoutUpdate(world, bpos, rock); + } } } } } } + brimstone.forEach((blockPos) -> { + placeBrimstone(world, blockPos, random); + }); + + BlocksHelper.fixBlocks(world, new BlockPos(x1, y1, z1), new BlockPos(x2, y2, z2)); return true; } private boolean isReplaceable(BlockState state) { return state.isIn(EndTags.GEN_TERRAIN) + || state.isOf(EndBlocks.SULPHUR_CRYSTAL) || state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.LEAVES); } + + private void placeBrimstone(StructureWorldAccess world, BlockPos pos, Random random) { + BlockState state = getBrimstone(world, pos); + BlocksHelper.setWithoutUpdate(world, pos, state); + if (state.get(BlockProperties.ACTIVATED)) { + makeShards(world, pos, random); + } + } + + private BlockState getBrimstone(StructureWorldAccess world, BlockPos pos) { + for (Direction dir: BlocksHelper.DIRECTIONS) { + if (world.getBlockState(pos.offset(dir)).isOf(Blocks.WATER)) { + return EndBlocks.BRIMSTONE.getDefaultState().with(BlockProperties.ACTIVATED, true); + } + } + return EndBlocks.BRIMSTONE.getDefaultState(); + } + + private void makeShards(StructureWorldAccess world, BlockPos pos, Random random) { + for (Direction dir: BlocksHelper.DIRECTIONS) { + BlockPos side; + if (random.nextInt(3) == 0 && world.getBlockState((side = pos.offset(dir))).isOf(Blocks.WATER)) { + BlockState state = EndBlocks.SULPHUR_CRYSTAL.getDefaultState() + .with(BlockSulphurCrystal.WATERLOGGED, true) + .with(BlockSulphurCrystal.FACING, dir) + .with(BlockSulphurCrystal.AGE, random.nextInt(3)); + BlocksHelper.setWithoutUpdate(world, side, state); + } + } + } } From bf47e9a2b5bc7d81a0bb5406cfe5f4609266d449 Mon Sep 17 00:00:00 2001 From: paulevsGitch Date: Fri, 4 Dec 2020 14:30:21 +0300 Subject: [PATCH 2/3] Geyser prototype --- .../ru/betterend/blocks/BlockBrimstone.java | 2 +- .../blocks/BlockSulphuricGeyser.java | 69 ++++++++ .../java/ru/betterend/registry/EndBlocks.java | 5 +- .../terrain/SulphuricCaveFeature.java | 4 +- .../terrain/SulphuricLakeFeature.java | 2 +- .../blockstates/sulphuric_geyser.json | 10 ++ .../models/block/sulphuric_geyser.json | 164 ++++++++++++++++++ .../models/item/sulphuric_geyser.json | 3 + .../betterend/textures/block/geyser_top.png | Bin 0 -> 2032 bytes 9 files changed, 254 insertions(+), 5 deletions(-) create mode 100644 src/main/java/ru/betterend/blocks/BlockSulphuricGeyser.java create mode 100644 src/main/resources/assets/betterend/blockstates/sulphuric_geyser.json create mode 100644 src/main/resources/assets/betterend/models/block/sulphuric_geyser.json create mode 100644 src/main/resources/assets/betterend/models/item/sulphuric_geyser.json create mode 100644 src/main/resources/assets/betterend/textures/block/geyser_top.png diff --git a/src/main/java/ru/betterend/blocks/BlockBrimstone.java b/src/main/java/ru/betterend/blocks/BlockBrimstone.java index 7e7cd1fc..09d8963f 100644 --- a/src/main/java/ru/betterend/blocks/BlockBrimstone.java +++ b/src/main/java/ru/betterend/blocks/BlockBrimstone.java @@ -43,7 +43,7 @@ public class BlockBrimstone extends BlockBase { if (deactivate) { world.setBlockState(pos, getDefaultState().with(ACTIVATED, false)); } - else if (state.get(ACTIVATED)) { + else if (state.get(ACTIVATED) && random.nextInt(16) == 0) { Direction dir = BlocksHelper.randomDirection(random); BlockPos side = pos.offset(dir); BlockState sideState = world.getBlockState(side); diff --git a/src/main/java/ru/betterend/blocks/BlockSulphuricGeyser.java b/src/main/java/ru/betterend/blocks/BlockSulphuricGeyser.java new file mode 100644 index 00000000..164ad09f --- /dev/null +++ b/src/main/java/ru/betterend/blocks/BlockSulphuricGeyser.java @@ -0,0 +1,69 @@ +package ru.betterend.blocks; + +import java.util.Random; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.FluidFillable; +import net.minecraft.block.Material; +import net.minecraft.fluid.Fluid; +import net.minecraft.fluid.FluidState; +import net.minecraft.particle.ParticleTypes; +import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.world.BlockView; +import net.minecraft.world.World; +import net.minecraft.world.WorldAccess; +import net.minecraft.world.WorldView; +import ru.betterend.blocks.basis.BlockBaseNotFull; +import ru.betterend.registry.EndBlocks; + +public class BlockSulphuricGeyser extends BlockBaseNotFull implements FluidFillable { + public BlockSulphuricGeyser() { + super(FabricBlockSettings.of(Material.STONE) + .breakByTool(FabricToolTags.PICKAXES) + .sounds(BlockSoundGroup.STONE) + .nonOpaque() + .requiresTool()); + } + + @Override + public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) { + return false; + } + + @Override + public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) { + return false; + } + + @Override + public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { + state = world.getBlockState(pos.down()); + return state.isOf(EndBlocks.SULPHURIC_ROCK.stone); + } + + @Override + public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + if (!canPlaceAt(state, world, pos)) { + return Blocks.WATER.getDefaultState(); + } + else { + return state; + } + } + + @Environment(EnvType.CLIENT) + public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { + super.randomDisplayTick(state, world, pos, random); + double x = pos.getX() + random.nextDouble(); + double y = pos.getY() + 0.9 + random.nextDouble() * 0.3; + double z = pos.getZ() + random.nextDouble(); + world.addParticle(ParticleTypes.CAMPFIRE_SIGNAL_SMOKE, x, y, z, 0, 0, 0); + } +} diff --git a/src/main/java/ru/betterend/registry/EndBlocks.java b/src/main/java/ru/betterend/registry/EndBlocks.java index a6834dcf..61a089c4 100644 --- a/src/main/java/ru/betterend/registry/EndBlocks.java +++ b/src/main/java/ru/betterend/registry/EndBlocks.java @@ -39,6 +39,7 @@ import ru.betterend.blocks.BlockPythadendronSapling; import ru.betterend.blocks.BlockShadowBerry; import ru.betterend.blocks.BlockShadowGrass; import ru.betterend.blocks.BlockSulphurCrystal; +import ru.betterend.blocks.BlockSulphuricGeyser; import ru.betterend.blocks.BlockTenaneaFlowers; import ru.betterend.blocks.BlockTenaneaSapling; import ru.betterend.blocks.BlockTerrain; @@ -111,6 +112,8 @@ public class EndBlocks { public static final Block QUARTZ_PEDESTAL = registerBlock("quartz_pedestal", new PedestalVanilla(Blocks.QUARTZ_BLOCK)); public static final Block PURPUR_PEDESTAL = registerBlock("purpur_pedestal", new PedestalVanilla(Blocks.PURPUR_BLOCK)); + public static final Block SULPHURIC_GEYSER = registerBlock("sulphuric_geyser", new BlockSulphuricGeyser()); + // Wooden Materials And Trees // public static final Block MOSSY_GLOWSHROOM_SAPLING = registerBlock("mossy_glowshroom_sapling", new BlockMossyGlowshroomSapling()); public static final Block MOSSY_GLOWSHROOM_CAP = registerBlock("mossy_glowshroom_cap", new BlockMossyGlowshroomCap()); @@ -209,7 +212,7 @@ public class EndBlocks { public static final Block ETERNAL_PEDESTAL = registerBlock("eternal_pedestal", new EternalPedestal()); public static final Block INFUSION_PEDESTAL = registerBlock("infusion_pedestal", new InfusionPedestal()); - //Technical + // Technical public static final Block END_PORTAL_BLOCK = registerBlockNI("end_portal_block", new EndPortalBlock()); public static void register() {} diff --git a/src/main/java/ru/betterend/world/features/terrain/SulphuricCaveFeature.java b/src/main/java/ru/betterend/world/features/terrain/SulphuricCaveFeature.java index 2d5b5576..75f46b19 100644 --- a/src/main/java/ru/betterend/world/features/terrain/SulphuricCaveFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/SulphuricCaveFeature.java @@ -81,7 +81,7 @@ public class SulphuricCaveFeature extends DefaultFeature { else if (dist < r2 * r2) { if (world.getBlockState(bpos).isIn(EndTags.GEN_TERRAIN)) { double v = noise.eval(x * 0.1, y * 0.1, z * 0.1) + noise.eval(x * 0.03, y * 0.03, z * 0.03) * 0.5; - if (v < 0) { + if (v > 0.4) { brimstone.add(bpos.toImmutable()); } else { @@ -129,7 +129,7 @@ public class SulphuricCaveFeature extends DefaultFeature { private void makeShards(StructureWorldAccess world, BlockPos pos, Random random) { for (Direction dir: BlocksHelper.DIRECTIONS) { BlockPos side; - if (random.nextInt(3) == 0 && world.getBlockState((side = pos.offset(dir))).isOf(Blocks.WATER)) { + if (random.nextInt(16) == 0 && world.getBlockState((side = pos.offset(dir))).isOf(Blocks.WATER)) { BlockState state = EndBlocks.SULPHUR_CRYSTAL.getDefaultState() .with(BlockSulphurCrystal.WATERLOGGED, true) .with(BlockSulphurCrystal.FACING, dir) diff --git a/src/main/java/ru/betterend/world/features/terrain/SulphuricLakeFeature.java b/src/main/java/ru/betterend/world/features/terrain/SulphuricLakeFeature.java index 73723179..a62adeac 100644 --- a/src/main/java/ru/betterend/world/features/terrain/SulphuricLakeFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/SulphuricLakeFeature.java @@ -193,7 +193,7 @@ public class SulphuricLakeFeature extends DefaultFeature { private void makeShards(StructureWorldAccess world, BlockPos pos, Random random) { for (Direction dir: BlocksHelper.DIRECTIONS) { BlockPos side; - if (random.nextInt(3) == 0 && world.getBlockState((side = pos.offset(dir))).isOf(Blocks.WATER)) { + if (random.nextInt(16) == 0 && world.getBlockState((side = pos.offset(dir))).isOf(Blocks.WATER)) { BlockState state = EndBlocks.SULPHUR_CRYSTAL.getDefaultState() .with(BlockSulphurCrystal.WATERLOGGED, true) .with(BlockSulphurCrystal.FACING, dir) diff --git a/src/main/resources/assets/betterend/blockstates/sulphuric_geyser.json b/src/main/resources/assets/betterend/blockstates/sulphuric_geyser.json new file mode 100644 index 00000000..fabfd5d9 --- /dev/null +++ b/src/main/resources/assets/betterend/blockstates/sulphuric_geyser.json @@ -0,0 +1,10 @@ +{ + "variants": { + "": [ + { "model": "betterend:block/sulphuric_geyser" }, + { "model": "betterend:block/sulphuric_geyser", "y": 90 }, + { "model": "betterend:block/sulphuric_geyser", "y": 180 }, + { "model": "betterend:block/sulphuric_geyser", "y": 270 } + ] + } +} diff --git a/src/main/resources/assets/betterend/models/block/sulphuric_geyser.json b/src/main/resources/assets/betterend/models/block/sulphuric_geyser.json new file mode 100644 index 00000000..40f1962b --- /dev/null +++ b/src/main/resources/assets/betterend/models/block/sulphuric_geyser.json @@ -0,0 +1,164 @@ +{ + "__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio", + "parent": "block/block", + "textures": { + "particle": "betterend:block/sulphuric_rock", + "texture": "betterend:block/sulphuric_rock", + "rock_top": "betterend:block/sulphuric_rock_top", + "geyser_top": "betterend:block/geyser_top" + }, + "elements": [ + { + "__comment": "Box1", + "from": [ 9, 10, 8 ], + "to": [ 13, 16, 12 ], + "faces": { + "up": { "uv": [ 0, 0, 4, 4 ], "texture": "#geyser_top", "cullface": "up" }, + "north": { "uv": [ 3, 0, 7, 6 ], "texture": "#texture" }, + "south": { "uv": [ 9, 0, 13, 6 ], "texture": "#texture" }, + "west": { "uv": [ 8, 0, 12, 6 ], "texture": "#texture" }, + "east": { "uv": [ 4, 0, 8, 6 ], "texture": "#texture" } + } + }, + { + "__comment": "Box1", + "from": [ 8, 0, 7 ], + "to": [ 14, 10, 13 ], + "faces": { + "down": { "uv": [ 5, 5, 11, 11 ], "texture": "#rock_top", "cullface": "down" }, + "up": { "uv": [ 10, 5, 16, 11 ], "texture": "#geyser_top" }, + "north": { "uv": [ 5, 6, 11, 16 ], "texture": "#texture" }, + "south": { "uv": [ 5, 6, 11, 16 ], "texture": "#texture" }, + "west": { "uv": [ 5, 6, 11, 16 ], "texture": "#texture" }, + "east": { "uv": [ 5, 6, 11, 16 ], "texture": "#texture" } + } + }, + { + "__comment": "Box1", + "from": [ 4, 0, 1 ], + "to": [ 8, 5, 5 ], + "faces": { + "down": { "uv": [ 4, 11, 8, 15 ], "texture": "#rock_top", "cullface": "down" }, + "up": { "uv": [ 4, 1, 8, 5 ], "texture": "#geyser_top" }, + "north": { "uv": [ 8, 11, 12, 16 ], "texture": "#texture" }, + "west": { "uv": [ 1, 11, 5, 16 ], "texture": "#texture" }, + "east": { "uv": [ 11, 11, 15, 16 ], "texture": "#texture" } + } + }, + { + "__comment": "Box1", + "from": [ 5, 5, 2 ], + "to": [ 7, 11, 4 ], + "faces": { + "up": { "uv": [ 0, 4, 2, 6 ], "texture": "#geyser_top" }, + "north": { "uv": [ 8, 5, 10, 11 ], "texture": "#texture" }, + "south": { "uv": [ 6, 5, 8, 11 ], "texture": "#texture" }, + "west": { "uv": [ 1, 5, 3, 11 ], "texture": "#texture" }, + "east": { "uv": [ 13, 5, 15, 11 ], "texture": "#texture" } + } + }, + { + "__comment": "Box1", + "from": [ 1, 0, 8 ], + "to": [ 5, 8, 12 ], + "faces": { + "down": { "uv": [ 1, 4, 5, 8 ], "texture": "#rock_top", "cullface": "down" }, + "up": { "uv": [ 5, 12, 9, 16 ], "texture": "#geyser_top" }, + "north": { "uv": [ 11, 8, 15, 16 ], "texture": "#texture" }, + "south": { "uv": [ 1, 8, 5, 16 ], "texture": "#texture" }, + "west": { "uv": [ 8, 8, 12, 16 ], "texture": "#texture" }, + "east": { "uv": [ 4, 8, 8, 16 ], "texture": "#texture" } + } + }, + { + "__comment": "Box1", + "from": [ 2, 8, 9 ], + "to": [ 4, 14, 11 ], + "faces": { + "up": { "uv": [ 0, 4, 2, 6 ], "texture": "#geyser_top" }, + "north": { "uv": [ 12, 2, 14, 8 ], "texture": "#texture" }, + "south": { "uv": [ 2, 2, 4, 8 ], "texture": "#texture" }, + "west": { "uv": [ 9, 2, 11, 8 ], "texture": "#texture" }, + "east": { "uv": [ 5, 2, 7, 8 ], "texture": "#texture" } + } + }, + { + "__comment": "Box7", + "from": [ 2, 0, 4 ], + "to": [ 5, 4, 7 ], + "faces": { + "down": { "uv": [ 2, 9, 5, 12 ], "texture": "#rock_top", "cullface": "down" }, + "up": { "uv": [ 9, 13, 12, 16 ], "texture": "#geyser_top" }, + "north": { "uv": [ 11, 12, 14, 16 ], "texture": "#texture" }, + "south": { "uv": [ 2, 12, 5, 16 ], "texture": "#texture" }, + "west": { "uv": [ 4, 12, 7, 16 ], "texture": "#texture" }, + "east": { "uv": [ 9, 12, 12, 16 ], "texture": "#texture" } + } + }, + { + "__comment": "Box7", + "from": [ 3, 0, 13 ], + "to": [ 6, 4, 16 ], + "faces": { + "down": { "uv": [ 3, 0, 6, 3 ], "texture": "#rock_top", "cullface": "down" }, + "up": { "uv": [ 9, 0, 12, 3 ], "texture": "#geyser_top" }, + "north": { "uv": [ 10, 12, 13, 16 ], "texture": "#texture" }, + "south": { "uv": [ 3, 12, 6, 16 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 13, 12, 16, 16 ], "texture": "#texture" }, + "east": { "uv": [ 0, 12, 3, 16 ], "texture": "#texture" } + } + }, + { + "__comment": "Box7", + "from": [ 12, 0, 2 ], + "to": [ 15, 4, 5 ], + "faces": { + "down": { "uv": [ 12, 11, 15, 14 ], "texture": "#rock_top", "cullface": "down" }, + "up": { "uv": [ 9, 13, 12, 16 ], "texture": "#geyser_top" }, + "north": { "uv": [ 1, 12, 4, 16 ], "texture": "#texture" }, + "south": { "uv": [ 12, 12, 15, 16 ], "texture": "#texture" }, + "west": { "uv": [ 2, 12, 5, 16 ], "texture": "#texture" }, + "east": { "uv": [ 11, 12, 14, 16 ], "texture": "#texture" } + } + }, + { + "__comment": "Box7", + "from": [ 7, 0, 3 ], + "to": [ 12, 7, 8 ], + "faces": { + "down": { "uv": [ 7, 8, 12, 13 ], "texture": "#rock_top", "cullface": "down" }, + "up": { "uv": [ 4, 0, 9, 5 ], "texture": "#geyser_top" }, + "north": { "uv": [ 4, 9, 9, 16 ], "texture": "#texture" }, + "south": { "uv": [ 7, 9, 12, 16 ], "texture": "#texture" }, + "west": { "uv": [ 3, 9, 8, 16 ], "texture": "#texture" }, + "east": { "uv": [ 8, 9, 13, 16 ], "texture": "#texture" } + } + }, + { + "__comment": "Box7", + "from": [ 4, 0, 9 ], + "to": [ 9, 7, 14 ], + "faces": { + "down": { "uv": [ 4, 2, 9, 7 ], "texture": "#rock_top", "cullface": "down" }, + "up": { "uv": [ 4, 0, 9, 5 ], "texture": "#geyser_top" }, + "north": { "uv": [ 7, 9, 12, 16 ], "texture": "#texture" }, + "south": { "uv": [ 4, 9, 9, 16 ], "texture": "#texture" }, + "west": { "uv": [ 9, 9, 14, 16 ], "texture": "#texture" }, + "east": { "uv": [ 2, 9, 7, 16 ], "texture": "#texture" } + } + }, + { + "__comment": "Box7", + "from": [ 3, 0, 5 ], + "to": [ 8, 9, 10 ], + "faces": { + "down": { "uv": [ 3, 6, 8, 11 ], "texture": "#rock_top", "cullface": "down" }, + "up": { "uv": [ 4, 0, 9, 5 ], "texture": "#geyser_top" }, + "north": { "uv": [ 8, 7, 13, 16 ], "texture": "#texture" }, + "south": { "uv": [ 3, 7, 8, 16 ], "texture": "#texture" }, + "west": { "uv": [ 5, 7, 10, 16 ], "texture": "#texture" }, + "east": { "uv": [ 6, 7, 11, 16 ], "texture": "#texture" } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/betterend/models/item/sulphuric_geyser.json b/src/main/resources/assets/betterend/models/item/sulphuric_geyser.json new file mode 100644 index 00000000..ba3c0280 --- /dev/null +++ b/src/main/resources/assets/betterend/models/item/sulphuric_geyser.json @@ -0,0 +1,3 @@ +{ + "parent": "betterend:block/sulphuric_geyser" +} diff --git a/src/main/resources/assets/betterend/textures/block/geyser_top.png b/src/main/resources/assets/betterend/textures/block/geyser_top.png new file mode 100644 index 0000000000000000000000000000000000000000..cda6167b9749f79c072f87137d378893ff244de3 GIT binary patch literal 2032 zcmb_dTWs4@81|N}Y;7aTs%><<7+f3Xr%d4?K)ff7)mtVb; zAR6Y(Cf@?JwFuAA=s5f*I3_QA=meQlx3bs9{NCH9HQo zX5W+pk4z0D^{FvkF{u3ykX=O;JIF&1ki~q?a@Asts`yp$*q>%7vI6nOVpNYGkQ~tl z$vAQ#DTO1n&WSu3Rl;0^Rd_K(@+=o+*eJsZG|Q=ML=_aWdQmuW*o9CbCH1BS@ifFGk@^ zS4zm+b+?vVZ4+)7Qv^1{g;~F(3eeE&ID6d5Re~Ej19LDBEziYRu8zfB(zH5!Rk!(k z9qoF(6F8%4ZL6Z)QcF;cRau2sKk_L9nrHT`Wc`)YIbEU+>V@0kp> z@p{&$)3w>SX+8a~^)UW!xgs^@-zu#9`^V0T>8woQ?b;vK&k6idKWU(aTjk($$ov5S%G03;dH?n+ z4dq}<@JpVb|EXn9*E^xJ$NrlB`TAD!wo`43x4(9BmwsUsWeL&w Date: Fri, 4 Dec 2020 14:44:14 +0300 Subject: [PATCH 3/3] Geyser fixes --- .../blocks/BlockSulphuricGeyser.java | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/betterend/blocks/BlockSulphuricGeyser.java b/src/main/java/ru/betterend/blocks/BlockSulphuricGeyser.java index 164ad09f..a8676666 100644 --- a/src/main/java/ru/betterend/blocks/BlockSulphuricGeyser.java +++ b/src/main/java/ru/betterend/blocks/BlockSulphuricGeyser.java @@ -6,16 +6,25 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.FluidFillable; import net.minecraft.block.Material; +import net.minecraft.block.ShapeContext; +import net.minecraft.block.Waterloggable; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.FluidState; +import net.minecraft.fluid.Fluids; +import net.minecraft.item.ItemPlacementContext; import net.minecraft.particle.ParticleTypes; import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.BooleanProperty; +import net.minecraft.state.property.Properties; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; import net.minecraft.world.BlockView; import net.minecraft.world.World; import net.minecraft.world.WorldAccess; @@ -23,13 +32,27 @@ import net.minecraft.world.WorldView; import ru.betterend.blocks.basis.BlockBaseNotFull; import ru.betterend.registry.EndBlocks; -public class BlockSulphuricGeyser extends BlockBaseNotFull implements FluidFillable { +public class BlockSulphuricGeyser extends BlockBaseNotFull implements FluidFillable, Waterloggable { + public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; + private static final VoxelShape SHAPE = Block.createCuboidShape(1, 1, 1, 15, 16, 15); + public BlockSulphuricGeyser() { super(FabricBlockSettings.of(Material.STONE) .breakByTool(FabricToolTags.PICKAXES) .sounds(BlockSoundGroup.STONE) - .nonOpaque() + .noCollision() .requiresTool()); + this.setDefaultState(getDefaultState().with(WATERLOGGED, true)); + } + + @Override + protected void appendProperties(StateManager.Builder builder) { + builder.add(WATERLOGGED); + } + + @Override + public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { + return SHAPE; } @Override @@ -58,6 +81,18 @@ public class BlockSulphuricGeyser extends BlockBaseNotFull implements FluidFilla } } + @Override + public BlockState getPlacementState(ItemPlacementContext ctx) { + WorldAccess worldAccess = ctx.getWorld(); + BlockPos blockPos = ctx.getBlockPos(); + return this.getDefaultState().with(WATERLOGGED, worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER); + } + + @Override + public FluidState getFluidState(BlockState state) { + return (Boolean) state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); + } + @Environment(EnvType.CLIENT) public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { super.randomDisplayTick(state, world, pos, random);