Jump to content

[1.11] Get a list of all tile entities registered


Recommended Posts

I have two questions that I am stuck on. Question one: How do I get a list of all the tile entities that have been registered? Question two: Would I do this in post init to ensure all of the tiles have been registered, or would I use a different event? Any help on this is appreciated.


Edit: I found GameData::getTileEntityRegistry, but it's deprecated.

Edited by Awesome_Spider
Link to comment
Share on other sites

To address your first answer, if I'm not supposed to use the GameData method, is there an event I could subscribe to that is called when a tile entity is registered? I don't see one, but I'll look some more into it.


For answer 2, I have an api that can be used by other mods that containes a capability that can be attached to a tile entity. I would like to get all the tile entities to check if their classes have the capability.


However, on second thought, I will have to rethink that. The method I would use to check (hasCapability) isn't static. Meaning it is a per instance deal.

Link to comment
Share on other sites

I haven't done much with making my own APIs for my mods, but here are some random ideas:

- You could make an empty interface that you would require mods using your API to use. In the attach capabilities event, you could check if a mod's TileEntity implements said interface and attach your capability accordingly.

- Make a custom annotation that you would require other mods' tile entities to have if they want your capability. In your mod's preinit, you can scan for all classes with said annotation via the ASMDataTable (you can see how Forge does it with @ICapabilityInject in CapabilityManager#injectCapabilities). You could populate a list with all those classes and then use it to apply your capability in the capabilities event.

- You could require all mods who want your capability to send you a IMC message with their TileEntity class name, which you would add to a list. Then in the event you can check if the TE is in the list and attach the capability if it is.


The first one is definitely the easiest to do (although it might not be the best), the second and third are just ramblings but might be helpful if you want to do anything more complicated in the future. I'm not really an expert, so there might be a much better way to do this.

Edited by TheMasterGabriel
  • Like 1
Link to comment
Share on other sites

I am creating a temperature system where some blocks give off heat. I have an api that contains a capability that mod developers can attach to their tile entities. This allows the tile entities to dynamically change their temperature. The amount of heat that reaches the player depends on how far the player is away from the tile entity.


Yesterday, I asked how I should get blocks within a cube around the player, and now I need to know how far I should look for tile entities. To do this, I put a maximum temperature value in the capability that is set in the constructor of the capability. Now I need to get the tile entity with the highest maximum value, if that makes any sense.


Long story short, getting all the tile entity classes was a stupid idea. I'm not sure how to go about this at this point. Sorry about the long post.

Link to comment
Share on other sites

Heat falloff by distance, btw, is not linear. Its inverse square. 

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.

Link to comment
Share on other sites

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.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • we tried both versions and both cant run on her laptop for some reason idk what to do  
    • Okay so we tried both versions and both cant run on her pc for some reason!  
    • Well. Make sure you installed a correct jdk for your forge mdk version. Make sure your JAVA_HOME and %PATH% environment-variables are setup correctly. (If you're on windows)   I downloaded an example forge mdk for my version and extracted the contents to a folder I'm working in Using Eclipse, I opened Eclipse and imported an existing gradle Project (with its root directory in the folder directory which I previously extracted my contents to). Waited for Eclipse to do its thing After it having finished, I ran genEclipseRuns, setupDecompWorkspace and setupDevWorkspace (Gradle Tasks > your mod name here > forgegradle)    If it still didn't work (and you're using Eclipse) run cleanEclipse and, in a command prompt  Also If I recall correctly, someone, somewhere said that the way you setup your workspace changes depending on your Minecraft Version. I did this in 1.8.9.
    • https://mclo.gs/ZlRMU4G Still crash, help 
    • Hi, im having problem with error: Could not resolve dependency: net.minecraftforge:forge:1.20.1:userdev   im new in modding, but i tried everything, and it is still not working. all versions are correct etc.   build gradle: plugins {     id 'eclipse'     id 'idea'     id 'maven-publish'     id 'net.minecraftforge.gradle' version '[6.0,6.2)'     id 'org.parchmentmc.librarian.forgegradle' version '1.+' } version = mod_version group = mod_group_id base {     archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft {     // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md     // Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started     mappings channel: mapping_channel, version: mapping_version          copyIdeResources = true          runs {         // applies to all the run configs below         configureEach {             workingDirectory project.file('run')             property 'forge.logging.markers', 'REGISTRIES'             // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels             property 'forge.logging.console.level', 'debug'             mods {                 "${mod_id}" {                     source sourceSets.main                 }             }         }         client {             // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.             property 'forge.enabledGameTestNamespaces', mod_id         }         server {             property 'forge.enabledGameTestNamespaces', mod_id             args '--nogui'         }                  gameTestServer {             property 'forge.enabledGameTestNamespaces', mod_id         }         data {             workingDirectory project.file('run-data')                          args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')         }     } } // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { } dependencies {     minecraft "net.minecraftforge:forge:1.20.1" } tasks.named('processResources', ProcessResources).configure {     var replaceProperties = [             minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,             forge_version: forge_version, forge_version_range: forge_version_range,             loader_version_range: loader_version_range,             mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,             mod_authors: mod_authors, mod_description: mod_description,     ]     inputs.properties replaceProperties     filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {         expand replaceProperties + [project: project]     } } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure {     manifest {         attributes([                 'Specification-Title'     : mod_id,                 'Specification-Vendor'    : mod_authors,                 'Specification-Version'   : '1', // We are version 1 of ourselves                 'Implementation-Title'    : project.name,                 'Implementation-Version'  : project.jar.archiveVersion,                 'Implementation-Vendor'   : mod_authors,                 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")         ])     }     // This is the preferred method to reobfuscate your jar file     finalizedBy 'reobfJar' } publishing {     publications {         register('mavenJava', MavenPublication) {             artifact jar         }     }     repositories {         maven {             url "file://${project.projectDir}/mcmodsrepo"         }     } } tasks.withType(JavaCompile).configureEach {     options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation }       please help me out
  • Topics

  • Create New...

Important Information

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