Jump to content

[1.16] Converting a legacy block after update


A Soulspark

Recommended Posts

After accepting the way I was doing things in my mod wasn't quite ideal, I decided I have to upgrade a certain block when users update into the newest version of my mod.

This block currently has a Content blockstate (an enum with 3 values) and it should convert into a different block for each value. So,

  • tea_kettle:kettle[content=empty] -> tea_kettle:empty_kettle
  • tea_kettle:kettle[content=water] -> tea_kettle:water_kettle
  • tea_kettle:kettle[content=hot_water] -> tea_kettle:boiling_kettle

 

I just don't know how to do that! Maybe I'd need to keep the tea_kettle:kettle block and when it gets instantiated into the world, I immediately run the conversion. But

  1. How do I detect a block getting instantiated?
  2. Is there a better solution to this?
Link to comment
Share on other sites

Honestly this is a perfectly valid blockstate block. All three "versions" are a tea_kettle, but with some stateful information (full, empty, hot).

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

 

20 hours ago, Draco18s said:

Honestly this is a perfectly valid blockstate block. All three "versions" are a tea_kettle, but with some stateful information (full, empty, hot).

That's true, but an empty kettle doesn't need a tile entity, whereas the other two do, and they have other states that are only necessary in each case.

e.g. the boiling kettle has a fullness state, for how many uses it has left. this isn't necessary for empty or full kettles, as their "fullness" doesn't change: it's 0% or 100%.

 

Plus, each version also has a different item/name/texture, and it was really troublesome to manage all that in a single item and block.

If what I'm trying to do is extremely forbidden, then I could revert ofc. But this just sounds like it makes more sense :v

Link to comment
Share on other sites

14 minutes ago, A Soulspark said:

 

That's true, but an empty kettle doesn't need a tile entity, whereas the other two do, and they have other states that are only necessary in each case.

e.g. the boiling kettle has a fullness state, for how many uses it has left. this isn't necessary for empty or full kettles, as their "fullness" doesn't change: it's 0% or 100%.

the method hasTileEntity, and createTileEntity, take the current blockstate as a parameter, so you can decide wether or not your block has a tile entity based on the blockstate. that solves this problem

 

blockstates do seem like the easier way to do what you want...

Link to comment
Share on other sites

29 minutes ago, kiou.23 said:

the method hasTileEntity, and createTileEntity, take the current blockstate as a parameter, so you can decide wether or not your block has a tile entity based on the blockstate. that solves this problem

 

blockstates do seem like the easier way to do what you want...

ok, I'll try that. but is it possible to have multiple block items for the same block, just with different states? last time I tried this, the Creative inventory got messed up and it just added one of the items multiple times.

 

p.s.: I do need multiple items because there are recipes where only hot kettles can be used.

Link to comment
Share on other sites

Yes, but you need a custom BlockItem that knows what state needs to be set.

  • Thanks 1

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

12 minutes ago, A Soulspark said:

ok, I'll try that. but is it possible to have multiple block items for the same block, just with different states? last time I tried this, the Creative inventory got messed up and it just added one of the items multiple times.

what comes to mind is that you could extend BlockItem, to make a KettleBlockItem, which places a block with a given blockstate, which you can set when creating a new instance of it in registration... look like the more elegant way of doing it, but I'm really not sure (and after looking at the BlockItem class for a few seconds trying to see wht you could override, I imagine it'd give a headache)

and you could change what item the block drops based on blockstate as well

Edited by kiou.23
  • Thanks 1
Link to comment
Share on other sites

2 hours ago, Draco18s said:

Yes, but you need a custom BlockItem that knows what state needs to be set.

2 hours ago, kiou.23 said:

what comes to mind is that you could extend BlockItem, to make a KettleBlockItem, which places a block with a given blockstate, which you can set when creating a new instance of it in registration... look like the more elegant way of doing it, but I'm really not sure (and after looking at the BlockItem class for a few seconds trying to see wht you could override, I imagine it'd give a headache)

