Jump to content

Rendering Block Model dependiong on a property loaded from a Tile entity


ThePiekar

Recommended Posts

So I've been trying to add some more beds to Minecraft. (1.12.2)
Naturally for my block i extended BlockBed class and for my item ItemBed class.
I've got most of the funcionality working but due to lack of expirience I resorted to having Blocks be the model and not the tile entity. (i know i should just make the colored part a TE model but I have no real idea how to)
Limited by block meta I stored the color property in the tile entity, upon placing the bed has its desired color, testing for drops also confirms that the entity works.
However after reolading the bed (via either leaving the area or loading up the save again) the bed is always white, but upon breaking the particles have the correct color, the dropped items also correspond to the color stored in TE.
(note that im not very expirienced in java or forge, code is mostly what i picked up from others and slight modifications to vanilla)

 

Block class

pastebin

 

Item class (i dont think this one matters in this situation)

pastebin

 

TileEntity class 

pastebin

 

 

Edited by ThePiekar
Link to comment
Share on other sites

Please post your code as a GitHub repository, I think your probably not syncing the data correctly.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

BlockBase is an anti-pattern, there is already a BlockBase class, it’s called Block.

Don’t use IHasModel, all items need models. You can do all your item model registration automatically in 1 line. IHasModel forces you to write the exact same code over and over again.

Package names should be singular

Methods should start lowercase

A CommonProxy doesn’t make sense. Proxies seperate code. If it’s common code it doesn’t belong in a proxy.

Have you tried stepping through your code in a debugger? You seem to be overriding all the correct syncing methods.

Where is your rendering code?

  • Confused 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Sorry for lack of proffesionality, lot of things are there temporary, like block and item base, for me to just test if certain things work on an easier basis.

 

I'll look into renaming stuff according to the rules and getting rid of IHasModel and CommonProxy ( to be fair by the time I introduced them I had no idea what anything did), where do you advise me to put the things i had in common proxy (basically a empty void called registerItemRenderer)?

 

That's all the code I have, maybe besides json files, they are a bit ugly, since I didn't want to spend my whole life checking where I missed the coma, but I'll upload them as well.

 

Sorry to be difficult but if that's not what you mean by rendering code, could you specify and/or give examples?

 

 

///EDIT///

Updated github with jsons

 

Also i wouldn't really know what to do with debugger information 

Edited by ThePiekar
Link to comment
Share on other sites

You should set up your GitHub repo differently, it should be in your root mod folder (the one right above /src/)

Your repository is currently missing the files needed for someone else to download and set it up.

Here’s an example of a properly set up repository (notice the build.gradle file) https://github.com/Cadiboo/Example-Mod.

I think you should put a breakpoint in loadColor in your block class, and see what color it returns and why. As a programmer you need to know how to use the debugger, it’s an extremely helpful and powerful tool and there are plenty of online tutorials about it.

 

12 hours ago, ThePiekar said:

Sorry to be difficult but if that's not what you mean by rendering code, could you specify and/or give examples?

Because you were using a TE, I assumed you were using a TESR. It’s good that you’re not though

  • Like 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Ok, I've set up something that resembles a proper repo now, same link.
Even if i make loadColor method always return let's say red it still renders the bed white after reolading.
That's why i suspect it to be a sync issue, as destroy particles have the correct texture, as if getActualState was called on breaking the block but not on choosing a model for it.
I'm trying to further investigate the loadColor right now.

Replacing code in getActualState to make it always return a let's say red as color property makes the bed be still white but always have red destruction particles.

Is there any way for me to pass the state from TE to the block before it's rendered (I was convinced getActualState already did it)? 

 

///Edit///


