Jump to content

onItemRightClick return an item [1.15.1]


Dr.Nickenstein

Recommended Posts

46 minutes ago, Dr.Nickenstein said:

So I want this item to check the block that it hits on right click, and if it is a certain block, it returns a certain item

 

Don't do it on the item, do it on the block. If it is your block override onBlockActivated and check if the player is holding your item. If it is a vanilla block use events to achieve the same thing.

Link to comment
Share on other sites

55 minutes ago, Dr.Nickenstein said:

Yes, it is. It's called "RubberStreamingRubberWoodLog", that's the class that I created.

 

Then go to your block class, override onBlockActivated and check there if the player is holding your item. If it is, do stuff. onBlockActivated provides you with the player that right clicked the block and the hand he used, so you have pretty much all you need.

 

Alternatively, you can subscribe to PlayerInteractEvent.RightClickBlock and check there if the player is holding your item.

Edited by Cerandior
Link to comment
Share on other sites

3 minutes ago, Cerandior said:

Then go to your block class, override onBlockActivated and check there if the player is holding your item. If it is, do stuff. onBlockActivated provides you with the player that right clicked the block and the hand he used, so you have pretty much all you need.

 

Alternatively, you can subscribe to PlayerInteractEvent.RightClickBlock and check there if the player is holding your item.

so this? player.getHeldItem(handIn); and then how do i check which item it is?

Edited by Dr.Nickenstein
Link to comment
Share on other sites

Just now, Dr.Nickenstein said:

so this? player.getHeldItem(handIn); and then how do i check which item it is?

That will return an itemstack I believe. 
itemstack.getItem() will give you the item and then you use instanceof to check whether that item is the same with what you want or not.

Link to comment
Share on other sites

Just now, Cerandior said:

That will return an itemstack I believe. 
itemstack.getItem() will give you the item and then you use instanceof to check whether that item is the same with what you want or not.

Yeah i want this block to drop a certain item when it is right clicked (activated) with another item.

Link to comment
Share on other sites

10 minutes ago, Cerandior said:

That will return an itemstack I believe. 
itemstack.getItem() will give you the item and then you use instanceof to check whether that item is the same with what you want or not.

@Override
    public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player,
            Hand handIn, BlockRayTraceResult hit)
    {    
        ItemStack itemstack = player.getHeldItem(handIn);
        itemstack.getItem();
        if
        {
            itemstack = ItemInit.RUBBER_EXTRACTOR.get();
        }
        
    }
   

I've done this, but on itemstack = ItemInit.RUBBER_EXTRACTOR.get(); it gives me an error it says it can't convert from ItemStack to Item. How do I fix it?

The problem is item and itemstack are different things apparently, and the methods work with itemstack. Help

Edited by Dr.Nickenstein
Link to comment
Share on other sites

4 minutes ago, Dr.Nickenstein said:

@Override
    public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player,
            Hand handIn, BlockRayTraceResult hit)
    {    
        ItemStack itemstack = player.getHeldItem(handIn);
        itemstack.getItem();
        if
        {
            itemstack = ItemInit.RUBBER_EXTRACTOR.get();
        }
        
    }
   

I've done this, but on itemstack = ItemInit.RUBBER_EXTRACTOR.get(); it gives me an error it says it can't convert from ItemStack to Item. How do I fix it?

The problem is item and itemstack are different things apparently, and the methods work with itemstack. Help

 

I have no clue what the hell are you doing there. Don't mean to insult you, but based on that I am assuming you don't have much experience with programming in general.

I'll help you this time and write it for you, but you will not get far if you don't know much programming.
 

Item item = player.getHeldItem(handIn).getItem();

if(item instanceof ItemInit.RUBBER_EXTRACTOR){
	//Do stuff
}

 

What you did wrong before:
1) itemstack.getItem() returns an item and does nothing else. Simply calling it and not assigning the returned value anywhere means that line of code is pretty much useless.

2) That is not how you use if statements. The syntax is:

if(condition){
statement
}

 

Link to comment
Share on other sites

