Jump to content

[1.15] I have multiple questions about a few things.


Recommended Posts


I know, the title is not saying much, but I didn't want to open multiple threads for maybe easy questions. First thing first, here is my repository.


1. I use a capability to store extra information for an itemstack. I want to fill this capability, with default values (this works) and also when the item has a certain enchantment. For the default values I use the attachCapabilityEvent and this works just fine. However I can't do the same for the enchantments, because the enchantments haven't be applied to the itemstack in this event yet. If I call "EnchantmentHelper.getEnchantments(item)" in this event, I will always get an empty map, even if the actual itemstack has an enchantment ingame. My question is, which event should I use instead? The event only needs to be fired once, so I can check for the right enchantment and add the data to the capability.


2. Speaking of capabilities. I still have one problem with mine. Please take a look at the defense capability. It has 2 sets, but theire data won't get saved. This is most likely due to an error in the readNBT functions, because I don't know how use "NBTHelper.fromNBTToSet(...)" properly.


3. I would like to change the 'hurt'-animation of an LivingEntity (the mob-flashes-red-animation). In fact, I only want to change the color of it to either be yellow or green. Is this possible at all and if so, which event would I need to use?

4. How can I disable vanilla enchantments? In this case, I don't want the fire resistance enchantment to be obtainable ingame. Unregistering this enchantment is probably to much and will only cause problems down the line.


Thank you in advance, if you have an answere for any of my questions :)

Link to comment
Share on other sites

22 hours ago, diesieben07 said:
  1. Lazily populate the values whenever they are accessed. E.g in your capability make a method getSomeValue(ItemStack). When it's called, check if "some value" is set. If not, compute it first using the provided ItemStack. Otherwise just return it. Then whenever you need "some value", call this method.
  2. The 2nd parameter for CompoundNBT#getList is the type ID for the tag contained in the list. So if you have a list of strings, you need to pass the NBT ID for string. Use Constants.NBT for the NBT type IDs. Currently you are always passing the type ID for "list" (think a bit about why that is). This means you want a list of lists. getList will realize the actual list stored is a list of strings and return an empty list instead because the types don't match.

That helped a lot! I could fix both these issues.


22 hours ago, diesieben07 said:
  1. The hurt overlay is, as far as I can tell, handled by OverlayTexture. You need to replicate what the constructor does in FMLClientSetupEvent (use DeferredWorkQueue to run on the main thread). You can get the OverlayTexture instance from Minecraft#gameRenderer. You'll need some reflection to get it's internal values, but then you should be able to overwrite the image data and re-upload it using OpenGL (like done in it's constructor).

This sounds like I would override the red overlayTexture completly and only my yellow/green one would be applied, which I don't want. I formulated my question badly, so this is on me. What I want is to change this overlayTexture to a yellow one, if the damage is 0 and to a green one, if the damage is negativ (aka healing the entity). Would your suggestion still work in this case? (I haven't started to read the code yet. All I want is a heads up from someone more advanced on this topic.)


22 hours ago, diesieben07 said:
  1. Add your own EnchantmentType (EnchantmentType.create, note that the name must include your ModID to avoid collisions). This allows you to provide a predicate that chooses which items can be enchanted by this type. In your case you can just make a predicate that always returns false. Then set Enchantment#type to your new EnchantmentType for whichever Enchantments you want to disable. Note that individual items can still override this behavior by overriding IForgeItem#canApplyAtEnchantingTable. There is no way to prevent this. And yes, unregistering things is not supported.
    This won't disable enchanted books for this enchantment, but the books are not usable.

From a player perspective I would be annoyed, if I have an enchanted book, that can't be applied to any of my items. I want this enchantment to be removed, because I changed the damage calculation and currently this enchantment would reduce fire damage twice. If I could disable the calculation in ProtectionEnchantment::calcModifierDamage for the FIRE case, I would be happy too. With 1.16 forge added mixins, which I played around with through fabric. Could applying a mixin in this method be a solution? If you don't have a better idea, I might go with your suggested solution.

Link to comment
Share on other sites

7 minutes ago, diesieben07 said:

There is no "negative damage" in Minecraft.

Healing an entity does not cause an overlay currently, you'd have to somehow add a new overlay for when an entity is healed (LivingHealEvent, most likely a server-only event).

Please take a look at https://github.com/Tavi007/ElementalCombat/blob/00f3f7b3bef6f065f4ef264b82bdba53bce853ac/1.15.2/src/main/java/Tavi007/ElementalCombat/events/ElementifyLivingHurtEvent.java#L185

ignore the setCanceled(), because this was from testing (I hoped this would cancel the red overlay from being applied). In my method I could differentiate between the 3 damage cases (damage>0, damage=0 and damage<0). If damage>0, I want to apply the red overlay. if damage=0, apply yellow overlay and so on. So I would have to cancel the red overlay (if the right conditions are met) and instead apply my costum overlays. But I don't know where to start with this. Do you know by chance, which vanilla class I should take a look at?


