Welcome, Guest!

Custom Blocks

Last Updated: Sat Jul 27 04:22:09 2024

Scraps introduces new 'Custom Blocks' into the game, which have custom models and custom functionality. All custom blocks have a durability value, and can be repaired.

Contents

Technology

Custom blocks were only possible through a creative workaround of Minecraft resource pack limitations. If Scraps was a Minecraft mod, it would be extremely simple to add new blocks, entities, armor, weapons, items, etc. However, since the game is plugin-based, we can only do as much as can be handled by the vanilla Minecraft client. Thankfully, Minecraft has support for resource packs. Resource packs allow developers to create their own textures, sounds, and 3D models to replace vanilla resources with. It is relatively simple to replace vanilla item textures with new textures; however blocks work differently.

Blocks can't persist model data like items can. This means that if we were to add a new texture for a block, every block of that type would use the same texture. Yet, Scraps v2.0.0-beta released with custom blocks implemented - as a plugin-based game? The solution was to use regular barrier blocks as a 'foundation', since they can be walked on and behave like a solid hitbox, while being completely invisible (which cannot be achieved in vanilla with resource packs, as Minecraft will render transparent block textures as pitch-black). Then, with this invisible hitbox, an invisible armor stand wearing a custom modeled item on it's head can be summoned inside of the block, creating the illusion of a custom model on a solid block. A custom event listener will simulate the block being mined over time, with particles and sound effects when its punched by a player. The invulnerable, invisible armor stand is associated with the block, and is always spawned when the block is placed. When the block is destroyed, the armor stand is also destroyed.

This solution has its problems, but it works more than well enough for our purposes.