Jump to content

F43nd1r

Members
  • Posts

    15
  • Joined

  • Last visited

F43nd1r's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. @LexManos if you can see the usecase, but my solution has downsides, maybe we could build a new solution in forge without these downsides?
  2. Lets assume a mod like quark, which is registering lots of blocks. IMO such a mod should provide a userfriendly way to enable/disable groups of these blocks. Overwriting all recipes of blocks in this group is not user friendly, because a group can have like 50 recipes (Do you disagree?). This also doesn't consider creative tabs. My current solution registers all blocks (according to you "always register everything"), and then disables recipes of disabled blocks and removes them from creative tabs based on a configuration file. Would you say this approach is valid? Is there a better approach?
  3. I reported the issue, but it was closed off. I do not care about this enough to fight it through.
  4. Here is an example using this condition: magma_bricks.json { "result":{"item":"hadron:magma_bricks","count":4}, "conditions":[{"config":"Building.MagmaBricks","type":"hadron:config"}], "ingredients":[ {"item":"minecraft:stone_bricks"}, {"item":"minecraft:stone_bricks"}, {"item":"minecraft:magma_block"}, {"item":"minecraft:magma_block"}], "type":"minecraft:crafting_shapeless" } I'm not aware of any solutions outside of conditions to disable multiple recipes based on settings. Aren't loot tables for item drops?
  5. It does work, thanks! If a solution exists, should I really report it?
  6. I've tried that. Problem is, that calls to ForgeConfigSpec.config , while the real values are in ForgeConficSpec.childConfig . Hence the dirty workaround to access childConfig.
  7. You're right, it works in theory. I didn't notice it was working, because the items still show up in the search. Is there any way to hide an item completely, making it not show up in search?
  8. I have my configuration, it is HadronConfigHolder.config The problem is I need to access a value by name, which usually is done by ConfigValue. But I don't have those in a IConditionSerializer, because it reads from json.
  9. I need to access my configuration inside my IConditionSerializer. My current solution is very ugly, as it relies on reflection. How would I do this correctly? Current code: @Mod.EventBusSubscriber( modid = "hadron", bus = Mod.EventBusSubscriber.Bus.MOD ) public class HadronConfigConditionFactory implements IConditionSerializer { @Override public BooleanSupplier parse(JsonObject json) { String setting = JSONUtils.getString(json, "config", null); if (setting != null) { return new BooleanSupplier() { @Override public boolean getAsBoolean() { try { Field f = ForgeConfigSpec.class.getDeclaredField("childConfig"); f.setAccessible(true); Config config = (Config) f.get(HadronConfigHolder.config); return config.getOrElse(setting, true); } catch(Exception e) { return true; } } }; } else { return () -> true; } } @SubscribeEvent public static void setup(FMLCommonSetupEvent e) { CraftingHelper.register(new ResourceLocation("hadron", "config"), new HadronConfigConditionFactory()); } }
  10. In https://github.com/MinecraftForge/MinecraftForge/issues/5928#issuecomment-511094784 KinghtMiner mentions fillItemGroup as a valid approach for hiding items that are unobtainable. However, it seems to me that fillItemGroup is called before configurations are loaded from file. Is there any way to hide an item from creative menu based on mod configuration?
  11. That works. No need to do it in the mod constructor, FMLCommonSetup works as well.
  12. The problem was actually related to gradle subprojects. I split my code into two modules, with one depending on the other. Apparently forge doesn't support this scenario.
  13. I tried to register a custom IConditionSerializer using _factories.json, but my class is never called. Is there a different way to do this in 1.14? _factories.json: { "conditions": { "config":"com.faendir.minecraft.hadron.generated.HadronConfigConditionFactory" } }
  14. Click on "Edit Configurations" -> Select your configuration -> "Use classpath of module" -> Select your module. I think this was mentioned somewhere in the docs, but I can't find it right now.
  15. I tried to register a custom Stairs Block in my mod, but it always leads to a crash: java.lang.ExceptionInInitializerError at net.minecraftforge.registries.NamespacedDefaultedWrapper$Factory.onCreate(NamespacedDefaultedWrapper.java:154) at net.minecraftforge.registries.RegistryBuilder.lambda$getCreate$2(RegistryBuilder.java:228) at net.minecraftforge.registries.ForgeRegistry.<init>(ForgeRegistry.java:127) at net.minecraftforge.registries.RegistryManager.createRegistry(RegistryManager.java:134) at net.minecraftforge.registries.RegistryBuilder.create(RegistryBuilder.java:184) at net.minecraftforge.registries.GameData.init(GameData.java:169) at net.minecraftforge.registries.GameData.<clinit>(GameData.java:153) at net.minecraft.block.Block.<clinit>(Block.java:81) at com.faendir.minecraft.hadron.generated.ModObjects0.<clinit>(ModObjects0.java:76) at com.faendir.minecraft.hadron.generated.Registry1.registerBlock(Registry1.java:35) at net.minecraftforge.eventbus.ASMEventHandler_10_Registry1_registerBlock_Register.invoke(.dynamic) at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80) at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258) at net.minecraftforge.fml.javafmlmod.FMLModContainer.fireEvent(FMLModContainer.java:106) at java.base/java.util.function.Consumer.lambda$andThen$0(Consumer.java:65) at java.base/java.util.function.Consumer.lambda$andThen$0(Consumer.java:65) at net.minecraftforge.fml.ModContainer.transitionState(ModContainer.java:112) at net.minecraftforge.fml.ModList.lambda$dispatchSynchronousEvent$4(ModList.java:110) at java.base/java.util.ArrayList.forEach(ArrayList.java:1378) at net.minecraftforge.fml.ModList.dispatchSynchronousEvent(ModList.java:110) at net.minecraftforge.fml.ModList.lambda$static$0(ModList.java:81) at net.minecraftforge.fml.LifecycleEventProvider.dispatch(LifecycleEventProvider.java:71) at net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:173) at net.minecraftforge.fml.ModLoader.lambda$gatherAndInitializeMods$21(ModLoader.java:165) at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:918) at net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:165) at net.minecraftforge.fml.client.ClientModLoader.lambda$begin$2(ClientModLoader.java:68) at net.minecraftforge.fml.client.ClientModLoader.lambda$createRunnableWithCatch$5(ClientModLoader.java:84) at net.minecraftforge.fml.client.ClientModLoader.begin(ClientModLoader.java:68) at net.minecraft.client.Minecraft.init(Minecraft.java:456) at net.minecraft.client.Minecraft.run(Minecraft.java:365) at net.minecraft.client.main.Main.main(Main.java:128) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:50) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:68) at cpw.mods.modlauncher.Launcher.run(Launcher.java:80) at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:101) Caused by: java.lang.NullPointerException: Attempted to get vanilla wrapper for unknown registry: class net.minecraft.util.SoundEvent at org.apache.commons.lang3.Validate.notNull(Validate.java:225) at net.minecraftforge.registries.GameData.getWrapper(GameData.java:233) at net.minecraft.util.registry.Registry.forge(Registry.java:250) at net.minecraft.util.registry.Registry.<clinit>(Registry.java:77) ... 43 more I'll try to add all relevant classes here, please ask if I need to provide more information to receive help. @Mod.EventBusSubscriber( modid = "hadron", bus = Mod.EventBusSubscriber.Bus.MOD ) public class Registry1 { ... @SubscribeEvent public static void registerBlock(RegistryEvent.Register<Block> event) { event.getRegistry().register(ModObjects0.OAK_WOOD_WALL); event.getRegistry().register(ModObjects0.DIORITE_BRICK_STAIRS); event.getRegistry().register(ModObjects0.ANDESITE_BRICK_STAIRS); event.getRegistry().register(ModObjects0.GRANITE_BRICK_SLABS); event.getRegistry().register(ModObjects0.ANDESITE_BRICK_SLABS); event.getRegistry().register(ModObjects0.DIORITE_BRICK_SLABS); event.getRegistry().register(ModObjects0.OAK_WOOD_SLABS); event.getRegistry().register(ModObjects0.OAK_WOOD_STAIRS); event.getRegistry().register(ModObjects0.GRANITE_BRICK_STAIRS); } } public class ModObjects0 { ... public static final Block DIORITE_BRICK_SLABS = new SlabBlock(Block.Properties.from(StoneBricks.DIORITE_BRICKS)).setRegistryName("diorite_brick_slabs"); public static final Block OAK_WOOD_SLABS = new SlabBlock(Block.Properties.from(MoreBark.OAK_BARK)).setRegistryName("oak_wood_slabs"); public static final Block GRANITE_BRICK_SLABS = new SlabBlock(Block.Properties.from(StoneBricks.GRANITE_BRICKS)).setRegistryName("granite_brick_slabs"); public static final Block ANDESITE_BRICK_SLABS = new SlabBlock(Block.Properties.from(StoneBricks.ANDESITE_BRICKS)).setRegistryName("andesite_brick_slabs"); public static final Block DIORITE_BRICK_STAIRS = new HadronStairsBlock(StoneBricks.DIORITE_BRICKS.getDefaultState(), Block.Properties.from(StoneBricks.DIORITE_BRICKS)).setRegistryName("diorite_brick_stairs"); public static final Block OAK_WOOD_STAIRS = new HadronStairsBlock(MoreBark.OAK_BARK.getDefaultState(), Block.Properties.from(MoreBark.OAK_BARK)).setRegistryName("oak_wood_stairs"); public static final Block GRANITE_BRICK_STAIRS = new HadronStairsBlock(StoneBricks.GRANITE_BRICKS.getDefaultState(), Block.Properties.from(StoneBricks.GRANITE_BRICKS)).setRegistryName("granite_brick_stairs"); public static final Block ANDESITE_BRICK_STAIRS = new HadronStairsBlock(StoneBricks.ANDESITE_BRICKS.getDefaultState(), Block.Properties.from(StoneBricks.ANDESITE_BRICKS)).setRegistryName("andesite_brick_stairs"); public static final Block OAK_WOOD_WALL = new WallBlock(Block.Properties.from(MoreBark.OAK_BARK)).setRegistryName("oak_wood_wall"); } public class HadronStairsBlock extends StairsBlock { public HadronStairsBlock(BlockState state, Properties properties) { super(state, properties); } } It seems to me that my class is loaded at the wrong point in time (too late?), but I'm not sure if that's the issue or how to fix it. Am I doing something wrong?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.