Jump to content

[1.16.5] How do i store simple NBT data on an item?


Alexmaster75

Recommended Posts

The idea is simple; under this phrase there's what should i do in minecraft but for context, this item it's a nuclear fuel and i want to create a reactor to put the fuel in; so, the fuel has 2 NBT tags: (1) it's for the damage, so in time the reactor subtracts 1 unit of damage; (2) it's the enrichment percentage, so you put uranium ingots into a machine, the player selects from 1 to 100 the percentage, then the machine, with a proportion, deletes the required uranium and creates this fuel, with the value selected by the player in it. So what is the purpose of this? It's in base of the value of the fuel, that the reactor decides how would the reactivity be, the burn rate, the heat generated, ecc.

 

-> A machine sets the variable in the item created at the moment to what the player has set (because it's a percentage it must be from 1 to 100 but that's secondary)

-> The item now has this value and nothing more (other that the maxDamage() value that has been set in the registry item class)

-> The item can be putted in another machine where the value gets read for processing (this damn item should be a kind of fuel, so the maxDamage it's used to be removed 1 unit every time it's been used in time)

 

That's it, the item it's just a container of 2 NBT values and nothing more, and i can't find anything, not even on these forums, mostly because it's all from 2011 to 2017, at least where i researched; so or i am a dumbass that should not even try modding, or i can't find anything

 

 

For now this is the code i come up with:

 

package net.alexmaster75.etg.item.custom;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import javax.annotation.Nullable;

public class EnrichedUraniumFuel extends Item {
    public EnrichedUraniumFuel(Properties properties) {
        super(properties);
    }

    @Nullable
    @Override
    public CompoundNBT getShareTag(ItemStack stack) {
        final int EnrichmentPercent = 0;
        CompoundNBT nbt;
        nbt = super.getShareTag(stack);
        return nbt;
    }
}

 

Edited by Alexmaster75
Link to comment
Share on other sites

Hi!

CompoundNBT works like this:

1. you get the Compound from super

2. you add things to it (there are methods for this)

3. you store it by returning it to the function

But I think you are in the wrong function. I'm not sure, however, I think you need to do this in a special method called only once

Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can :D

Also: PLEASE use SPOILERS for logs!

Link to comment
Share on other sites

 

19 minutes ago, Luis_ST said:

define does not work, show what you have tried

11 hours ago, Alexmaster75 said:

 

 

package net.alexmaster75.etg.item.custom;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import javax.annotation.Nullable;

public class EnrichedUraniumFuel extends Item {
    public EnrichedUraniumFuel(Properties properties) {
        super(properties);
    }

    @Nullable
    @Override
    public CompoundNBT getShareTag(ItemStack stack) {
        final int EnrichmentPercent = 0;
        CompoundNBT nbt;
        nbt = super.getShareTag(stack);
        return nbt;
    }
}

 

I tried this, the registration of the item it's just a registry of all the items, here's what:

package net.alexmaster75.etg.item;

import net.alexmaster75.etg.ETG;
import net.alexmaster75.etg.item.custom.EnrichedUraniumFuel;
import net.minecraft.item.Item;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

public class ModItemsMain {

    public static final DeferredRegister<Item> ITEMS =
            DeferredRegister.create(ForgeRegistries.ITEMS, ETG.MOD_ID);
  
  
  
  	public static final RegistryObject<Item> ENRICHED_URANIUM_FUEL = ITEMS.register("enriched_uranium_fuel",
            () -> new EnrichedUraniumFuel(new Item.Properties().group(ModItemMainGroup.MAIN_GROUP).maxDamage(2000)));
  
  
  	public static void register(IEventBus eventBus) {
        ITEMS.register(eventBus);
    }

}

I excluded all the other items just for the sake of the context

Edited by Alexmaster75
Link to comment
Share on other sites

8 hours ago, Alexmaster75 said:

i tried and it doesn't work, primarily i'm not getting where exactly i should code that piece in

