Jump to content

What's the proper way to register a tileEntity?


MrDireball

Recommended Posts

I'm trying to register the TileEnity for my custom block called "data_block", but Forge says that the method I'm using is obsolete, and also I don't even know if I'm doing it right.

 

GameRegistry.registerTileEntity(DataTileEntity.class, Reference.MOD_ID + ".data_block"); //This is in preInit of Main.

 

I say that I don't know if I'm doing it right because I've also seen different people us all of the following when entering the path string for TileEntites.

 

Reference.MOD_ID + "data_block"

Reference.MOD_ID + ".data_block"

Reference.MOD_ID + "_data_block"

Reference.MOD_ID + ":data_block"

Edited by MrDireball
additional information
Link to comment
Share on other sites

1 hour ago, MrDireball said:

I'm trying to register the TileEnity for my custom block called "data_block", but Forge says that the method I'm using is obsolete, and also I don't even know if I'm doing it right.

 

GameRegistry.registerTileEntity(DataTileEntity.class, Reference.MOD_ID + ".data_block"); //This is in preInit of Main.

 

I say that I don't know if I'm doing it right because I've also seen different people us all of the following when entering the path string for TileEntites.

 

Reference.MOD_ID + "data_block"

Reference.MOD_ID + ".data_block"

Reference.MOD_ID + "_data_block"

Reference.MOD_ID + ":data_block"

 

I believe it needs to be a ResourceLocation instead of just a String

e.g.,

 

GameRegistry.registerTileEntity(DataTileEntity.class, new ResourceLocation(Reference.MOD_ID + ".data_block"));

 

  • Like 1
Link to comment
Share on other sites

1 hour ago, cptcorndog said:

 

I believe it needs to be a ResourceLocation instead of just a String

e.g.,

 

GameRegistry.registerTileEntity(DataTileEntity.class, new ResourceLocation(Reference.MOD_ID + ".data_block"));

 

Using this method made the obsolete warning go away and seems to be the correct way of doing it, but how do I check to see if it actually ends up getting registered?

Link to comment
Share on other sites

9 hours ago, Siqhter said:

How I do it is something like:

  Hide contents


public static void register() {
    GameRegistry.registerTileEntity(YourTileEntity.class, "modidyourtileentity");
}

and then call the method in your Main.java init method.

Don't do that, please. You're registering your TE with a plain string and not even prefixing it with your mod ID.  That method is even deprecated in recent Forge builds.  Correct way is:

