93 lines
3.8 KiB
Java
93 lines
3.8 KiB
Java
package com.atsuishio.superbwarfare.block;
|
|
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.world.entity.Mob;
|
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.world.level.LevelAccessor;
|
|
import net.minecraft.world.level.block.Block;
|
|
import net.minecraft.world.level.block.SoundType;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.level.block.state.StateDefinition;
|
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
|
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
|
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
|
|
import net.minecraft.world.level.material.FluidState;
|
|
import net.minecraft.world.level.material.Fluids;
|
|
import net.minecraft.world.level.material.PushReaction;
|
|
import net.minecraft.world.level.pathfinder.PathType;
|
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
|
import net.minecraft.world.phys.shapes.Shapes;
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
import javax.annotation.ParametersAreNonnullByDefault;
|
|
|
|
public class DragonTeethBlock extends Block {
|
|
|
|
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
|
|
|
public DragonTeethBlock() {
|
|
super(Properties.of().instrument(NoteBlockInstrument.BASEDRUM).sound(SoundType.STONE).strength(25f, 500f).requiresCorrectToolForDrops().pushReaction(PushReaction.BLOCK).noOcclusion().isRedstoneConductor((bs, br, bp) -> false));
|
|
this.registerDefaultState(this.stateDefinition.any().setValue(WATERLOGGED, false));
|
|
}
|
|
|
|
@Override
|
|
@ParametersAreNonnullByDefault
|
|
public boolean propagatesSkylightDown(BlockState state, BlockGetter reader, BlockPos pos) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
@ParametersAreNonnullByDefault
|
|
public int getLightBlock(BlockState state, BlockGetter worldIn, BlockPos pos) {
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
@ParametersAreNonnullByDefault
|
|
public @NotNull VoxelShape getVisualShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
|
|
return Shapes.empty();
|
|
}
|
|
|
|
@Override
|
|
@ParametersAreNonnullByDefault
|
|
public @NotNull VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
|
|
return Shapes.or(box(2, 0, 2, 14, 25, 14));
|
|
}
|
|
|
|
@Override
|
|
@ParametersAreNonnullByDefault
|
|
public @Nullable PathType getAdjacentBlockPathType(BlockState state, BlockGetter level, BlockPos pos, @Nullable Mob mob, PathType originalType) {
|
|
return PathType.LAVA;
|
|
}
|
|
|
|
|
|
@Override
|
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
|
builder.add(WATERLOGGED);
|
|
}
|
|
|
|
@Override
|
|
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
|
boolean flag = context.getLevel().getFluidState(context.getClickedPos()).getType() == Fluids.WATER;
|
|
return this.defaultBlockState().setValue(WATERLOGGED, flag);
|
|
}
|
|
|
|
@Override
|
|
public @NotNull FluidState getFluidState(BlockState state) {
|
|
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
|
|
}
|
|
|
|
@Override
|
|
@ParametersAreNonnullByDefault
|
|
public @NotNull BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor world, BlockPos currentPos, BlockPos facingPos) {
|
|
if (state.getValue(WATERLOGGED)) {
|
|
world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
|
|
}
|
|
return super.updateShape(state, facing, facingState, world, currentPos, facingPos);
|
|
}
|
|
}
|
|
|