More fixes, vents generation prototype

This commit is contained in:
paulevsGitch 2020-12-04 15:52:44 +03:00
parent a93d7b7ef1
commit cec37f10d6
5 changed files with 72 additions and 12 deletions

View file

@ -7,12 +7,14 @@ import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.FluidFillable; import net.minecraft.block.FluidFillable;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext; import net.minecraft.block.ShapeContext;
import net.minecraft.block.Waterloggable; import net.minecraft.block.Waterloggable;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState; import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids; import net.minecraft.fluid.Fluids;
@ -30,10 +32,11 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView; import net.minecraft.world.WorldView;
import ru.betterend.blocks.basis.BlockBaseNotFull; import ru.betterend.blocks.basis.BlockBaseNotFull;
import ru.betterend.blocks.entities.BlockEntityHydrothermalVent;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndParticles; import ru.betterend.registry.EndParticles;
public class BlockHydrothermalVent extends BlockBaseNotFull implements FluidFillable, Waterloggable { public class BlockHydrothermalVent extends BlockBaseNotFull implements BlockEntityProvider, FluidFillable, Waterloggable {
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
private static final VoxelShape SHAPE = Block.createCuboidShape(1, 1, 1, 15, 16, 15); private static final VoxelShape SHAPE = Block.createCuboidShape(1, 1, 1, 15, 16, 15);
@ -107,4 +110,9 @@ public class BlockHydrothermalVent extends BlockBaseNotFull implements FluidFill
world.addParticle(ParticleTypes.BUBBLE, x, y, z, 0, 0, 0); world.addParticle(ParticleTypes.BUBBLE, x, y, z, 0, 0, 0);
} }
} }
@Override
public BlockEntity createBlockEntity(BlockView world) {
return new BlockEntityHydrothermalVent();
}
} }

View file

@ -0,0 +1,32 @@
package ru.betterend.blocks.entities;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.Tickable;
import ru.betterend.blocks.BlockHydrothermalVent;
import ru.betterend.registry.EndBlockEntities;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndParticles;
public class BlockEntityHydrothermalVent extends BlockEntity implements Tickable {
public BlockEntityHydrothermalVent() {
super(EndBlockEntities.HYDROTHERMAL_VENT);
}
@Override
public void tick() {
double x = pos.getX() + world.random.nextDouble();
double y = pos.getY() + 0.9 + world.random.nextDouble() * 0.3;
double z = pos.getZ() + world.random.nextDouble();
BlockState state = getCachedState();
if (state.isOf(EndBlocks.HYDROTHERMAL_VENT)) {
if (getCachedState().get(BlockHydrothermalVent.WATERLOGGED)) {
world.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0);
}
else {
world.addParticle(ParticleTypes.BUBBLE, x, y, z, 0, 0, 0);
}
}
}
}

View file

@ -28,8 +28,8 @@ public class ParticleGeyser extends SpriteBillboardParticle {
if (this.age >= this.maxAge + 40) { if (this.age >= this.maxAge + 40) {
this.setColorAlpha((this.maxAge - this.age) / 40F); this.setColorAlpha((this.maxAge - this.age) / 40F);
} }
this.velocityX = 0; //this.velocityX = 0;
this.velocityZ = 0; //this.velocityZ = 0;
this.velocityY = 0.125; this.velocityY = 0.125;
super.tick(); super.tick();
} }

View file

