mirror of
https://github.com/Jacobwasbeast/LegacyWeaveLoader.git
synced 2026-05-30 09:34:31 +00:00
wip(loot): snapshot runtime loot hook refactor and diagnostics
This commit is contained in:
@@ -2,6 +2,7 @@ using WeaveLoader.API;
|
||||
using WeaveLoader.API.Block;
|
||||
using WeaveLoader.API.Item;
|
||||
using WeaveLoader.API.Events;
|
||||
using WeaveLoader.API.Loot;
|
||||
|
||||
namespace ExampleMod;
|
||||
|
||||
@@ -11,6 +12,7 @@ public class ExampleMod : IMod
|
||||
{
|
||||
private static nint s_currentLevel;
|
||||
private static bool s_hasLevel;
|
||||
private static bool s_loggedCreeperLootInjection;
|
||||
public static RegisteredBlock? RubyOre;
|
||||
public static RegisteredBlock? RubyStone;
|
||||
public static RegisteredBlock? RubyWoodPlanks;
|
||||
@@ -561,6 +563,29 @@ public class ExampleMod : IMod
|
||||
.Name(Text.Translatable("item.examplemod.ruby_wand"))
|
||||
.InCreativeTab(CreativeTab.ToolsAndWeapons));
|
||||
|
||||
LootTableEvents.MODIFY.Register((_, _, tableId, tableBuilder, _) =>
|
||||
{
|
||||
if (!tableId.Namespace.Equals("minecraft", StringComparison.OrdinalIgnoreCase) ||
|
||||
!tableId.Path.Equals("entities/creeper", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var pool = LootPool.builder()
|
||||
.rolls(ConstantLootNumberProvider.create(1))
|
||||
.conditionally(RandomChanceLootCondition.builder(0.05f))
|
||||
.with(ItemEntry.builder(new Identifier("examplemod:ruby_sand"))
|
||||
.apply(new SetCountLootFunction(1)));
|
||||
|
||||
tableBuilder.pool(pool);
|
||||
|
||||
if (!s_loggedCreeperLootInjection)
|
||||
{
|
||||
s_loggedCreeperLootInjection = true;
|
||||
Logger.Info("ExampleMod: injected creeper loot pool (ruby_sand)");
|
||||
}
|
||||
});
|
||||
|
||||
Registry.Recipe.AddFurnace("examplemod:ruby_ore", "examplemod:ruby", 1.0f);
|
||||
|
||||
GameEvents.OnBlockBreak += OnBlockBroken;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="assets\**\*" CopyToOutputDirectory="PreserveNewest" />
|
||||
<Content Include="data\**\*" CopyToOutputDirectory="PreserveNewest" />
|
||||
<Content Include="weave.mixins.json" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "examplemod:debug_item"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
47
ExampleMod/data/minecraft/loot_tables/entities/chicken.json
Normal file
47
ExampleMod/data/minecraft/loot_tables/entities/chicken.json
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"type": "minecraft:entity",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:empty",
|
||||
"weight": 50
|
||||
},
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "examplemod:ruby",
|
||||
"weight": 30,
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:set_count",
|
||||
"count": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "examplemod:ruby",
|
||||
"weight": 15,
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:set_count",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "examplemod:ruby",
|
||||
"weight": 5,
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:set_count",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user