Jump to content

[1.15.2] Is it possible to store data in normal blocks?


HappyHippo77

Recommended Posts

So I've got a really cool idea for a system for a mod of mine. Basically, it's a magic mod, and there will be two kinda of energy (mana), natural and personal. Natural energy exists in every natural block in the game, to different extents depending on the block itself. Personal energy is from the player themselves. By depleting personal energy too far you'll begin to experience negative effects, but if you don't give an area enough time to "recharge" after performing more magic there and trying again, the energy might be completely depleted from the blocks and they might die, rendering the area useless. Thus, you'd have to balance between using personal and natural energy in order to keep your casting areas alive.

 

I really want to implement this system, but I've run into a massive barrier. I don't know how I would be able to store information, not only in normal vanilla blocks, but in EVERY natural block which has been depleted from its default energy in some way.. I've seen other mods do things somewhat similar to this, so I get the feeling it's possible, I just have no idea how to do it myself. Would I use Capabilities? Or is there a better system?

Edited by HappyHippo77
Link to comment
Share on other sites

Hi

I don't think it's possible to directly add this information to vanilla blocks.  If it were your own blocks, you could have blockstates for each one (say 16 levels) or a tileentity.

However it's certainly possible to maintain a parallel data structure of your own which stores the energy level for every block (or perhaps more efficiently - every partially depleted block) - you can store it in WorldSavedData, and can update it regularly using server world tick.  You may need to be careful about chunks loading in or out (not trying to update information for chunks which have been unloaded because the player is a long way away, for example) but it wouldn't be particularly difficult.

 

If there are other mods which seem to do something similar, you could look at their source code too.

-TGG

 

 

  • Thanks 1
Link to comment
Share on other sites

41 minutes ago, TheGreyGhost said:

Hi

I don't think it's possible to directly add this information to vanilla blocks.  If it were your own blocks, you could have blockstates for each one (say 16 levels) or a tileentity.

However it's certainly possible to maintain a parallel data structure of your own which stores the energy level for every block (or perhaps more efficiently - every partially depleted block) - you can store it in WorldSavedData, and can update it regularly using server world tick.  You may need to be careful about chunks loading in or out (not trying to update information for chunks which have been unloaded because the player is a long way away, for example) but it wouldn't be particularly difficult.

 

If there are other mods which seem to do something similar, you could look at their source code too.

-TGG

 

 

Thanks for the response! So to do this, would I basically need to add a value for every modified block containing the location and energy values (and potentially the block type as well) of each block?

Edited by HappyHippo77
Link to comment
Share on other sites

Hi

>Thanks for the response! So to do this, would I basically need to add a value for every modified block containing the location and energy values (and potentially the block type as well) of each block?

Yeah, pretty much.

 

You might use (say) a HashMap of BlockPos vs energy value for all blocks which are are partially depleted.  The block type is stored already (in the World) so you don't need to store that.

You might also need some sort of second datastructure (eg HashSet) for blocks which are permanently depleted.

 

I think you also need to decide how the game should react if the data structures get too big and you need to cull them from memory.  What's your game mechanic for that?  eg

Do you strip out the depleted blocks which are a long way away? ("Natural energy regenerates instantly when there are no spellcasters within X radius")

If too many blocks get fully depleted in an area, does it destroy the entire chunk? ("If the flow of natural energy is sufficiently disturbed, then all natural energy in the area sickens and dies")

 

If those have an unacceptable game impact, you might need to split your data structure into chunks and store them in parallel with normal world data.  i.e. hook into the chunk loading and unloading events, and load+unload your own datastructures in parallel with those.  WorldSavedData might not be suitable for storing large amounts of data (I'm not sure); you may need to write your own datastructures on disk similar to how the chunk system does it, i.e. allows you to modify chunks within the file without having to rewrite the entire file.

That would be more complicated but it would still work if you're careful. 

 

-TGG

 

 

 

  • Thanks 1
Link to comment
Share on other sites

15 hours ago, TheGreyGhost said:

Yeah, pretty much.

 

You might use (say) a HashMap of BlockPos vs energy value for all blocks which are are partially depleted.  The block type is stored already (in the World) so you don't need to store that.

You might also need some sort of second datastructure (eg HashSet) for blocks which are permanently depleted.

I'm relatively new to Forge, so all of this is very complicated and out of my league, but I'm good at learning, so I'll try. Do you know of any resources for this kind of thing?

 

15 hours ago, TheGreyGhost said:

I think you also need to decide how the game should react if the data structures get too big and you need to cull them from memory.  What's your game mechanic for that?  eg

Do you strip out the depleted blocks which are a long way away? ("Natural energy regenerates instantly when there are no spellcasters within X radius")

If too many blocks get fully depleted in an area, does it destroy the entire chunk? ("If the flow of natural energy is sufficiently disturbed, then all natural energy in the area sickens and dies")

Well, once the blocks "die", they'd probably be replaced with separate blocks from the mod which would have a more "dead" appearance, and no ability to receive energy (and may have lesser value drops), so I don't think I'd need that kind of thing too much (the energy will restore naturally over time, and not an overly long time, so it shouldn't ever get too full of data).

