Search in sources :

Example 76 with Block

use of net.minecraft.server.v1_16_R3.Block in project Citizens2 by CitizensDev.

the class FallingBlockController method createEntity.

@Override
protected Entity createEntity(Location at, NPC npc) {
    WorldServer ws = ((CraftWorld) at.getWorld()).getHandle();
    Block id = Blocks.STONE;
    int data = npc.data().get(NPC.ITEM_DATA_METADATA, npc.data().get("falling-block-data", 0));
    if (npc.data().has("falling-block-id") || npc.data().has(NPC.ITEM_ID_METADATA)) {
        id = CraftMagicNumbers.getBlock(Material.getMaterial(npc.data().<String>get(NPC.ITEM_ID_METADATA, npc.data().<String>get("falling-block-id"))));
    }
    final EntityFallingBlockNPC handle = new EntityFallingBlockNPC(ws, npc, at.getX(), at.getY(), at.getZ(), id.fromLegacyData(data));
    return handle.getBukkitEntity();
}
Also used : EntityFallingBlock(net.minecraft.server.v1_8_R3.EntityFallingBlock) Block(net.minecraft.server.v1_8_R3.Block) FallingBlock(org.bukkit.entity.FallingBlock) WorldServer(net.minecraft.server.v1_8_R3.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Example 77 with Block

use of net.minecraft.server.v1_16_R3.Block in project Atlas by funkemunky.

the class BlockBox1_16_R3 method getCollisionBox.

@Override
public CollisionBox getCollisionBox(org.bukkit.block.Block block) {
    final net.minecraft.server.v1_16_R3.World world = ((org.bukkit.craftbukkit.v1_16_R3.CraftWorld) block.getWorld()).getHandle();
    final int x = block.getX(), y = block.getY(), z = block.getZ();
    net.minecraft.server.v1_16_R3.IBlockData iblockData = ((CraftBlock) block).getNMS();
    net.minecraft.server.v1_16_R3.Block vblock = iblockData.getBlock();
    BlockPosition blockPos = new BlockPosition(x, y, z);
    VoxelShape shape = vblock.a(iblockData, world, blockPos, VoxelShapeCollision.a());
    List<AxisAlignedBB> boxes = shape.d();
    if (boxes.size() == 0) {
        return BlockData.getData(block.getType()).getBox(block, ProtocolVersion.getGameVersion());
    } else if (boxes.size() == 1) {
        AxisAlignedBB box = boxes.get(0);
        return new SimpleCollisionBox(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ);
    } else {
        ComplexCollisionBox complexBox = new ComplexCollisionBox();
        for (AxisAlignedBB box : boxes) {
            complexBox.add(new SimpleCollisionBox(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ));
        }
        return complexBox;
    }
}
Also used : World(net.minecraft.server.v1_16_R3.World) ComplexCollisionBox(cc.funkemunky.api.utils.world.types.ComplexCollisionBox) CraftBlock(org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) net.minecraft.server.v1_16_R3(net.minecraft.server.v1_16_R3) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 78 with Block

use of net.minecraft.server.v1_16_R3.Block in project java-vision by googleapis.

the class Detect method detectDocumentText.

/**
 * Performs document text detection on a local image file.
 *
 * @param filePath The path to the local file to detect document text on.
 * @throws Exception on errors while closing the client.
 * @throws IOException on Input/Output errors.
 */
// [START vision_fulltext_detection]
public static void detectDocumentText(String filePath) throws IOException {
    List<AnnotateImageRequest> requests = new ArrayList<>();
    ByteString imgBytes = ByteString.readFrom(new FileInputStream(filePath));
    Image img = Image.newBuilder().setContent(imgBytes).build();
    Feature feat = Feature.newBuilder().setType(Type.DOCUMENT_TEXT_DETECTION).build();
    AnnotateImageRequest request = AnnotateImageRequest.newBuilder().addFeatures(feat).setImage(img).build();
    requests.add(request);
    // the "close" method on the client to safely clean up any remaining background resources.
    try (ImageAnnotatorClient client = ImageAnnotatorClient.create()) {
        BatchAnnotateImagesResponse response = client.batchAnnotateImages(requests);
        List<AnnotateImageResponse> responses = response.getResponsesList();
        client.close();
        for (AnnotateImageResponse res : responses) {
            if (res.hasError()) {
                System.out.format("Error: %s%n", res.getError().getMessage());
                return;
            }
            // For full list of available annotations, see http://g.co/cloud/vision/docs
            TextAnnotation annotation = res.getFullTextAnnotation();
            for (Page page : annotation.getPagesList()) {
                String pageText = "";
                for (Block block : page.getBlocksList()) {
                    String blockText = "";
                    for (Paragraph para : block.getParagraphsList()) {
                        String paraText = "";
                        for (Word word : para.getWordsList()) {
                            String wordText = "";
                            for (Symbol symbol : word.getSymbolsList()) {
                                wordText = wordText + symbol.getText();
                                System.out.format("Symbol text: %s (confidence: %f)%n", symbol.getText(), symbol.getConfidence());
                            }
                            System.out.format("Word text: %s (confidence: %f)%n%n", wordText, word.getConfidence());
                            paraText = String.format("%s %s", paraText, wordText);
                        }
                        // Output Example using Paragraph:
                        System.out.println("%nParagraph: %n" + paraText);
                        System.out.format("Paragraph Confidence: %f%n", para.getConfidence());
                        blockText = blockText + paraText;
                    }
                    pageText = pageText + blockText;
                }
            }
            System.out.println("%nComplete annotation:");
            System.out.println(annotation.getText());
        }
    }
}
Also used : Word(com.google.cloud.vision.v1.Word) ByteString(com.google.protobuf.ByteString) Symbol(com.google.cloud.vision.v1.Symbol) ImageAnnotatorClient(com.google.cloud.vision.v1.ImageAnnotatorClient) ArrayList(java.util.ArrayList) Page(com.google.cloud.vision.v1.Page) ByteString(com.google.protobuf.ByteString) Image(com.google.cloud.vision.v1.Image) Feature(com.google.cloud.vision.v1.Feature) FileInputStream(java.io.FileInputStream) Paragraph(com.google.cloud.vision.v1.Paragraph) AnnotateImageRequest(com.google.cloud.vision.v1.AnnotateImageRequest) AnnotateImageResponse(com.google.cloud.vision.v1.AnnotateImageResponse) Block(com.google.cloud.vision.v1.Block) TextAnnotation(com.google.cloud.vision.v1.TextAnnotation) BatchAnnotateImagesResponse(com.google.cloud.vision.v1.BatchAnnotateImagesResponse)

Example 79 with Block

use of net.minecraft.server.v1_16_R3.Block in project java-vision by googleapis.

the class DetectBatchAnnotateFilesGcs method detectBatchAnnotateFilesGcs.

// Performs document feature detection on a remote PDF/TIFF/GIF file on Google Cloud Storage.
public static void detectBatchAnnotateFilesGcs(String gcsPath) {
    try (ImageAnnotatorClient client = ImageAnnotatorClient.create()) {
        // Annotate the first two pages and the last one (max 5 pages)
        // First page starts at 1, and not 0. Last page is -1.
        List<Integer> pages = Arrays.asList(1, 2, -1);
        GcsSource gcsSource = GcsSource.newBuilder().setUri(gcsPath).build();
        Feature feat = Feature.newBuilder().setType(Type.DOCUMENT_TEXT_DETECTION).build();
        // Other supported mime types : 'image/tiff' or 'image/gif'
        InputConfig inputConfig = InputConfig.newBuilder().setMimeType("application/pdf").setGcsSource(gcsSource).build();
        AnnotateFileRequest request = AnnotateFileRequest.newBuilder().addFeatures(feat).setInputConfig(inputConfig).addAllPages(pages).build();
        List<AnnotateFileRequest> requests = new ArrayList<>();
        requests.add(request);
        BatchAnnotateFilesRequest batchAnnotateFilesRequest = BatchAnnotateFilesRequest.newBuilder().addAllRequests(requests).build();
        ApiFuture<BatchAnnotateFilesResponse> future = client.batchAnnotateFilesCallable().futureCall(batchAnnotateFilesRequest);
        BatchAnnotateFilesResponse response = future.get();
        // Getting the first response
        AnnotateFileResponse annotateFileResponse = response.getResponses(0);
        // For full list of available annotations, see http://g.co/cloud/vision/docs
        TextAnnotation textAnnotation = annotateFileResponse.getResponses(0).getFullTextAnnotation();
        for (Page page : textAnnotation.getPagesList()) {
            String pageText = "";
            for (Block block : page.getBlocksList()) {
                String blockText = "";
                for (Paragraph para : block.getParagraphsList()) {
                    String paraText = "";
                    for (Word word : para.getWordsList()) {
                        String wordText = "";
                        for (Symbol symbol : word.getSymbolsList()) {
                            wordText = wordText + symbol.getText();
                            System.out.format("Symbol text: %s (Confidence: %f)\n", symbol.getText(), symbol.getConfidence());
                        }
                        System.out.format("Word text: %s (Confidence: %f)\n\n", wordText, word.getConfidence());
                        paraText = String.format("%s %s", paraText, wordText);
                    }
                    // Output Example using Paragraph:
                    System.out.println("\nParagraph: \n" + paraText);
                    System.out.format("Paragraph Confidence: %f\n", para.getConfidence());
                    blockText = blockText + paraText;
                }
                pageText = pageText + blockText;
            }
        }
        System.out.println("\nComplete annotation:");
        System.out.println(textAnnotation.getText());
    } catch (Exception e) {
        System.out.println("Error during detectPdfText: \n" + e.toString());
    }
}
Also used : GcsSource(com.google.cloud.vision.v1p4beta1.GcsSource) Word(com.google.cloud.vision.v1p4beta1.Word) BatchAnnotateFilesRequest(com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest) Symbol(com.google.cloud.vision.v1p4beta1.Symbol) ImageAnnotatorClient(com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient) ArrayList(java.util.ArrayList) Page(com.google.cloud.vision.v1p4beta1.Page) Feature(com.google.cloud.vision.v1p4beta1.Feature) Paragraph(com.google.cloud.vision.v1p4beta1.Paragraph) BatchAnnotateFilesResponse(com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse) AnnotateFileResponse(com.google.cloud.vision.v1p4beta1.AnnotateFileResponse) AnnotateFileRequest(com.google.cloud.vision.v1p4beta1.AnnotateFileRequest) Block(com.google.cloud.vision.v1p4beta1.Block) InputConfig(com.google.cloud.vision.v1p4beta1.InputConfig) TextAnnotation(com.google.cloud.vision.v1p4beta1.TextAnnotation)

Example 80 with Block

use of net.minecraft.server.v1_16_R3.Block in project java-vision by googleapis.

the class DetectBatchAnnotateFiles method detectBatchAnnotateFiles.

// Performs document feature detection on a local PDF/TIFF/GIF file.
public static void detectBatchAnnotateFiles(String filePath) {
    try (ImageAnnotatorClient client = ImageAnnotatorClient.create()) {
        // Annotate the first two pages and the last one (max 5 pages)
        // First page starts at 1, and not 0. Last page is -1.
        List<Integer> pages = Arrays.asList(1, 2, -1);
        ByteString pdfBytes = ByteString.readFrom(new FileInputStream(filePath));
        Feature feat = Feature.newBuilder().setType(Type.DOCUMENT_TEXT_DETECTION).build();
        // Other supported mime types : 'image/tiff' or 'image/gif'
        InputConfig inputConfig = InputConfig.newBuilder().setMimeType("application/pdf").setContent(pdfBytes).build();
        AnnotateFileRequest request = AnnotateFileRequest.newBuilder().addFeatures(feat).setInputConfig(inputConfig).addAllPages(pages).build();
        List<AnnotateFileRequest> requests = new ArrayList<>();
        requests.add(request);
        BatchAnnotateFilesRequest batchAnnotateFilesRequest = BatchAnnotateFilesRequest.newBuilder().addAllRequests(requests).build();
        ApiFuture<BatchAnnotateFilesResponse> future = client.batchAnnotateFilesCallable().futureCall(batchAnnotateFilesRequest);
        BatchAnnotateFilesResponse response = future.get();
        // Getting the first response
        AnnotateFileResponse annotateFileResponse = response.getResponses(0);
        // For full list of available annotations, see http://g.co/cloud/vision/docs
        TextAnnotation textAnnotation = annotateFileResponse.getResponses(0).getFullTextAnnotation();
        for (Page page : textAnnotation.getPagesList()) {
            String pageText = "";
            for (Block block : page.getBlocksList()) {
                String blockText = "";
                for (Paragraph para : block.getParagraphsList()) {
                    String paraText = "";
                    for (Word word : para.getWordsList()) {
                        String wordText = "";
                        for (Symbol symbol : word.getSymbolsList()) {
                            wordText = wordText + symbol.getText();
                            System.out.format("Symbol text: %s (Confidence: %f)\n", symbol.getText(), symbol.getConfidence());
                        }
                        System.out.format("Word text: %s (Confidence: %f)\n\n", wordText, word.getConfidence());
                        paraText = String.format("%s %s", paraText, wordText);
                    }
                    // Output Example using Paragraph:
                    System.out.println("\nParagraph: \n" + paraText);
                    System.out.format("Paragraph Confidence: %f\n", para.getConfidence());
                    blockText = blockText + paraText;
                }
                pageText = pageText + blockText;
            }
        }
        System.out.println("\nComplete annotation:");
        System.out.println(textAnnotation.getText());
    } catch (Exception e) {
        System.out.println("Error during detectPdfText: \n" + e.toString());
    }
}
Also used : Word(com.google.cloud.vision.v1p4beta1.Word) BatchAnnotateFilesRequest(com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest) ByteString(com.google.protobuf.ByteString) Symbol(com.google.cloud.vision.v1p4beta1.Symbol) ImageAnnotatorClient(com.google.cloud.vision.v1p4beta1.ImageAnnotatorClient) ArrayList(java.util.ArrayList) Page(com.google.cloud.vision.v1p4beta1.Page) ByteString(com.google.protobuf.ByteString) Feature(com.google.cloud.vision.v1p4beta1.Feature) FileInputStream(java.io.FileInputStream) Paragraph(com.google.cloud.vision.v1p4beta1.Paragraph) BatchAnnotateFilesResponse(com.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse) AnnotateFileResponse(com.google.cloud.vision.v1p4beta1.AnnotateFileResponse) AnnotateFileRequest(com.google.cloud.vision.v1p4beta1.AnnotateFileRequest) Block(com.google.cloud.vision.v1p4beta1.Block) InputConfig(com.google.cloud.vision.v1p4beta1.InputConfig) TextAnnotation(com.google.cloud.vision.v1p4beta1.TextAnnotation)

Aggregations

ArrayList (java.util.ArrayList)12 Block (net.minecraft.server.v1_12_R1.Block)12 ByteString (com.google.protobuf.ByteString)8 HashMap (java.util.HashMap)8 Block (net.minecraft.server.v1_10_R1.Block)8 Block (net.minecraft.server.v1_11_R1.Block)8 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)8 IBlockData (net.minecraft.server.v1_16_R3.IBlockData)8 Block (net.minecraft.server.v1_8_R3.Block)8 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)8 FallingBlock (org.bukkit.entity.FallingBlock)8 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)7 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)7 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)6 Block (com.google.cloud.vision.v1.Block)6 Feature (com.google.cloud.vision.v1.Feature)6 ImageAnnotatorClient (com.google.cloud.vision.v1.ImageAnnotatorClient)6 Page (com.google.cloud.vision.v1.Page)6 Paragraph (com.google.cloud.vision.v1.Paragraph)6 Symbol (com.google.cloud.vision.v1.Symbol)6