Posted March 9, 20196 yr My mod is supposed to allow users to customise any tile entity's behaviour by entering its ResourceLocation string and other parameters in a text file. This text file is imported at runtime and used to add Capabilities. For a given TileEntity object , it should obtain the ResourceLocation and use that to search the data imported from the text file. In 1.12, I got that data for any given TileEntity by using the registry in the TileEntity class, which mapped between ResourceLocations and TileEntity Classes. In 1.13, it looks like that registry has been replaced with ForgeRegistries.TILE_ENTITIES, which maps between TileEntityTypes and ResourceLocations. However, when a Capability is constructed I can't get the TileEntityType because TileEntity variables are always null or 0 when Capabilities are being added. It seems that the Class is the only distinguishing information I can get from a TileEntity object when Capabilities are being attached. Is there a simple way around this that will let me keep using ResourceLocations, or will I need to ask users to enter the Class name instead of the ResourceLocation? Thanks for reading.
March 9, 20196 yr It looks like TileEntity#type is set before the TileEntity constructor calls CapabilityProvider#gatherCapabilities (which fires AttachCapabilitiesEvent); so it should be possible to call TileEntity#getType and get a valid return in your AttachCapabilitiesEvent handler. Have you tried this? Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
March 9, 20196 yr Author Sorry, I screwed up. The TileEntityType was null because I had forgotten to make that variable an ObjectHolder. Thank you anyway!
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.