19 minutes ago, diesieben07 said:

You could use registry-replacement (simply register a new enchantment with the same name) and override canApplyAtEnchantingTable and isAllowedOnBooks to return false.

Coremodding is a last-resort and not necessary here.

I will try this and hopefully it works as I want :)

Link to comment
Share on other sites

23 hours ago, diesieben07 said:

You could use registry-replacement (simply register a new enchantment with the same name) and override canApplyAtEnchantingTable and isAllowedOnBooks to return false.

Coremodding is a last-resort and not necessary here.

Here is what I tried. I call this line in a Register<Enchantment> event, which should replace the vanilla enchantment with my costum one.


However this fails on runtime:

[31Jul2020 17:00:48.655] [Render thread/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/]: Exception caught during firing event: Attempted to set registry name with existing registry name! New: minecraft:fire_protection Old: elementalcombat:fire_protection
	Index: 2
		1: ASM: class Tavi007.ElementalCombat.StartupCommon onIParticleTypeRegistration(Lnet/minecraftforge/event/RegistryEvent$Register;)V
		2: ASM: class Tavi007.ElementalCombat.StartupCommon registerEnchantments(Lnet/minecraftforge/event/RegistryEvent$Register;)V
java.lang.IllegalStateException: Attempted to set registry name with existing registry name! New: minecraft:fire_protection Old: elementalcombat:fire_protection
	at net.minecraftforge.registries.ForgeRegistryEntry.setRegistryName(ForgeRegistryEntry.java:43)
	at net.minecraftforge.registries.ForgeRegistryEntry.setRegistryName(ForgeRegistryEntry.java:50)
	at Tavi007.ElementalCombat.StartupCommon.registerEnchantments(StartupCommon.java:61)
	at net.minecraftforge.eventbus.ASMEventHandler_1_StartupCommon_registerEnchantments_Register.invoke(.dynamic)
	at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80)
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258)
	at net.minecraftforge.fml.javafmlmod.FMLModContainer.fireEvent(FMLModContainer.java:106)
	at java.util.function.Consumer.lambda$andThen$0(Unknown Source)
	at java.util.function.Consumer.lambda$andThen$0(Unknown Source)
	at net.minecraftforge.fml.ModContainer.transitionState(ModContainer.java:112)
	at net.minecraftforge.fml.ModList.lambda$dispatchSynchronousEvent$5(ModList.java:126)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
	at java.util.stream.ReferencePipeline$Head.forEach(Unknown Source)
	at net.minecraftforge.fml.ModList.dispatchSynchronousEvent(ModList.java:126)
	at net.minecraftforge.fml.ModList.lambda$static$1(ModList.java:96)
	at net.minecraftforge.fml.LifecycleEventProvider.dispatch(LifecycleEventProvider.java:71)
	at net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:214)
	at net.minecraftforge.fml.ModLoader.lambda$gatherAndInitializeMods$25(ModLoader.java:206)
	at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:973)
	at net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:206)
	at net.minecraftforge.fml.client.ClientModLoader.lambda$begin$2(ClientModLoader.java:97)
	at net.minecraftforge.fml.client.ClientModLoader.lambda$createRunnableWithCatch$5(ClientModLoader.java:113)
	at net.minecraftforge.fml.client.ClientModLoader.begin(ClientModLoader.java:97)
	at net.minecraft.client.Minecraft.<init>(Minecraft.java:397)
	at net.minecraft.client.main.Main.main(Main.java:141)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55)
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37)
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54)
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72)
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:81)
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:65)
	at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102)

I'm kinda stumped now. An idea how I could fix this?

Link to comment
Share on other sites



