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

@ -4,22 +4,22 @@ import java.io.Reader;
import java.util.Random;
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.Fertilizable;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry;
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.Fertilizable;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.SoundType;
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.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import net.minecraft.world.gen.feature.Feature;
import ru.betterend.client.render.ERenderLayer;
@ -29,26 +29,17 @@ import ru.betterend.registry.EndTags;
public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements Fertilizable, IRenderTypeable {
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 14, 12);
public FeatureSaplingBlock() {
super(FabricBlockSettings.of(Material.PLANT)
.breakByHand(true)
.collidable(false)
.breakInstantly()
.sounds(BlockSoundGroup.GRASS)
.ticksRandomly());
super(FabricBlockSettings.of(Material.PLANT).breakByHand(true).collidable(false).breakInstantly()
.sounds(SoundType.GRASS).ticksRandomly());
}
public FeatureSaplingBlock(int light) {
super(FabricBlockSettings.of(Material.PLANT)
.breakByHand(true)
.collidable(false)
.breakInstantly()
.sounds(BlockSoundGroup.GRASS)
.luminance(light)
.ticksRandomly());
super(FabricBlockSettings.of(Material.PLANT).breakByHand(true).collidable(false).breakInstantly()
.sounds(SoundType.GRASS).luminance(light).ticksRandomly());
}
protected abstract Feature<?> getFeature();
@Override
@ -58,13 +49,14 @@ public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements Fe
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return world.getBlockState(pos.down()).isIn(EndTags.END_GROUND);
return world.getBlockState(pos.below()).isIn(EndTags.END_GROUND);
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos))
return Blocks.AIR.getDefaultState();
return Blocks.AIR.defaultBlockState();
else
return state;
}
@ -75,34 +67,34 @@ public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements Fe
}
@Override
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
return random.nextInt(16) == 0;
}
@Override
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
getFeature().generate(world, world.getChunkManager().getChunkGenerator(), random, pos, null);
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
getFeature().generate(world, world.getChunkManager().getChunkGenerator(), random, pos, null);
}
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
super.scheduledTick(state, world, pos, random);
if (canGrow(world, random, pos, state)) {
grow(world, random, pos, state);
}
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String block) {
if (block.contains("item")) {
@ -111,9 +103,9 @@ public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements Fe
}
return Patterns.createJson(Patterns.BLOCK_CROSS, block);
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_SAPLING;
}
}