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

@ -6,25 +6,25 @@ import com.google.common.collect.Lists;
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.Blocks;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
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.material.Material;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.entity.player.PlayerEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
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 ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
@ -32,13 +32,10 @@ import ru.betterend.registry.EndTags;
public class UpDownPlantBlock extends BlockBaseNotFull implements IRenderTypeable {
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 16, 12);
public UpDownPlantBlock() {
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.GRASS)
.breakByHand(true)
.noCollision());
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS)
.breakByHand(true).noCollision());
}
@Override
@ -48,48 +45,49 @@ public class UpDownPlantBlock extends BlockBaseNotFull implements IRenderTypeabl
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
BlockState down = world.getBlockState(pos.down());
BlockState down = world.getBlockState(pos.below());
BlockState up = world.getBlockState(pos.up());
return (isTerrain(down) || down.getBlock() == this) && (isSupport(up, world, pos) || up.getBlock() == this);
}
protected boolean isTerrain(BlockState state) {
return state.isIn(EndTags.END_GROUND);
}
protected boolean isSupport(BlockState state, WorldView world, BlockPos pos) {
return sideCoversSmallSquare(world, pos.up(), Direction.UP);
}
@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();
}
else {
return Blocks.AIR.defaultBlockState();
} else {
return state;
}
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.get(LootContextParameters.TOOL);
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS)
|| EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Lists.newArrayList(new ItemStack(this));
}
else {
} else {
return Lists.newArrayList();
}
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
@Override
public void afterBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, BlockEntity blockEntity, ItemStack stack) {
public void afterBreak(Level world, PlayerEntity player, BlockPos pos, BlockState state, BlockEntity blockEntity,
ItemStack stack) {
super.afterBreak(world, player, pos, state, blockEntity, stack);
world.updateNeighbor(pos, Blocks.AIR, pos.down());
world.updateNeighbor(pos, Blocks.AIR, pos.below());
}
}