~~I managed to get the color of  bed loaded last( I'm not entirely sure)(so still not the desired one, particles and drops match the desired one) of TE to be the color of the block until the game is restarted, after which it gets back ot block default (white). Even after game restart item drops and particles are correct, so I'd assume TE saves and reads the data correctly. 
Im as confused as it gets
(code added to TE)

	@Override
	    public void onLoad()
	{
		Block bed = getWorld().getBlockState(getPos()).getBlock();
		BlockFancyBed fbed = (BlockFancyBed) bed;
		fbed.setRenderState(fbed.getActualState(getWorld().getBlockState(getPos()), getWorld(), getPos()));
		notifyBlockUpdate();
	}

 

(code added to Block)

    	   public void setRenderState(IBlockState state) {
    		   this.setDefaultState(state);
    	   }

~~ doesn't work anymore for some reason

///Edit2///
Woking with debugger confirms that getActualState is called after interacting with block and not on rendering it, so thats why clolor stays default.

 

So the question is how to change the state of a single block before it's rendered
(defaulst state and actual state don't seem to cut it)
 

///Edit3///
i played around with setBlockState in onLoad method of the TE and discovered it gets seemingly called twice per TE, once by Server (color values from debugger seem fine here) and second time by the client Thread (with either null or default color value declared in the TE class)
 

///Edit4///
Even if I don't get to solve it just yet, thank You for giving me great leads, I have learned a lot.

Edited by ThePiekar
Link to comment
Share on other sites

Don’t call set default state anywhere other than the constructor.

Have you tried debugging your syncing?

  • Thanks 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

I figured out as much, took me a while.

 

Well I'm going to have to take a break this weekend, but as soon as I'm back I'll check every sync method. Till then thanks for all help till now, I have a much better understanding on how to fiddle with code just after those few replies.

Link to comment
Share on other sites

6 hours ago, ThePiekar said:

Also I noticed a lot of tile enitites using public void update with Override adnotation. I cannot seem to find it in my code, any hints?

To use that method you need to implement ITickable.

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

  • 2 weeks later...

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

    • Halo para penggemar slot online! Apakah Anda mencari pengalaman bermain slot yang seru dan menguntungkan? Apakah Anda ingin menikmati slot gacor dari server Thailand sambil melakukan deposit melalui Mandiri dengan kesempatan meraih kemenangan besar? Anda telah sampai di tempat yang tepat! Kami di WINNING303 siap memberikan Anda pengalaman bermain yang mengasyikkan dan menguntungkan. Mengapa Memilih WINNING303? WINNING303 telah dikenal sebagai salah satu platform terbaik untuk bermain slot dengan berbagai keunggulan yang kami tawarkan kepada para pemain kami. Berikut adalah beberapa alasan mengapa Anda harus memilih WINNING303: Slot Gacor dari Server Thailand Kami menyajikan koleksi slot gacor terbaik dari server Thailand yang pastinya akan memberikan Anda pengalaman bermain yang menarik dan menguntungkan. Nikmati berbagai jenis permainan slot dengan tingkat kemenangan yang tinggi dan jackpot yang menarik. Deposit Mudah Melalui Mandiri Kami memahami pentingnya kemudahan dalam bertransaksi bagi para pemain kami. Oleh karena itu, kami menyediakan layanan deposit melalui bank Mandiri, salah satu bank terbesar di Indonesia. Proses depositnya cepat, mudah, dan aman, sehingga Anda dapat langsung memulai petualangan bermain tanpa hambatan. Peluang Maxwin Besar Di WINNING303, kami selalu memberikan peluang untuk meraih kemenangan besar. Dengan berbagai promosi dan bonus menarik yang kami sediakan, Anda memiliki kesempatan untuk memenangkan hadiah-hadiah yang fantastis dan meraih maxwin dalam bermain slot.  
    • SLOT Ratubet77 adalah bocoran slot gacor rekomendasi dari Ratubet77 yang bisa anda temukan di SLOT Ratubet77. Situs SLOT Ratubet77 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Ratubet77 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Ratubet77 merupakan SLOT Ratubet77 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 Ratubet77. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Ratubet77 hari ini yang telah disediakan SLOT Ratubet77. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Ratubet77 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 Ratubet77 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Ratubet77 di link SLOT Ratubet77. DAFTAR SEKARANG DAFTAR SEKARANG DAFTAR SEKARANG
    • I am currently running the 1.20.1 Occultcraft modpack in Curseforge and am having numerous troubles making a mob farm with the apotheosis mod. When trying to modify the stats of the spawners specific stats such as the range, spawn count, and max entities reset to default after every spawn. When the spawners spawn boss mobs with certain attributes, that I'm not sure of, the building it is in explode even with mob griefing turned off. This has happened multiple times with varying sizes for the explosions. I was wonder if there is any way to disable these explosions from happening or disable boss abilities with something in the game. I also wanted to know a fix for the resetting stats on spawners and why this is happening.
    • SLOT Bank BSI adalah pilihan terbaik untuk Anda yang ingin merasakan sensasi bermain slot dengan layanan dari Bank BSI. Dengan keamanan terjamin, beragam pilihan permainan, kemudahan deposit via Bank BSI, dan berbagai bonus menarik, kami siap memberikan Anda pengalaman bermain yang tak terlupakan. Bergabunglah dengan kami sekarang dan mulailah petualangan seru Anda!    
    • Mengapa Memilih WINNING303? WINNING303 telah dikenal sebagai salah satu platform terbaik untuk bermain slot Pragmatic di Indonesia. Apa yang membuat kami unggul? Kami memiliki sejumlah keunggulan yang akan membuat pengalaman bermain Anda lebih menyenangkan. Keamanan Terjamin Keamanan adalah prioritas utama kami di WINNING303. Kami menggunakan teknologi enkripsi terbaru untuk melindungi data pribadi dan keuangan Anda. Dengan begitu, Anda dapat bermain dengan tenang tanpa perlu khawatir tentang keamanan informasi Anda. Beragam Pilihan Permainan Kami menyediakan berbagai macam permainan slot Pragmatic yang menarik dan menghibur. Mulai dari tema klasik hingga yang paling modern, Anda pasti akan menemukan permainan yang sesuai dengan selera Anda di WINNING303. Selain itu, kami juga secara teratur memperbarui koleksi permainan kami untuk memberikan pengalaman bermain yang segar dan menarik setiap saat. Kemudahan Deposit Via Bank Niaga 24 Jam Kami mengerti bahwa kenyamanan dalam bertransaksi sangatlah penting bagi para pemain. Oleh karena itu, kami menyediakan layanan deposit melalui Bank Niaga yang dapat diakses 24 jam sehari, 7 hari seminggu. Prosesnya cepat dan mudah, sehingga Anda dapat langsung memulai permainan tanpa menunggu waktu lama. Bonus dan Promosi Menarik Di WINNING303, kami selalu memberikan bonus dan promosi yang menggiurkan bagi para pemain setia kami. Mulai dari bonus selamat datang hingga bonus deposit, ada banyak penawaran menarik yang dapat Anda manfaatkan untuk meningkatkan peluang kemenangan Anda.         
  • Topics

×
×
  • Create New...

Important Information

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