Continue mapping migration

This commit is contained in:
Aleksey 2021-04-12 21:38:22 +03:00
parent 99ade39404
commit f03fd03bd0
499 changed files with 12567 additions and 12723 deletions

View file

@ -3,28 +3,28 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
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.HorizontalFacingBlock;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.fluid.FluidState;
import net.minecraft.world.level.material.Fluids;
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.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.BlockMirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
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.DirectionProperty;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.patterns.BlockPatterned;
@ -32,15 +32,15 @@ import ru.betterend.patterns.Patterns;
import ru.betterend.util.BlocksHelper;
public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable, BlockPatterned {
public static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
protected static final VoxelShape EAST_SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 3.0D, 16.0D, 16.0D);
protected static final VoxelShape WEST_SHAPE = Block.createCuboidShape(13.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D);
protected static final VoxelShape SOUTH_SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 3.0D);
protected static final VoxelShape NORTH_SHAPE = Block.createCuboidShape(0.0D, 0.0D, 13.0D, 16.0D, 16.0D, 16.0D);
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
protected static final VoxelShape EAST_SHAPE = Block.box(0.0D, 0.0D, 0.0D, 3.0D, 16.0D, 16.0D);
protected static final VoxelShape WEST_SHAPE = Block.box(13.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D);
protected static final VoxelShape SOUTH_SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 3.0D);
protected static final VoxelShape NORTH_SHAPE = Block.box(0.0D, 0.0D, 13.0D, 16.0D, 16.0D, 16.0D);
public EndLadderBlock(Block block) {
super(FabricBlockSettings.copyOf(block).nonOpaque());
super(FabricBlockSettings.copyOf(block).noOcclusion());
}
@Override
@ -49,7 +49,7 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable,
stateManager.add(WATERLOGGED);
}
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
switch (state.getValue(FACING)) {
case SOUTH:
return SOUTH_SHAPE;
@ -62,25 +62,25 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable,
}
}
private boolean canPlaceOn(BlockView world, BlockPos pos, Direction side) {
private boolean canPlaceOn(BlockGetter world, BlockPos pos, Direction side) {
BlockState blockState = world.getBlockState(pos);
return !blockState.emitsRedstonePower() && blockState.isSideSolidFullSquare(world, pos, side);
return !blockState.isSignalSource() && blockState.isFaceSturdy(world, pos, side);
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = (Direction) state.getValue(FACING);
return this.canPlaceOn(world, pos.relative(direction.getOpposite()), direction);
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (facing.getOpposite() == state.getValue(FACING) && !state.canPlaceAt(world, pos)) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState,
LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (facing.getOpposite() == state.getValue(FACING) && !state.canSurvive(world, pos)) {
return Blocks.AIR.defaultBlockState();
} else {
if ((Boolean) state.getValue(WATERLOGGED)) {
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
}
return super.updateShape(state, facing, neighborState, world, pos, neighborPos);
@ -88,28 +88,28 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable,
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
BlockState blockState2;
if (!ctx.canReplaceExisting()) {
blockState2 = ctx.getLevel().getBlockState(ctx.getBlockPos().offset(ctx.getSide().getOpposite()));
if (blockState2.getBlock() == this && blockState2.get(FACING) == ctx.getSide()) {
if (!ctx.replacingClickedOnBlock()) {
blockState2 = ctx.getLevel().getBlockState(ctx.getClickedPos().relative(ctx.getClickedFace().getOpposite()));
if (blockState2.getBlock() == this && blockState2.getValue(FACING) == ctx.getClickedFace()) {
return null;
}
}
blockState2 = this.defaultBlockState();
WorldView worldView = ctx.getLevel();
BlockPos blockPos = ctx.getBlockPos();
FluidState fluidState = ctx.getLevel().getFluidState(ctx.getBlockPos());
Direction[] var6 = ctx.getPlacementDirections();
LevelReader worldView = ctx.getLevel();
BlockPos blockPos = ctx.getClickedPos();
FluidState fluidState = ctx.getLevel().getFluidState(ctx.getClickedPos());
Direction[] var6 = ctx.getNearestLookingDirections();
int var7 = var6.length;
for (int var8 = 0; var8 < var7; ++var8) {
Direction direction = var6[var8];
if (direction.getAxis().isHorizontal()) {
blockState2 = (BlockState) blockState2.with(FACING, direction.getOpposite());
if (blockState2.canPlaceAt(worldView, blockPos)) {
return (BlockState) blockState2.with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER);
blockState2 = (BlockState) blockState2.setValue(FACING, direction.getOpposite());
if (blockState2.canSurvive(worldView, blockPos)) {
return (BlockState) blockState2.setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER);
}
}
}
@ -123,26 +123,26 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable,
}
@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
}
@Override
public FluidState getFluidState(BlockState state) {
return (Boolean) state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
return (Boolean) state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
@Override
public String getStatesPattern(Reader data) {
String blockId = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(data, blockId, blockId);
}
@Override
public String getModelPattern(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
@ -151,7 +151,7 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable,
}
return Patterns.createJson(Patterns.BLOCK_LADDER, blockId.getPath());
}
@Override
public ResourceLocation statePatternId() {
return Patterns.STATE_LADDER;