Minecraft Teleport in Survival Mode (Without Plugins)

Illustration

As my kids got old enough to play Minecraft we decided that our home server had it light for far too long and that it is time we create a Minecraft world on it. Of course I decided to add myself as an operator with special powers and I was crazy enough to inform kids I can even help them move around via teleport.

It didn’t took long before I was completely swamped with teleport request. Get me to sister, get me to my home, get me to my mine, get me to an island… Having to enter coordinates every time gets boring quickly. So I decided to figure way to make it simpler. Answer was in command blocks. Just add a pressure plate and you can make them do whatever you want. Including teleport.

First order of business was to modify server.properties and set

enable-command-block=true

After that I gave myself a block using

/give @p command_block

Next I tried to get block console so I can enter command and I failed. All YouTube videos seemed to get it so easy but for me there was no console. I tried everything but nothing seemed to work. Console would simply not appear. It took me few re-reads to notice that command block setup is restricted to creative mode - if you are in survivor as I was, nothing could be done. Or could it?

With

/gamemode c

I could switch to creative mode and set command block text to

/tp @p -16 72 186

After placing pressure plate right next to a block, I switched back to survivor

/gamemode s

and my teleport was working just fine.

PS: To get coordinates just press F3 and look at block. Its coordinates will be shown under “Looking at” (last line). Add 1 to middle coordinate and that is your destination.

Seobiseu 1.20

Illustration

Seobiseu hasn’t been updated for a long time. It worked good enough and I simply don’t have enough time to add every little thing I might want.

But one thing started bothering me - its looks on the high-DPI screens. Single purpose of this update is to bring it to the high resolution world.

Download newest version here.

OpenGraph

Illustration

When you want to share your posts on social networks, having a help with formatting cannot hurt. For that purpose I used to be a happy user of Facebook Open Graph Meta Tags for WordPress. However, with version 1.3 something went kaboom and I started getting “failed to open stream” errors. After a few attempts of repair I decided it was a time to search for a new plugin.

I tried quite a few of them and, while they all worked with Facebook, Google+ presented a challenge. Some outright didn’t support it, some supported it only in non-free version and quite a few of them were huge SEO systems that would bring my poor installation to its knees. Thus I figured it was a time to make my own. I mean, how hard can it be?

Well It was quite easy to get a basic callback working:

add_action('wp_head', 'medo_opengraph_wp_head_action');

function medo_opengraph_wp_head_action() {
    if (is_single() || is_page()) {
        $post = get_post();

        $title = $post->post_title;
        $type = 'article';
        $url = get_permalink($post);
    } else {
        $title = get_bloginfo('name');
        $type = 'website';
        $url = home_url();
    }

    echo '<meta property="og:title" content="' . $title . '" />';
    echo '<meta property="og:type" content="' . $type . '" />';
    echo '<meta property="og:url" content="' . $url . '" />';
    echo '<meta name="twitter:title" content="' . $title . '" />'; //Twitter
    echo '<meta itemprop="name" content="' . $title . '" />'; //Google+
}

With this simple code I would get posts/pages having their proper title and everything else simply having a generic title alongside my main URL. But that was not really enough - my images were missing. Ignoring crazy array return parameters, code was pretty straightforward:

foreach(get_attached_media('image') as $media) {
    $imageAttrs = wp_get_attachment_image_src($media->ID, 'full');
    $image_url =  home_url($imageAttrs[0]);
    $image_type = $media->post_mime_type;
    $image_width = $imageAttrs[1];
    $image_height = $imageAttrs[2];
    break;
}

echo '<meta property="og:image" content="' . $image_url . '" />';
echo '<meta property="og:image:type" content="' . $image_type . '" />';
echo '<meta property="og:image:width" content="' . $image_width . '" />';
echo '<meta property="og:image:height" content="' . $image_height . '" />';
echo '<meta itemprop="image" content="' . $image_url . '" />'; //Google+

And the last one was to get excerpt for the post description. Here wp_trim_words came in really handy:

$description = $post->post_excerpt;
if (strlen($description) == 0) { $description = wp_trim_words($post->post_content); }

echo '<meta property="og:description" content="' . $description . '" />';
echo '<meta name="twitter:description" content="' . $description . '" />'; //Twitter
echo '<meta itemprop="description" content="' . $description . '" />'; //Google+

Did it went as smoothly as it could? Not really. WordPress Codex was less than helpful, rarely telling you anything more than a function syntax. Coding was more trial and error than anything else. But I cannot really complain. Even with all tryouts it took me less than two hours to get plugin working with all the functionality I needed. I would consider that a success.

And, like a masochist I am, I didn’t stop after those two hours. I got some profile options for Facebook ID in. And then I built a settings page. Made code a bit cleaner. Reordered thing or two. Before I knew it, couple of hours passed and I had something one might call a proper plugin. And it is available for download. Just unzip it in wp-content/plugins and you are golden.

Easiest Black Bitmap

For one program of mine I had a lot of dynamic resource fetching to do. Unfortunately, sometimes a lookup in resources would return null bitmap. Whether that was due to the missing resource or because of a wrong key is of less importance. I didn’t want system to crash but I did want for program to crash just because bitmap was missing. But I did want to have that clearly visible so that I could catch it.

One idea was to use dummy resource, e.g.:

item.Image = (bitmap != null) ? bitmap : dummyBitmap;

However, I didn’t like that solution due to a potential resource release at other places. Nothing worse then releasing resource in use somewhere else. And I was more in the mood for one-liner - resources be damned.

But how to create an bitmap and color it at the same time (by default, bitmap is transparent)? Well, we could always create one without alpha channel, e.g.:

item.Image = (bitmap != null) ? bitmap : new Bitmap(size, size, PixelFormat.Format8bppIndexed);

This will make your bitmap one big black rectangle. It might not be ideal but it is definitely noticeable.

PS: Since I wanted this only during debugging, my final code ended up being just a smidge more complicated:

#if DEBUG
    item.Image = (bitmap != null) ? bitmap : new Bitmap(size, size, PixelFormat.Format8bppIndexed);
#else
    if (bitmap != null) { item.Image = bitmap; }
#endif

Black Screen on Boot After Enabling ReFS

After playing with ReFS a bit, time came for Windows update restart. After initial second or so of booting screen blanked and stayed that way. I waited and waited but there was neither screen nor disk activity. And same thing happened every time I rebooted.

And it got frozen at the worst spot. I have a dual boot and freeze happen to be just before OS selection screen. With one error both installations were dead. And since I used BitLocker on both I wasn’t really in the mood for recovery.

Fortunately, after turning off system few times during boot, I got into Automatic Repair prompt. I entered BitLocker key for my main OS and proceeded with Advanced Options. There I just selected Continue (Exit and continue to Windows 8.1). While this should have technically been exactly the same boot, it was different enough that it actually worked. And then, as soon as system booted up, I removed ReFS capability (this registry file) and rebooted again. All came back successfully.

PS: Even when ReFS functionality is “turned off” you can still use existing ReFS disks. You just cannot format new ones.