Search in sources :

Example 36 with Block

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

the class NMSImpl method getCollisionBox.

@Override
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
    WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
    Block type = CraftMagicNumbers.getBlock(block);
    BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ());
    AxisAlignedBB aabb = type.a(world, pos, world.getType(pos));
    return aabb == null ? BoundingBox.EMPTY : new BoundingBox(aabb.a, aabb.b, aabb.c, aabb.d, aabb.e, aabb.f);
}
Also used : AxisAlignedBB(net.minecraft.server.v1_8_R3.AxisAlignedBB) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) BoundingBox(net.citizensnpcs.api.util.BoundingBox) CraftBlock(org.bukkit.craftbukkit.v1_8_R3.block.CraftBlock) Block(net.minecraft.server.v1_8_R3.Block) WorldServer(net.minecraft.server.v1_8_R3.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Example 37 with Block

use of net.minecraft.server.v1_9_R2.Block in project NoCheatPlus by NoCheatPlus.

the class BlockCacheCB3100 method fetchBounds.

@Override
public double[] fetchBounds(final int x, final int y, final int z) {
    @SuppressWarnings("deprecation") final int id = getType(x, y, z).getId();
    final net.minecraft.server.v1_7_R4.Block block = net.minecraft.server.v1_7_R4.Block.getById(id);
    if (block == null) {
        // TODO: Convention for null bounds -> full ?
        return null;
    }
    // getData from cache.
    block.updateShape(iBlockAccess, x, y, z);
    // minX, minY, minZ, maxX, maxY, maxZ
    return new double[] { block.x(), block.z(), block.B(), block.y(), block.A(), block.C() };
}
Also used : Block(net.minecraft.server.v1_7_R4.Block)

Example 38 with Block

use of net.minecraft.server.v1_9_R2.Block in project NoCheatPlus by NoCheatPlus.

the class BlockCacheSpigotCB1_9_R2 method fetchBounds.

@Override
public double[] fetchBounds(final int x, final int y, final int z) {
    @SuppressWarnings("deprecation") final int id = getType(x, y, z).getId();
    final net.minecraft.server.v1_9_R2.Block block = net.minecraft.server.v1_9_R2.Block.getById(id);
    if (block == null) {
        // TODO: Convention for null blocks -> full ?
        return null;
    }
    final BlockPosition pos = new BlockPosition(x, y, z);
    // TODO: Deprecation warning below (reason / substitute?).
    @SuppressWarnings("deprecation") final AxisAlignedBB bb = block.a(world.getType(pos), world, pos);
    if (bb == null) {
        // Special case.
        return new double[] { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 };
    // return null;
    }
    // minX, minY, minZ, maxX, maxY, maxZ
    return new double[] { bb.a, bb.b, bb.c, bb.d, bb.e, bb.f };
}
Also used : AxisAlignedBB(net.minecraft.server.v1_9_R2.AxisAlignedBB) BlockPosition(net.minecraft.server.v1_9_R2.BlockPosition)

Example 39 with Block

use of net.minecraft.server.v1_9_R2.Block in project NoCheatPlus by NoCheatPlus.

the class BlockCacheCB2922 method fetchBounds.

@Override
public double[] fetchBounds(final int x, final int y, final int z) {
    // TODO: change api for this / use nodes (!)
    @SuppressWarnings("deprecation") final int id = getType(x, y, z).getId();
    final net.minecraft.server.v1_7_R1.Block block = net.minecraft.server.v1_7_R1.Block.e(id);
    if (block == null)
        return null;
    // data from cache.
    block.updateShape(iBlockAccess, x, y, z);
    // minX, minY, minZ, maxX, maxY, maxZ
    return new double[] { block.x(), block.z(), block.B(), block.y(), block.A(), block.C() };
}
Also used : Block(net.minecraft.server.v1_7_R1.Block)

Example 40 with Block

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

the class Detect method detectDocumentTextGcs.

// [END vision_fulltext_detection]
/**
 * Performs document text detection on a remote image on Google Cloud Storage.
 *
 * @param gcsPath The path to the remote file on Google Cloud Storage to detect document text on.
 * @throws Exception on errors while closing the client.
 * @throws IOException on Input/Output errors.
 */
// [START vision_fulltext_detection_gcs]
public static void detectDocumentTextGcs(String gcsPath) throws IOException {
    List<AnnotateImageRequest> requests = new ArrayList<>();
    ImageSource imgSource = ImageSource.newBuilder().setGcsImageUri(gcsPath).build();
    Image img = Image.newBuilder().setSource(imgSource).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) 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) 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) ImageSource(com.google.cloud.vision.v1.ImageSource) TextAnnotation(com.google.cloud.vision.v1.TextAnnotation) BatchAnnotateImagesResponse(com.google.cloud.vision.v1.BatchAnnotateImagesResponse)

Aggregations

Block (net.minecraft.server.v1_12_R1.Block)12 ArrayList (java.util.ArrayList)11 BlockPosition (net.minecraft.server.v1_9_R2.BlockPosition)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 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)7 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)7 CraftWorld (org.bukkit.craftbukkit.v1_9_R2.CraftWorld)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