Link to comment
Share on other sites

1 hour ago, HappyHippo77 said:

Do you know of any resources for this kind of thing?

This is a very complicated thing and almost no one does it because its complicated and a pain in the ass because vanilla doesn't support it directly.

This is the best example I have, but doesn't store data at the block level, but rather in 16x16x8 block-groups. Mind, its old code.

Edited by Draco18s

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

3 hours ago, Draco18s said:

This is a very complicated thing and almost no one does it because its complicated and a pain in the ass because vanilla doesn't support it directly.

This is the best example I have, but doesn't store data at the block level, but rather in 16x16x8 block-groups. Mind, its old code.

Thanks for the help, sorry I keep asking so many questions. Where would I use this hashmap? In a class which extends WorldSavedData?

Edited by HappyHippo77
Link to comment
Share on other sites

I haven't messed with it in a while. I'm not sure how I'd handle it today.

(I need to figure that out at some point, but I'm blocked by other things that need to be available first)

Edited by Draco18s

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

WorldSavedData uses its read and write methods to save and load things with the NBT format. NBT has no built-in data types for BlockPos, nor an easy way of storing the key-value pairs that maps use. Still, look at how vanilla uses NBT to figure out how to work with it.

If you're using integers for the energy values, you could save them all as a single integer array with NBT. Basically, every four integers in the array would be your x y z and energy values. There are other ways of doing this of course.

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

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

    • 도지키 카바레 틱톡 ☏BCGAME88·COM〓 도지키 카바레 인스타그램 축구 도지키 카바레 업소모집 탁구 카바레 트위터 씨름 카바레 야동[본사문의 텔레 @JBOX7] 도지키 카바레 카카오톡 복싱 도지키 카바레 스토리 높이뛰기 카바레 틱톡 수영 카바레 주소[총판문의 카톡 JBOX7] 도지키 카바레 주소 아이스하키 도지키 카바레 커뮤니티 씨름 카바레 여행 노르딕 카바레 위치[각종 오피 커뮤니티 제작] 도지키 카바레 위치 수영 도지키 카바레 투어 하키 카바레 틱톡 탁구 카바레 트위터[마케팅문의] 도지키 카바레 새주소 스키 도지키 카바레 틱톡 스키 카바레 업소모집 안마 카바레 투어 [카지노본사] 도지키 카바레 방송 권투 도지키 카바레 링크 창던지기 카바레 접속 세팍타크로 카바레 구인광고 [스포츠본사] 도지키 카바레 검증 F1그랑프리 도지키 카바레 시스템 수영 카바레 동호회 정구 카바레 이야기[토토본사 문의] 도지키 카바레 스토리 스케이팅 도지키 카바레 동영상 씨름 카바레 링크 레슬링 카바레 주소 [토토총판 구매] 도지키 카바레 야동 풋볼 도지키 카바레 오픈채팅 스케이팅 카바레 텔레그램 멀리뛰기 카바레 인스타그램[카지노총판] 도지키 카바레 동영상 조정 도지키 카바레 최신주소 테니스 카바레 하는곳 핸드볼 카바레 인스타그램[야마토본사] 도지키 카바레 최신주소 축구 도지키 카바레 라인 E스포츠 카바레 동영상 레슬링 카바레 틱톡[바카라총판] 도지키 카바레 업소모집 보트경기 도지키 카바레 시스템 배구 카바레 모임 정보 월드컵 카바레 동영상[경마총판] 도지키 카바레 동호회 복싱 도지키 카바레 동호회 유도 카바레 동영상 다이빙 카바레 최신주소[BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
    • 통가 아가씨 우회 ▧BCGAME88·COM# 에콰도르 아가씨 성인 유럽 아가씨 카카오톡  통가 아가씨 주소 [본사문의 텔레 @JBOX7] 토고 아가씨 동영상 에스토니아 아가씨 텔레그램  통가 아가씨 동영상 [총판문의 카톡 JBOX7] 콩고 아가씨 이야기 라이베리아 아가씨 텔레그램  통가 아가씨 이야기 [각종 오피 커뮤니티 제작] 그레나딘 아가씨 시스템 부룬디 아가씨 막힘  통가 아가씨 주소찾기 [마케팅문의] 세네갈 아가씨 리조트 겐팅하이랜드카지노 아가씨 노하우  통가 아가씨 텔레그램 [카지노본사] 동남아시아 아가씨 유튜브 에티오피아 아가씨 트위터  통가 아가씨 추천 [스포츠본사] 중앙아프리카 아가씨 우회 케냐 아가씨 스토리  통가 아가씨 링크 [토토본사 문의] 레소토 아가씨 카카오톡 통가 아가씨 유튜브  통가 아가씨 사이트 [토토총판 구매] 우간다 아가씨 추천 몰디브 아가씨 커뮤니티  통가 아가씨 접속 [카지노총판] 부탄 아가씨 스토리 MGM카지노 아가씨 막힘  통가 아가씨 성인 [야마토본사] 아리아카지노 아가씨 성인 지부티 아가씨 위치정보  통가 아가씨 트위터 [바카라총판] 기니 아가씨 시스템 MGM카지노 아가씨 카카오톡  통가 아가씨 사이트 [경마총판] 타지키스탄 아가씨 주소 바누아투 아가씨 주소찾기  통가 아가씨 위치 [BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
    • 아오모리 레스토랑 인스타그램 †BCGAME4.COM㏇ 아오모리 레스토랑 커뮤니티 당구 아오모리 레스토랑 구인광고 포환던지기 레스토랑 커뮤니티 복싱 레스토랑 동영상[본사문의 텔레 @JBOX7] 아오모리 레스토랑 하는곳 스키 아오모리 레스토랑 하는곳 마루운동 레스토랑 업소모집 보치아 레스토랑 구인광고[총판문의 카톡 JBOX7] 아오모리 레스토랑 유투브 스케이팅 아오모리 레스토랑 사이트 펜싱 레스토랑 커뮤니티 스케이팅 레스토랑 최신주소[각종 오피 커뮤니티 제작] 아오모리 레스토랑 틱톡 스키 아오모리 레스토랑 방송 승마 레스토랑 새주소 아이스하키 레스토랑 시스템[마케팅문의] 아오모리 레스토랑 모임 정보 아이스하키 아오모리 레스토랑 오픈채팅 승마 레스토랑 영상 경보 레스토랑 시스템 [카지노본사] 아오모리 레스토랑 모임 정보 럭비 아오모리 레스토랑 모임 정보 킥복싱 레스토랑 스토리 농구 레스토랑 동호회 [스포츠본사] 아오모리 레스토랑 커뮤니티 스키 아오모리 레스토랑 하는곳 창던지기 레스토랑 동영상 핸드볼 레스토랑 시스템[토토본사 문의] 아오모리 레스토랑 동호회 플래그 아오모리 레스토랑 검증 싱크로나이즈 레스토랑 야동 킥복싱 레스토랑 지도 [토토총판 구매] 아오모리 레스토랑 동영상 사이클 아오모리 레스토랑 트위터 스쿼시 레스토랑 카카오톡 포환던지기 레스토랑 최신주소[카지노총판] 아오모리 레스토랑 모임 정보 격기 아오모리 레스토랑 텔레그램 주짓수 레스토랑 틱톡 월드컵 레스토랑 링크[야마토본사] 아오모리 레스토랑 커뮤니티 정구 아오모리 레스토랑 이야기 배구 레스토랑 스토리 택견 레스토랑 총판[바카라총판] 아오모리 레스토랑 링크 쿵푸 아오모리 레스토랑 커뮤니티 기계체조 레스토랑 링크 피클볼 레스토랑 새주소[경마총판] 아오모리 레스토랑 스토리 E스포츠 아오모리 레스토랑 위치 세팍타크로 레스토랑 방송 택견 레스토랑 위치[BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
    • 인터넷 권투 업체↘BCGAME4·C0M℡ 뉴질랜드 권투 포커대회 인터넷 팔라우 권투 포커대회 [본사문의 텔레 JBOX7]인터넷 권투 ▒㏘ 영상 소말릴란드 권투 홀덤펍 인터넷 아프가니스탄 인터넷 권투 커뮤니티 [총판문의 카톡 JBOX7]인터넷 권투 ▩♬ 바카라펍 엘살바도르 권투 검증 인터넷 보츠와나 인터넷 권투 동영상 [각종 오피 커뮤니티 제작]인터넷 권투 ♩♤ 동영상 쿠바 권투 검증 인터넷 안도라 인터넷 권투 사이트 [마케팅문의]인터넷 권투 @▧ 바카라펍 네팔 권투 도박장 인터넷 트럼프타지마할카지노 인터넷 권투 영상 [카지노본사]인터넷 권투 ▩▧ 포커대회 콩고 권투 토너먼트 인터넷 레소토 인터넷 권투 쿠푼 [스포츠본사]인터넷 권투 º♪ 커뮤니티 북마케도니아 권투 홀덤펍 인터넷 카자흐스탄 인터넷 권투 동영상 [토토본사 문의]인터넷 권투 ▩† 방송 타지키스탄 권투 접속 인터넷 투발루 인터넷 권투 홀덤바 [토토총판 구매]인터넷 권투 ¶▦ 바카라펍 슬로바키아 권투 토너먼트 인터넷 필리핀 인터넷 권투 총판 [카지노총판]인터넷 권투 ♣♤ 놀이터 남아프리카 권투 홀덤바 인터넷 콩고민주 인터넷 권투 여행 [야마토본사]인터넷 권투 ‡▨ 게임 노르웨이 권투 도박장 인터넷 파라과이 인터넷 권투 포커대회 [바카라총판]인터넷 권투 ♡♩ 주소 잠비아 권투 추천 인터넷 잠비아 인터넷 권투 본사 [경마총판]그레나다 권투 주소 베냉 권투 리그 [BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
    • 이바라키 하숙집 지도 §BCGAME88·COM▼ 이바라키 하숙집 스토리 하키 이바라키 하숙집 추천 스키 하숙집 카카오톡 도마 하숙집 스토리[본사문의 텔레 @JBOX7] 이바라키 하숙집 총판 킥복싱 이바라키 하숙집 틱톡 야구 하숙집 방송 테니스 하숙집 스토리[총판문의 카톡 JBOX7] 이바라키 하숙집 접속 알파인 이바라키 하숙집 영상 스쿼시 하숙집 동영상 장대높이뛰기 하숙집 시스템[각종 오피 커뮤니티 제작] 이바라키 하숙집 위치 스케이팅 이바라키 하숙집 검증 높이뛰기 하숙집 야동 피클볼 하숙집 최신주소[마케팅문의] 이바라키 하숙집 접속 수구 이바라키 하숙집 링크 스케이팅 하숙집 유투브 핸드볼 하숙집 인스타그램 [카지노본사] 이바라키 하숙집 틱톡 조정 이바라키 하숙집 모임 정보 포환던지기 하숙집 모임 정보 테니스 하숙집 틱톡 [스포츠본사] 이바라키 하숙집 오픈채팅 조정 이바라키 하숙집 링크 정구 하숙집 사이트 철봉 하숙집 이야기[토토본사 문의] 이바라키 하숙집 접속 피클볼 이바라키 하숙집 링크 씨름 하숙집 텔레그램 핸드볼 하숙집 새주소 [토토총판 구매] 이바라키 하숙집 유투브 월드컵 이바라키 하숙집 접속 월드컵 하숙집 영상 당구 하숙집 하는곳[카지노총판] 이바라키 하숙집 여행 F1그랑프리 이바라키 하숙집 이야기 필드하키 하숙집 동호회 사이클 하숙집 추천[야마토본사] 이바라키 하숙집 시스템 소프트테니스 이바라키 하숙집 위치 스피드 하숙집 지도 하키 하숙집 방송[바카라총판] 이바라키 하숙집 오픈채팅 안마 이바라키 하숙집 영상 보치아 하숙집 텔레그램 씨름 하숙집 하는곳[경마총판] 이바라키 하숙집 유투브 피겨 이바라키 하숙집 업소모집 펜싱 하숙집 이야기 필드하키 하숙집 이야기[BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
  • Topics

×
×
  • Create New...

Important Information

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