Hello everyone! I am working on my first mod, a minimalistic thing that adds a trash bin custom block (The block, the custom gui for the block, recipe, a loot table, block item) to the game.
Everything is working in single player, but when I add it to the mods folder of my forge server, I get log messages that loading the recipes and loot tables fails because it doesn't find the items I'm referencing in them. I realise I am likely doing something wrong with where I'm registering the items, like reaching across the sides or something, but I can't figure out exactly what I should be doing differently.
The full server log is here https://pastebin.com/z6B0uwh8 but I think this is the relevant part:
...
[13:25:38.185] [Server thread/INFO] [minecraft/DedicatedServer]: Preparing level "world"
[13:25:38.369] [Server thread/INFO] [minecraft/SimpleReloadableResourceManager]: Reloading ResourceManager: trashbin-1.0.0.jar, forge-1.14.4-28.0.45-universal.jar, Default
[13:25:38.813] [Server thread/ERROR] [minecraft/RecipeManager]: Parsing error loading recipe trashbin:item_trashbin
com.google.gson.JsonSyntaxException: Unknown item 'trashbin:item_trashbin'
at net.minecraft.item.crafting.ShapedRecipe.lambda$deserializeItem$0(ShapedRecipe.java:264) ~[?:?]
at java.util.Optional.orElseThrow(Unknown Source) ~[?:1.8.0_221]
...
...
[13:25:39.048] [Server thread/ERROR] [minecraft/LootTableManager]: Couldn't parse loot table trashbin:blocks/block_trashbin
com.google.gson.JsonSyntaxException: Expected name to be an item, was unknown string 'trashbin:item_trashbin'
at net.minecraft.util.JSONUtils.func_219793_a(SourceFile:128) ~[?:?]
at java.util.Optional.orElseThrow(Unknown Source) ~[?:1.8.0_221]
...
...
So it seems to me it's loading the mod but "trashbin:item_trashbin" can't be found because it wasn't registered properly (?).
The full source can be found here https://github.com/PekkaAstala/minecraft-mod-trashbin but I think this is the relevant file:
@Mod("trashbin")
public class TrashbinMod
{
private static final Logger LOGGER = LogManager.getLogger();
public TrashbinMod() {
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
MinecraftForge.EVENT_BUS.register(this);
}
private void doClientStuff(final FMLClientSetupEvent event) {
ScreenManager.registerFactory(ModBlocks.TRASHBIN_CONTAINER, BlockTrashbinScreen::new);
}
@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
public static class RegistryEvents {
@SubscribeEvent
public static void onBlocksRegistry(final RegistryEvent.Register<Block> event) {
event.getRegistry().registerAll(
new BlockTrashbin().setRegistryName(Reference.MODID, "block_trashbin")
);
}
@SubscribeEvent
public static void onTileEntityRegistry(final RegistryEvent.Register<TileEntityType<?>> event) {
event.getRegistry().register(TileEntityType.Builder.create(BlockTrashbinTile::new, ModBlocks.TRASHBIN).build(null).setRegistryName("tile_trashbin"));
}
@SubscribeEvent
public static void onItemsRegistry(final RegistryEvent.Register<Item> event) {
event.getRegistry().registerAll(
new BlockItem(
GameRegistry.findRegistry(Block.class).getValue(ResourceLocation.tryCreate("trashbin:block_trashbin")),
new Item.Properties()
).setRegistryName(Reference.MODID, "item_trashbin")
);
}
@SubscribeEvent
public static void onContainerRegistry(final RegistryEvent.Register<ContainerType<?>> event) {
event.getRegistry().registerAll(
IForgeContainerType.create(((windowId, inv, data) -> {
BlockPos pos = data.readBlockPos();
return new BlockTrashbinContainer(windowId, Minecraft.getInstance().world, pos, inv, Minecraft.getInstance().player);
})).setRegistryName("container_trashbin")
);
}
}
}
Could someone help me forward? I have read the basic docs on the forge site about sides and registries but I might need a code example of this being done right or something. Thank you!