Search in sources :

Example 1 with CoreData

use of com.teamresourceful.resourcefulbees.api.beedata.CoreData in project ResourcefulBees by Resourceful-Bees.

the class HoneyDipper method useOn.

@Override
@NotNull
public InteractionResult useOn(@NotNull UseOnContext useContext) {
    if (!useContext.getLevel().isClientSide()) {
        Block clickedBlock = useContext.getLevel().getBlockState(useContext.getClickedPos()).getBlock();
        if (selectedBee instanceof CustomBeeEntity) {
            CoreData beeData = ((CustomBeeEntity) selectedBee).getCoreData();
            if (!beeData.getBlockFlowers().isEmpty() && beeData.getBlockFlowers().contains(clickedBlock)) {
                setFlowerPosition(useContext);
                return InteractionResult.SUCCESS;
            }
        } else if (selectedBee != null && clickedBlock.is(BlockTags.FLOWERS)) {
            setFlowerPosition(useContext);
            return InteractionResult.SUCCESS;
        }
        BlockEntity clickedTile = useContext.getLevel().getBlockEntity(useContext.getClickedPos());
        if (selectedBee != null && (clickedTile instanceof BeehiveBlockEntity || clickedTile instanceof ApiaryTileEntity)) {
            selectedBee.hivePos = useContext.getClickedPos();
            sendMessageToPlayer(useContext.getPlayer(), MessageTypes.HIVE, useContext.getClickedPos());
            selectedBee = null;
            return InteractionResult.SUCCESS;
        }
    }
    return super.useOn(useContext);
}
Also used : CustomBeeEntity(com.teamresourceful.resourcefulbees.entity.passive.CustomBeeEntity) CoreData(com.teamresourceful.resourcefulbees.api.beedata.CoreData) ApiaryTileEntity(com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity) Block(net.minecraft.world.level.block.Block) BeehiveBlockEntity(net.minecraft.world.level.block.entity.BeehiveBlockEntity) BeehiveBlockEntity(net.minecraft.world.level.block.entity.BeehiveBlockEntity) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

CoreData (com.teamresourceful.resourcefulbees.api.beedata.CoreData)1 CustomBeeEntity (com.teamresourceful.resourcefulbees.entity.passive.CustomBeeEntity)1 ApiaryTileEntity (com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity)1 Block (net.minecraft.world.level.block.Block)1 BeehiveBlockEntity (net.minecraft.world.level.block.entity.BeehiveBlockEntity)1 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)1 NotNull (org.jetbrains.annotations.NotNull)1