@ -17,6 +17,7 @@ import ru.betterend.blocks.basis.BlockBarrel;
import ru.betterend.blocks.basis.BlockChest; import ru.betterend.blocks.basis.BlockChest;
import ru.betterend.blocks.basis.BlockPedestal; import ru.betterend.blocks.basis.BlockPedestal;
import ru.betterend.blocks.basis.BlockSign; import ru.betterend.blocks.basis.BlockSign;
import ru.betterend.blocks.entities.BlockEntityHydrothermalVent;
import ru.betterend.blocks.entities.EBarrelBlockEntity; import ru.betterend.blocks.entities.EBarrelBlockEntity;
import ru.betterend.blocks.entities.EChestBlockEntity; import ru.betterend.blocks.entities.EChestBlockEntity;
import ru.betterend.blocks.entities.ESignBlockEntity; import ru.betterend.blocks.entities.ESignBlockEntity;
@ -40,6 +41,8 @@ public class EndBlockEntities {
BlockEntityType.Builder.create(EBarrelBlockEntity::new, getBarrels())); BlockEntityType.Builder.create(EBarrelBlockEntity::new, getBarrels()));
public static final BlockEntityType<ESignBlockEntity> SIGN = registerBlockEntity("sign", public static final BlockEntityType<ESignBlockEntity> SIGN = registerBlockEntity("sign",
BlockEntityType.Builder.create(ESignBlockEntity::new, getSigns())); BlockEntityType.Builder.create(ESignBlockEntity::new, getSigns()));
public final static BlockEntityType<BlockEntityHydrothermalVent> HYDROTHERMAL_VENT = registerBlockEntity("hydrother_malvent",
BlockEntityType.Builder.create(BlockEntityHydrothermalVent::new, EndBlocks.HYDROTHERMAL_VENT));
public static <T extends BlockEntity> BlockEntityType<T> registerBlockEntity(String id, BlockEntityType.Builder<T> builder) { public static <T extends BlockEntity> BlockEntityType<T> registerBlockEntity(String id, BlockEntityType.Builder<T> builder) {
return Registry.register(Registry.BLOCK_ENTITY_TYPE, BetterEnd.makeID(id), builder.build(null)); return Registry.register(Registry.BLOCK_ENTITY_TYPE, BetterEnd.makeID(id), builder.build(null));

View file

@ -10,6 +10,7 @@ import net.minecraft.block.Material;
import net.minecraft.client.util.math.Vector3f; import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.Mutable; import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.ChunkGenerator;
@ -128,23 +129,39 @@ public class GeyserFeature extends DefaultFeature {
obj2.setBlock(EndBlocks.SULPHURIC_ROCK.stone); obj2.setBlock(EndBlocks.SULPHURIC_ROCK.stone);
new SDFDisplacement().setFunction((vec) -> { new SDFDisplacement().setFunction((vec) -> {
return -4F; return -4F;
}).setSource(sdf).setReplaceFunction(REPLACE1).fillRecursiveIgnore(world, pos, IGNORE); }).setSource(cave).setReplaceFunction(REPLACE1).fillRecursiveIgnore(world, pos, IGNORE);
obj1.setBlock(Blocks.END_STONE); obj1.setBlock(Blocks.END_STONE);
obj2.setBlock(Blocks.END_STONE); obj2.setBlock(Blocks.END_STONE);
new SDFDisplacement().setFunction((vec) -> { new SDFDisplacement().setFunction((vec) -> {
return -6F; return -6F;
}).setSource(sdf).setReplaceFunction(REPLACE1).fillRecursiveIgnore(world, pos, IGNORE); }).setSource(cave).setReplaceFunction(REPLACE1).fillRecursiveIgnore(world, pos, IGNORE);
BlocksHelper.setWithoutUpdate(world, pos, WATER);
Mutable mut = new Mutable().set(pos); Mutable mut = new Mutable().set(pos);
for (int i = 0; i < halfHeight + 5; i++) { count = getYOnSurface(world, pos.getX(), pos.getZ()) - pos.getY();
BlockState state = world.getBlockState(mut); for (int i = 0; i < count; i++) {
if (state.isIn(EndTags.GEN_TERRAIN) || state.isOf(Blocks.WATER)) { BlocksHelper.setWithoutUpdate(world, mut, WATER);
BlocksHelper.setWithoutUpdate(world, mut, WATER); for (Direction dir: BlocksHelper.HORIZONTAL) {
mut.setY(mut.getY() + 1); BlocksHelper.setWithoutUpdate(world, mut.offset(dir), WATER);
} }
else { mut.setY(mut.getY() + 1);
break; }
for (int i = 0; i < 30; i++) {
mut.set(pos).add(random.nextGaussian() * 2, -halfHeight - 10, random.nextGaussian() * 2);
int dist = MHelper.floor(6 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + random.nextInt(2);
BlockState state = world.getBlockState(mut);
while (state.isOf(Blocks.WATER)) {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
if (state.isIn(EndTags.GEN_TERRAIN)) {
for (int j = 0; j < dist; j++) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
mut.setY(mut.getY() + 1);
}
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.HYDROTHERMAL_VENT);
} }
} }