Geekiness Daryl Ducharme Geekiness Daryl Ducharme

Fast Leaf Decay for Minecraft: Bedrock Edition

One of the main add-ons I've wanted as I play on Java servers is fast leaf decay. It's a quality of life add-on that doesn't take away from many players experience. Why isn't it on Bedrock? Well it is now, because I've made it. It is called Spoiled Leaves. Here is my story of development to finally making it public just this past week.

I'm not an old timer when it comes to Minecraft, but I have been playing since 2020. I started on the Java edition but I prefer Bedrock edition. I have multiple devices, I like to play on the same worlds, and I use realms to make that happen.

One of the areas where the Bedrock edition is usually called out is in the world of mods (called add-ons for Bedrock). There just aren't as many, and they are much more limited. There are many reasons for this and it has been steadily improving over time. But there is a long way to go.

One of the main add-ons I've wanted as I play on Java servers is fast leaf decay. It's a quality of life add-on that doesn't take away from many players experience. Why isn't it on Bedrock? Well it is now, because I've made it. It is called Spoiled Leaves. Here is my story of development to finally making it public just this past week.

Demo video for the Spoiled Leaves add-on.

The making of

I didn't know what it would take to make a script based add-on. The only one I made before just replaced the audio for villagers so it didn't require any programming. Instead of making a full plan, I started with creating a proof of concept so that I could see if I could do it with the scripting API.

For my IDE, I wanted to use NeoVim (and did) but also used bridge. (the period is part of the name) to make some of the process smoother. Since I was just making a proof of concept for my own education I could poke around without any time constraints. It was so much fun. It had been a long time since I had that much fun programming.

After a while, my work showed that it was doable, now I decided to try to make an actual add-on. All the other examples I saw were using experimental APIs, so I decided to start with those on then see if and when it became possible to use stable APIs. The examples were also in Javascript, and I hadn't setup a typescript compiler so I also started with it in javascript with the idea that I would convert to typescript after I got it working.

Recursion

The solution that I saw for the leaf decay mechanic on Bedrock was going to involve recursion for all the connected blocks to broken logs and leaves. This, I believe, is different than the way it is handled on Java but this is what I saw I had access to and understood.

For recursion to work and be performant, one thing you need to do is make sure to limit the depth of recursion. Because of Bedrock's leaf decay radius of 4 I had an easy answer for that. Another thing that usually needs to happen, especially in graph like structures (which blocks have through the 6 directional reference methods), is to make sure to only recurse over an entry once.

Javascript and equality

Javascript is two things, a great language and a terrible language. It has some weirdness that you would not expect, especially coming from other languages that don't have its history. For me this was with Block object equality and even the Vector objects representing the locations of those blocks. The Microsoft APIs were giving me new Block objects each time I referenced it from another method. The same thing happened with Vectors, which in my mind were closer to primitive and should have had proper equality already coded. Nope. When I tested if a block or location had been processed before, it always looked like a new object so it would be processed again. For an exponential algorithm like I was using this was a performance hit that I calculated shouldn't matter if it was limited to only processing blocks once.

The solution (for now, I know I can probably do better) that I figured out was to create a special class called a VectorSet that acts like a Set but you put the 3 dimensional vector objects in it and get all the benefits of a set. It worked right away, well after I made my initial code less confusing and understood what I was doing, and all of the sudden performance was acceptable again. From there I was able to get it working enough to start testing and stabilizing.

More performance improvements

Scripting in Minecraft is still limited and I had to trigger some commands. These aren't perfectly performant and asynchronous command calls are limited to 128 per tick. Because of this and because instantaneous leaf breaking is a bit disconcerting, I decided to break this up into processing chunks of leaves at a time. That improved performance even more and gave me another config option I could tweak to improve performance and feel.

Speaking of performance and feel, leaf decay on Java still feels really organic and I do like that. To get closer to that feel I added some randomness to the time between processing of leaf blocks to decay. More configurations to use.

Javascript ready, how do I Typescript

Once I had it working in javascript I wanted to clean it up by using Typescript. I was already using lots of comments to annotate the type information and it was ugly. Type information makes the job of coding much simpler so I wasn't going to remove those. I just needed to code in Typescript.

Honestly, the most difficult thing was dealing with myself and how complicated I thought it was going to be. The compiler that bridge. uses for Javascript will turn Typescript into the proper javascript when it exports it without any extra settings. Because of this, no config or manifest options need to be changed. Ugh, I should have started in Typescript.

Stopping the experiment

