Start migration

This commit is contained in:
Aleksey 2021-04-08 21:55:07 +03:00
parent 6630ce0cab
commit 47ed597358
491 changed files with 12045 additions and 11953 deletions

View file

@ -1,119 +1,110 @@
package ru.betterend.blocks.basis;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.FluidFillable;
import net.minecraft.block.Waterloggable;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FluidFillable;
import net.minecraft.world.level.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.state.StateManager;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.level.block.state.StateDefinition;
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.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.BlockProperties;
public class EndLanternBlock extends BlockBaseNotFull implements Waterloggable, FluidFillable {
public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR;
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
public EndLanternBlock(Block source) {
this(FabricBlockSettings.copyOf(source).luminance(15).nonOpaque());
}
public EndLanternBlock(FabricBlockSettings settings) {
super(settings.nonOpaque());
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(IS_FLOOR, WATERLOGGED);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
WorldView worldView = ctx.getWorld();
WorldView worldView = ctx.getLevel();
BlockPos blockPos = ctx.getBlockPos();
Direction dir = ctx.getSide();
boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER;
if (dir != Direction.DOWN && dir != Direction.UP) {
if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) {
return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water);
}
else if (sideCoversSmallSquare(worldView, blockPos.down(), Direction.UP)) {
} else if (sideCoversSmallSquare(worldView, blockPos.below(), Direction.UP)) {
return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water);
}
else {
} else {
return null;
}
}
else if (dir == Direction.DOWN) {
} else if (dir == Direction.DOWN) {
if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) {
return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water);
}
else if (sideCoversSmallSquare(worldView, blockPos.down(), Direction.UP)) {
} else if (sideCoversSmallSquare(worldView, blockPos.below(), Direction.UP)) {
return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water);
}
else {
} else {
return null;
}
}
else {
if (sideCoversSmallSquare(worldView, blockPos.down(), Direction.UP)) {
} else {
if (sideCoversSmallSquare(worldView, blockPos.below(), Direction.UP)) {
return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water);
}
else if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) {
} else if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) {
return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water);
}
else {
} else {
return null;
}
}
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
if (state.get(IS_FLOOR)) {
return sideCoversSmallSquare(world, pos.down(), Direction.UP);
}
else {
if (state.getValue(IS_FLOOR)) {
return sideCoversSmallSquare(world, pos.below(), Direction.UP);
} else {
return sideCoversSmallSquare(world, pos.up(), Direction.DOWN);
}
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
Boolean water = state.get(WATERLOGGED);
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
Boolean water = state.getValue(WATERLOGGED);
if (water) {
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
}
if (!canPlaceAt(state, world, pos)) {
return water ? Blocks.WATER.getDefaultState() : Blocks.AIR.getDefaultState();
}
else {
return water ? Blocks.WATER.defaultBlockState() : Blocks.AIR.defaultBlockState();
} else {
return state;
}
}
@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) {
public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return false;
}
@Override
public FluidState getFluidState(BlockState state) {
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.getDefaultState();
return state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.defaultBlockState();
}
}