mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-14 14:34:16 +01:00
PR for #2893
This commit is contained in:
parent
97da6be27f
commit
e39f9ce7a1
@ -15,12 +15,19 @@ import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
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.material.FluidState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
@ -29,11 +36,12 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
public class DrillBlock extends DirectionalKineticBlock implements ITE<DrillTileEntity> {
|
||||
public class DrillBlock extends DirectionalKineticBlock implements ITE<DrillTileEntity>, SimpleWaterloggedBlock {
|
||||
public static DamageSource damageSourceDrill = new DamageSource("create.mechanical_drill").bypassArmor();
|
||||
|
||||
public DrillBlock(Properties properties) {
|
||||
super(properties);
|
||||
registerDefaultState(super.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -83,6 +91,31 @@ public class DrillBlock extends DirectionalKineticBlock implements ITE<DrillTile
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidState getFluidState(BlockState state) {
|
||||
return state.getValue(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(BlockStateProperties.WATERLOGGED);
|
||||
super.createBlockStateDefinition(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState,
|
||||
LevelAccessor world, BlockPos pos, BlockPos neighbourPos) {
|
||||
if (state.getValue(BlockStateProperties.WATERLOGGED))
|
||||
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
FluidState FluidState = context.getLevel().getFluidState(context.getClickedPos());
|
||||
return super.getStateForPlacement(context).setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(FluidState.getType() == Fluids.WATER));
|
||||
}
|
||||
|
||||
public static double getDamage(float speed) {
|
||||
float speedAbs = Math.abs(speed);
|
||||
double sub1 = Math.min(speedAbs / 16, 2);
|
||||
|
Loading…
Reference in New Issue
Block a user