feat(pickaxe): implement Hooked_PickaxeItemGetDestroySpeed and Hooked_PickaxeItemCanDestroySpecial
- Add hook implementations for custom pickaxe tier support - Hooked_PickaxeItemGetDestroySpeed: use CustomPickaxeRegistry destroy speed for configured pickaxes when mining effective blocks - Hooked_PickaxeItemCanDestroySpecial: use CustomPickaxeRegistry effective blocks and harvest level (obsidian requires level 3) - Add TryReadItemIdFromPickaxe and TryReadTileId helpers for reading item/tile IDs from native pointers
@@ -10,19 +10,15 @@ namespace ExampleMod;
|
||||
public class ExampleMod : IMod
|
||||
{
|
||||
public static RegisteredBlock? RubyOre;
|
||||
public static RegisteredBlock? Orichalcum;
|
||||
public static RegisteredItem? Ruby;
|
||||
public static RegisteredItem? RubyPickaxeItem;
|
||||
public static RegisteredItem? RubyShovelItem;
|
||||
public static RegisteredItem? RubyHoeItem;
|
||||
public static RegisteredItem? RubyAxeItem;
|
||||
public static RegisteredItem? RubySwordItem;
|
||||
public static RegisteredItem? RubyWandItem;
|
||||
|
||||
private sealed class RubyPickaxe : PickaxeItem
|
||||
{
|
||||
public override MineBlockResult OnMineBlock(MineBlockContext context)
|
||||
{
|
||||
Logger.Info($"RubyPickaxe mined tile={context.TileId} at ({context.X}, {context.Y}, {context.Z})");
|
||||
return base.OnMineBlock(context);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class RubyWand : Item
|
||||
{
|
||||
private const long CooldownMs = 1500;
|
||||
@@ -70,6 +66,31 @@ public class ExampleMod : IMod
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class RubyShovel : ShovelItem
|
||||
{
|
||||
}
|
||||
|
||||
private sealed class RubyPickaxe : PickaxeItem
|
||||
{
|
||||
public override MineBlockResult OnMineBlock(MineBlockContext context)
|
||||
{
|
||||
Logger.Info($"RubyPickaxe mined tile={context.TileId} at ({context.X}, {context.Y}, {context.Z})");
|
||||
return base.OnMineBlock(context);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class RubyAxe : AxeItem
|
||||
{
|
||||
}
|
||||
|
||||
private sealed class RubyHoe : HoeItem
|
||||
{
|
||||
}
|
||||
|
||||
private sealed class RubySword : SwordItem
|
||||
{
|
||||
}
|
||||
|
||||
public void OnInitialize()
|
||||
{
|
||||
RubyOre = Registry.Block.Register("examplemod:ruby_ore",
|
||||
@@ -80,6 +101,20 @@ public class ExampleMod : IMod
|
||||
.Sound(SoundType.Stone)
|
||||
.Icon("examplemod:ruby_ore") // From assets/blocks/ruby_ore.png
|
||||
.Name("Ruby Ore")
|
||||
.RequiredHarvestLevel(2)
|
||||
.RequiredTool(ToolType.Pickaxe)
|
||||
.InCreativeTab(CreativeTab.BuildingBlocks));
|
||||
|
||||
Orichalcum = Registry.Block.Register("examplemod:orichalcum_ore",
|
||||
new BlockProperties()
|
||||
.Material(MaterialType.Metal)
|
||||
.Hardness(5.0f)
|
||||
.Resistance(30f)
|
||||
.Sound(SoundType.Metal)
|
||||
.Icon("examplemod:orichalcum_ore") // From assets/blocks/orichalcum.png
|
||||
.Name("Orichalcum Ore")
|
||||
.RequiredHarvestLevel(4)
|
||||
.RequiredTool(ToolType.Pickaxe)
|
||||
.InCreativeTab(CreativeTab.BuildingBlocks));
|
||||
|
||||
Ruby = Registry.Item.Register("examplemod:ruby",
|
||||
@@ -89,14 +124,57 @@ public class ExampleMod : IMod
|
||||
.Name("Ruby")
|
||||
.InCreativeTab(CreativeTab.Materials));
|
||||
|
||||
RubyPickaxeItem = Registry.Item.Register("examplemod:ruby_pickaxe", new RubyPickaxe(),
|
||||
Registry.Item.RegisterToolMaterial("examplemod:ruby_material",
|
||||
new ToolMaterialDefinition()
|
||||
.BaseTier(ToolTier.Diamond)
|
||||
.HarvestLevel(4)
|
||||
.DestroySpeed(10.0f));
|
||||
|
||||
RubySwordItem = Registry.Item.Register("examplemod:ruby_sword", new RubySword { CustomMaterialId = "examplemod:ruby_material" },
|
||||
new ItemProperties()
|
||||
.MaxStackSize(1)
|
||||
.MaxDamage(512)
|
||||
.AttackDamage(8.0f)
|
||||
.Icon("examplemod:ruby_sword")
|
||||
.Name("Ruby Sword")
|
||||
.InCreativeTab(CreativeTab.ToolsAndWeapons));
|
||||
|
||||
RubyShovelItem = Registry.Item.Register("examplemod:ruby_shovel", new RubyShovel { CustomMaterialId = "examplemod:ruby_material" },
|
||||
new ItemProperties()
|
||||
.MaxStackSize(1)
|
||||
.MaxDamage(512)
|
||||
.AttackDamage(4.5f)
|
||||
.Icon("examplemod:ruby_shovel")
|
||||
.Name("Ruby Shovel")
|
||||
.InCreativeTab(CreativeTab.ToolsAndWeapons));
|
||||
|
||||
RubyPickaxeItem = Registry.Item.Register("examplemod:ruby_pickaxe", new RubyPickaxe { CustomMaterialId = "examplemod:ruby_material" },
|
||||
new ItemProperties()
|
||||
.MaxStackSize(1)
|
||||
.MaxDamage(512)
|
||||
.AttackDamage(5.0f)
|
||||
.Icon("examplemod:ruby_pickaxe") // From assets/items/ruby_pickaxe.png
|
||||
.Name("Ruby Pickaxe")
|
||||
.InCreativeTab(CreativeTab.ToolsAndWeapons));
|
||||
|
||||
RubyAxeItem = Registry.Item.Register("examplemod:ruby_axe", new RubyAxe { CustomMaterialId = "examplemod:ruby_material" },
|
||||
new ItemProperties()
|
||||
.MaxStackSize(1)
|
||||
.MaxDamage(512)
|
||||
.AttackDamage(7.0f)
|
||||
.Icon("examplemod:ruby_axe")
|
||||
.Name("Ruby Axe")
|
||||
.InCreativeTab(CreativeTab.ToolsAndWeapons));
|
||||
|
||||
RubyHoeItem = Registry.Item.Register("examplemod:ruby_hoe", new RubyHoe { CustomMaterialId = "examplemod:ruby_material" },
|
||||
new ItemProperties()
|
||||
.MaxStackSize(1)
|
||||
.MaxDamage(512)
|
||||
.AttackDamage(1.0f)
|
||||
.Icon("examplemod:ruby_hoe")
|
||||
.Name("Ruby Hoe")
|
||||
.InCreativeTab(CreativeTab.ToolsAndWeapons));
|
||||
|
||||
RubyWandItem = Registry.Item.Register("examplemod:ruby_wand", new RubyWand(),
|
||||
new ItemProperties()
|
||||
.MaxStackSize(1)
|
||||
|
||||
BIN
ExampleMod/assets/blocks/orichalcum_ore.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
ExampleMod/assets/items/ruby_axe.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
ExampleMod/assets/items/ruby_hoe.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 2.9 KiB |
BIN
ExampleMod/assets/items/ruby_shovel.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
ExampleMod/assets/items/ruby_sword.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
@@ -4,4 +4,11 @@
|
||||
# This file documents the expected format for future multi-locale support.
|
||||
|
||||
block.examplemod.ruby_ore=Ruby Ore
|
||||
block.examplemod.orichalcum_ore=Orichalcum Ore
|
||||
item.examplemod.ruby=Ruby
|
||||
item.examplemod.ruby_sword=Ruby Sword
|
||||
item.examplemod.ruby_shovel=Ruby Shovel
|
||||
item.examplemod.ruby_pickaxe=Ruby Pickaxe
|
||||
item.examplemod.ruby_axe=Ruby Axe
|
||||
item.examplemod.ruby_hoe=Ruby Hoe
|
||||
item.examplemod.ruby_wand=Ruby Wand
|
||||
|
||||