and you could change what item the block drops based on blockstate as well

alright, I think this turned out well. I had already done this "multiple items per block" thing before, but this time I managed to solve the duplicate items in Creative by adding a fillItemGroup() override to my items. I still had to split the blocks into Empty and Water Kettles because I'll later add Milk Kettles too.

Still, it indeed would've been a lot messier if I'd done it with 3 blocks and 2 tile entities lmao. thanks for the guidance!

Link to comment
Share on other sites

You can get an idea of how I handle it here:

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderores/HarderOres.java#L134

(I needed to support Silk Touch on a property that made no sense to be separate blocks)

Magic registry stuff (old event-style rather than new DeferredRegister style):

https://github.com/Draco18s/ReasonableRealism/blob/033da26f8ba4bcd25b0911aa9775764f12d7dbbe/src/main/java/com/draco18s/hardlib/EasyRegistry.java#L57

getPickBlock (reg names were dynamic, so this is a bit ugly):
https://github.com/Draco18s/ReasonableRealism/blob/033da26f8ba4bcd25b0911aa9775764f12d7dbbe/src/main/java/com/draco18s/harderores/block/ore/HardOreBlock.java#L80

getStateForPlacement:
https://github.com/Draco18s/ReasonableRealism/blob/033da26f8ba4bcd25b0911aa9775764f12d7dbbe/src/main/java/com/draco18s/harderores/block/ore/HardOreBlock.java#L90

 

