Posted March 15, 20205 yr So I want to add an item to the vanilla loot table "simple_dungeon", but whatever I try, it doesn't work... Any help appreciated. EDIT: I now have this code: @SubscribeEvent public void onLootLoad(LootTableLoadEvent e) { if (e.getName().toString().equals("minecraft:chests/simple_dungeon")) { LootPool pool = LootPool.builder().rolls(ConstantRange.of(1)).addEntry(ItemLootEntry.builder(ModItems.GOLDEN_FEATHER).weight(25)).addEntry(ItemLootEntry.builder(Items.AIR).weight(75)).build(); e.getTable().addPool(pool); } } but it still doesn't add it to the the loot table. I can check the loot tables with /loot, but I also added in some messages to be printed to the console when onLootLoad was run, and they never got printed. What's going on? Edited March 15, 20205 yr by BlockyPenguin Today (22/10/20) I reached 100 posts! I'm probably more excited than I should be for something so realistically minor...
March 15, 20205 yr Create a json loot table for what you want. Then do this: https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderfarming/EventHandlers.java#L51-L53 Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 15, 20205 yr Author @Draco18s, thanks for your reply. I now have this code: @SubscribeEvent public void onLootLoad(LootTableLoadEvent e) { LOGGER.info("LOOT IS LOADING"); if(e.getName().equals(new ResourceLocation("minecraft", "chests/simple_dungeon"))) { e.getTable().addPool(LootPool.builder().addEntry(TableLootEntry.builder(new ResourceLocation(MODID, "inject/simple_dungeon"))).build()); } } But it still doesn't work. In fact "LOOT IS LOADING" never gets sent to the console! Why is this? My json file is in "resources/data/labkit/loot_tables/inject/simple_dungeon.json", that seems fine... Today (22/10/20) I reached 100 posts! I'm probably more excited than I should be for something so realistically minor...
March 15, 20205 yr Show more of your code. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 16, 20205 yr Author EUREKA! Halfway through pasting a bunch of my code here, I realised my mistake. I'd accidentally put the onLootLoad method in with the registries. I've moved it to its proper place in my main class. Running a test now Today (22/10/20) I reached 100 posts! I'm probably more excited than I should be for something so realistically minor...
March 17, 20205 yr Author Nope, nevermind, whatever I tweak, the code never seems to run in the first place... Here's my Main Class: Spoiler package ... import ... // The value here should match an entry in the META-INF/mods.toml file @Mod(LabKit.MODID) public class LabKit { public static final String MODID = "labkit"; public static final Logger LOGGER = LogManager.getLogger(); public static IProxy proxy = DistExecutor.runForDist(() -> () -> new ClientProxy(), () -> () -> new ServerProxy()); public static ModSetup setup = new ModSetup(); public LabKit() { // Register the setup method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); MinecraftForge.EVENT_BUS.register(LabKit.class); } private void setup(final FMLCommonSetupEvent event) { LOGGER.info("Hello, Scientists!"); LOGGER.info("LabKit now starting..."); setup.init(); proxy.init(); } // You can use SubscribeEvent and let the Event Bus discover methods to call @SubscribeEvent public void onServerStarting(FMLServerStartingEvent e) { LOGGER.info("LabKit now starting on server..."); } @SubscribeEvent public void onLootLoad(LootTableLoadEvent e) { LOGGER.info("LOOT IS LOADING"); if(e.getName().equals(new ResourceLocation("minecraft", "chests/simple_dungeon"))) { e.getTable().addPool(LootPool.builder().addEntry(TableLootEntry.builder(new ResourceLocation(MODID, "inject/simple_dungeon"))).build()); } } public static Item.Properties mainItemGroup = new Item.Properties() .group(ModItemGroups.LABKIT_MAIN_ITEMGROUP); public static Item.Properties WIPItemGroup = new Item.Properties() .group(ModItemGroups.LABKIT_WIP_ITEMGROUP); // You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD // Event bus for receiving Registry Events) @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void onBlocksRegistry(final RegistryEvent.Register<Block> event) { event.getRegistry().register(new WhiteFloorTiles()); event.getRegistry().register(new GreyFloorTiles()); event.getRegistry().register(new DarkGreyFloorTiles()); event.getRegistry().register(new ReinforcedWhiteFloorTiles()); event.getRegistry().register(new ReinforcedGreyFloorTiles()); event.getRegistry().register(new ReinforcedDarkGreyFloorTiles()); event.getRegistry().register(new CautionBlock()); event.getRegistry().register(new ReinforcedCautionBlock()); event.getRegistry().register(new KeycardReader()); event.getRegistry().register(new SolarPanel()); LOGGER.info("Blocks Registered!"); } @SubscribeEvent public static void onItemsRegistry(final RegistryEvent.Register<Item> event) { event.getRegistry().register(new BlockItem(ModBlocks.WHITE_FLOOR_TILES, mainItemGroup).setRegistryName("white_floor_tiles")); event.getRegistry().register(new BlockItem(ModBlocks.GREY_FLOOR_TILES, mainItemGroup).setRegistryName("grey_floor_tiles")); event.getRegistry().register(new BlockItem(ModBlocks.DARK_GREY_FLOOR_TILES, mainItemGroup).setRegistryName("dark_grey_floor_tiles")); event.getRegistry().register(new BlockItem(ModBlocks.REINFORCED_WHITE_FLOOR_TILES, mainItemGroup).setRegistryName("reinforced_white_floor_tiles")); event.getRegistry().register(new BlockItem(ModBlocks.REINFORCED_GREY_FLOOR_TILES, mainItemGroup).setRegistryName("reinforced_grey_floor_tiles")); event.getRegistry().register(new BlockItem(ModBlocks.REINFORCED_DARK_GREY_FLOOR_TILES, mainItemGroup).setRegistryName("reinforced_dark_grey_floor_tiles")); event.getRegistry().register(new BlockItem(ModBlocks.CAUTION_BLOCK, mainItemGroup).setRegistryName("caution_block")); event.getRegistry().register(new BlockItem(ModBlocks.REINFORCED_CAUTION_BLOCK, mainItemGroup).setRegistryName("reinforced_caution_block")); event.getRegistry().register(new BlockItem(ModBlocks.KEYCARD_READER, WIPItemGroup).setRegistryName("keycard_reader")); event.getRegistry().register(new BlockItem(ModBlocks.SOLAR_PANEL, WIPItemGroup).setRegistryName("solar_panel")); event.getRegistry().register(new Keycard()); event.getRegistry().register(new ObsidianShards()); event.getRegistry().register(new GoldenFeather()); LOGGER.info("Items Registered!"); } @SubscribeEvent public static void onTileEntityRegistry(final RegistryEvent.Register<TileEntityType<?>> event) { event.getRegistry().register(TileEntityType.Builder.create(SolarPanelTile::new, ModBlocks.SOLAR_PANEL).build(null).setRegistryName("solar_panel")); event.getRegistry().register(TileEntityType.Builder.create(KeycardReaderTile::new, ModBlocks.KEYCARD_READER).build(null).setRegistryName("keycard_reader")); LOGGER.info("TileEntities Registered!"); } @SubscribeEvent public static void onEffectsRegistry(final RegistryEvent.Register<Effect> event) { event.getRegistry().register(ModEffects.FLYING); event.getRegistry().register(ModEffects.SPAWN_SETTING); LOGGER.info("Effects Registered!"); } @SubscribeEvent public static void onPotionsRegistry(final RegistryEvent.Register<Potion> event) { event.getRegistry().register(ModPotions.FLYING_POTION); event.getRegistry().register(ModPotions.FLYING_POTION_LONG); event.getRegistry().register(ModPotions.SPAWN_SETTING_POTION); LOGGER.info("Potions Registered!"); } } } And here's my resources/data/labkit/inject/simple_dungeon.json: Spoiler { "pools": [ { "name": "main", "rolls": 1, "entries": [ { "type": "item", "name": "labkit:golden_feather", "weight": 25 }, { "type": "empty", "weight": 75 } ] } ] } Today (22/10/20) I reached 100 posts! I'm probably more excited than I should be for something so realistically minor...
March 17, 20205 yr 5 hours ago, BlockyPenguin said: MinecraftForge.EVENT_BUS.register(LabKit.class); You registered the class itself to the event bus. This requires the event listeners to be static (because instance methods require an instance). Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
April 6, 20205 yr Author Ah right! Thanks, I've fixed it! :) Today (22/10/20) I reached 100 posts! I'm probably more excited than I should be for something so realistically minor...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.