Posted February 24, 201510 yr 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 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 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 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 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 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 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 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 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 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 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 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 My question is the topic right below you It says: [1.6.4] Custom branches and custom leaf patterns
February 27, 201510 yr 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 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 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.