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

@ -9,30 +9,30 @@ import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FluidFillable;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.block.ShapeContext;
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.FluidFillable;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.block.ShapeContext;
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.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.IntProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.basis.AttachedBlock;
import ru.betterend.client.render.ERenderLayer;
@ -43,73 +43,71 @@ import ru.betterend.util.MHelper;
public class SulphurCrystalBlock extends AttachedBlock implements IRenderTypeable, Waterloggable, FluidFillable {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public static final IntProperty AGE = IntProperty.of("age", 0, 2);
public static final IntegerProperty AGE = IntegerProperty.of("age", 0, 2);
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
public SulphurCrystalBlock() {
super(FabricBlockSettings.of(Material.STONE)
.materialColor(MaterialColor.YELLOW)
.breakByTool(FabricToolTags.PICKAXES)
.sounds(BlockSoundGroup.GLASS)
.requiresTool()
.noCollision());
super(FabricBlockSettings.of(Material.STONE).materialColor(MaterialColor.COLOR_YELLOW)
.breakByTool(FabricToolTags.PICKAXES).sounds(SoundType.GLASS).requiresTool().noCollision());
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
super.appendProperties(stateManager);
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
super.createBlockStateDefinition(stateManager);
stateManager.add(AGE, WATERLOGGED);
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
return state.get(AGE) < 2 ? Collections.emptyList() : Lists.newArrayList(new ItemStack(EndItems.CRYSTALLINE_SULPHUR, MHelper.randRange(1, 3, MHelper.RANDOM)));
}
@Override
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
return !state.get(WATERLOGGED);
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return state.getValue(AGE) < 2 ? Collections.emptyList()
: Lists.newArrayList(
new ItemStack(EndItems.CRYSTALLINE_SULPHUR, MHelper.randRange(1, 3, MHelper.RANDOM)));
}
@Override
public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) {
return !state.get(WATERLOGGED);
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
return !state.getValue(WATERLOGGED);
}
@Override
public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return !state.getValue(WATERLOGGED);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
BlockState state = super.getPlacementState(ctx);
if (state != null) {
WorldView worldView = ctx.getWorld();
WorldView worldView = ctx.getLevel();
BlockPos blockPos = ctx.getBlockPos();
boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER;
return state.with(WATERLOGGED, water);
}
return null;
}
@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();
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
return BOUNDING_SHAPES.get(state.get(FACING));
return BOUNDING_SHAPES.get(state.getValue(FACING));
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
Direction direction = (Direction) state.get(FACING);
BlockPos blockPos = pos.offset(direction.getOpposite());
return world.getBlockState(blockPos).isOf(EndBlocks.BRIMSTONE);
Direction direction = (Direction) state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite());
return world.getBlockState(blockPos).is(EndBlocks.BRIMSTONE);
}
static {
BOUNDING_SHAPES.put(Direction.UP, VoxelShapes.cuboid(0.125, 0.0, 0.125, 0.875F, 0.5, 0.875F));
BOUNDING_SHAPES.put(Direction.DOWN, VoxelShapes.cuboid(0.125, 0.5, 0.125, 0.875F, 1.0, 0.875F));