Jump to content

[1.14.4] ContainerGUI not syncing with Server


Tessa

Recommended Posts

I've been trying to build a custom container block with a GUI that has an input slot that can consume items.
So far i can open the GUI, see and use my own inventory, put items into the input slot of my GUI and by pressing a button in the GUI, the stack in the input slot is "consumed" one item at a time.
However, when i click the input slot, I get all of the items I put in back, even if the slot appears to be completely empty.
I'm assuming there is something going wrong communicating the changes in stack size to the server and when I click the slot, the game assumes nothing has changed.
Does anyone have any idea of what I could've missed?

Edited by Tessa
follow common formatting
Link to comment
Share on other sites

Hard to know for sure without seeing your code, but I'm guessing you're doing the "consume" operation client-side, and that's not to going to work.

 

When the button is clicked, the server needs to know; in other words, send a custom "this button was clicked" packet to the server, and do the inventory change there.  Changes don't get magically sent to the server if you modify a slot client-side; if you look at vanilla code, you'll see packets are used to handle this (take a look at PlayerController#windowClick() for example - modifying the container slot and sending a packet to the server are done separately).

Link to comment
Share on other sites

37 minutes ago, Tessa said:

I was assuming the item/slot manipulation functions in the base container class would take care of it manually, but then i'll take a look at the vanilla click code.
Thanks a lot!

GUI-Slots are, yes. But your button doesn't hook into those mechanisms. You must send a packet.

See this (old, 1.12) code:

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/ores/client/gui/GuiContainerOreCart.java#L77

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

Okay, so making and sending custom packets appears to be pretty challenging and I doubt that I have the knowledge to take that beast on. In some tutorials I see people using the ItemStackHandler Capability, in which case they often have inventories in an entity instead of a container. Would that be an alternative or do you guys know a different workaround for me?

Link to comment
Share on other sites

24 minutes ago, Tessa said:

Okay, so making and sending custom packets appears to be pretty challenging and I doubt that I have the knowledge to take that beast on. In some tutorials I see people using the ItemStackHandler Capability, in which case they often have inventories in an entity instead of a container. Would that be an alternative or do you guys know a different workaround for me?

capabilities have to be synced too so no you must use packets and its not that difficult to be honest. 

https://mcforge.readthedocs.io/en/latest/networking/simpleimpl/

 

Link to comment
Share on other sites

  • 1 month later...

Just wanted to "close" this topic by saying I managed to get the packets working. Indeed, it wasn't too difficult. I didn't feel like the Forge documentation got me all the way there, but with the help of a few tutorials and other forum posts I got it together. When clicking the GUI button a packet gets sent to the server telling it to reduce the stack size of my input slot.

Link to comment
Share on other sites

1 hour ago, Tessa said:

Just wanted to "close" this topic by saying I managed to get the packets working. Indeed, it wasn't too difficult. I didn't feel like the Forge documentation got me all the way there, but with the help of a few tutorials and other forum posts I got it together. When clicking the GUI button a packet gets sent to the server telling it to reduce the stack size of my input slot.

The server should also check if the operation is successful (if you haven't added that already). Clients could just send fake information to the server, which would carry them out if no check is in place.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

After handling the packet I did the "setPacketHandled" thing, and the packet itself is registered through forge's SimpleChannel

	public static void handle(Packet_HandInQuest msg, Supplier<NetworkEvent.Context> ctx) {
		DangerSignTile te = (DangerSignTile)ctx.get().getSender().getServerWorld().getTileEntity(msg.pos);
		te.container.takeQuestItems(msg.questInt);
		te.container.takeKillCount(msg.questInt);
		te.container.giveRewards(msg.questInt);
		te.setQuestCompleted(msg.questInt);
		ctx.get().setPacketHandled(true);
	}
Link to comment
Share on other sites

What happens if a client sends a packet with forged (fake) information in it?

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

If I am a malicious player playing on a server, I can modify my clients to send fake quest complete packets.

Your current packet handling code will allow me to obtain quest rewards over and over, since it does not check for 1) if the quest is already completed 2) if the player has the quest items in his inventory.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

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

    • 광주대딸방 ↙BCGAME4·COM▥ 강일대딸방 성남대딸방 돈의대딸방 개포대딸방 ppv24 거여대딸방 예산대딸방 동두천대딸방 부천대딸방 pbq07 입정대딸방 구미대딸방 북창대딸방 상일대딸방 uea11 황학대딸방 관철대딸방 고양대딸방 권농대딸방 wsr21 고흥대딸방 안산대딸방 안성대딸방 제기대딸방 tij52 통영대딸방 공릉대딸방 구의대딸방 원지대딸방 swq56 냉천대딸방 상일대딸방 영등포대딸방 상계대딸방 ern28 체부대딸방 적선대딸방 선릉대딸방 관철대딸방 bct02 공릉대딸방 수원대딸방 공평대딸방 서계대딸방 lvs44 상월곡대딸방 봉래대딸방 내발산대딸방 남학대딸방 mxo24 서린대딸방 쌍문대딸방 와룡대딸방 용강대딸방 vye81 길동대딸방 구기대딸방 삼청대딸방 서계대딸방 elt92 장충대딸방 삼선대딸방 장위대딸방 태평대딸방 ive92 안국대딸방 제기대딸방 봉원대딸방 궁정대딸방 ldm27 누하대딸방 이태원대딸방 양천대딸방 상왕십리대딸방 gck30 봉래대딸방 금호대딸방 안양대딸방 미아대딸방 mxa45 포천대딸방 노량진대딸방 한강대딸방 신공덕대딸방 sbx37 낙원대딸방 이촌대딸방 오금대딸방 본동대딸방 tpe46 평동대딸방 등촌대딸방 상왕십리대딸방 종암대딸방 hdu99 창전대딸방 주자대딸방 포천대딸방 북가좌대딸방 bpu12 군산대딸방 옥천대딸방 금산대딸방 인천대딸방 iwh79 옥인대딸방 정릉대딸방 정릉대딸방 구리대딸방 sit63 신내대딸방 수서대딸방 봉익대딸방 도원대딸방 uix24
    • 남양주나이트 ▥BCGAME4·COMª 창신나이트 서초나이트 회현나이트 망우나이트 apm15 남현나이트 대현나이트 인의나이트 아현나이트 jkm18 토정나이트 봉래나이트 필동나이트 미아나이트 vny57 통영나이트 연희나이트 구산나이트 무학나이트 chb00 대흥나이트 용인나이트 증산나이트 계동나이트 tkb71 신길나이트 장지나이트 훈정나이트 청담나이트 dpm44 창원나이트 서산나이트 하계나이트 창동나이트 jha68 서초나이트 종암나이트 과천나이트 월계나이트 ctp87 의정부나이트 예지나이트 북아현나이트 망원나이트 iho34 경주나이트 상봉나이트 구리나이트 주성나이트 efe11 압구정나이트 한강나이트 구리나이트 능동나이트 ayb86 염리나이트 강일나이트 중화나이트 송파나이트 qbu44 정동나이트 궁동나이트 개포나이트 중구나이트 tej17 논현나이트 평창나이트 안성나이트 광희나이트 uim96 도봉나이트 전주나이트 오산나이트 개포나이트 sfc86 이천나이트 성수나이트 영등포나이트 가평나이트 dur90 광진나이트 구의나이트 서린나이트 장위나이트 gdr63 신림나이트 남양주나이트 중랑나이트 암사나이트 vge22 한강나이트 서빙고나이트 을지나이트 주교나이트 vlp03 천연나이트 양평나이트 천안나이트 교남나이트 woe74 완주나이트 평택나이트 소격나이트 화양나이트 nrs82 남원나이트 파주나이트 명일나이트 세종나이트 nka13 상주나이트 전주나이트 다동나이트 오산나이트 mtd02
    • 아프가니스탄 동호회 위치 ㉿BCGAME88·COM♥ 키프로스 동호회 투어 호주 동호회 오픈채팅  아프가니스탄 동호회 라인 [본사문의 텔레 @JBOX7] 팔라우 동호회 주소찾기 몰도바 동호회 우회  아프가니스탄 동호회 동영상 [총판문의 카톡 JBOX7] 에콰도르 동호회 투어 세인트빈센트 동호회 막힘  아프가니스탄 동호회 시스템 [각종 오피 커뮤니티 제작] 서아시아 동호회 시스템 선시티 동호회 하는곳  아프가니스탄 동호회 위치정보 [마케팅문의] 벨기에 동호회 추천 싱가포르 동호회 성인  아프가니스탄 동호회 유투브 [카지노본사] 사하라 동호회 주소 짐바브웨 동호회 검증  아프가니스탄 동호회 투어 [스포츠본사] 터키 동호회 카카오톡 사모아 동호회 지도  아프가니스탄 동호회 막힘 [토토본사 문의] 멕시코 동호회 카카오톡 솔로몬제도 동호회 트위터  아프가니스탄 동호회 추천 [토토총판 구매] 사우디아라비아 동호회 커뮤니티 부탄 동호회 최신주소  아프가니스탄 동호회 사이트 [카지노총판] 잠비아 동호회 텔레그램 바베이도스 동호회 이야기  아프가니스탄 동호회 막힘 [야마토본사] 중앙아프리카 동호회 새주소 덴마크 동호회 스토리  아프가니스탄 동호회 위치정보 [바카라총판] 크라운카지노 동호회 접속 짐바브웨 동호회 추천  아프가니스탄 동호회 유투브 [경마총판] 북키프로스 동호회 트위터 부탄 동호회 사이트  아프가니스탄 동호회 리조트 [BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
    • 오오츠 옷가게 업소모집 ▣BCGAME88·COM▶ 오오츠 옷가게 위치 세팍타크로 오오츠 옷가게 주소 크리켓 옷가게 모임 정보 스피드 옷가게 최신주소[본사문의 텔레 @JBOX7] 오오츠 옷가게 투어 미식축구 오오츠 옷가게 업소모집 핸드볼 옷가게 인스타그램 F1그랑프리 옷가게 여행[총판문의 카톡 JBOX7] 오오츠 옷가게 텔레그램 유도 오오츠 옷가게 투어 링 옷가게 주소 씨름 옷가게 추천[각종 오피 커뮤니티 제작] 오오츠 옷가게 유투브 탁구 오오츠 옷가게 커뮤니티 스키 옷가게 틱톡 스키 옷가게 시스템[마케팅문의] 오오츠 옷가게 야동 철봉 오오츠 옷가게 접속 조정 옷가게 틱톡 팔씨름 옷가게 텔레그램 [카지노본사] 오오츠 옷가게 접속 라켓볼 오오츠 옷가게 추천 기계체조 옷가게 라인 정구 옷가게 방송 [스포츠본사] 오오츠 옷가게 리조트 포환던지기 오오츠 옷가게 위치 풋볼 옷가게 모임 정보 경보 옷가게 접속[토토본사 문의] 오오츠 옷가게 인스타그램 소프트테니스 오오츠 옷가게 주소 킥복싱 옷가게 스토리 권투 옷가게 모임 정보 [토토총판 구매] 오오츠 옷가게 인스타그램 다이빙 오오츠 옷가게 링크 레슬링 옷가게 최신주소 장대높이뛰기 옷가게 리조트[카지노총판] 오오츠 옷가게 라인 테니스 오오츠 옷가게 오픈채팅 스키 옷가게 지도 프리스타일 옷가게 구인광고[야마토본사] 오오츠 옷가게 시스템 포환던지기 오오츠 옷가게 방송 탁구 옷가게 카카오톡 철봉 옷가게 스토리[바카라총판] 오오츠 옷가게 인스타그램 하키 오오츠 옷가게 방송 수구 옷가게 야동 탁구 옷가게 트위터[경마총판] 오오츠 옷가게 이야기 철봉 오오츠 옷가게 스토리 스키 옷가게 트위터 주짓수 옷가게 방송[BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
    • 2023(2024 Remidial Admission Form for Anchor University Ayobo Lagos State Pre degree/Direct-Entry form ☎️08039816237 OR {2348039816237} JUPEB Form, Postgraduate Form,Pre-Degree Form (08039816237, Jupeb form IJMB Form, masters form,Ph.D Form,Sandwich Form,Diploma Form,Change of institution form,Part-Time call (08039816237 OR {08039816237} Change of course Form,POST UTME Form.
  • Topics

×
×
  • Create New...

Important Information

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