Search in sources :

Example 1 with ApiaryBlock

use of com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock in project ResourcefulBees by Resourceful-Bees.

the class ApiaryController method runCreativeBuild.

public void runCreativeBuild(ServerPlayer player) {
    if (this.level != null) {
        buildStructureBlockList();
        boolean addedStorage = false;
        for (BlockPos pos : structureBlocks) {
            Block block = this.level.getBlockState(pos).getBlock();
            if (!(block instanceof ApiaryBlock)) {
                if (addedStorage) {
                    this.level.setBlockAndUpdate(pos, Blocks.GLASS.defaultBlockState());
                } else {
                    this.level.setBlockAndUpdate(pos, ModBlocks.APIARY_STORAGE_BLOCK.get().defaultBlockState());
                    addedStorage = true;
                }
            }
        }
        runStructureValidation(player);
    }
}
Also used : ApiaryBlock(com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock) ApiaryBlock(com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock) ApiaryBreederBlock(com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBreederBlock) ApiaryStorageBlock(com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryStorageBlock) Block(net.minecraft.world.level.block.Block) BlockPos(net.minecraft.core.BlockPos)

Example 2 with ApiaryBlock

use of com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock in project ResourcefulBees by Resourceful-Bees.

the class ApiaryUpgradeRecipe method getRemainingItems.

@Override
@NotNull
public NonNullList<ItemStack> getRemainingItems(@NotNull CraftingContainer inventory) {
    NonNullList<ItemStack> remainingItems = super.getRemainingItems(inventory);
    for (int i = 0; i < inventory.getContainerSize(); i++) {
        ItemStack item = inventory.getItem(i);
        Block block = Block.byItem(item.getItem());
        if (block instanceof ApiaryBlock || block instanceof BeehiveBlock) {
            ItemStack box = getBeeBoxFromHive(item);
            if (box == null)
                continue;
            remainingItems.set(i, box);
        }
    }
    return remainingItems;
}
Also used : ApiaryBlock(com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock) BeehiveBlock(net.minecraft.world.level.block.BeehiveBlock) ApiaryBlock(com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock) Block(net.minecraft.world.level.block.Block) ItemStack(net.minecraft.world.item.ItemStack) BeehiveBlock(net.minecraft.world.level.block.BeehiveBlock) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ApiaryBlock

use of com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock in project ResourcefulBees by Resourceful-Bees.

the class ApiaryController method validateBlocks.

private boolean validateBlocks(AtomicBoolean isStructureValid, Level worldIn, @Nullable ServerPlayer validatingPlayer) {
    structureBlocks.forEach(pos -> {
        Block block = worldIn.getBlockState(pos).getBlock();
        if (block.is(BeeInfoUtils.getValidApiaryTag()) || block instanceof ApiaryBreederBlock || block instanceof ApiaryStorageBlock || block instanceof ApiaryBlock) {
            BlockEntity tile = worldIn.getBlockEntity(pos);
            linkStorageAndBreeder(tile);
        } else {
            isStructureValid.set(false);
            if (validatingPlayer != null)
                validatingPlayer.displayClientMessage(new TextComponent(String.format("Block at position (X: %1$s Y: %2$s Z: %3$s) is invalid!", pos.getX(), pos.getY(), pos.getZ())), false);
        }
    });
    return isStructureValid.get();
}
Also used : ApiaryBreederBlock(com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBreederBlock) TextComponent(net.minecraft.network.chat.TextComponent) ApiaryStorageBlock(com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryStorageBlock) ApiaryBlock(com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock) ApiaryBlock(com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock) ApiaryBreederBlock(com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBreederBlock) ApiaryStorageBlock(com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryStorageBlock) Block(net.minecraft.world.level.block.Block) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) TickableBlockEntity(net.minecraft.world.level.block.entity.TickableBlockEntity)

Example 4 with ApiaryBlock

use of com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock in project ResourcefulBees by Resourceful-Bees.

the class PreviewHandler method onWorldRenderLast.

public static void onWorldRenderLast(RenderWorldLastEvent event) {
    Level world = Minecraft.getInstance().level;
    PoseStack ms = event.getMatrixStack();
    MultiBufferSource.BufferSource buffers = Minecraft.getInstance().renderBuffers().bufferSource();
    VertexConsumer buffer = buffers.getBuffer(RenderType.translucent());
    if (apiaryPos != null && enabled) {
        if (world != null && world.getBlockState(apiaryPos).getBlock() instanceof ApiaryBlock) {
            if (world.getBlockEntity(apiaryPos) instanceof ApiaryTileEntity) {
                ApiaryTileEntity apiaryTE = (ApiaryTileEntity) world.getBlockEntity(apiaryPos);
                if (apiaryTE != null && apiaryTE.isPreviewed())
                    for (BlockPos pos : STRUCTURE_PREVIEW_POS) {
                        if (world.getBlockState(pos).equals(Blocks.AIR.defaultBlockState()))
                            renderBlockAt(ms, buffer, ModBlocks.PREVIEW_BLOCK.get().defaultBlockState(), pos);
                        else {
                            if (BeeInfoUtils.getBlockTag("resourcefulbees:valid_apiary") != null && !world.getBlockState(pos).is(BeeInfoUtils.getBlockTag("resourcefulbees:valid_apiary"))) {
                                renderBlockAt(ms, buffer, ModBlocks.ERRORED_PREVIEW_BLOCK.get().defaultBlockState(), pos);
                            }
                        }
                    }
            }
        } else {
            STRUCTURE_PREVIEW_POS.clear();
            apiaryPos = null;
            PreviewHandler.enabled = false;
        }
    }
    buffers.endBatch(RenderType.translucent());
}
Also used : ApiaryBlock(com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock) PoseStack(com.mojang.blaze3d.vertex.PoseStack) ApiaryTileEntity(com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity) MultiBufferSource(net.minecraft.client.renderer.MultiBufferSource) Level(net.minecraft.world.level.Level) VertexConsumer(com.mojang.blaze3d.vertex.VertexConsumer) BlockPos(net.minecraft.core.BlockPos)

Aggregations

ApiaryBlock (com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock)4 Block (net.minecraft.world.level.block.Block)3 ApiaryBreederBlock (com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBreederBlock)2 ApiaryStorageBlock (com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryStorageBlock)2 BlockPos (net.minecraft.core.BlockPos)2 PoseStack (com.mojang.blaze3d.vertex.PoseStack)1 VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)1 ApiaryTileEntity (com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity)1 MultiBufferSource (net.minecraft.client.renderer.MultiBufferSource)1 TextComponent (net.minecraft.network.chat.TextComponent)1 ItemStack (net.minecraft.world.item.ItemStack)1 Level (net.minecraft.world.level.Level)1 BeehiveBlock (net.minecraft.world.level.block.BeehiveBlock)1 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)1 TickableBlockEntity (net.minecraft.world.level.block.entity.TickableBlockEntity)1 NotNull (org.jetbrains.annotations.NotNull)1