Search in sources :

Example 71 with Block

use of net.minecraft.server.v1_13_R2.Block in project SSB-OneBlock by BG-Software-LLC.

the class NMSAdapter_v1_8_R3 method setBlock.

@Override
public void setBlock(Location location, Material type, byte data, String nbt) {
    assert location.getWorld() != null;
    World worldServer = ((CraftWorld) location.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    worldServer.t(blockPosition);
    org.bukkit.block.Block bukkitBlock = location.getBlock();
    bukkitBlock.setType(type);
    if (data > 0)
        // noinspection deprecation
        bukkitBlock.setData(data);
    if (nbt != null) {
        try {
            Block block = worldServer.getType(blockPosition).getBlock();
            IBlockData blockData = block.fromLegacyData(CommandAbstract.a(nbt, 0, 15));
            worldServer.setTypeAndData(blockPosition, blockData, 2);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
Also used : IBlockData(net.minecraft.server.v1_8_R3.IBlockData) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) Block(net.minecraft.server.v1_8_R3.Block) World(net.minecraft.server.v1_8_R3.World) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Example 72 with Block

use of net.minecraft.server.v1_13_R2.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 73 with Block

use of net.minecraft.server.v1_13_R2.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 74 with Block

use of net.minecraft.server.v1_13_R2.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 75 with Block

use of net.minecraft.server.v1_13_R2.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

Block (net.minecraft.server.v1_12_R1.Block)12 ArrayList (java.util.ArrayList)10 ByteString (com.google.protobuf.ByteString)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 Block (net.minecraft.server.v1_8_R3.Block)8 FallingBlock (org.bukkit.entity.FallingBlock)8 HashMap (java.util.HashMap)7 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 Word (com.google.cloud.vision.v1.Word)6 IdentityHashMap (java.util.IdentityHashMap)5