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,25 +9,25 @@ 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.Blocks;
import net.minecraft.block.Fertilizable;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.server.world.ServerWorld;
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.block.Fertilizable;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
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.server.level.ServerLevel;
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.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.basis.AttachedBlock;
import ru.betterend.client.render.ERenderLayer;
@ -38,44 +38,41 @@ import ru.betterend.util.BlocksHelper;
public class SmallJellyshroomBlock extends AttachedBlock implements IRenderTypeable, Fertilizable {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public SmallJellyshroomBlock() {
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.NETHER_WART)
.breakByHand(true)
.noCollision());
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.NETHER_WART)
.breakByHand(true).noCollision());
}
@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 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 boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
Direction direction = state.get(FACING);
BlockPos blockPos = pos.offset(direction.getOpposite());
Direction direction = state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite());
BlockState support = world.getBlockState(blockPos);
return sideCoversSmallSquare(world, blockPos, direction) && support.isOpaque() && support.getLuminance() == 0;
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
static {
BOUNDING_SHAPES.put(Direction.UP, Block.createCuboidShape(3, 0, 3, 13, 16, 13));
BOUNDING_SHAPES.put(Direction.DOWN, Block.createCuboidShape(3, 0, 3, 13, 16, 13));
@ -87,16 +84,16 @@ public class SmallJellyshroomBlock extends AttachedBlock implements IRenderTypea
@Override
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
return state.get(FACING) == Direction.UP && world.getBlockState(pos.down()).isIn(EndTags.END_GROUND);
return state.getValue(FACING) == Direction.UP && world.getBlockState(pos.below()).isIn(EndTags.END_GROUND);
}
@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) {
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
BlocksHelper.setWithUpdate(world, pos, Blocks.AIR);
EndFeatures.JELLYSHROOM.getFeature().generate(world, null, random, pos, null);
}