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,31 +4,31 @@ import java.util.Random;
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.Material;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateManager;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.entity.ItemEntity;
import net.minecraft.world.entity.player.PlayerEntity;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.DirectionProperty;
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.ActionResult;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction;
import net.minecraft.core.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.level.Level;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.entity.SilkMothEntity;
import ru.betterend.registry.EndEntities;
@ -38,26 +38,27 @@ import ru.betterend.util.MHelper;
public class SilkMothHiveBlock extends BlockBase {
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
public static final IntProperty FULLNESS = BlockProperties.FULLNESS;
public static final IntegerProperty FULLNESS = BlockProperties.FULLNESS;
public SilkMothHiveBlock() {
super(FabricBlockSettings.of(Material.WOOD).hardness(0.5F).resistance(0.1F).sounds(BlockSoundGroup.WOOL).nonOpaque().ticksRandomly().breakByHand(true));
super(FabricBlockSettings.of(Material.WOOD).hardness(0.5F).resistance(0.1F).sounds(SoundType.WOOL).nonOpaque()
.ticksRandomly().breakByHand(true));
this.setDefaultState(getDefaultState().with(FULLNESS, 0));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(FACING, FULLNESS);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
Direction dir = ctx.getPlayerFacing().getOpposite();
return this.getDefaultState().with(FACING, dir);
return this.defaultBlockState().with(FACING, dir);
}
@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
}
@ -65,15 +66,17 @@ public class SilkMothHiveBlock extends BlockBase {
public BlockState mirror(BlockState state, BlockMirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
}
@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
Direction dir = state.get(FACING);
BlockPos spawn = pos.offset(dir);
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
Direction dir = state.getValue(FACING);
BlockPos spawn = pos.relative(dir);
if (!world.getBlockState(spawn).isAir()) {
return;
}
int count = world.getEntitiesByType(EndEntities.SILK_MOTH, new Box(pos).expand(16), (entity) -> { return true; }).size();
int count = world.getEntitiesByType(EndEntities.SILK_MOTH, new Box(pos).expand(16), (entity) -> {
return true;
}).size();
if (count > 6) {
return;
}
@ -82,16 +85,17 @@ public class SilkMothHiveBlock extends BlockBase {
moth.setVelocity(new Vec3d(dir.getOffsetX() * 0.4, 0, dir.getOffsetZ() * 0.4));
moth.setHive(world, pos);
world.spawnEntity(moth);
world.playSound(null, pos, SoundEvents.BLOCK_BEEHIVE_EXIT, SoundCategory.BLOCKS, 1, 1);
world.playLocalSound(null, pos, SoundEvents.BLOCK_BEEHIVE_EXIT, SoundSource.BLOCKS, 1, 1);
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand,
BlockHitResult hit) {
if (hand == Hand.MAIN_HAND) {
ItemStack stack = player.getMainHandStack();
if (stack.getItem().isIn(FabricToolTags.SHEARS) && state.get(FULLNESS) == 3) {
if (stack.getItem().isIn(FabricToolTags.SHEARS) && state.getValue(FULLNESS) == 3) {
BlocksHelper.setWithUpdate(world, pos, state.with(FULLNESS, 0));
Direction dir = state.get(FACING);
Direction dir = state.getValue(FACING);
double px = pos.getX() + dir.getOffsetX() + 0.5;
double py = pos.getY() + dir.getOffsetY() + 0.5;
double pz = pos.getZ() + dir.getOffsetZ() + 0.5;