Block class rename

This commit is contained in:
paulevsGitch 2021-01-05 04:02:08 +03:00
parent 4b55bf30a8
commit 5f3547de8e
157 changed files with 748 additions and 756 deletions

View file

@ -0,0 +1,96 @@
package ru.betterend.blocks;
import java.util.Map;
import com.google.common.collect.Maps;
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.ShapeContext;
import net.minecraft.block.Waterloggable;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Direction.Axis;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BaseBlock;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.util.BlocksHelper;
public class EndLotusStemBlock extends BaseBlock implements Waterloggable, IRenderTypeable {
public static final EnumProperty<Direction> FACING = Properties.FACING;
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
public static final BooleanProperty LEAF = BooleanProperty.of("leaf");
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final Map<Axis, VoxelShape> SHAPES = Maps.newEnumMap(Axis.class);
public EndLotusStemBlock() {
super(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS));
this.setDefaultState(getDefaultState().with(WATERLOGGED, false).with(SHAPE, TripleShape.MIDDLE).with(LEAF, false).with(FACING, Direction.UP));
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
return state.get(LEAF) ? SHAPES.get(Axis.Y) : SHAPES.get(state.get(FACING).getAxis());
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(FACING, WATERLOGGED, SHAPE, LEAF);
}
@Override
public FluidState getFluidState(BlockState state) {
return (Boolean) state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
WorldAccess worldAccess = ctx.getWorld();
BlockPos blockPos = ctx.getBlockPos();
return this.getDefaultState().with(WATERLOGGED, worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER).with(FACING, ctx.getSide());
}
@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
}
@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
if ((Boolean) state.get(WATERLOGGED)) {
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
}
return state;
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
static {
SHAPES.put(Axis.X, Block.createCuboidShape(0, 6, 6, 16, 10, 10));
SHAPES.put(Axis.Y, Block.createCuboidShape(6, 0, 6, 10, 16, 10));
SHAPES.put(Axis.Z, Block.createCuboidShape(6, 6, 0, 10, 10, 16));
}
}