use of org.bukkit.craftbukkit.v1_18_R2.block in project Denizen-For-Bukkit by DenizenScript.
the class BlockHelperImpl method ringBell.
@Override
public void ringBell(Bell block) {
org.bukkit.block.data.type.Bell bellData = (org.bukkit.block.data.type.Bell) block.getBlockData();
Direction face = Direction.byName(bellData.getFacing().name());
Direction dir = Direction.NORTH;
switch(bellData.getAttachment()) {
case DOUBLE_WALL:
case SINGLE_WALL:
switch(face) {
case NORTH:
case SOUTH:
dir = Direction.EAST;
break;
}
break;
case FLOOR:
dir = face;
break;
}
CraftBlock craftBlock = (CraftBlock) block.getBlock();
((BellBlock) Blocks.BELL).attemptToRing(craftBlock.getCraftWorld().getHandle(), craftBlock.getPosition(), dir);
}
use of org.bukkit.craftbukkit.v1_18_R2.block in project java-docs-samples by GoogleCloudPlatform.
the class Detect method detectDocumentText.
// [START vision_detect_document]
/**
* Performs document text detection on a local image file.
*
* @param filePath The path to the local file to detect document text on.
* @param out A {@link PrintStream} to write the results to.
* @throws Exception on errors while closing the client.
* @throws IOException on Input/Output errors.
*/
public static void detectDocumentText(String filePath, PrintStream out) throws Exception, 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);
try (ImageAnnotatorClient client = ImageAnnotatorClient.create()) {
BatchAnnotateImagesResponse response = client.batchAnnotateImages(requests);
List<AnnotateImageResponse> responses = response.getResponsesList();
client.close();
for (AnnotateImageResponse res : responses) {
if (res.hasError()) {
out.printf("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();
out.format("Symbol text: %s (confidence: %f)\n", symbol.getText(), symbol.getConfidence());
}
out.format("Word text: %s (confidence: %f)\n\n", wordText, word.getConfidence());
paraText = String.format("%s %s", paraText, wordText);
}
// Output Example using Paragraph:
out.println("\nParagraph: \n" + paraText);
out.format("Paragraph Confidence: %f\n", para.getConfidence());
blockText = blockText + paraText;
}
pageText = pageText + blockText;
}
}
out.println("\nComplete annotation:");
out.println(annotation.getText());
}
}
}
use of org.bukkit.craftbukkit.v1_18_R2.block in project java-docs-samples by GoogleCloudPlatform.
the class Detect method detectDocumentTextGcs.
// [END vision_detect_document]
// [START vision_detect_document_uri]
/**
* 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.
* @param out A {@link PrintStream} to write the results to.
* @throws Exception on errors while closing the client.
* @throws IOException on Input/Output errors.
*/
public static void detectDocumentTextGcs(String gcsPath, PrintStream out) throws Exception, 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);
try (ImageAnnotatorClient client = ImageAnnotatorClient.create()) {
BatchAnnotateImagesResponse response = client.batchAnnotateImages(requests);
List<AnnotateImageResponse> responses = response.getResponsesList();
client.close();
for (AnnotateImageResponse res : responses) {
if (res.hasError()) {
out.printf("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();
out.format("Symbol text: %s (confidence: %f)\n", symbol.getText(), symbol.getConfidence());
}
out.format("Word text: %s (confidence: %f)\n\n", wordText, word.getConfidence());
paraText = String.format("%s %s", paraText, wordText);
}
// Output Example using Paragraph:
out.println("\nParagraph: \n" + paraText);
out.format("Paragraph Confidence: %f\n", para.getConfidence());
blockText = blockText + paraText;
}
pageText = pageText + blockText;
}
}
out.println("\nComplete annotation:");
out.println(annotation.getText());
}
}
}
use of org.bukkit.craftbukkit.v1_18_R2.block in project MagicPlugin by elBukkit.
the class CompatibilityUtils method clearItems.
@Override
public void clearItems(Location location) {
if (location == null)
return;
// Block-specific behaviors
Block block = location.getBlock();
BlockState blockState = block.getState();
if (blockState instanceof Lootable) {
Lootable lootable = (Lootable) blockState;
lootable.setLootTable(null);
blockState.update();
}
if (blockState instanceof Lectern) {
Lectern lectern = (Lectern) blockState;
lectern.getInventory().setItem(0, new ItemStack(Material.AIR));
blockState.update();
}
if (blockState instanceof Jukebox) {
((Jukebox) blockState).setRecord(null);
blockState.update();
}
// TODO: Just clear inventory instead?
BlockEntity tileEntity = getTileEntity(location);
if (tileEntity == null)
return;
CompoundTag tag = tileEntity.saveWithFullMetadata();
// Is there really not an enum for these NBT types?
ListTag itemList = tag.getList("Items", CompatibilityConstants.NBT_TYPE_COMPOUND);
// Is it really necessary to clear the list before removing it?
if (itemList != null) {
itemList.clear();
tag.remove("Items");
tileEntity.load(tag);
tileEntity.setChanged();
}
}
use of org.bukkit.craftbukkit.v1_18_R2.block in project MagicPlugin by elBukkit.
the class CompatibilityUtils method forceUpdate.
@Override
public boolean forceUpdate(Block block, boolean physics) {
if (block == null)
return false;
net.minecraft.world.level.block.state.BlockState blockState = ((CraftBlock) block).getNMS();
if (blockState == null)
return false;
net.minecraft.world.level.block.Block nmsBlock = blockState.getBlock();
net.minecraft.world.level.block.state.BlockState blockData = nmsBlock.defaultBlockState();
ServerLevel world = ((CraftWorld) block.getWorld()).getHandle();
BlockPos blockPosition = new BlockPos(block.getX(), block.getY(), block.getZ());
world.setBlock(blockPosition, blockData, 11);
return false;
}
Aggregations