I had to do some custom shenanigans for the loot table as well. But if your three items are sensibly named I don't think you need to do much that vanilla doesn't already support. It was just easier for me to write a loot condition that got the blockstate's numerical value and did a lookup on the item than it was to specify a 1:1 relationship in the loot table.

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

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☜ 일원여관바리 서귀포여관바리 마천여관바리 충정로여관바리 nkf94 봉익여관바리 평택여관바리 효자여관바리 오장여관바리 vqm93 연남여관바리 오류여관바리 고양여관바리 광양여관바리 yed44 무안여관바리 와룡여관바리 공주여관바리 안성여관바리 nrs95 상수여관바리 당진여관바리 광명여관바리 필동여관바리 ktk75 이천여관바리 의주여관바리 삼척여관바리 의왕여관바리 smy75 옥천여관바리 이화여관바리 광명여관바리 다동여관바리 bqt53 풍납여관바리 합동여관바리 누상여관바리 문정여관바리 cvt74 사근여관바리 광명여관바리 제천여관바리 자곡여관바리 mys96 봉익여관바리 강동여관바리 김제여관바리 김포여관바리 cnc91 다동여관바리 삼성여관바리 부암여관바리 오곡여관바리 cpf85 중림여관바리 익선여관바리 관철여관바리 홍은여관바리 ylt53 여주여관바리 하월곡여관바리 부천여관바리 구산여관바리 lxw06 마포여관바리 안산여관바리 하남여관바리 창녕여관바리 nxk55 성북여관바리 강일여관바리 중계여관바리 사간여관바리 mlk39 성수여관바리 신내여관바리 신림여관바리 진관여관바리 fmx04 태평여관바리 천연여관바리 누하여관바리 삼성여관바리 vxn36 세종여관바리 광주여관바리 신촌여관바리 반포여관바리 gqk54 연지여관바리 인천여관바리 강북여관바리 신수여관바리 uca61 당진여관바리 상암여관바리 삼선여관바리 안양여관바리 vyv45 일원여관바리 필동여관바리 구리여관바리 남대문여관바리 agu71 성구여관바리 의왕여관바리 화동여관바리 석촌여관바리 lds22 불광여관바리 구산여관바리 창천여관바리 한강여관바리 vot55
    • 도곡주점 ■BCGAME88·COM@ 마장주점 광양주점 의왕주점 송월주점 eck28 금천주점 강서주점 문경주점 무안주점 vay56 용인주점 청량리주점 공항주점 시흥주점 osb73 무악주점 고양주점 광진주점 속초주점 snq45 묵정주점 남산주점 주교주점 개포주점 lga73 신설주점 구로주점 자곡주점 신림주점 nsv47 의정부주점 청운주점 구리주점 관악주점 aqk26 삼척주점 필동주점 김제주점 강남주점 jls25 입정주점 공주주점 관철주점 아산주점 rwh86 공평주점 고양주점 남산주점 도림주점 rel03 오장주점 이방주점 동선주점 응암주점 yad05 양재주점 상왕십리주점 원지주점 도곡주점 rmx61 홍익주점 태평로주점 봉천주점 통영주점 yel58 도림주점 성남주점 성남주점 광장주점 vhs06 중구주점 학방주점 인사주점 중림주점 ksb38 군포주점 인현주점 관수주점 신정주점 xjs99 석촌주점 문배주점 당주주점 공릉주점 ypu89 동대문주점 홍제주점 수유주점 역삼주점 isf25 견지주점 동교주점 개포주점 관악주점 koy35 무악주점 논현주점 구기주점 관철주점 cwq12 우이주점 문배주점 양재주점 계동주점 ysf40 논산주점 낙원주점 용두주점 하중주점 lkp08 창신주점 속초주점 내수주점 김해주점 qgh70
    • 모리오카 찜질방 동호회 ↔BCGAME4.COM@ 모리오카 찜질방 인스타그램 배구 모리오카 찜질방 이야기 포환던지기 찜질방 추천 링 찜질방 이야기[본사문의 텔레 @JBOX7] 모리오카 찜질방 업소모집 경보 모리오카 찜질방 검증 쇼트트랙 찜질방 모임 정보 스쿼시 찜질방 주소[총판문의 카톡 JBOX7] 모리오카 찜질방 커뮤니티 수상스포츠 모리오카 찜질방 오픈채팅 소프트테니스 찜질방 유투브 정구 찜질방 사이트[각종 오피 커뮤니티 제작] 모리오카 찜질방 사이트 수상스포츠 모리오카 찜질방 유투브 월드컵 찜질방 링크 테니스 찜질방 총판[마케팅문의] 모리오카 찜질방 업소모집 경보 모리오카 찜질방 트위터 유도 찜질방 야동 수구 찜질방 업소모집 [카지노본사] 모리오카 찜질방 새주소 복싱 모리오카 찜질방 인스타그램 농구 찜질방 유투브 보트경기 찜질방 주소 [스포츠본사] 모리오카 찜질방 검증 핸드볼 모리오카 찜질방 시스템 철봉 찜질방 오픈채팅 레슬링 찜질방 새주소[토토본사 문의] 모리오카 찜질방 사이트 배구 모리오카 찜질방 사이트 필드하키 찜질방 스토리 다이빙 찜질방 카카오톡 [토토총판 구매] 모리오카 찜질방 동영상 스피드 모리오카 찜질방 접속 럭비 찜질방 사이트 테니스 찜질방 인스타그램[카지노총판] 모리오카 찜질방 업소모집 평균대 모리오카 찜질방 인스타그램 수영 찜질방 검증 유도 찜질방 이야기[야마토본사] 모리오카 찜질방 최신주소 필드하키 모리오카 찜질방 유투브 격기 찜질방 하는곳 세팍타크로 찜질방 추천[바카라총판] 모리오카 찜질방 여행 멀리뛰기 모리오카 찜질방 위치 노르딕 찜질방 접속 씨름 찜질방 링크[경마총판] 모리오카 찜질방 동영상 스쿼시 모리오카 찜질방 총판 필드하키 찜질방 최신주소 테니스 찜질방 시스템[BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
    • 광주호텔 ☆BCGAME88·COM㉿ 온수호텔 영주호텔 개포호텔 송월호텔 dli03 화곡호텔 군포호텔 동두천호텔 사천호텔 mbt02 관악호텔 인의호텔 장교호텔 가락호텔 qrq83 오산호텔 이천호텔 완주호텔 예지호텔 vxv66 신교호텔 하월곡호텔 녹번호텔 남창호텔 crt34 신원호텔 구수호텔 남대문호텔 중구호텔 qxk48 청암호텔 동두천호텔 광명호텔 평창호텔 faf67 노원호텔 신길호텔 성북호텔 흑석호텔 wrb13 행촌호텔 효자호텔 장교호텔 토정호텔 tux58 세곡호텔 신문호텔 광주호텔 북가좌호텔 tqg27 봉래호텔 성남호텔 개봉호텔 구수호텔 gnn16 체부호텔 양평호텔 보광호텔 하중호텔 ntf27 광희호텔 염창호텔 압구정호텔 강릉호텔 wrd63 상왕십리호텔 강일호텔 외발산호텔 압구정호텔 ppg58 인천호텔 효제호텔 영등포호텔 용답호텔 eqe04 우면호텔 명륜호텔 김포호텔 금천호텔 mkh21 인의호텔 대흥호텔 중구호텔 평창호텔 tvd41 충주호텔 마장호텔 정릉호텔 파주호텔 aii94 시흥호텔 만리호텔 역촌호텔 노고산호텔 hcv22 흥인호텔 오장호텔 인천호텔 상왕십리호텔 mcj15 신영호텔 수송호텔 회현호텔 훈정호텔 bgp24 도봉호텔 망우호텔 충신호텔 구수호텔 lta49 남산호텔 수서호텔 원서호텔 세종호텔 ukx18
    • 아오모리 음식점 오픈채팅 ㏇BCGAME4.COM& 아오모리 음식점 추천 쿵푸 아오모리 음식점 야동 배드민턴 음식점 스토리 다이빙 음식점 텔레그램[본사문의 텔레 @JBOX7] 아오모리 음식점 커뮤니티 권투 아오모리 음식점 여행 장대높이뛰기 음식점 이야기 태권도 음식점 동호회[총판문의 카톡 JBOX7] 아오모리 음식점 텔레그램 철봉 아오모리 음식점 총판 핸드볼 음식점 시스템 권투 음식점 시스템[각종 오피 커뮤니티 제작] 아오모리 음식점 동호회 수영 아오모리 음식점 위치 농구 음식점 구인광고 당구 음식점 검증[마케팅문의] 아오모리 음식점 사이트 평균대 아오모리 음식점 최신주소 골프 음식점 트위터 수영 음식점 지도 [카지노본사] 아오모리 음식점 여행 정구 아오모리 음식점 추천 스키 음식점 동호회 다이빙 음식점 틱톡 [스포츠본사] 아오모리 음식점 틱톡 격기 아오모리 음식점 여행 필드하키 음식점 트위터 안마 음식점 시스템[토토본사 문의] 아오모리 음식점 이야기 라켓볼 아오모리 음식점 주소 피겨 음식점 이야기 다이빙 음식점 스토리 [토토총판 구매] 아오모리 음식점 투어 승마 아오모리 음식점 모임 정보 스케이팅 음식점 유투브 배드민턴 음식점 야동[카지노총판] 아오모리 음식점 라인 펜싱 아오모리 음식점 라인 족구 음식점 검증 핸드볼 음식점 모임 정보[야마토본사] 아오모리 음식점 스토리 테니스 아오모리 음식점 투어 싱크로나이즈 음식점 커뮤니티 배구 음식점 총판[바카라총판] 아오모리 음식점 영상 스키 아오모리 음식점 업소모집 수영 음식점 지도 풋볼 음식점 링크[경마총판] 아오모리 음식점 접속 씨름 아오모리 음식점 라인 노르딕 음식점 트위터 알파인 음식점 주소[BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
  • Topics

×
×
  • Create New...

Important Information

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