I just had an idea and it worked out. I have to set the registryName in the constructor of my costum enchantment like this

	public FireResistanceEnchantment() {
		super(Rarity.VERY_RARE, EnchantmentType.ARMOR, ARMOR_SLOTS);
		super.name = "New Fire Protection";


Link to comment
Share on other sites

1 minute ago, diesieben07 said:

Okay, before you continue: You are currently creating all your registry entries in a static initializer.

You cannot do this. Registry entries must be created in their appropriate registry event. 


The error you get is because you called setRegistryName twice for the same registry entry.

oh, okay. I will fix this

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

Okay, before you continue: You are currently creating all your registry entries in a static initializer.

You cannot do this. Registry entries must be created in their appropriate registry event. 


The error you get is because you called setRegistryName twice for the same registry entry.

Is this better now?


	public static void registerEnchantments(Register<Enchantment> event) {
		event.getRegistry().register(new ElementalResistanceEnchantment(ElementalResistanceEnchantment.Type.FIRE).setRegistryName(Enchantments.FIRE_PROTECTION.getRegistryName()));
		event.getRegistry().register(new ElementalResistanceEnchantment(ElementalResistanceEnchantment.Type.ICE).setRegistryName("ice_protection"));
		event.getRegistry().register(new ElementalResistanceEnchantment(ElementalResistanceEnchantment.Type.WATER).setRegistryName("water_protection"));
		event.getRegistry().register(new ElementalResistanceEnchantment(ElementalResistanceEnchantment.Type.THUNDER).setRegistryName("thunder_protection"));

		event.getRegistry().register(new ElementalWeaponEnchantment(ElementalWeaponEnchantment.Type.ICE).setRegistryName("ice_aspect"));
		event.getRegistry().register(new ElementalWeaponEnchantment(ElementalWeaponEnchantment.Type.WATER).setRegistryName("water_aspect"));
		event.getRegistry().register(new ElementalWeaponEnchantment(ElementalWeaponEnchantment.Type.THUNDER).setRegistryName("thunder_aspect"));


sometimes I wish the example mod would provide more code. A proper example for a particle/an item/a block/an enchantment/whatever could reduce a lot of question... I would support you, but since I'm a newbie, I wouldn't be helpful :/

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.

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.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • 해외 KSOP 커뮤니티↓BCGAME4.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 비씨게임 총판문의]알림 설정 추천 구독 좋아요
    • 메이져 대출 홀덤바♥BCGAME4·C0M↔ 선시티 대출 카지노펍 메이져 타지키스탄 대출 경기 [본사문의 텔레 JBOX7]메이져 대출 ◈↗ 포커대회 이집트 대출 유투브 메이져 모리타니 메이져 대출 총판 [총판문의 카톡 JBOX7]메이져 대출 ª㏇ 모집 세네갈 대출 접속 메이져 말라위 메이져 대출 바카라펍 [각종 오피 커뮤니티 제작]메이져 대출 ▧♩ 토너먼트 캐나다 대출 리그 메이져 아일랜드 메이져 대출 도박장 [마케팅문의]메이져 대출 ♬▧ 총판 브라질 대출 토너먼트 메이져 키프로스 메이져 대출 포커대회 [카지노본사]메이져 대출 ◈■ 도박장 세인트키츠 대출 검증 메이져 엘살바도르 메이져 대출 싸이트 [스포츠본사]메이져 대출 ㏘♥ 여행 리오올스위트카지노 대출 사이트 메이져 팔라우 메이져 대출 중계 [토토본사 문의]메이져 대출 ♧◀ 사이트 아이슬란드 대출 유투브 메이져 이스라엘 메이져 대출 투어 [토토총판 구매]메이져 대출 ◇▼ 영상 MGM카지노 대출 여행 메이져 오세아니아 메이져 대출 전략 [카지노총판]메이져 대출 ▲♭ 캐쉬게임 덴마크 대출 토너먼트 메이져 베네시안카지노 메이져 대출 놀이터 [야마토본사]메이져 대출 ☜& 도박장 겐팅하이랜드카지노 대출 경기 메이져 엘살바도르 메이져 대출 경기 [바카라총판]메이져 대출 ▷▼ 총판 페루 대출 캐쉬게임 메이져 파키스탄 메이져 대출 게임장 [경마총판]동아시아 대출 동영상 BCGAME카지노 대출 경기 [BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
    • 아시아 피치슬로 카지노펍†BCGAME88·COM▥ 그레나딘 피치슬로 캐쉬게임 아시아 안도라 피치슬로 리그 [본사문의 텔레 JBOX7]아시아 피치슬로 ◇№ 커뮤니티 키르기스스탄 피치슬로 경기 아시아 베네수엘라 아시아 피치슬로 리그 [총판문의 카톡 JBOX7]아시아 피치슬로 ☎☞ 중계 네팔 피치슬로 추천 아시아 베네수엘라 아시아 피치슬로 사이트 [각종 오피 커뮤니티 제작]아시아 피치슬로 ♡◇ 전략 폴스뷰카지노 피치슬로 유투브 아시아 볼리비아 아시아 피치슬로 모집 [마케팅문의]아시아 피치슬로 #& 사이트 통가 피치슬로 방송 아시아 서아시아 아시아 피치슬로 본사 [카지노본사]아시아 피치슬로 ♠▧ 홀덤바 이비자그란카지노 피치슬로 리그 아시아 모리타니 아시아 피치슬로 커뮤니티 [스포츠본사]아시아 피치슬로 &↙ 방법 슬로바키아 피치슬로 게임장 아시아 안도라 아시아 피치슬로 방법 [토토본사 문의]아시아 피치슬로 ▣㉿ 주소 아이티 피치슬로 경기 아시아 체코 아시아 피치슬로 유투브 [토토총판 구매]아시아 피치슬로 #□ 전략 마리나베이 피치슬로 총판 아시아 폴스뷰카지노 아시아 피치슬로 방법 [카지노총판]아시아 피치슬로 ⊙※ 모집 잠비아 피치슬로 싸이트 아시아 니카라과 아시아 피치슬로 경기 [야마토본사]아시아 피치슬로 ◐♨ 투어 아이티 피치슬로 유투브 아시아 콩고 아시아 피치슬로 도박장 [바카라총판]아시아 피치슬로 @▼ 주소 시저스팰리스카지노 피치슬로 쿠푼 아시아 팔레스타인 아시아 피치슬로 방송 [경마총판]에콰도르 피치슬로 게임장 우간다 피치슬로 홀덤바 [BCGAME 비씨게임 총판문의]알림 설정 추천 구독 좋아요
    • 원서휴게텔 ☎BCGAME88·COM☆ 상주휴게텔 광진휴게텔 사근휴게텔 신계휴게텔 sgc22 천안휴게텔 사직휴게텔 견지휴게텔 장위휴게텔 skh16 장충휴게텔 을지휴게텔 삼청휴게텔 동두천휴게텔 jet22 혜화휴게텔 세종로휴게텔 제기휴게텔 강릉휴게텔 guo99 내자휴게텔 권농휴게텔 구로휴게텔 창천휴게텔 cfv28 원남휴게텔 충무휴게텔 신교휴게텔 송월휴게텔 uwb61 보령휴게텔 망원휴게텔 응암휴게텔 고척휴게텔 npn28 안양휴게텔 수유휴게텔 공항휴게텔 갈현휴게텔 mub76 본동휴게텔 냉천휴게텔 남영휴게텔 종암휴게텔 dqp79 연희휴게텔 필운휴게텔 강릉휴게텔 은평휴게텔 ykc63 통인휴게텔 만리휴게텔 효창휴게텔 광명휴게텔 roh96 상수휴게텔 토정휴게텔 답십리휴게텔 용강휴게텔 bqt99 평택휴게텔 옥수휴게텔 홍은휴게텔 중림휴게텔 gwd97 고창휴게텔 홍은휴게텔 내자휴게텔 송현휴게텔 ovu06 일원휴게텔 음성휴게텔 여주휴게텔 목동휴게텔 vjj18 내곡휴게텔 과해휴게텔 포천휴게텔 문래휴게텔 yfo12 연희휴게텔 화양휴게텔 체부휴게텔 도곡휴게텔 syr38 파주휴게텔 세종로휴게텔 녹번휴게텔 계동휴게텔 cme11 답십리휴게텔 용두휴게텔 현저휴게텔 합동휴게텔 dsh56 창전휴게텔 후암휴게텔 숭인휴게텔 대치휴게텔 wqe04 종로휴게텔 대치휴게텔 파주휴게텔 둔촌휴게텔 pon77 전주휴게텔 창천휴게텔 송현휴게텔 상왕십리휴게텔 tos50 송정휴게텔 삼각휴게텔 쌍림휴게텔 신촌휴게텔 qww17
    • 계동립카페 ‡BCGAME88·COMª 개화립카페 낙원립카페 묵동립카페 전주립카페 pws48 가양립카페 구산립카페 염리립카페 신사립카페 yww73 대흥립카페 성남립카페 홍익립카페 청담립카페 qnq33 대흥립카페 용인립카페 평택립카페 예관립카페 nnk63 거제립카페 공평립카페 성남립카페 돈암립카페 sqd86 광희립카페 가평립카페 거창립카페 주교립카페 jel33 대전립카페 율현립카페 고흥립카페 학방립카페 wvk74 평창립카페 구의립카페 반포립카페 항동립카페 jkv21 구수립카페 청운립카페 가평립카페 과천립카페 sbm57 동두천립카페 안암립카페 무안립카페 충주립카페 teq64 신계립카페 신촌립카페 장사립카페 인사립카페 xnq30 의왕립카페 신내립카페 구수립카페 우이립카페 fwp63 운니립카페 청파립카페 문배립카페 김포립카페 emk62 명륜립카페 진주립카페 가평립카페 능동립카페 ikw35 휘경립카페 김천립카페 남대문립카페 가양립카페 uco72 신교립카페 효제립카페 이태원립카페 불광립카페 nkf25 신사립카페 상암립카페 삼선립카페 여주립카페 tnc50 안산립카페 강릉립카페 남원립카페 경산립카페 iea75 산방립카페 묵정립카페 양화립카페 서린립카페 gid81 중곡립카페 중동립카페 광주립카페 불광립카페 xie47 회기립카페 흥인립카페 구의립카페 재동립카페 pvk56 사직립카페 운니립카페 내수립카페 묘동립카페 eje05 혜화립카페 냉천립카페 면목립카페 압구정립카페 wht22
  • Topics

  • Create New...

Important Information

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