mirror of
https://github.com/Jacobwasbeast/LegacyWeaveLoader.git
synced 2026-05-22 13:44:31 +00:00
- Add GameObjectFactory: create actual Tile/TileItem/Item objects via PDB symbols
- Fix IdRegistry ID ranges: BLOCK_MOD_START=174, ITEM_MOD_START=3000
- Add icon parameter to item registration (API, NativeInterop, NativeExports)
- Use protected (IEAA/MEAA) decorated names for Tile/Item constructors
- Lazy-dereference Material/SoundType pointers (NULL until staticCtor runs)
- CrashHandler: skip __debugbreak() from game exe so missing texture fallback runs
- ExampleMod: add .Icon("ruby") to item registration
57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using LegacyForge.API;
|
|
using LegacyForge.API.Block;
|
|
using LegacyForge.API.Item;
|
|
using LegacyForge.API.Events;
|
|
|
|
namespace ExampleMod;
|
|
|
|
[Mod("examplemod", Name = "Example Mod", Version = "1.0.0", Author = "LegacyForge",
|
|
Description = "A sample mod demonstrating the LegacyForge API")]
|
|
public class ExampleMod : IMod
|
|
{
|
|
public static RegisteredBlock? RubyOre;
|
|
public static RegisteredItem? Ruby;
|
|
|
|
public void OnInitialize()
|
|
{
|
|
RubyOre = Registry.Block.Register("examplemod:ruby_ore",
|
|
new BlockProperties()
|
|
.Material(MaterialType.Stone)
|
|
.Hardness(3.0f)
|
|
.Resistance(15f)
|
|
.Sound(SoundType.Stone)
|
|
.Icon("ruby_ore")
|
|
.InCreativeTab(CreativeTab.BuildingBlocks));
|
|
|
|
Ruby = Registry.Item.Register("examplemod:ruby",
|
|
new ItemProperties()
|
|
.MaxStackSize(64)
|
|
.Icon("ruby")
|
|
.InCreativeTab(CreativeTab.Materials));
|
|
|
|
Registry.Recipe.AddFurnace("examplemod:ruby_ore", "examplemod:ruby", 1.0f);
|
|
|
|
GameEvents.OnBlockBreak += OnBlockBroken;
|
|
|
|
Logger.Info("Example Mod initialized! Ruby ore and ruby registered.");
|
|
}
|
|
|
|
private void OnBlockBroken(object? sender, BlockBreakEventArgs e)
|
|
{
|
|
if (RubyOre != null && e.BlockId == RubyOre.StringId.ToString())
|
|
{
|
|
Logger.Info($"Ruby ore broken at ({e.X}, {e.Y}, {e.Z})!");
|
|
}
|
|
}
|
|
|
|
public void OnTick()
|
|
{
|
|
// Per-tick logic goes here
|
|
}
|
|
|
|
public void OnShutdown()
|
|
{
|
|
Logger.Info("Example Mod shutting down.");
|
|
}
|
|
}
|