如何解决在多层模式下无法触发LootTableLoad事件
我想将自定义物品注入箱子战利品表,但仅在单人游戏模式下有效,相同的代码在多人游戏模式下不起作用(也不出错)。该事件不会触发或未被订阅者捕获(永远不会显示LOGGER信息)。尽管我以相同的方式处理所有其他事件,但在双方都可以正常工作。
编辑:我认为我要注册的项目未正确注册。物品(一把剑)在那里,但是没有预期的属性(这也可能是所有其他问题的原因)。我在崩溃报告日志中找到了这个(尽管抱歉,我没有在控制台上看到错误):
[09sep2020 15:00:19.058] [Server thread/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/Minecraft for invalid dist DEDICATED_SERVER
[09sep2020 15:00:19.070] [Server thread/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/LOADING]: Failed to load class com.alef.simpleclock.SimpleClock
这使我怀疑我的代码中有什么问题,但是我什至无法猜测是什么,因为它在单人游戏模式下可以完美地工作!
这是我的代码:
@SubscribeEvent
public static void onLootTablesLoaded(final LootTableLoadEvent event) {
LOGGER.info("HELLO from LootTableLoad");
// Test it using: /loot give @p loot minecraft:chests/pillager_outpost
if (event.getName().equals(new ResourceLocation("minecraft","chests/buried_treasure"))
|| event.getName().equals(new ResourceLocation("minecraft","chests/underwater_ruin_big"))
|| event.getName().equals(new ResourceLocation("minecraft","chests/pillager_outpost"))
|| event.getName().equals(new ResourceLocation("minecraft","chests/shipwreck_treasure"))
|| event.getName().equals(new ResourceLocation("minecraft","chests/end_city_treasure"))
|| event.getName().equals(new ResourceLocation("minecraft","chests/stronghold_library"))
) {
event.getTable().addPool(LootPool.builder().addEntry(TableLootEntry.builder(new ResourceLocation("simpleclock","chests/time_sword"))).build());
}
}
此方法在此类之内:
@Mod("simpleclock")
public class SimpleClock
{
// Directly reference a log4j logger.
private static final Logger LOGGER = LogManager.getLogger();
public static final Minecraft mc = Minecraft.getInstance();
public static World world = null;
public static KeyBinding[] keyBindings;
public SimpleClock() {
// Register the setup method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
// Register the enqueueIMC method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
// Register the processIMC method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
// Register the doClientStuff method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
}
这是我的自定义战利品表json:
{
"pools": [{
"name": "main","rolls": 1,"entries": [
{
"type": "item","name": "simpleclock:time_sword","weight": 30,"functions": [{ "function": "set_count","count": { "min": 1,"max": 1 } }]
},{
"type": "empty","weight": 70
}
]
}]
}
欢迎任何帮助或想法进行测试!!!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。