Magna is a library that assists with tools that break more than 1 block (Hammers, Excavators, etc). It powers the mods Vanilla Hammers and Vanilla Excavators.
Magna provides 2 base tools: HammerItem
and ExcavatorItem
. Registering an instance of one of these will offer a fully featured tool that is effective on dirt or stone.
public class MyMod implements ModInitializer {
public static final HammerItem EPIC_HAMMER = Registry.register(
Registry.ITEM,
new Identifier("mymod", "epic_hammer"),
new HammerItem(
ToolMaterials.DIAMOND,
1,
-2.8f,
new Item.Settings()
)
);
@Override
public void onInitialize() {
}
}
The Curse of Gigantism is a feature used by both Vanilla Hammers and Vanilla Excavators. If a relevant tool has the curse, it will gain +1 break radius, but lose 80% speed.
If you want to create a custom tool with extended breaking mechanics, you can implement the MagnaTool
interface on your Item
class.
The only thing you'll have to do is override getRadius(ItemStack stack)
and playBreakEffects()
, which help define behavior related to your tool.
For more information, see implementation in HammerItem
or ExcavatorItem
.
If you don't want to use a tool for large breaking, you use the BlockBreaker
findPositions
method to gather positions relative to where a player is looking in a certain radius.
Magna provides 2 custom events.
If you want to only add a Hammer or Excavator while Vanilla Hammers / Vanilla Excavators is installed,
you can call Magna#isVanillaHammersInstalled()
or Magna#isVanillaExcavatorsInstalled()
.
Magna provides nothing out of the box for users, and developers should JIJ it.
Magna does provide a unified set of config options to keep all your large-break-tools consistent. You can either edit the config file at /run/magna.json
,
or edit the config through Mod Menu.
Magna is licensed under CC0-1.0.