GameRegistry.registerTileEntity(YourTileEntity.class, new ResourceLocation("your_mod_id", "your_tile_entity_name));

 

7 hours ago, MrDireball said:

Using this method made the obsolete warning go away and seems to be the correct way of doing it, but how do I check to see if it actually ends up getting registered?

You'll know pretty quickly if you registered it when you attempt to place any blocks of that tile entity. If you can place them, your TE is registered :)  However, if the registerTileEntity() call didn't throw an exception or log a warning in your log file, it should be safe to assume it succeeded.

Link to comment
Share on other sites

6 hours ago, desht said:

Don't do that, please. You're registering your TE with a plain string and not even prefixing it with your mod ID.  That method is even deprecated in recent Forge builds.  Correct way is:


GameRegistry.registerTileEntity(YourTileEntity.class, new ResourceLocation("your_mod_id", "your_tile_entity_name));

 

You'll know pretty quickly if you registered it when you attempt to place any blocks of that tile entity. If you can place them, your TE is registered :)  However, if the registerTileEntity() call didn't throw an exception or log a warning in your log file, it should be safe to assume it succeeded.

I disabled the line of code that I had in Main, and nothing happened. Then I realized that I had put code in CommonProxy to register it, and apparently didn't need anything in Main. So I commented out the code in CommonProxy to see what would happen. I was able to place the block and interact with it and everything, and I saw no indication in-game that something was wrong, but errors were repeatedly logged in the console complaining about missing mapping or something.

Link to comment
Share on other sites

17 hours ago, MrDireball said:

I disabled the line of code that I had in Main, and nothing happened. Then I realized that I had put code in CommonProxy to register it, and apparently didn't need anything in Main. So I commented out the code in CommonProxy to see what would happen. I was able to place the block and interact with it and everything, and I saw no indication in-game that something was wrong, but errors were repeatedly logged in the console complaining about missing mapping or something.

Tile entity registration needs to be done on both client and server, so why are you even using a proxy??  While we're at it, "CommonProxy" is an anti-pattern you should get rid of. The whole point of proxies is to implement different behaviour on the client and server; if the same code needs to be executed, then it shouldn't be in a proxy at all. The correct way to do this is to create an IProxy interface, and two implementations: a ClientProxy for the client and ServerProxy for the server. Pass those classnames to your @SidedProxy annotation, and define your proxy object with type IProxy.

 

As for your tile entities, just register them from your FMLPreInitializationEvent handler.

Edited by desht
Link to comment
Share on other sites

On 1/11/2019 at 6:49 AM, desht said:

Tile entity registration needs to be done on both client and server, so why are you even using a proxy??  While we're at it, "CommonProxy" is an anti-pattern you should get rid of. The whole point of proxies is to implement different behaviour on the client and server; if the same code needs to be executed, then it shouldn't be in a proxy at all. The correct way to do this is to create an IProxy interface, and two implementations: a ClientProxy for the client and ServerProxy for the server. Pass those classnames to your @SidedProxy annotation, and define your proxy object with type IProxy.

 

As for your tile entities, just register them from your FMLPreInitializationEvent handler.

I just learned both Java and how to mod Minecraft a few days ago, so I don't actually know what a proxy is. I was just told somewhere to register TileEntities in a proxy.

Link to comment
Share on other sites

On 1/13/2019 at 1:46 AM, MrDireball said:

I just learned both Java and how to mod Minecraft a few days ago, so I don't actually know what a proxy is. I was just told somewhere to register TileEntities in a proxy.

Whoever told you that didn't know what they were talking about. Proxies exist because the Minecraft client and server, while sharing a lot of common code, also do things that other does not, e.g. the client knows about models, textures, GUI's, and the server neither knows nor cares about such things - try to register a model on the server, and it'll crash. So you should be doing client-side specific code from your side-specific proxy implementation. On the other hand, tile entity registration is identical on both sides, so proxies are completely unnecessary there.

 

Have a read of https://mcforge.readthedocs.io/en/latest/concepts/sides/ and when you're done, go back and read it again.  It's really important to understand this fundamental Forge concept.

Edited by desht
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.

Guest
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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • 🚀Link Daftar Klik Disini🚀 Tips Bermain Slot Bank Jago agar Meraih Maxwin dan Jackpot di MAXWINBET77 Bermain slot online Bank jago adalah cara yang seru dan mengasyikkan untuk mencari keuntungan besar di MAXWINBET77. Jika kamu ingin meningkatkan peluangmu untuk meraih maxwin dan jackpot secara terus-menerus, ada beberapa tips dan strategi yang bisa kamu terapkan. Berikut adalah panduan lengkapnya: Pilih Slot dengan RTP Tinggi: RTP (Return to Player) adalah persentase rata-rata dari total taruhan yang dikembalikan kepada pemain sebagai kemenangan. Pilihlah mesin slot Bank jago yang memiliki RTP tinggi, karena ini meningkatkan peluangmu untuk meraih kemenangan dalam jangka panjang. Kenali Fitur Bonus: Setiap slot Bank jago memiliki fitur bonus yang berbeda, seperti putaran gratis, simbol liar (wild), dan bonus game. Pelajari dengan baik fitur-fitur ini karena mereka dapat membantu meningkatkan peluang meraih kemenangan besar. Kelola Taruhan dengan Bijak: Tentukan batasan taruhan yang sesuai dengan budget dan jangan tergoda untuk bertaruh melebihi kemampuan finansialmu. Terapkan strategi taruhan yang bijak untuk memaksimalkan penggunaan saldo. Mainkan Slot Bank jago Progresif: Jika tujuanmu adalah meraih jackpot besar, coba mainkan slot Bank jago progresif di MAXWINBET77. Jackpot pada jenis slot Bank ini terus bertambah seiring dengan taruhan pemain lainnya, sehingga dapat mencapai jumlah yang sangat besar. Manfaatkan Promosi dan Bonus: MAXWINBET77 sering kali menawarkan promosi dan bonus kepada pemainnya. Manfaatkan bonus-bonus ini untuk meningkatkan peluangmu meraih kemenangan tanpa menggunakan modal tambahan. Berkonsentrasi dan Bersabar: Fokuslah saat bermain slot bank jago dan jangan terburu-buru. Bersabarlah meskipun tidak langsung mendapatkan hasil yang diharapkan. Kadang-kadang diperlukan waktu dan keberuntungan untuk mencapai maxwin atau jackpot. Baca Aturan Permainan: Sebelum bermain, pastikan untuk membaca aturan dan pembayaran pada slot Bank Jago yang dipilih. Mengetahui cara kerja mesin slot akan membantu mengoptimalkan strategi bermainmu. Dengan menerapkan tips-tips di atas dan tetap bermain secara bertanggung jawab, kamu dapat meningkatkan peluang meraih maxwin dan jackpot di Slot Bank Jago MAXWINBET77. Selamat bermain dan semoga sukses meraih kemenangan besar Anda Hari Ini.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 SLOT BCA 10K adalah bocoran slot rekomendasi gacor dari RATUASIA77 yang bisa anda temukan di SLOT BCA 10K. Situs SLOT BCA 5K hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT BSI 5K terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT BCA 10K merupakan SLOT BCA 10K hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT BSI 10K. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT BCA 10K hari ini yang telah disediakan SLOT BCA 10K. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs RATUASIA77 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT BCA 10K terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT BCA 10K di link SLOT BCA RATUASIA77.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 SLOT BSI 10K adalah bocoran slot rekomendasi gacor dari RATUASIA77 yang bisa anda temukan di SLOT BSI 10K. Situs SLOT BSI 5K hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT BSI 5K terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT BSI 10K merupakan SLOT BSI 10K hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT BSI 10K. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT BSI 10K hari ini yang telah disediakan SLOT BSI 10K. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs RATUASIA77 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT BSI 10K terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT BSI 10K di link SLOT BSI RATUASIA77.
    • DAFTAR SCATTER HITAM MAHJONG WAYS DISINI DAFTAR SCATTER HITAM MAHJONG WAYS DISINI DAFTAR SCATTER HITAM MAHJONG WAYS DISINI Mencari scatter hitam dalam permainan slot demo mahjong ways server thailand adalah salah satu jalan menuju kemenangan melalui bentuk kombinasi pola. Mengetahui bocoran pola scatter dapat meningkatkan peluang kemenangan jackpot maxwin yang cukup besar. TAG : Scatter Hitam Scatter Hitam Scatter Hitam Scatter Hitam Scatter Hitam Scatter Hitam Scatter Hitam Scatter Hitam
    • DAFTAR SCATTER HITAM MAHJONG DISINI DAFTAR SCATTER HITAM MAHJONG DISINI DAFTAR SCATTER HITAM MAHJONG DISINI Scatter Hitam merupakan salah satu provider Pg Soft dari game slot mahjong ways terpopuler dan terkenal saat ini dengan inovasi terbaru scatter hitam bisa menghasilkan kemenangan maxwin jackpot yang luar biasa sangat besar. TAG : Scatter Hitam Scatter Hitam Scatter Hitam Scatter Hitam Scatter Hitam Scatter Hitam Scatter Hitam Scatter Hitam
  • Topics

×
×
  • Create New...

Important Information

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