As I said before, I was using the experimental APIs because that is what I saw other add-ons using. However, this sucks for most players who don't want to use the experimental APIs. Every update can break them and that makes them less useful on public servers and realms. So, I created a branch to use the stable APIs and got to work.

I had been using several parts of the API that were experimental. So, when I turned them off, I had lots of errors and nothing was working. I wasn't sure if the stable APIs were capable of doing what I needed yet, but I was planning on seeing how far I could get and when the stable APIs caught up with my needs I would release it using the stable APIs then.

It turns out I was able to accomplish this task with the stable APIs. I probably started coding at the right time as some of my solutions used parts of the API that had only recently been made stable. I am glad I started with the experimental APIs though, for two reasons. One, the experimental based solutions were simpler for me to wrap my mind around so that when I went to the stable branch I only had to solve the problem of how to replace what I was doing before. Two, I think the solutions with the experimental API were a little more performant. So, as those become stabilized I will likely move back to using those (or at least test my hypothesis).

Testing on my realm

It worked on my local worlds, but what would performance be like on a realm. I have a realm that I play with people I love called Derp & Chill. It is descriptive of how we play when we are there and especially when we play together. It isn't a super busy realm but I wanted to make sure it worked and no-one noticed any (new) performance issues.

I heard not a peep. This can either mean no-one played and cut down trees or no one noticed performance issues. Either way, it was time to make it public.

Making it public

I was using GitHub but had it as a private repo. The work I did was fun and I hope it can help others make even more exciting things by adding it to there worlds and add-on packs. So, I made it public and shared with a very expansive add-on pack I use called Better on Bedrock.

When the creator saw it, I was reminded that this was new. No one had really done this on Bedrock so there was some excitement. He checked it out and said that he didn't understand what I was doing. Ah, right. I should comment my code and explain myself. So, now it is up on GitHub, with comments explaining what I was trying to do. It is ready for you to download from the release page and give your feedback.

Read More
Randomness Daryl Ducharme Randomness Daryl Ducharme

FSI Navigator Alpha 2 released

I have released the alpha 2 version of my FSI Navigator AIR Application. The only new feature is that it uses the AIR Update Framework to check for an update once a day. At this point the updates are automatic only, with no way to manually update. Manual update checks will be available before the 1.0 release.

It is recommended that all current users update to this version so that they can keep up with the latest news in the pre-release process.

Also, don't forget to report bugs and request features at my issue tracking site:
http://www.ducharme.cc/mantis/

Read More
Randomness Daryl Ducharme Randomness Daryl Ducharme

Language Lessons 2 - My first decent AIR app

A while ago I wrote a blog post titled "Language Lessons." It was a post designed to showcase some of the 'cheap as free'™ ways to study a language. One of those ways was fsi-language-courses.com, a website dedicated to making the public domain FSI language courses freely available in an electronic format. While it is a great resource, the site isn't extremely usable. Adobe Integrated Runtime(AIR) to the rescue. ...

For all my talk of being a Flash/Flex expert ( Flexpert? ), I have yet to make a decent AIR app. Sure I've made a couple of tools to help me out with some minor tasks( get map lat/lon coordinates, creating a tool to help me learn degrafa ) but nothing very usable for anybody else ( or exciting to make ).

With all that in mind it is with great excitement that I announce my first alpha release of th AIR FSI Navigator. This tool allows you to navigate their different language programs and view the pdfs while you listen to the accompanying audio ( if they are available of course ). As with most alpha software, this has a long way to go before it is considered released ( and I will most likely release it as open source long before that ), but you might find it useful.


FSI_Navigator.air
This application requires Adobe AIR 1.1 be installed on your computer. If it is not you can download it from the Adobe website.UPDATE: It is easier to just use the install badge at the bottom of this post.

Known Issues ( not an exhaustive list )

  • Certain courses do not work. Especially if the course contents are located in a zip file.
  • PDFs take a while to load and there is no download notification. Be patient, if you have Adobe Acrobat 8.1 and the screen is black,it just means the PDF is loading ( some of them are quite large ).
  • Closing the MP3 Playback window shade and then reopening it decreases its height.
  • Downloads are not saved to your hard drive for offline work. This feature is planned for the future, in fact it will be the default so that files don't have to be downloaded from the server every time.
  • Volume thumb bar isn't visible when the program starts. Just click on the volume adjustment area and it will show up.

Update: I thought I'd do a quick attempt to add an install badge for this:

Read More
Randomness Daryl Ducharme Randomness Daryl Ducharme

Yahoo Flex Map Component Part 3 available

