Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Choonster

Forge Modder
  • Posts

    5104
  • Joined

  • Last visited

  • Days Won

    75

Everything posted by Choonster

  1. The second argument of withExistingParent is the path to a model file to use as a parent, not a texture. For basic block items, the model normally uses the block model as the parent, rather than specifying individual textures. I use this helper method in my BlockStateProvider implementation to generate block item models that simply extend the block model. You can see an example of this here. On a side note, the DeferredRegister instance should always be created in the same class as it's used in; don't put the DeferredRegister and RegistryObject fields in separate classes.
  2. NBTIngredient doesn't have an of method itself, you're actually calling Ingredient.of. You need to create an instance of NBTIngredient directly (or a class that extends it, since the constructor is protected).
  3. Java doesn't have ref either, but does have tuples (from Minecraft and Apache Commons Lang).
  4. Thanks, I think that makes sense. I've tried to follow this advice and clean up all my DistExecutor code in this commit, does this look correct?
  5. I have a packet that's sent to the client to open a GUI, which I'm using DistExecutor to do. The packet's handler method does the following: DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> ClientOnlyNetworkMethods.openClientScreen(message)) ClientOnlyNetworkMethods.openClientScreen currently looks like this: public static DistExecutor.SafeRunnable openClientScreen(final OpenClientScreenMessage message) { return new DistExecutor.SafeRunnable() { @Override public void run() { ClientScreenManager.openScreen(message.getId(), message.getAdditionalData(), Minecraft.getInstance()); } }; } ClientScreenManager is a client-only class that handles opening the GUI. As you can see from the code, I need to pass arguments from the packet to the client-only method; which rules out using a method reference as the SafeRunnable implementation. When I replace the anonymous class implementation of SafeRunnable in ClientOnlyNetworkMethods.openClientScreen with a lambda, DistExecutor.validateSafeReferent throws an "Unsafe Referent usage found in safe referent method" exception. From what I can see, using any non-lambda implementation of SafeReferent simply bypasses the safety checks in validateSafeReferent but doesn't necessarily mean that the code is safe. The current code with the anonymous class does seem to work on the dedicated server, but is this the correct way to use DistExecutor; or is there a better way to do it?
  6. Yes, that probably would have been a useful feature. It's a shame that the author didn't have time to complete it.
  7. Part of the idea with my system was to allow syncing capabilities attached to arbitrary items, not just items that know about their capabilities. What would you recommend for capabilities attached to items from Vanilla or another mod?
  8. I've had a brief look at this and can't see any easy way to work around it, so I've created a suggestion thread for a change here: I'm not sure if it will go anywhere.
  9. I have a system for syncing item capability data that uses ICapabilityListener, as explained here: I discovered in that thread that this pull request for 1.12.2 back in 2017 partially broke my system by changing Container#detectAndSendChanges to only call IContainerListener#sendSlotContents if a slot's Item, count or share tag has changed; which often won't be the case for capability-only updates. The change does make sense for Vanilla IContainerListener implementations to reduce unnecessary network traffic, but would it be possible to allow modded IContainerListeners to opt-in to having sendSlotContents called even if the Items, counts and share tags are equal?
  10. It looks like Forge patches Container#detectAndSendChanges to only call IContainerListener#sendSlotContents if a slot's Item, count or share tag has changed; which often won't be the case for capability-only updates. I may need to re-evaluate the IContainerListener system to see if there's any way around this. This change was actually introduced in August 2017 for 1.12.2, six months after I created my system. I thought it was working more recently than that, but I must not have tested it properly.
  11. With my system, each capability type that needs to be synced to the client has several sync-related classes: A single update network message (extending UpdateContainerCapabilityMessage) that syncs the capability data for a single slot of a Container. A bulk update network message (extending BulkUpdateContainerCapabilityMessage) that syncs the capability data for all slots of a Container. A "functions" class containing static methods used by both the single and bulk update messages. A container listener class (extending CapabilityContainerListener) that sends the single/bulk update messages when the Container's contents change. A factory function for the container listener is registered with CapabilityContainerListenerManager.registerListenerFactory at startup so that when a player opens a Container, a new listener can be created and added to it. The network messages have the concept of a "data" class, which is a simple POJO (or even a primitive type like int or long) containing only the data that needs to be synced from the server to the client. The base classes for the messages handle the functionality that's common to all capability types, the message classes for each capability just need to provide functions to do the following: On the server: Convert an instance of the capability handler (e.g. IFluidHandlerItem for a fluid tank) to a data object Encode (write) the data object to the packet buffer On the client: Decode (read) the data object from the packet buffer Apply the data from the data object to the capability handler instance These functions could be defined anywhere (they could even be lambdas passed directly to the base class methods), but I keep them as static methods in a "functions" class so they can be shared between the single and bulk messages. The system might be a bit over-engineered, but it means that I can easily add syncing for a new item capability without having to rewrite all the common syncing logic. There are several implementations of this in TestMod3 that you could use as examples: ILastUseTime, which tracks the time at which an item was last used. This is a simple implementation that syncs a single long value to the client, so it uses Long as its data class. Single update message Bulk update message Functions class Container listener Container listener registration (called during FMLCommonSetupEvent) IFluidHandlerItem, Forge's fluid tank capability. This is a slightly more complex implementation that syncs a FluidStack (the tank contents) and an int (the tank capacity), so it uses FluidTankSnapshot as its data class. Single update message Bulk update message Functions class Container listener (only syncs data for my own fluid tank item, to avoid conflicts with other mods' fluid handler items) Container listener registration (called during FMLCommonSetupEvent)
  12. The OP is asking about Vanilla loot conditions and functions, not global loot modifiers. I'm not 100% sure if it's the correct time to register them, but I do it on the main thread after FMLCommonSetupEvent (i.e. inside a lambda passed to event.enqueueWork). I use the Vanilla registries, just like in your example. I'm not sure if it's necessary to register non-Forge registry entries at any specific time like it is with Forge registry entries. This is my FMLCommonSetup handler, this is my LootConditionType registration and this is my LootFunctionType registration.
  13. Thanks, I saw the Supplier overloads but didn't think to use them for lazy/deferred references. I realised after posting that my issue was actually with a SurfaceBuilder rather than a Feature (I could have moved the Feature registration since it wasn't being used in the Biome), but the same solution applies: use the Supplier overload instead of trying to pass the ConfiguredSurfaceBuilder directly. For future reference, I fixed the original issue and a few related worldgen registration issues with this commit. I decided not to go with the JSON route since my biome makes use of a lot of Vanilla features/structures (the same ones as the Vanilla Desert biome) and I didn't want to write all of that out by hand. I would have liked a data generator approach like blockstates, models, loot tables, etc.; but the Vanilla BiomeProvider is only designed to generate "report" files from already-registered Biomes. I did end up adding my own version of BiomeProvider that only generates files for my own mod's biomes in this commit, the generated JSON file is 1,968 lines.
  14. I'm trying to register a Biome with a Feature from my mod, but I'm having difficulty because Biome registration happens before Feature registration. This is the relevant registration code: Feature (DeferredRegister) Biome (DeferredRegister) ConfiguredFeature (Vanilla registry, called from here in RegistryEvent.Register<Biome> with HIGH priority to run before Biome DeferredRegister). The game crashes on startup because the ConfiguredFeature registration runs before the Feature has been registered: java.lang.NullPointerException: Registry Object not present: testmod3:banner at java.util.Objects.requireNonNull(Objects.java:290) at net.minecraftforge.fml.RegistryObject.get(RegistryObject.java:120) at choonster.testmod3.init.ModConfiguredFeatures.register(ModConfiguredFeatures.java:25) at choonster.testmod3.TestMod3.registerBiomes(TestMod3.java:57) What's the best way to work around this? Should I create the Features in RegistryEvent.Register<Biome> and then register them in RegistryEvent.Register<Feature>?
  15. I've cross-posted this to StackOverflow here, hopefully someone over there will have an answer.
  16. That lets it continue to other tasks after javadoc, but the Javadoc generation still fails.
  17. My mod depends on HWYLA, which has an API JAR containing both compiled classes and their source code. Unfortunately there seem to be some Javadoc errors in this code, which is preventing the generation of Javadoc for my own code. The Gradle output looks like this (from this CI run): > Task :processResources > Task :classes > Task :makeLibraryMetas UP-TO-DATE > Task :jar > Task :downloadMcpConfig > Task :extractSrg > Task :createMcpToSrg > Task :reobfJar /home/runner/.gradle/caches/forge_gradle/deobf_dependencies/mcp/mobius/waila/Hwyla/1.10.11-B78_1.16.2_mapped_snapshot_20200916-1.16.2/Hwyla-1.10.11-B78_1.16.2_mapped_snapshot_20200916-1.16.2-api.jar(mcp/mobius/waila/api/IComponentProvider.java):56: error: invalid end tag: </br> * Callback used to add lines to one of the three sections of the tooltip (Head, Body, Tail).</br> ^ /home/runner/.gradle/caches/forge_gradle/deobf_dependencies/mcp/mobius/waila/Hwyla/1.10.11-B78_1.16.2_mapped_snapshot_20200916-1.16.2/Hwyla-1.10.11-B78_1.16.2_mapped_snapshot_20200916-1.16.2-api.jar(mcp/mobius/waila/api/IComponentProvider.java):57: error: invalid end tag: </br> * Will only be called if the implementing class is registered via {@link IRegistrar#registerComponentProvider(IComponentProvider, TooltipPosition, Class)}.</br> > Task :javadoc ^ /home/runner/.gradle/caches/forge_gradle/deobf_dependencies/mcp/mobius/waila/Hwyla/1.10.11-B78_1.16.2_mapped_snapshot_20200916-1.16.2/Hwyla-1.10.11-B78_1.16.2_mapped_snapshot_20200916-1.16.2-api.jar(mcp/mobius/waila/api/IComponentProvider.java):58: error: invalid end tag: </br> * You are supposed to always return the modified input tooltip.</br> ^ /home/runner/.gradle/caches/forge_gradle/deobf_dependencies/mcp/mobius/waila/Hwyla/1.10.11-B78_1.16.2_mapped_snapshot_20200916-1.16.2/Hwyla-1.10.11-B78_1.16.2_mapped_snapshot_20200916-1.16.2-api.jar(mcp/mobius/waila/api/RenderableTextComponent.java):5: error: package mcp.mobius.waila.api.impl does not exist import mcp.mobius.waila.api.impl.WailaRegistrar; ^ 4 errors > Task :javadoc FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':javadoc'. > Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '/home/runner/work/TestMod3/TestMod3/build/tmp/javadoc/javadoc.options' How can I tell Gradle/Javadoc to ignore these errors and just generate the documentation for my own code? I could probably turn off doclint, but I'd rather avoid doing that. I've tried inspecting the tasks.javadoc.source property and adding an exclude filter to the task; but these only contain the paths of my own code, not the HWYLA JAR or source files.
  18. Instead of using multiple DeferredReigsters and iterating through your Blocks to register your BlockItems, it's probably simpler to just register the BlockItem at the same time as the Block (with DeferredRegister, so the actual registration still happens at the right time). This can be done helper methods like these; you could create a single method that takes the ItemGroup as a parameter, or separate methods for each ItemGroup.
  19. You can register BlockItems with DeferredRegister in the same way as normal Items. Since Blocks are registered before Items, just call RegistryObject#get on your RegistryObject<Block> in the Supplier. I use these two utility methods to automatically register a BlockItem with the Block using DeferredRegister. RegistryUtil.getRequiredRegistryEntry just returns the registry entry from a RegistryObject or throws an exception if it's not present; but this isn't required in 1.15+ because RegistryObject#get already does this (it didn't in 1.14).
  20. You could probably pass a Supplier/RegistryObject of the TileEntityType to the Block's constructor, then use that to create the TileEntity.
  21. williewillus has an explanation of the changes in 1.13/1.14 here and 1.15 here.
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.