Posted September 30, 201411 yr I'm trying to make an item that gives you a fly potion when you right click with it. I made everything, should work but it ain't Here's some src In my main class public static Potion flyingEffect; flyingEffect = (new FlyingPotionEffect(32, false, 7889559)).setPotionName("potion.fly"); FlyingPotionEffect.class public class FlyingPotionEffect extends Potion { protected FlyingPotionEffect(int par1, boolean par2, int par3) { super(par1, par2, par3); } public void performEffect(EntityLivingBase lb, int par2) { if (this.id == InfusionCraft.flyingEffect.id && lb instanceof EntityPlayer) { if (!lb.worldObj.isRemote) ((EntityPlayer)lb).capabilities.allowFlying = true; } } } Item on right click method public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer player) { player.addPotionEffect((new PotionEffect(InfusionCraft.flyingEffect.id, 200, 1))); // ticks 20, level 1 return par1ItemStack; } I hope you guys can help me _ ___ ___| |__ _ __ / __/ __| '_ \| '_ \ \__ \__ \ | | | | | | |___/___/_| |_|_| |_|
October 2, 201411 yr Author anyone? _ ___ ___| |__ _ __ / __/ __| '_ \| '_ \ \__ \__ \ | | | | | | |___/___/_| |_|_| |_|
October 2, 201411 yr Author I didn't quite understand. Can you tell me where and what i need to override? And thank you _ ___ ___| |__ _ __ / __/ __| '_ \| '_ \ \__ \__ \ | | | | | | |___/___/_| |_|_| |_|
October 2, 201411 yr Author done it like this @Override public boolean isReady(int par1, int par2) { return this.id == InfusionCraft.flyingEffect.id; } i got crash when i try to run minecraft _ ___ ___| |__ _ __ / __/ __| '_ \| '_ \ \__ \__ \ | | | | | | |___/___/_| |_|_| |_|
October 2, 201411 yr Author Oh yeah, sorry i forgot to do that http://pastebin.com/YCTfpKAv _ ___ ___| |__ _ __ / __/ __| '_ \| '_ \ \__ \__ \ | | | | | | |___/___/_| |_|_| |_|
October 3, 201411 yr Author but all 31 id's are used by vanilla potions _ ___ ___| |__ _ __ / __/ __| '_ \| '_ \ \__ \__ \ | | | | | | |___/___/_| |_|_| |_|
October 3, 201411 yr Author Wow, i set the id to 31 and it worked When i right click with item i get my potion of flying and i can fly. That cool! But 1 thing...when the potion effect ends i can still fly. Is there a way that i can check if the player has potion effect? And where should i put it? Here's the PotionEffect class public class FlyingPotionEffect extends Potion { protected FlyingPotionEffect(int par1, boolean par2, int par3) { super(par1, par2, par3); } @Override public void performEffect(EntityLivingBase lb, int par2) { if (this.id == InfusionCraft.flyingEffect.id && lb instanceof EntityPlayer) { ((EntityPlayer)lb).capabilities.allowFlying = true; } } @Override public boolean isReady(int par1, int par2) { return this.id == InfusionCraft.flyingEffect.id; } } _ ___ ___| |__ _ __ / __/ __| '_ \| '_ \ \__ \__ \ | | | | | | |___/___/_| |_|_| |_|
October 6, 201411 yr Author Well, I can't get it to work. I tried everything. Setting if statements, changing 0 to 1, nothing. Here's what i did so far @Override public void performEffect(EntityLivingBase lb, int ticksLeft) { if(this.id == InfusionCraft.flyingEffect.id && lb instanceof EntityPlayer) { if(ticksLeft == 0) { ((EntityPlayer)lb).capabilities.allowFlying = false; ((EntityPlayer)lb).capabilities.isFlying = false; } else ((EntityPlayer)lb).capabilities.allowFlying = true; } } Also, I tried to add an icon for the potion effect. The image is loaded and it's there, just it doesn't show the whole image. Here's what i mean http://i.imgur.com/XApGbPg.png It's like the image is too big (Don't think so, i copied the vanilla template 17x17 for potion icon) Here's my class package com.nuclearbanana.ic; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.util.ResourceLocation; public class FlyingPotionEffect extends Potion { private static final ResourceLocation icon = new ResourceLocation(InfusionCraft.modid,"/textures/potion/fly.png"); protected FlyingPotionEffect(int par1, boolean par2, int par3) { super(par1, par2, par3); this.setIconIndex(0, 0); } @Override public void performEffect(EntityLivingBase lb, int ticksLeft) { if(this.id == InfusionCraft.flyingEffect.id && lb instanceof EntityPlayer) { if(ticksLeft == 0) { ((EntityPlayer)lb).capabilities.allowFlying = false; ((EntityPlayer)lb).capabilities.isFlying = false; } else ((EntityPlayer)lb).capabilities.allowFlying = true; } } @Override public boolean isReady(int par1, int par2) { return this.id == InfusionCraft.flyingEffect.id; } @Override @SideOnly(Side.CLIENT) public boolean hasStatusIcon() { Minecraft.getMinecraft().renderEngine.bindTexture(icon); return true; } } _ ___ ___| |__ _ __ / __/ __| '_ \| '_ \ \__ \__ \ | | | | | | |___/___/_| |_|_| |_|
October 6, 201411 yr Author After debugging, i saw that it only prints the number 1, always. So when i set if it is 0, that code never executes @Override public void performEffect(EntityLivingBase lb, int ticksLeft) { if(this.id == InfusionCraft.flyingEffect.id && lb instanceof EntityPlayer) { if(ticksLeft == 1) { ((EntityPlayer)lb).capabilities.allowFlying = true; System.out.println("If: "+ticksLeft); } else { ((EntityPlayer)lb).capabilities.allowFlying = false; ((EntityPlayer)lb).capabilities.isFlying = false; System.out.println("Else: "+ticksLeft); } System.out.println("N: "+ticksLeft); } } _ ___ ___| |__ _ __ / __/ __| '_ \| '_ \ \__ \__ \ | | | | | | |___/___/_| |_|_| |_|
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.