Part 3 in my multi part series on building a flex component out of the Yahoo! Maps API is available over at the Flexcoders group.

In part 1 of this series I talked about the reasons why you would want to make a flex component out of something you can do in actionscript. In part 2 I discussed the basics of the component architecture. From that second article you can create a component that works however you still haven't handled most of the reasons to make a component in the first place. In this article I will take care of those issues the issues of data binding, event handling and making it easier for non coders( sometimes called designers or managers :) ) to work with.

Read More
Randomness Daryl Ducharme Randomness Daryl Ducharme

YahooFlexMap part 2 is available

Part 2 in my multipart series about creating a Flex component fromt he new Yahoo! map API for actionscript 3 is now available in the my.opera Flexcoders group blog.

In part 1 of my series on making a flex component out of the new Yahoo! Maps API for actionscript 3 I talked about the reasons I was taking the time to componentize something I could easily build with pure actionscript. Today I will be talking through the basics of creating a visual component. While these basics are covered at the LiveDocs for Flex 3, I will go over them in a slightly different way, as well as talk about how they affect the Yahoo! map component in particular.

Also make sure to join the Flexcoders group as it is new and looking for new members. At the very least, feel free to ask questions in the forum.

Read More
Randomness Daryl Ducharme Randomness Daryl Ducharme

Last Day of Flex 360

Yesterday was the last day of the Flex 360 conference and it was a whirlwind. Along with checking out of the hotel and making sure to get to the airport on time I still had a conference to attend, including the final keynote. I don't have all my notes about what I did yesterday, so bear with me as I describe the highlights of the day. ...

The morning started out with the final keynote of the conference that included short talks on some community projects. One cool non-project community development was Flex Authority, which is a community driven zine that will be coming out in early summer. As for projects there were short demonstrations of OpenFlux and Degrafa that were great. The highlight was the last project which was a social musical notation program complete with keyboard( QWERTY not the 88s ) entry. A very cool program that I think is still not open to the public and unfortunately, no name was given.

Of the talks I went to yesterday, 2 stand out for very different reasons. One talk was about video in Flex and the other was about architecting AIR applications.

The presentation on video in flex stands out because, I realized I actually understand this concept quite a bit. The company I work for, Provis Media Group, is all about the powerful use of video on the web and I've been dealing with video and the flash player since day one. This doesn't mean I didn't learn anything. One glaring detail I learned is about the index on H.264 files that can keep HD videos from streaming progressively. The answer to that problem can be found here. The main thing I got out of this session, that can be applied to more than just video, is the usefulness of creating components based on the flex framework. It takes a little extra work up front but it can save a ton of time in the long run.

Architecting AIR applications stood out because it made me realize how much I hadn't thought of. The talk was led by a former .NET developer who went to web applications and now, thanks to AIR, is back to making desktop applications. Because of his background, he had a perspective about architecting an occasionally connected app that was different than the standard line. It was a great talk and I've got a lot of researching to do on new approaches. The main thing that got driven home was while tools like Cairngorm and Pure MVC have their uses, especially for web apps, their are some limitations when creating a desktop app. It's important to have many more tools and good OOP knowledge and practice under your belt so that you don't fall into the 'Golden Hammer' syndrome.

To finalize, Flex 360 was awesome and I hope to go to many more of these types of events. There is a Flex 360 event in Europe happening in April, I believe and I would love to go there, even though I know I wouldn't really get to see any of Europe. So if you are in Europe, check out 360 Flex Europe coming to Milan very soon.

Read More
Randomness Daryl Ducharme Randomness Daryl Ducharme

Flex 360 - Day 2

Today was day two of Flex 360 here in Atlanta and definately the geekiest group of presentations so far. And by geekiest I mean best. My days presentation list included presentations on item renders, deep tour of the new open source Flex SDK, the big bang of your applications start up, open source flex community projects and enhancing flex presentations with bitmap techniques. ...

Building Components that use Item Renderers
One thing that I hated in Flash and Actionscript 2 is the API for generating Item Renderers. The documentation was poor and so were many of the examples that people created on the subject. With Flex there are 3 ways of doing custom item renderers and building an advanced item renderer seems much easier than before. On top of it all, this presentation made me see the reasons behind the item renderer API. I have a feeling I will be creating quite a few in upcoming projects.

Deep Dive Tour into the Open Source Flex SDK
One of the biggest pieces of news with the release of Flex 3 was the fact that it is now officially open source. This presentation was showing the open source project and what pieces of the Flex Framework are a part of the open source project. Along with that we got to get a high level overview of the compilation process. Both Java and Actionscript files that weren't available before are now available for viewing. I may or may not ever contribute to the project but I did get some new ideas about what I could do with this level of access. There is a whole world to blog about inside the Flex repositories.

