Code style changes, entities fixes
This commit is contained in:
parent
9d604b2d25
commit
44962e18b6
377 changed files with 5038 additions and 4914 deletions
|
@ -1,7 +1,5 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
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.core.BlockPos;
|
||||
|
@ -36,26 +34,28 @@ import ru.betterend.entity.SilkMothEntity;
|
|||
import ru.betterend.registry.EndEntities;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class SilkMothHiveBlock extends BaseBlock {
|
||||
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
|
||||
public static final IntegerProperty FULLNESS = EndBlockProperties.FULLNESS;
|
||||
|
||||
|
||||
public SilkMothHiveBlock() {
|
||||
super(FabricBlockSettings.of(Material.WOOD).breakByHand(true).hardness(0.5F).resistance(0.1F).sound(SoundType.WOOL).noOcclusion().randomTicks());
|
||||
this.registerDefaultState(defaultBlockState().setValue(FULLNESS, 0));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||
stateManager.add(FACING, FULLNESS);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
|
||||
Direction dir = ctx.getHorizontalDirection().getOpposite();
|
||||
return this.defaultBlockState().setValue(FACING, dir);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, Rotation rotation) {
|
||||
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
|
||||
|
@ -65,7 +65,7 @@ public class SilkMothHiveBlock extends BaseBlock {
|
|||
public BlockState mirror(BlockState state, Mirror mirror) {
|
||||
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||
Direction dir = state.getValue(FACING);
|
||||
|
@ -73,7 +73,9 @@ public class SilkMothHiveBlock extends BaseBlock {
|
|||
if (!world.getBlockState(spawn).isAir()) {
|
||||
return;
|
||||
}
|
||||
int count = world.getEntities(EndEntities.SILK_MOTH, new AABB(pos).inflate(16), (entity) -> { return true; }).size();
|
||||
int count = world.getEntities(EndEntities.SILK_MOTH, new AABB(pos).inflate(16), (entity) -> {
|
||||
return true;
|
||||
}).size();
|
||||
if (count > 6) {
|
||||
return;
|
||||
}
|
||||
|
@ -84,7 +86,7 @@ public class SilkMothHiveBlock extends BaseBlock {
|
|||
world.addFreshEntity(moth);
|
||||
world.playSound(null, pos, SoundEvents.BEEHIVE_EXIT, SoundSource.BLOCKS, 1, 1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (hand == InteractionHand.MAIN_HAND) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue