Search in sources :

Example 1 with ApiaryTileEntity

use of com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity 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)

Example 2 with ApiaryTileEntity

use of com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity in project ResourcefulBees by Resourceful-Bees.

the class ExportBeeMessage method handle.

public static void handle(ExportBeeMessage message, Supplier<NetworkEvent.Context> context) {
    context.get().enqueueWork(() -> {
        ServerPlayer player = context.get().getSender();
        if (player != null && player.level.isLoaded(message.pos)) {
            BlockEntity tileEntity = player.level.getBlockEntity(message.pos);
            if (tileEntity instanceof ApiaryTileEntity) {
                ApiaryTileEntity apiaryTileEntity = (ApiaryTileEntity) tileEntity;
                apiaryTileEntity.exportBee(player, message.beeType);
            }
        }
    });
    context.get().setPacketHandled(true);
}
Also used : ApiaryTileEntity(com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity) ServerPlayer(net.minecraft.server.level.ServerPlayer) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 3 with ApiaryTileEntity

use of com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity in project ResourcefulBees by Resourceful-Bees.

the class ImportBeeMessage method handle.

public static void handle(ImportBeeMessage message, Supplier<NetworkEvent.Context> context) {
    context.get().enqueueWork(() -> {
        ServerPlayer player = context.get().getSender();
        if (player != null && player.level.isLoaded(message.pos)) {
            BlockEntity tileEntity = player.level.getBlockEntity(message.pos);
            if (tileEntity instanceof ApiaryTileEntity) {
                ApiaryTileEntity apiaryTileEntity = (ApiaryTileEntity) tileEntity;
                apiaryTileEntity.importBee(player);
            }
        }
    });
    context.get().setPacketHandled(true);
}
Also used : ApiaryTileEntity(com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity) ServerPlayer(net.minecraft.server.level.ServerPlayer) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 4 with ApiaryTileEntity

use of com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity in project ResourcefulBees by Resourceful-Bees.

the class ApiaryBlock method setPlacedBy.

@Override
public void setPlacedBy(Level worldIn, @NotNull BlockPos pos, @NotNull BlockState state, @Nullable LivingEntity placer, @NotNull ItemStack stack) {
    BlockEntity tile = worldIn.getBlockEntity(pos);
    if (tile instanceof ApiaryTileEntity) {
        ApiaryTileEntity apiaryTileEntity = (ApiaryTileEntity) tile;
        apiaryTileEntity.setTier(tier);
    }
}
Also used : ApiaryTileEntity(com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 5 with ApiaryTileEntity

use of com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity in project ResourcefulBees by Resourceful-Bees.

the class MixinEnterBeehiveGoal method start.

/**
 * @author epic_oreo
 * @reason crashes when switching to vanilla code due to hivePos being null. retained vanilla checks in overwrite.
 */
@Overwrite()
public void start() {
    if (beeEntity.hivePos != null) {
        BlockEntity tileentity = beeEntity.level.getBlockEntity(beeEntity.hivePos);
        if (tileentity != null) {
            if (tileentity instanceof BeehiveBlockEntity) {
                BeehiveBlockEntity beehivetileentity = (BeehiveBlockEntity) tileentity;
                beehivetileentity.addOccupant(beeEntity, beeEntity.hasNectar());
            } else if (tileentity instanceof ApiaryTileEntity) {
                ApiaryTileEntity apiaryTileEntity = (ApiaryTileEntity) tileentity;
                apiaryTileEntity.tryEnterHive(beeEntity, beeEntity.hasNectar(), false);
            }
        }
    }
}
Also used : ApiaryTileEntity(com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity) BeehiveBlockEntity(net.minecraft.world.level.block.entity.BeehiveBlockEntity) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) BeehiveBlockEntity(net.minecraft.world.level.block.entity.BeehiveBlockEntity) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Aggregations

ApiaryTileEntity (com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity)10 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)9 ServerPlayer (net.minecraft.server.level.ServerPlayer)5 BeehiveBlockEntity (net.minecraft.world.level.block.entity.BeehiveBlockEntity)2 PoseStack (com.mojang.blaze3d.vertex.PoseStack)1 VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)1 CoreData (com.teamresourceful.resourcefulbees.api.beedata.CoreData)1 ApiaryBlock (com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock)1 CustomBeeEntity (com.teamresourceful.resourcefulbees.entity.passive.CustomBeeEntity)1 AbstractClientPlayer (net.minecraft.client.player.AbstractClientPlayer)1 MultiBufferSource (net.minecraft.client.renderer.MultiBufferSource)1 BlockPos (net.minecraft.core.BlockPos)1 Level (net.minecraft.world.level.Level)1 Block (net.minecraft.world.level.block.Block)1 NotNull (org.jetbrains.annotations.NotNull)1 Overwrite (org.spongepowered.asm.mixin.Overwrite)1