Dense and Hot: The big bang of your application's start up
I missed the presentation about what's coming in Flex 4 to be in the packed presentation. It was worth it. With everything that is going on at startup, you have a lot of opportunity to slow down your application unless you understand its nature. I learned about application, and really all components, lifecycle as well as the best times to take certain application initialization actions. The onCreationComplete event usually is seen as the best time to do things when you look for examples online and yet it probably isn't. There could be a blog posting on this topic coming soon.

Open Source Flex Community Projects
While I have been very interested in open source projects for flex and flash, this presentation got me interested in some projects I might have dismissed for various reasons. Projects like the physics engines for actionscript or Degrafa. From now on I'll be keeping my eyes open, just in case they can help me with the projects I am working on in ways I wouldn't have originally thought of.

Enhancing Flex Presentations with Bitmap Techniques
Coming from a pure actionscript background, there are many things I already understand about BitmapData objects. I also learned a lot in a previous e-seminar about bit blitting. However, this class focused on the benefits of creating Flex framework components that benefit from bitmap data. There are a lot of opportunities to create applications that can just wow people while still being very easy to use. This is an untapped area of RIAs and occasionally connected applications. Expect to see some posts and possibly some tools or components based on this subject in the near future.

Again and again I am seeing the benefits of coding in the Flex framework versus pure actionscript. Obviously Flex is based off of actionscript, but I could get the best benefit by writing actionscript that allows me to code in the flex framework. Things just get so easy when you take advantage of the framework, I don't know why I have fought it for so long.

Read More
Randomness Daryl Ducharme Randomness Daryl Ducharme

Flex 360 - Day 1

Monday was the official first Day of the Flex 360 conference here in Atlanta, GA and so far it has been a blast. I took some classes on FlexUnit, Custom Components, the Ribbit API and building a brand as an independent developer. Then after the classes we had the Adobe party that was the party to mark the release of Flex 3, AIR and Blaze DS. ...

The first class I took was on Flex Unit, a unit testing library for Flex, Flash CS3 and Actionscript 3 files. I got to see a good workflow for using it, including automation using apache Ant. I also learned about a relatively new testing framework called dpUnit that I really want to check out. It's created by the guys at Digital Primates.

The second class I took was about creating polished custom components. In this class the presenter used the example of FlexMDI, a window management system that he was a part of creating, to show some of the important things you need to take into consideration when creating a reusable component. A great presentation and I got to see some of the inner workings of an awesome library for flex.

The third presentation I went to was about the Ribbit API, a way to handle telephony through flash. With this system you can make and receive calls, as well as make and receive messages. There are also some new features of the system coming through the pike. It will be fun to see what I can create with this API.

The final presentation was led by a Doug Mccune and from Scale Nine, Juan Sanchez. It was all about building the brand that is you. It reinspired me to build the Daryl Ducharme brand. Let's just say, I think I will be blogging more about Flex, AIR and other fun related topics.

After that we walked over to the Stats sports bar for the Adobe party to celebrate the release of a few products in the Flex family. Don't forget the official launch of Flex as an open source project. This party had a ton of people and we all were talking Flex, AIR and related issues. It's nice to just be able to geek out sometimes. Some people played Rock Band and Guitar Hero until they closed the private lounge area we were in. Good times, I just wish I had a chance to talk to more of the people at the party. Well, there are 2 more days to this conference. I better get to bed so I can get the most out of all the sessions tomorrow.

Read More
Randomness Daryl Ducharme Randomness Daryl Ducharme

Flex 360 - Atlanta

This week I am at the Flex 360 conference in Atlanta. As this is the first Flex conference I've been able to go to I am very excited. Today is the official first day and I am sure they will talk about how Flex 3 and AIR are now currently live, since that is exactly what happened as of sometime last night. I wonder what other nuggets of information they have in store for us. I'll share with you what I can. ...

Today may be the official first day of the conference but yesterday was the day of hands on pretraining. Since I got here early in the morning I went to the all day Flex 101 session. While the session was very basic, it was a 101 session after all, I learned that many people coming from other backgrounds might need more help jumping into the fray. So, while I will still try to write my articles on cool tips and tricks you might not know about, I will start to write more articles at the 101 level to help people jump right into the Flex platform. With AIR finally in release, it is an exciting time to be a part of the flex community.

Well, off to the keynote. I'll write more as I hear it.

Read More