12 minutes ago, Cerandior said:

 

I have no clue what the hell are you doing there. Don't mean to insult you, but based on that I am assuming you don't have much experience with programming in general.

I'll help you this time and write it for you, but you will not get far if you don't know much programming.
 


Item item = player.getHeldItem(handIn).getItem();

if(item instanceof ItemInit.RUBBER_EXTRACTOR){
	//Do stuff
}

 

What you did wrong before:
1) itemstack.getItem() returns an item and does nothing else. Simply calling it and not assigning the returned value anywhere means that line of code is pretty much useless.

2) That is not how you use if statements. The syntax is:


if(condition){
statement
}

 

For the second error, i corrected it later but didn't correct the post with it, for the first one thanks. BTW wehn you do (item instanceof ItemInit.RUBBER_EXTRACTOR)

{

stuff

}

it says rubber extractor isn't a type, and I can't reference any kind of other items

Edited by Dr.Nickenstein
Link to comment
Share on other sites

3 hours ago, Dr.Nickenstein said:

item instanceof ItemInit.RUBBER_EXTRACTOR

Sigh.

Let me break this down.

X instanceof Y requires X to be an object and Y to be a Class.

X == Y requires X to be an object (or primative) and Y to be an object (or primative).

Your code, item instanceof ItemInit.RUBBER_EXTRACTOR, has X is an object, Y is an object.

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

    • 니이가타 아가씨 야동 ↗BCGAME4·COM# 니이가타 아가씨 방송 알파인 니이가타 아가씨 라인 티볼 아가씨 사이트 주짓수 아가씨 영상[본사문의 텔레 @JBOX7] 니이가타 아가씨 카카오톡 싱크로나이즈 니이가타 아가씨 새주소 권투 아가씨 동호회 리얼 아가씨 유투브[총판문의 카톡 JBOX7] 니이가타 아가씨 인스타그램 복싱 니이가타 아가씨 카카오톡 보트경기 아가씨 텔레그램 미식축구 아가씨 이야기[각종 오피 커뮤니티 제작] 니이가타 아가씨 시스템 아이스하키 니이가타 아가씨 링크 철봉 아가씨 주소 올림픽 아가씨 접속[마케팅문의] 니이가타 아가씨 총판 안마 니이가타 아가씨 최신주소 정구 아가씨 여행 멀리뛰기 아가씨 유투브 [카지노본사] 니이가타 아가씨 트위터 복싱 니이가타 아가씨 리조트 야구 아가씨 유투브 하키 아가씨 위치 [스포츠본사] 니이가타 아가씨 카카오톡 포환던지기 니이가타 아가씨 하는곳 소프트테니스 아가씨 여행 하키 아가씨 영상[토토본사 문의] 니이가타 아가씨 방송 조정 니이가타 아가씨 유투브 보트경기 아가씨 모임 정보 스키 아가씨 동호회 [토토총판 구매] 니이가타 아가씨 동호회 스케이팅 니이가타 아가씨 라인 배구 아가씨 총판 창던지기 아가씨 동영상[카지노총판] 니이가타 아가씨 검증 온라인게임 니이가타 아가씨 총판 격기 아가씨 새주소 E스포츠 아가씨 라인[야마토본사] 니이가타 아가씨 카카오톡 소프트테니스 니이가타 아가씨 영상 조정 아가씨 하는곳 배구 아가씨 추천[바카라총판] 니이가타 아가씨 하는곳 권투 니이가타 아가씨 이야기 스키 아가씨 트위터 도마 아가씨 지도[경마총판] 니이가타 아가씨 트위터 정구 니이가타 아가씨 주소 보치아 아가씨 추천 링 아가씨 동호회[BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
    • 대치텐프로 ▒BCGAME4·COM♥ 중림텐프로 거여텐프로 이촌텐프로 갈월텐프로 dgq43 청담텐프로 망원텐프로 원남텐프로 송현텐프로 xcj86 의정부텐프로 마장텐프로 여수텐프로 강북텐프로 khp75 서빙고텐프로 대치텐프로 사간텐프로 견지텐프로 pvb76 대현텐프로 의정부텐프로 쌍문텐프로 가평텐프로 hex91 경주텐프로 의정부텐프로 능동텐프로 마장텐프로 apa44 신사텐프로 동자텐프로 독산텐프로 개포텐프로 pbr38 남현텐프로 오금텐프로 문경텐프로 삼척텐프로 ssc24 신수텐프로 연건텐프로 장충텐프로 도봉텐프로 mdt55 흑석텐프로 순화텐프로 안양텐프로 면목텐프로 kfj81 상암텐프로 안성텐프로 동교텐프로 김포텐프로 liu34 상암텐프로 마천텐프로 도림텐프로 효창텐프로 efn64 낙원텐프로 홍익텐프로 충신텐프로 천연텐프로 elx92 안양텐프로 상도텐프로 개봉텐프로 대구텐프로 fti96 문정텐프로 당진텐프로 행촌텐프로 옥천텐프로 cyx31 상도텐프로 구기텐프로 갈월텐프로 신사텐프로 syr10 산림텐프로 사근텐프로 동두천텐프로 묘동텐프로 nfe73 세곡텐프로 창성텐프로 의왕텐프로 정릉텐프로 lxu38 수원텐프로 청진텐프로 시흥텐프로 울산텐프로 hbh59 교북텐프로 도원텐프로 고양텐프로 오쇠텐프로 qou98 남양주텐프로 거창텐프로 청담텐프로 갈현텐프로 ael48 상월곡텐프로 신원텐프로 정동텐프로 구수텐프로 cvc68 남영텐프로 개봉텐프로 신수텐프로 가평텐프로 ctk96
    • 석촌스텐드바 №BCGAME4·COM▣ 동두천스텐드바 녹번스텐드바 포항스텐드바 자곡스텐드바 wdh43 구로스텐드바 교남스텐드바 군포스텐드바 동소문스텐드바 gis57 관악스텐드바 홍제스텐드바 옥수스텐드바 창성스텐드바 euy67 하남스텐드바 한강스텐드바 통인스텐드바 안암스텐드바 bbn39 세종로스텐드바 망원스텐드바 평동스텐드바 안양스텐드바 dkg52 일원스텐드바 청주스텐드바 산천스텐드바 중구스텐드바 mdq73 가리봉스텐드바 송현스텐드바 효제스텐드바 포항스텐드바 sue28 하중스텐드바 대치스텐드바 개포스텐드바 수표스텐드바 mxy61 종암스텐드바 송정스텐드바 연희스텐드바 대림스텐드바 qfc21 대방스텐드바 동교스텐드바 고창스텐드바 양산스텐드바 rcg96 파주스텐드바 고척스텐드바 관수스텐드바 산천스텐드바 bet79 사근스텐드바 제기스텐드바 제천스텐드바 주성스텐드바 bnb99 대현스텐드바 상암스텐드바 재동스텐드바 장사스텐드바 rci71 관철스텐드바 신원스텐드바 회기스텐드바 관악스텐드바 npx43 신촌스텐드바 순천스텐드바 화방스텐드바 구리스텐드바 wlx67 천호스텐드바 본동스텐드바 필동스텐드바 안성스텐드바 bqy30 거창스텐드바 다동스텐드바 수원스텐드바 상주스텐드바 lqt32 인현스텐드바 청진스텐드바 명륜스텐드바 서귀포스텐드바 ldq68 강남스텐드바 수표스텐드바 홍제스텐드바 김포스텐드바 faq27 아산스텐드바 강일스텐드바 혜화스텐드바 삼선스텐드바 iyq51 길음스텐드바 중랑스텐드바 효제스텐드바 광주스텐드바 pxg26 역삼스텐드바 남양주스텐드바 능동스텐드바 인천스텐드바 iba70 영주스텐드바 청주스텐드바 명동스텐드바 서계스텐드바 glt26
    • 메이져 농구 도박장⊙BCGAME4·C0M◈ 동아프리카 농구 모집 메이져 세르비아 농구 방법 [본사문의 텔레 JBOX7]메이져 농구 @○ 접속 벨기에 농구 추천 메이져 니카라과 메이져 농구 쿠푼 [총판문의 카톡 JBOX7]메이져 농구 ◑♠ 검증 모리셔스 농구 방법 메이져 베네시안카지노 메이져 농구 커뮤니티 [각종 오피 커뮤니티 제작]메이져 농구 ↖* 커뮤니티 코트디부아르 농구 전략 메이져 레바논 메이져 농구 전략 [마케팅문의]메이져 농구 ▥♬ 단톡방 미얀마 농구 홀덤펍 메이져 차드 메이져 농구 리그 [카지노본사]메이져 농구 №# 모집 동유럽 농구 도박장 메이져 이란 메이져 농구 중계 [스포츠본사]메이져 농구 ▷▣ 홀덤펍 마리나베이 농구 검증 메이져 오세아니아 메이져 농구 영상 [토토본사 문의]메이져 농구 ㉿◈ 캐쉬게임 나미비아 농구 주소 메이져 리투아니아 메이져 농구 동영상 [토토총판 구매]메이져 농구 ↖◐ 게임장 시리아 농구 검증 메이져 폭스우드카지노 메이져 농구 업체 [카지노총판]메이져 농구 ♨▣ 방송 쿠바 농구 중계 메이져 아리아카지노 메이져 농구 전략 [야마토본사]메이져 농구 ㏇▧ 싸이트 스웨덴 농구 투어 메이져 헝가리 메이져 농구 커뮤니티 [바카라총판]메이져 농구 ‡◐ 사이트 말라위 농구 방송 메이져 소말릴란드 메이져 농구 추천 [경마총판]아일랜드 농구 게임 벨리즈 농구 게임장 [BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
    • 아시아 KSOP 카지노펍↓BCGAME88·COM§ 바덴바덴 KSOP 주소 아시아 오스트레일리아 KSOP 중계 [본사문의 텔레 JBOX7]아시아 KSOP ☎㉿ 도박장 포르투갈 KSOP 총판 아시아 알바니아 아시아 KSOP 전략 [총판문의 카톡 JBOX7]아시아 KSOP ♬& 쿠푼 헤르체고비나 KSOP 본사 아시아 바덴바덴 아시아 KSOP 중계 [각종 오피 커뮤니티 제작]아시아 KSOP →♡ 캐쉬게임 기니 KSOP 토너먼트 아시아 룩셈부르크 아시아 KSOP 주소 [마케팅문의]아시아 KSOP ™☜ 단톡방 한국 KSOP 본사 아시아 에스토니아 아시아 KSOP 동영상 [카지노본사]아시아 KSOP ㈜# 본사 유럽 KSOP 게임 아시아 아시아 아시아 KSOP 홀덤펍 [스포츠본사]아시아 KSOP ♠◈ 경기 그레나딘 KSOP 바카라펍 아시아 르완다 아시아 KSOP 캐쉬게임 [토토본사 문의]아시아 KSOP ◐♨ 포커대회 예멘 KSOP 여행 아시아 모잠비크 아시아 KSOP 주소 [토토총판 구매]아시아 KSOP #↘ 토너먼트 시저스팰리스카지노 KSOP 바카라펍 아시아 모잠비크 아시아 KSOP 영상 [카지노총판]아시아 KSOP ☜→ 본사 남아프리카 KSOP 모집 아시아 세네갈 아시아 KSOP 총판 [야마토본사]아시아 KSOP #▧ 카지노펍 가이아나 KSOP 홀덤바 아시아 스위스 아시아 KSOP 홀덤펍 [바카라총판]아시아 KSOP ▩☞ 방법 이탈리아 KSOP 커뮤니티 아시아 한국 아시아 KSOP 접속 [경마총판]라트비아 KSOP 중계 부르키나파소 KSOP 추천 [BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
  • Topics

×
×
  • Create New...

Important Information

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