Posted February 24, 201510 yr comment_145556 I got it working, but when the time goes to 0 the potion effect still lasts. I'm trying to make an immortal potion so when they drink it nothing can damage them for 25 seconds. Main: public static Potion ImmortalPotion; @PreInit public void load(FMLPreInitializationEvent event) { Potion[] potionTypes = null; for (Field f : Potion.class.getDeclaredFields()) { f.setAccessible(true); try { if (f.getName().equals("potionTypes") || f.getName().equals("field_76425_a")) { Field modfield = Field.class.getDeclaredField("modifiers"); modfield.setAccessible(true); modfield.setInt(f, f.getModifiers() & ~Modifier.FINAL); potionTypes = (Potion[])f.get(null); final Potion[] newPotionTypes = new Potion[256]; System.arraycopy(potionTypes, 0, newPotionTypes, 0, potionTypes.length); f.set(null, newPotionTypes); } } catch (Exception e) { System.err.println("Severe error, please report this to the mod author:"); System.err.println(e); } MinecraftForge.EVENT_BUS.register(new AlchemyMainEventHooks()); } } @Init public void load(FMLInitializationEvent event) { ImmortalPotion = (new PotionAlchemy(32, false, 0)).setIconIndex(0, 0).setPotionName("potion.ImmortalPotion"); } Event Hook: @ForgeSubscribe public void onEntityUpdate(LivingUpdateEvent event) { if (event.entityLiving.isPotionActive(AlchemyMain.ImmortalPotion)) { if (event.entityLiving.worldObj.rand.nextInt(20) == 0) { PlayerCapabilities.disableDamage = true; } if (event.entityLiving.getActivePotionEffect(AlchemyMain.ImmortalPotion).getDuration() == 0) { event.entityLiving.removePotionEffect(AlchemyMain.ImmortalPotion.id); PlayerCapabilities.disableDamage = false; return; } } } If im missing anything let me know, thanks.
February 24, 201510 yr comment_145569 Where did you registered the potion to the array? You didn't in Main class. If you didn't, try adding the potion to the array. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
February 25, 201510 yr Author comment_145575 where exactly would i register the potion? and how would i register it? would i replace the potionType with my potion name? Thanks for your time!
February 25, 201510 yr comment_145577 Oh I misread the Potion class. The constructor would automatically registers the potion. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
February 25, 201510 yr comment_145588 It seems that PotionEfect#getDuration() does not return 0 when LivingUpdateEvent called. Maybe changing 0 to 1 would solve your problem. EDIT: No, Don't do the suggestion above. There is some methods in Potion meeting your needs. So. 1. Make your own Potion class, 2. Override applyAttributesModifiersToEntity, and add ability there. 3. Override removeAttributesModifiersFromEntity, and remove ability there. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
February 25, 201510 yr Author comment_145589 In my main class @Init public void load(FMLInitializationEvent event) { ImmortalPotion = (new PotionAlchemy(32, false, 0)).setIconIndex(0, 0).setPotionName("potion.ImmortalPotion"); } is the "PotionAlchemy" the potion class?
February 25, 201510 yr comment_145593 Of course it is your potion class : PotionAlchemy class. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
February 25, 201510 yr Author comment_145620 Like this? @Override public void applyAttributesModifiersToEntity(EntityLivingBase par1EntityLivingBase, BaseAttributeMap par2BaseAttributeMap, int par3) { PlayerCapabilities.disableDamage = true; } @Override public void removeAttributesModifiersFromEntity(EntityLivingBase par1EntityLivingBase, BaseAttributeMap par2BaseAttributeMap, int par3) { PlayerCapabilities.disableDamage = false; }
February 26, 201510 yr comment_145825 Like this? @Override public void applyAttributesModifiersToEntity(EntityLivingBase par1EntityLivingBase, BaseAttributeMap par2BaseAttributeMap, int par3) { PlayerCapabilities.disableDamage = true; } @Override public void removeAttributesModifiersFromEntity(EntityLivingBase par1EntityLivingBase, BaseAttributeMap par2BaseAttributeMap, int par3) { PlayerCapabilities.disableDamage = false; } Correct, try that. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
February 26, 201510 yr comment_145826 Update to 1.7.10 if not 1.8, 1.6.4 is ancient. Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
February 27, 201510 yr Author comment_145848 i don't want to update because im familiar to 1.6.4 code, and i already tested that and it doesn't work sooo im really stuck here
February 27, 201510 yr comment_145854 Shmcrae if you are familiar to the 1.6 code can you help me with my question I'm also stuck at 1.6.4
February 27, 201510 yr comment_145859 My question is the topic right below you It says: [1.6.4] Custom branches and custom leaf patterns
February 27, 201510 yr Author comment_145864 I still really need help with this if anyone can help me please
February 27, 201510 yr comment_145873 What was problem.? Doesn't the code work? I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
February 27, 201510 yr comment_145879 Ah yes of course. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
February 27, 201510 yr Author comment_145881 now it doesn't work at all, when i drink it i take damage
February 27, 201510 yr comment_145884 Sorry, there was some mistakes I did. 1. You have to check if the Entity is player, and get the PlayerCapabilities for the player, and disable Damage for that. 2. Does applyAttributesModifiersToEntity not called? Check it. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
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.