Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Are blockstates created only once and do they have some kind of index? 1.15.2
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
AntonBespoiasov

Are blockstates created only once and do they have some kind of index? 1.15.2

By AntonBespoiasov, May 13, 2020 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

AntonBespoiasov    0

AntonBespoiasov

AntonBespoiasov    0

  • Tree Puncher
  • AntonBespoiasov
  • Members
  • 0
  • 40 posts
Posted May 13, 2020 (edited)

Creating multiblock system I decided that I will store original blockstate in TEs of blocks of a multiblock because my multiblocks are pretty dynamic and some 3-dimensional array storing their structure wouldn't work. This blockstate will replace corresponding block of the multiblock with itself when the multiblock is dissassembled(some of its blocks are destroyed). But I don't know if each block in the world is unique blockstate or just reference to certain blockstate.

Doing some researches I came across StateContainer that is filled with blockstates in constructor of Block and stored there. This is a proof of blockstates being created only once for each combination of properties.

Do blockstates have fixed indexes? Because I want to store the indexes in unloaded chunks instead of map of properties and values(since O(1) is better than O(n)). "Fixed indexes" means that the same blockstate will have the same index each time game loads.

Edited May 13, 2020 by AntonBespoiasov
  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted May 13, 2020
2 hours ago, AntonBespoiasov said:

But I don't know if each block in the world is unique blockstate or just reference to certain blockstate.

Why not dig into the World and Chunk classes to find out what happens when you call setBlockState().

2 hours ago, AntonBespoiasov said:

Do blockstates have fixed indexes?

They don't have indexes at all.

  • Quote

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.

Share this post


Link to post
Share on other sites

diesieben07    7697

diesieben07

diesieben07    7697

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7697
  • 56382 posts
Posted May 14, 2020

The only way to reliably store block states is NBTUtil.writeBlockState, which will serialize a map of properties and their values.

Chunks use IDs to store the states, but these IDs are only valid within that chunk and might change.

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • GhostGamesFSM
      1.16 Ore generation.

      By GhostGamesFSM · Posted just now

      sorry for the txt, but thanks for the comment. I don't have a BiomeLoadingEvent, but I just have to see how I do that. When I have that I send you a message if that works.
    • HOTSAUCEMAN
      help with loading my world

      By HOTSAUCEMAN · Posted 1 minute ago

      just ran it again to get more updated logs  debug-1.log.gz
    • HOTSAUCEMAN
      help with loading my world

      By HOTSAUCEMAN · Posted 5 minutes ago

      when loading into my world it says its loading, and then changes to a dirt background with no text; i've looked at multiple threads, forums and videos but i can't find any issue similar to mine (at least on a similar version)  debug-1.log.gz
    • Beethoven92
      [1.16.5] Beacon Overwrite (Screen Error)

      By Beethoven92 · Posted 12 minutes ago

      I apologize...i misread the part where you say that your custom beacon inventory actually opens fine! Yeah, the proximity check is doing its job, the problem seems to be that when pressing the confirm button you are sending a vanilla CUpdateBeaconPacket, then handled by the server, which will check if your open container is a BeaconContainer. It would be helpful to see the complete code you have, please post a link to your repository
    • Beethoven92
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By Beethoven92 · Posted 30 minutes ago

      Show what you tried then. It should be "enchantment.your_mod_id.your_enchantment_id"
  • Topics

    • GhostGamesFSM
      2
      1.16 Ore generation.

      By GhostGamesFSM
      Started 17 hours ago

    • HOTSAUCEMAN
      1
      help with loading my world

      By HOTSAUCEMAN
      Started 5 minutes ago

    • Nyko
      3
      [1.16.5] Beacon Overwrite (Screen Error)

      By Nyko
      Started Yesterday at 07:22 AM

    • samjviana
      5
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By samjviana
      Started Sunday at 10:00 PM

    • DrigglyEast
      0
      Fatally Missing Registry Entries

      By DrigglyEast
      Started 2 hours ago

  • Who's Online (See full list)

    • GhostGamesFSM
    • Tavi007
    • HOTSAUCEMAN
    • Beethoven92
    • zlappedx3
    • am pro
    • Abrynos
    • vemerion
    • kaleojok12
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Are blockstates created only once and do they have some kind of index? 1.15.2
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community