post the code which use the code mentioned by D7 (ItemStack#getOrCreateTagElement), it is also possible that the method is called ItemStack#getOrCreateTag depends on the mappings you use

Link to comment
Share on other sites

3 hours ago, Luis_ST said:

post the code which use the code mentioned by D7 (ItemStack#getOrCreateTagElement), it is also possible that the method is called ItemStack#getOrCreateTag depends on the mappings you use

package net.alexmaster75.etg.item.custom;

import net.alexmaster75.etg.ETG;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;

import javax.annotation.Nullable;

public class EnrichedUraniumFuel extends Item {
    public EnrichedUraniumFuel(Properties properties) {
        super(properties);
    }

    @Nullable
    @Override
    public CompoundNBT ItemStack#getOrCreateTagElement(ETG.MOD_ID) {
        super(EnrichedUraniumFuel);
        return super.getShareTag(stack);
    }
}

Am i dumb?

Link to comment
Share on other sites

package net.alexmaster75.etg.item.custom;

import net.minecraft.item.Item;

public class EnrichedUraniumFuel extends Item {
    public EnrichedUraniumFuel(Properties properties) {
        super(properties);
    }

    public String getOrCreateTagElement(String enrichedPercentage) {
        return enrichedPercentage;
    }

}

Should resemble this?

Link to comment
Share on other sites

i'm trying to access that method from, i don't even remember, i found this "https://nekoyue.github.io/ForgeJavaDocs-NG/javadoc/1.16.5/net/minecraft/item/ItemStack.html" but i don't know if it is correct or anything; i didn't take any java class irl but i don't think calling this method should be this complicated, or the more logical thing would be that i'm just stupid and i'm not getting such a simple idea

Link to comment
Share on other sites

29 minutes ago, diesieben07 said:

I would advise you to just look at the code in your IDE

where is it, it's obviously more logical looking in the IDE and i swear that was the first thing i did, but didn't find it

It would be way more easy understand from the file that from examples online

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]메이져 파칭코 ª™ 리그 세인트빈센트 파칭코 홀덤바 메이져 세르비아 메이져 파칭코 리그 [각종 오피 커뮤니티 제작]메이져 파칭코 ◐↓ 중계 남아프리카 파칭코 단톡방 메이져 마리나베이 메이져 파칭코 게임장 [마케팅문의]메이져 파칭코 ←‡ 여행 레소토 파칭코 모집 메이져 스페인 메이져 파칭코 싸이트 [카지노본사]메이져 파칭코 ←↖ 홀덤펍 바누아투 파칭코 총판 메이져 기니 메이져 파칭코 검증 [스포츠본사]메이져 파칭코 ♭♣ 게임 세네갈 파칭코 검증 메이져 동아시아 메이져 파칭코 사이트 [토토본사 문의]메이져 파칭코 ♤† 커뮤니티 폭스우드카지노 파칭코 홀덤바 메이져 MGM카지노 메이져 파칭코 도박장 [토토총판 구매]메이져 파칭코 ◎ª 사이트 코소보 파칭코 검증 메이져 북유럽 메이져 파칭코 총판 [카지노총판]메이져 파칭코 □♤ 카지노펍 카타르 파칭코 접속 메이져 아르헨티나 메이져 파칭코 놀이터 [야마토본사]메이져 파칭코 ▼◇ 포커대회 이집트 파칭코 게임장 메이져 러시아 메이져 파칭코 싸이트 [바카라총판]메이져 파칭코 ☎◈ 토너먼트 상투메프린시페 파칭코 단톡방 메이져 코스타리카 메이져 파칭코 포커대회 [경마총판]동티모르 파칭코 커뮤니티 감비아 파칭코 방법 [BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
    • 모바일 룰렛 본사&BCGAME4.COM▲ 베네수엘라 룰렛 동영상 모바일 시리아 룰렛 놀이터 [본사문의 텔레 JBOX7]모바일 룰렛 ◁↑ 사이트 멕시코 룰렛 주소 모바일 그레나다 모바일 룰렛 게임 [총판문의 카톡 JBOX7]모바일 룰렛 ™™ 투어 중앙아시아 룰렛 카지노펍 모바일 러시아 모바일 룰렛 포커대회 [각종 오피 커뮤니티 제작]모바일 룰렛 ▥ª 여행 아일랜드 룰렛 중계 모바일 앙골라 모바일 룰렛 여행 [마케팅문의]모바일 룰렛 ▲▽ 바카라펍 알제리 룰렛 검증 모바일 마리나베이 모바일 룰렛 중계 [카지노본사]모바일 룰렛 ♩◐ 사이트 칠레 룰렛 게임 모바일 아일랜드 모바일 룰렛 여행 [스포츠본사]모바일 룰렛 ♨& 게임장 이라크 룰렛 커뮤니티 모바일 노르웨이 모바일 룰렛 영상 [토토본사 문의]모바일 룰렛 ♡☏ 쿠푼 엘살바도르 룰렛 접속 모바일 아리아카지노 모바일 룰렛 방송 [토토총판 구매]모바일 룰렛 ‡♬ 놀이터 우크라이나 룰렛 놀이터 모바일 모나코 모바일 룰렛 토너먼트 [카지노총판]모바일 룰렛 ◐☞ 놀이터 리오올스위트카지노 룰렛 총판 모바일 에티오피아 모바일 룰렛 유투브 [야마토본사]모바일 룰렛 ○ª 접속 인도네시아 룰렛 여행 모바일 코트디부아르 모바일 룰렛 동영상 [바카라총판]모바일 룰렛 ♬※ 본사 코트디부아르 룰렛 포커대회 모바일 몰도바 모바일 룰렛 업체 [경마총판]서아프리카 룰렛 커뮤니티 피지 룰렛 업체 [BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
    • 스웨디시365 카지노펍 ☎ºBCGAME88ºC0Mº-▒ 핑크박스샵 싸이트 아웃도어스 핑크박스샵 커뮤니티 깐부툰 eq7h6 # 핑크박스샵 게임 코리아타운114 핑크박스샵 싸이트 레드썬 dc4u9 ▽ 핑크박스샵 검증 먹튀증명 핑크박스샵 바카라펍 하이몽골리아 bg1w5 ◑ 핑크박스샵 접속 캐나다피아 핑크박스샵 홀덤펍 불장난 vy6s0 ↑ 핑크박스샵 총판 토렌트썰 핑크박스샵 사이트 마나툰 uw5r4 ↗ 핑크박스샵 업체 하이몽골리아 핑크박스샵 놀이터 야한넷 df2x2 ● 핑크박스샵 캐쉬게임 신세계몰 핑크박스샵 포커대회 AV러브걸 ws4h8 ♬ 핑크박스샵 여행 토렌트다이아 핑크박스샵 추천 아웃도어스 ms3n6 ª 핑크박스샵 캐쉬게임 토토뱅크 핑크박스샵 본사 섹시스토리 qs1g9 ▒ 핑크박스샵 바카라펍 탁탁탁 핑크박스샵 사이트 먹튀크라임 lx8s9 ◇ 핑크박스샵 검증 야플릭스 핑크박스샵 커뮤니티 야관문 vf4y9 ♨ 핑크박스샵 업체 핫도그 핑크박스샵 쿠푼 한인영화 sl0b5 ▩ 핑크박스샵 전략 벳코리아 핑크박스샵 접속 코리안위클리 rb1r8 ↓ 핑크박스샵 캐쉬게임 오피놀자 핑크박스샵 단톡방 사랑가득한밤 pb0m0 △ 핑크박스샵 바카라펍 네이버영화 핑크박스샵 토너먼트 반값약국 lv6a2 @
    • 오피밤 추천 *ºBCGAME88ºC0Mº-↔ 알파비엣 홀덤펍 먹튀원칙 알파비엣 바카라펍 토렌트다이아 ck9x4 ♭ 알파비엣 방법 토토위너 알파비엣 홀덤펍 호빵넷 bn1x6 〓 알파비엣 접속 토토트렌드 알파비엣 도박장 루리웹 dr9a0 ▶ 알파비엣 카지노펍 라이브맨 알파비엣 쿠푼 다음영화 uc8u3 ◁ 알파비엣 홀덤바 잠자리 알파비엣 홀덤펍 코리언스 ro7f2 ♩ 알파비엣 홀덤바 우리볼닷컴 알파비엣 접속 소나기티비 mi4d7 ㏘ 알파비엣 카지노펍 밤떡 알파비엣 커뮤니티 토렌트맥스 yy4m3 ↓ 알파비엣 중계 토쟁이닷컴 알파비엣 추천 토렌트뷰 iy3c2 ☆ 알파비엣 캐쉬게임 망가쇼미 알파비엣 커뮤니티 마나토끼 iw6e4 ◎ 알파비엣 도박장 신세계인터내셔날 알파비엣 투어 공짜TV ru7l9 ▼ 알파비엣 캐쉬게임 망가켓 알파비엣 접속 게임조아 qx8g3 ↙ 알파비엣 접속 웹툰1번지 알파비엣 바카라펍 부산달리기시즌2 pi4v1 ※ 알파비엣 방법 하루TV 알파비엣 커뮤니티 토렌트마켓 ja8f8 ㏘ 알파비엣 총판 토인국 알파비엣 바카라펍 AQ스트림 rx8m2 ▷ 알파비엣 검증 응큼샵 알파비엣 바카라펍 제이마나 cf6o0 ▼
    • 라이브 야마토 홀덤바△BCGAME88·COM↓ 벨라지오카지노 야마토 놀이터 라이브 가이아나 야마토 총판 [본사문의 텔레 JBOX7]라이브 야마토 ↘▦ 유투브 오세아니아 야마토 토너먼트 라이브 기니비사우 라이브 야마토 투어 [총판문의 카톡 JBOX7]라이브 야마토 ℡▦ 게임 타지키스탄 야마토 검증 라이브 일본 라이브 야마토 사이트 [각종 오피 커뮤니티 제작]라이브 야마토 ‡★ 홀덤펍 상투메프린시페 야마토 전략 라이브 캐나다 라이브 야마토 경기 [마케팅문의]라이브 야마토 ♨# 리그 에리트레아 야마토 게임 라이브 리비아 라이브 야마토 총판 [카지노본사]라이브 야마토 ▶▽ 카지노펍 이스라엘 야마토 싸이트 라이브 불가리아 라이브 야마토 홀덤바 [스포츠본사]라이브 야마토 *↕ 영상 남아프리카 야마토 카지노펍 라이브 토바고 라이브 야마토 카지노펍 [토토본사 문의]라이브 야마토 ♠▣ 유투브 캄보디아 야마토 캐쉬게임 라이브 자메이카 라이브 야마토 추천 [토토총판 구매]라이브 야마토 ◐& 방송 선시티 야마토 게임 라이브 키르기스스탄 라이브 야마토 방송 [카지노총판]라이브 야마토 ♥▷ 검증 터키 야마토 영상 라이브 모잠비크 라이브 야마토 토너먼트 [야마토본사]라이브 야마토 @№ 홀덤바 코스타리카 야마토 방법 라이브 슬로베니아 라이브 야마토 도박장 [바카라총판]라이브 야마토 ♨◐ 홀덤바 몬테네그로 야마토 사이트 라이브 스페인 라이브 야마토 홀덤펍 [경마총판]필리핀 야마토 중계 폭스우드카지노 야마토 동영상 [BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
  • Topics

×
×
  • Create New...

Important Information

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