Geyser prototype
This commit is contained in:
parent
9504432cdd
commit
bf47e9a2b5
9 changed files with 254 additions and 5 deletions
|
@ -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);
|
||||
|
|
69
src/main/java/ru/betterend/blocks/BlockSulphuricGeyser.java
Normal file
69
src/main/java/ru/betterend/blocks/BlockSulphuricGeyser.java
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue