Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

BoonieQuafter-CrAfTeR

Members
  • Posts

    337
  • Joined

  • Last visited

Everything posted by BoonieQuafter-CrAfTeR

  1. in one of my methods(it really shouldn't matter which it is, what I am asking a is really very simple. exp. onLivingUpdate it does not have access to the world, meaning, the world is not provided by the method) there is only access to the item stack and not the world. basically I want to access to world, like so: making a variable called world public World world; this would be easy and pretty awesome if this worked, im asking is if something like this is possible another example of accessing the world, player.worldObj this works, except I cannot access this in my method either. I hope by now you understand what im trying to say, because I have to basically keep saying the same thing over and over again in different ways. any way thank you all for your time
  2. so basically I made some methods to work together, then later on I wanted to add a variable (World minecraft world), and I want to be able to call on the world without having to add anything to my method, so yeah, thank you all for your time.
  3. Render Class package com.OlympiansMod.entity; import com.OlympiansMod.lib.Refstrings; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.entity.RenderBiped; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class RenderZeus extends RenderLiving{ private static final ResourceLocation mobTextures = new ResourceLocation(Refstrings.MODID + ":textures/entity/Zeus.png"); public RenderZeus(ZeusModel model, float par2) { super(model, par2); } protected ResourceLocation getEntityTexture(Zeus entity){ return mobTextures; } protected ResourceLocation getEntityTexture(Entity entity){ return this.getEntityTexture((Zeus)entity); } } ModelClass: package com.OlympiansMod.entity; import org.lwjgl.opengl.GL11; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; public class ZeusModel extends ModelBase { protected ModelRenderer head; protected ModelRenderer body; protected ModelRenderer rightarm; protected ModelRenderer leftarm; protected ModelRenderer rightleg; protected ModelRenderer leftleg; public int heldItemLeft; public int heldItemRight; public ZeusModel() { this.textureWidth = 64; this.textureHeight = 128; this.head = new ModelRenderer(this, 0, 0); this.head.mirror = true; this.head.addBox(-4F, -8F, -4F, 10, 10, 10); this.head.setRotationPoint(-1F, -10F, 0F); this.head.setTextureSize(64, 128); this.body = new ModelRenderer(this, 2, 20); this.body.mirror = true; this.body.addBox(-4F, 0F, -2F, 12, 16, 6); this.body.setRotationPoint(-2F, -8F, 0F); this.body.setTextureSize(64, 128); this.rightarm = new ModelRenderer(this, 40, 0); this.rightarm.mirror = true; this.rightarm.addBox(-3F, -2F, -2F, 6, 16, 6); this.rightarm.setRotationPoint(-9F, -6F, 0F); this.rightarm.setTextureSize(64, 128); this.leftarm = new ModelRenderer(this, 40, 22); this.leftarm.mirror = true; this.leftarm.addBox(-1F, -2F, -2F, 6, 16, 6); this.leftarm.setRotationPoint(7F, -6F, 0F); this.leftarm.setTextureSize(64, 128); this.rightleg = new ModelRenderer(this, 40, 44); this.rightleg.mirror = true; this.rightleg.addBox(-2F, 0F, -2F, 6, 16, 6); this.rightleg.setRotationPoint(-4F, 8F, 0F); this.rightleg.setTextureSize(64, 128); this.leftleg = new ModelRenderer(this, 40, 66); this.leftleg.mirror = true; this.leftleg.addBox(-2F, 0F, -2F, 6, 16, 6); this.leftleg.setRotationPoint(2F, 8F, 0F); this.leftleg.setTextureSize(64, 128); } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.head.render(f5); this.body.render(f5); this.rightarm.render(f5); this.leftarm.render(f5); this.rightleg.render(f5); this.leftleg.render(f5); } public static void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { Zeus zeus = (Zeus)entity; int i = zeus.getattackTimer(); super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.head.rotateAngleY = f3 / (180F / (float)Math.PI); this.head.rotateAngleX = f4 / (180F / (float)Math.PI); rightleg.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1; leftleg.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1; rightarm.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1; leftarm.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1; if (this.heldItemRight != 0) { this.rightarm.rotateAngleX = this.rightarm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemRight; } if (i > 0) { float f6 = 0.0F; float f7 = 0.0F; this.rightarm.rotateAngleZ = 0.0F; this.rightarm.rotateAngleY = -(0.1F - f6 * 0.6F); this.rightarm.rotateAngleX = -((float)Math.PI / 2F); this.rightarm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; this.rightarm.rotateAngleZ += MathHelper.cos(f2 * 0.09F) * 0.05F + 0.05F; this.rightarm.rotateAngleX += MathHelper.sin(f2 * 0.067F) * 0.05F; }else{ } int j = zeus.getattackTimer2(); if (j > 0) { float f6 = 1.0F - this.onGround; f6 *= f6; f6 *= f6; f6 = 1.0F - f6; float f7 = MathHelper.sin(f6 * (float)Math.PI); float f8 = MathHelper.sin(this.onGround * (float)Math.PI) * -(this.head.rotateAngleX - 0.7F) * 0.75F; this.leftarm.rotateAngleX = (float)((double)this.leftarm.rotateAngleX - ((double)f7 * 1.2D + (double)f8)); this.leftarm.rotateAngleY += this.body.rotateAngleY * 2.0F; this.leftarm.rotateAngleZ = MathHelper.sin(this.onGround * (float)Math.PI) * -0.4F; } } private float func_78172_a(float p_78172_1_, float p_78172_2_) { return (Math.abs(p_78172_1_ % p_78172_2_ - p_78172_2_ * 0.5F) - p_78172_2_ * 0.25F) / (p_78172_2_ * 0.25F); } } Client proxy: package com.OlympiansMod.Main; import java.util.EnumSet; import javax.swing.plaf.basic.BasicComboBoxUI.KeyHandler; import org.lwjgl.input.Keyboard; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.world.World; import com.OlympiansMod.Item.ModItems; import com.OlympiansMod.PlayerInventory.DNAContainer; import com.OlympiansMod.PlayerInventory.SlotGui; import com.OlympiansMod.Potionstuff.WizardsFatigue; import com.OlympiansMod.entity.Arachne; import com.OlympiansMod.entity.ArachneModel; import com.OlympiansMod.entity.Dioceltian; import com.OlympiansMod.entity.EntityBullet; import com.OlympiansMod.entity.EntityGreekFire; import com.OlympiansMod.entity.EntityMasterBolt; import com.OlympiansMod.entity.EntitySGolem; import com.OlympiansMod.entity.EntitySGuardian; import com.OlympiansMod.entity.EntityThunderBolt; import com.OlympiansMod.entity.EntityUndead; import com.OlympiansMod.entity.GreekUndead; import com.OlympiansMod.entity.MasterBoltModel; import com.OlympiansMod.entity.ModelDioclectian; import com.OlympiansMod.entity.ModelPosiedon; import com.OlympiansMod.entity.ModelUndeadGreek; import com.OlympiansMod.entity.Poseidon; import com.OlympiansMod.entity.RenderArachne; import com.OlympiansMod.entity.RenderDioclectian; import com.OlympiansMod.entity.RenderMasterBolt; import com.OlympiansMod.entity.RenderPoseidon; import com.OlympiansMod.entity.RenderSGolem; import com.OlympiansMod.entity.RenderSGuardian; import com.OlympiansMod.entity.RenderThunderBolt; import com.OlympiansMod.entity.RenderUndead; import com.OlympiansMod.entity.RenderUndeadGreek; import com.OlympiansMod.entity.RenderZeus; import com.OlympiansMod.entity.RenderZeusExtended; import com.OlympiansMod.entity.SGolemModel; import com.OlympiansMod.entity.SGuardianModel; import com.OlympiansMod.entity.SlownessSpell; import com.OlympiansMod.entity.SpellBombardo; import com.OlympiansMod.entity.SpellChicken; import com.OlympiansMod.entity.SpellIncendio; import com.OlympiansMod.entity.Undead; import com.OlympiansMod.entity.Zeus; import com.OlympiansMod.entity.ZeusExtended; import com.OlympiansMod.entity.ZeusExtendedModel; import com.OlympiansMod.entity.ZeusModel; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class ClientProxy extends ServerProxy{ public void registerRenderInfo(){ RenderingRegistry.registerEntityRenderingHandler(Zeus.class, new RenderZeus(new ZeusModel(), 0)); } } i get an error on renderzeus ect. when extending the render off biped. but that hardly matters because the real problem is with the model, when extending from biped, and changing all of the parts of the model to biped parts, and keeping the model dimensions some how my model gets extremely messed up. the head and legs ect. get scrambled.
  4. sorry yeah , im working in 1.7.10. except I don't think that I can extend off renderbiped unless my model extends biped, which was my problem in the first place, extending the model of biped made the model super weird, although I did make it techne.. anyways, since I thought that was the problem(techne model), I extended the model of biped, and copied the measurements, or dimensions of the model and pasted them in place of the biped dimensions.(like the skeleton does, extends off the biped model and makes the arms skinnier) but yeah im not sure what to do from here, if nothing works out properly in the end, I will have to code the model, so yeah it would be really nice to get the render biped to work.
  5. if (this.heldItemRight != 0) { this.rightarm.rotateAngleX = this.rightarm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemRight; } wait, shouldn't this render the item just fine? it seems as though it should work..
  6. package com.OlympiansMod.entity; import org.lwjgl.opengl.GL11; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.MathHelper; public class ZeusModel extends ModelBase { protected ModelRenderer head; protected ModelRenderer body; protected ModelRenderer rightarm; protected ModelRenderer leftarm; protected ModelRenderer rightleg; protected ModelRenderer leftleg; private int heldItemLeft; private int heldItemRight; public ZeusModel() { this.textureWidth = 64; this.textureHeight = 128; this.head = new ModelRenderer(this, 0, 0); this.head.mirror = true; this.head.addBox(-4F, -8F, -4F, 10, 10, 10); this.head.setRotationPoint(-1F, -10F, 0F); this.head.setTextureSize(64, 128); this.body = new ModelRenderer(this, 2, 20); this.body.mirror = true; this.body.addBox(-4F, 0F, -2F, 12, 16, 6); this.body.setRotationPoint(-2F, -8F, 0F); this.body.setTextureSize(64, 128); this.rightarm = new ModelRenderer(this, 40, 0); this.rightarm.mirror = true; this.rightarm.addBox(-3F, -2F, -2F, 6, 16, 6); this.rightarm.setRotationPoint(-9F, -6F, 0F); this.rightarm.setTextureSize(64, 128); this.leftarm = new ModelRenderer(this, 40, 22); this.leftarm.mirror = true; this.leftarm.addBox(-1F, -2F, -2F, 6, 16, 6); this.leftarm.setRotationPoint(7F, -6F, 0F); this.leftarm.setTextureSize(64, 128); this.rightleg = new ModelRenderer(this, 40, 44); this.rightleg.mirror = true; this.rightleg.addBox(-2F, 0F, -2F, 6, 16, 6); this.rightleg.setRotationPoint(-4F, 8F, 0F); this.rightleg.setTextureSize(64, 128); this.leftleg = new ModelRenderer(this, 40, 66); this.leftleg.mirror = true; this.leftleg.addBox(-2F, 0F, -2F, 6, 16, 6); this.leftleg.setRotationPoint(2F, 8F, 0F); this.leftleg.setTextureSize(64, 128); } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.head.render(f5); this.body.render(f5); this.rightarm.render(f5); this.leftarm.render(f5); this.rightleg.render(f5); this.leftleg.render(f5); } public static void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.head.rotateAngleY = f3 / (180F / (float)Math.PI); this.head.rotateAngleX = f4 / (180F / (float)Math.PI); rightleg.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1; leftleg.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1; rightarm.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1; leftarm.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1; if (this.heldItemRight != 0) { this.rightarm.rotateAngleX = this.rightarm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemRight; } Zeus zeus = (Zeus)entity; int i = zeus.getattackTimer(); if (i > 0) { float f6 = 0.0F; float f7 = 0.0F; this.rightarm.rotateAngleZ = 0.0F; this.rightarm.rotateAngleY = -(0.1F - f6 * 0.6F); this.rightarm.rotateAngleX = -((float)Math.PI / 2F); this.rightarm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; this.rightarm.rotateAngleZ += MathHelper.cos(f2 * 0.09F) * 0.05F + 0.05F; this.rightarm.rotateAngleX += MathHelper.sin(f2 * 0.067F) * 0.05F; }else{ } int j = zeus.getattackTimer2(); if (j > 0) { float f6 = 1.0F - this.onGround; f6 *= f6; f6 *= f6; f6 = 1.0F - f6; float f7 = MathHelper.sin(f6 * (float)Math.PI); float f8 = MathHelper.sin(this.onGround * (float)Math.PI) * -(this.head.rotateAngleX - 0.7F) * 0.75F; this.leftarm.rotateAngleX = (float)((double)this.leftarm.rotateAngleX - ((double)f7 * 1.2D + (double)f8)); this.leftarm.rotateAngleY += this.body.rotateAngleY * 2.0F; this.leftarm.rotateAngleZ = MathHelper.sin(this.onGround * (float)Math.PI) * -0.4F; } } private float func_78172_a(float p_78172_1_, float p_78172_2_) { return (Math.abs(p_78172_1_ % p_78172_2_ - p_78172_2_ * 0.5F) - p_78172_2_ * 0.25F) / (p_78172_2_ * 0.25F); } } how this model cant hold an item? ingame it doesn't render..
  7. maybe a better question is, where is the code that allows the item to hold an item in model biped?
  8. so im making a custom entity model, and I want it to be able to hold an item, so yeah the title says it all. btw I couldn't find how to do this in the bipedmodel class so im a little confused.
  9. So yeah im making a custom potion effect called wizards fatigue, problem is I get this crash report, and im pretty sure im doing allot wrong, so yeah, if you guys could help me out that'd be greatly appreciated. ok heres is my main class and other stuff Main: package com.OlympiansMod.Main; import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.potion.Potion; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.fluids.FluidRegistry; import com.OlympiansMod.Block.ModBlocks; import com.OlympiansMod.Item.DnaPosideonInfused; import com.OlympiansMod.Item.DnaStats; import com.OlympiansMod.Item.DnaStats2; import com.OlympiansMod.Item.DnaZeusInfused; import com.OlympiansMod.Item.ModItems; import com.OlympiansMod.Potionstuff.WizardsFatigue; import com.OlympiansMod.Potionstuff.WizardsFatigueHooks; import com.OlympiansMod.creativetabs.MCreativeTabs; import com.OlympiansMod.entity.EntityCell; import com.OlympiansMod.entity.EntityGreekFire; import com.OlympiansMod.entity.MEntity; import com.OlympiansMod.lib.Refstrings; import com.OlympiansMod.world.MWorld; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.registry.GameRegistry; @Mod(modid = Refstrings.MODID , name = Refstrings.NAME , version = Refstrings.VERSION) public class MainRegistry { private static int modGuiIndex = 0; public static final int GUI_CUSTOM_INV = modGuiIndex++; @SidedProxy(clientSide = Refstrings.CLIENTSIDE , serverSide = Refstrings.SERVERSIDE) public static ServerProxy proxy; @Instance public static MainRegistry modInstance; public static Potion customPotion = (new WizardsFatigue(32, false, 0)).setIconIndex(0, 0).setPotionName("potion.wizardsFatigue");; @EventHandler public static void PreLoad(FMLPreInitializationEvent PreEvent) { MCreativeTabs.initialiseTabs(); ModBlocks.MainRegistry(); MEntity.MainRegistry(); ModItems.MainRegistry(); FMLCommonHandler.instance().bus().register(new WizardsFatigueHooks()); FMLCommonHandler.instance().bus().register(new DnaZeusInfused()); MWorld.MainRegistry(); CraftingManager.mainRegistry(); } @EventHandler public static void Load(FMLInitializationEvent event) { proxy.registerRenderInfo(); } @EventHandler public static void PostLoad(FMLPostInitializationEvent PostEvent) { } } Potion Classes: package com.OlympiansMod.Potionstuff; import net.minecraft.potion.Potion; public class WizardsFatigue extends Potion { public WizardsFatigue(int par1, boolean par2, int par3) { super(par1, par2, par3); } public Potion setIconIndex(int par1, int par2) { super.setIconIndex(par1, par2); return this; } } and hooks class: package com.OlympiansMod.Potionstuff; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import com.OlympiansMod.Main.MainRegistry; import com.google.common.eventbus.Subscribe; public class WizardsFatigueHooks { @Subscribe public void onEntityUpdate(LivingUpdateEvent event) { if (event.entityLiving.isPotionActive(MainRegistry.customPotion)) { if (event.entityLiving.worldObj.rand.nextInt(20) == 0) { } } } } if some one has a good tutorial that would also be helpful, thank you for your time.
  10. ok here is the code(Formated): package com.OlympiansMod.Item; import java.util.List; import com.OlympiansMod.entity.SlownessSpell; import com.OlympiansMod.entity.SpellBombardo; import com.OlympiansMod.entity.SpellChicken; import com.OlympiansMod.entity.SpellIncendio; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagLong; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; public class RandomWand extends Item { // SlownessSpell public static final int FIRE_RATE = 300; private int getCooldown(ItemStack stack) { int Level = stack.stackTagCompound.getInteger("Level"); int spell = stack.stackTagCompound.getInteger("Spell"); if (Level == 1 && spell == 1) { return 300; } if (Level == 2 && spell == 1) { return 270; } if (Level == 3 && spell == 1) { return 255; } if (Level == 4 && spell == 1) { return 210; } if (Level == 5 && spell == 1) { return 195; } if (Level == 2 && spell == 2) { return 495; } if (Level == 3 && spell == 2) { return 466; } if (Level == 4 && spell == 2) { return 385; } if (Level == 5 && spell == 2) { return 357; } if (Level == 3 && spell == 3) { return 300; } if (Level == 4 && spell == 3) { return 255; } if (Level == 5 && spell == 3) { return 215; } if (Level == 4 && spell == 4) { return 650; } if (Level == 5 && spell == 4) { return 618; } if (Level == 5 && spell == 5) { return 300; } return 0; } private boolean isOffCooldown(ItemStack stack, World world) { return !stack.hasTagCompound() || (world.getTotalWorldTime() - stack.getTagCompound().getLong( "LastUseTime")) >= getCooldown(stack); } private void setLastUseTime(ItemStack stack, long time) { stack.setTagInfo("LastUseTime", new NBTTagLong(time)); } public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { if (!world.isRemote) { itemstack.damageItem(1, player); if (itemstack.getTagCompound() == null) { if (itemstack.hasTagCompound() == false) { itemstack.stackTagCompound = new NBTTagCompound(); itemstack.stackTagCompound.setInteger("Spell", 0); itemstack.stackTagCompound.setInteger("Other", 0); itemstack.stackTagCompound.setInteger("XP", 1); itemstack.stackTagCompound.setInteger("Level", 1); itemstack.stackTagCompound.setInteger("Focus", 0); itemstack.stackTagCompound.setString("owner", player.getDisplayName()); } } int Level = itemstack.stackTagCompound.getInteger("Level"); int Other = itemstack.stackTagCompound.getInteger("Other"); int spell = itemstack.stackTagCompound.getInteger("Spell"); int XP = itemstack.stackTagCompound.getInteger("XP"); int Focus = itemstack.stackTagCompound.getInteger("Focus"); String owner = itemstack.stackTagCompound.getString("owner"); boolean isowner = owner.equals(player.getDisplayName()); boolean offCooldown = isOffCooldown(itemstack, world); if (isowner) { if (player.isSneaking()) { if (spell == 0) { itemstack.stackTagCompound.setInteger("Spell", 1); player.addChatMessage(new ChatComponentText( EnumChatFormatting.GRAY + "Slowness Spell")); } if (spell == 1 && XP >= 20) { itemstack.stackTagCompound.setInteger("Spell", 2); player.addChatMessage(new ChatComponentText( EnumChatFormatting.RED + "Explosive Spell")); } else { if (spell == 1 && XP <= 20) { itemstack.stackTagCompound.setInteger("Spell", 0); player.addChatMessage(new ChatComponentText( EnumChatFormatting.BOLD + "Wand")); } } if (spell == 2 && XP >= 30) { itemstack.stackTagCompound.setInteger("Spell", 3); player.addChatMessage(new ChatComponentText( EnumChatFormatting.WHITE + "Chicken Spell")); } else { if (spell == 2 && XP <= 30) { itemstack.stackTagCompound.setInteger("Spell", 0); player.addChatMessage(new ChatComponentText( EnumChatFormatting.BOLD + "Wand")); } } if (spell == 3 && XP >= 65) { itemstack.stackTagCompound.setInteger("Spell", 4); player.addChatMessage(new ChatComponentText( EnumChatFormatting.LIGHT_PURPLE + "Healing Spell")); } else { if (spell == 3 && XP <= 65) { itemstack.stackTagCompound.setInteger("Spell", 0); player.addChatMessage(new ChatComponentText( EnumChatFormatting.BOLD + "Wand")); } } if (spell == 4 && XP >= 105) { itemstack.stackTagCompound.setInteger("Spell", 5); player.addChatMessage(new ChatComponentText( EnumChatFormatting.BOLD + "Fire Spell")); } else { if (spell == 4 && XP <= 105) { itemstack.stackTagCompound.setInteger("Spell", 0); player.addChatMessage(new ChatComponentText( EnumChatFormatting.BOLD + "Wand")); } } if (spell == 5 && XP >= 105) { itemstack.stackTagCompound.setInteger("Spell", 0); player.addChatMessage(new ChatComponentText( EnumChatFormatting.BOLD + "Wand")); } } if (player.isSneaking()) { } else { if (XP >= 19 && Other == 0 && offCooldown) { itemstack.stackTagCompound.setInteger("Other", 1); itemstack.stackTagCompound.setInteger("Level", 2); itemstack.stackTagCompound.setInteger("Focus", 10); player.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA + "You Have Leveled Up!")); player.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA + "You have learned a new spell,")); player.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA + "as well as reduced 10% focus energy")); player.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA + "for all learned spells ")); } if (spell == 1 && offCooldown) { setLastUseTime(itemstack, world.getTotalWorldTime()); player.playSound("fireworks.launch", 1.0f, 1.0f); world.spawnEntityInWorld(new SlownessSpell(world, player)); if (XP > 0) { itemstack.stackTagCompound.setInteger("XP", XP + 1); } } if (XP >= 29 && Other == 1 && offCooldown) { itemstack.stackTagCompound.setInteger("Other", 2); itemstack.stackTagCompound.setInteger("Focus", Focus + 5); itemstack.stackTagCompound.setInteger("Level", 3); player.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA + "You Have Leveled Up!")); player.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA + "You have learned a new spell,")); player.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA + "as well as reduced 5% focus energy")); player.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA + "for all learned spells ")); } if (spell == 2 && offCooldown) { setLastUseTime(itemstack, world.getTotalWorldTime()); player.playSound("fireworks.launch", 1.0f, 1.0f); world.spawnEntityInWorld(new SpellBombardo(world, player)); player.addChatMessage(new ChatComponentText( EnumChatFormatting.RED + "Bombarda!")); if (XP > 0) { itemstack.stackTagCompound.setInteger("XP", XP + 2); } } if (XP >= 64 && Other == 2 && offCooldown) { itemstack.stackTagCompound.setInteger("Other", 3); itemstack.stackTagCompound.setInteger("Focus", Focus + 15); itemstack.stackTagCompound.setInteger("Level", 4); player.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA + "You Have Leveled Up!")); player.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA + "You have learned a new spell,")); player.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA + "as well as reduced 15% focus energy")); player.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA + "for all learned spells ")); } if (spell == 3 && offCooldown) { setLastUseTime(itemstack, world.getTotalWorldTime()); player.playSound("fireworks.launch", 1.0f, 1.0f); world.spawnEntityInWorld(new SpellChicken(world, player)); if (XP > 0) { itemstack.stackTagCompound.setInteger("XP", XP + 1); } } if (XP >= 104 && Other == 3 && offCooldown) { itemstack.stackTagCompound.setInteger("Other", 4); itemstack.stackTagCompound.setInteger("Level", 5); itemstack.stackTagCompound.setInteger("Focus", Focus + 5); player.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA + "You Have Leveled Up!")); player.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA + "You have learned a new spell,")); player.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA + "as well as reduced 5% focus energy")); player.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA + "for all learned spells ")); } if (spell == 4 && offCooldown) { setLastUseTime(itemstack, world.getTotalWorldTime()); player.playSound("fireworks.launch", 1.0f, 1.0f); player.heal(3.0f); if (XP > 0) { itemstack.stackTagCompound.setInteger("XP", XP + 2); } } if (spell == 5 && offCooldown) { setLastUseTime(itemstack, world.getTotalWorldTime()); player.playSound("fireworks.launch", 1.0f, 1.0f); world.spawnEntityInWorld(new SpellIncendio(world, player)); player.addChatMessage(new ChatComponentText( EnumChatFormatting.YELLOW + "Incendio!")); if (XP > 0) { itemstack.stackTagCompound.setInteger("XP", XP + 1); } } } } else if (isowner == false) { } } return itemstack; } public boolean isFull3D() { return true; } public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean i) { list.add(EnumChatFormatting.BOLD + "Wand"); list.add(" "); if (stack.hasTagCompound() == true) { int Focus = stack.stackTagCompound.getInteger("Focus"); int Level = stack.stackTagCompound.getInteger("Level"); int spell = stack.stackTagCompound.getInteger("Spell"); String owner = stack.stackTagCompound.getString("owner"); int XP = stack.stackTagCompound.getInteger("XP"); boolean isowner = owner.equals(player.getDisplayName()); if (isowner) { list.add(EnumChatFormatting.GREEN + "owner: " + owner); if (spell == 1) { list.add(EnumChatFormatting.GRAY + "Slowness Spell"); } if (Level == 2 && spell == 1) { list.add(EnumChatFormatting.GRAY + "-10% Focus Energy"); } if (Level == 3 && spell == 1) { list.add(EnumChatFormatting.GRAY + "-15% Focus Energy"); } if (Level == 4 && spell == 1) { list.add(EnumChatFormatting.GRAY + "-30% Focus Energy"); } if (Level == 5 && spell == 1) { list.add(EnumChatFormatting.GRAY + "-35% Focus Energy"); } if (spell == 2) { list.add(EnumChatFormatting.RED + "Explosive Spell"); } if (Level == 3 && spell == 2) { list.add(EnumChatFormatting.GRAY + "-5% Focus Energy"); } if (Level == 4 && spell == 2) { list.add(EnumChatFormatting.GRAY + "-20% Focus Energy"); } if (Level == 5 && spell == 2) { list.add(EnumChatFormatting.GRAY + "-25% Focus Energy"); } if (spell == 3) { list.add(EnumChatFormatting.WHITE + "Chicken Spell"); } if (Level == 4 && spell == 3) { list.add(EnumChatFormatting.GRAY + "-15% Focus Energy"); } if (Level == 5 && spell == 3) { list.add(EnumChatFormatting.GRAY + "-20% Focus Energy"); } if (spell == 4) { list.add(EnumChatFormatting.LIGHT_PURPLE + "Healing Spell"); } if (Level == 5 && spell == 3) { list.add(EnumChatFormatting.GRAY + "-20% Focus Energy"); } if (spell == 5) { list.add(EnumChatFormatting.LIGHT_PURPLE + "Fire Spell"); } if (spell == 0) { list.add(EnumChatFormatting.WHITE + " "); } list.add(EnumChatFormatting.YELLOW + "Current XP: " + XP); list.add(EnumChatFormatting.GOLD + "Level " + Level + ":"); if (Level == 1) { list.add(EnumChatFormatting.AQUA + "Next Level at: " + EnumChatFormatting.YELLOW + "20 XP"); } if (Level == 2) { list.add(EnumChatFormatting.AQUA + "Next Level at: " + EnumChatFormatting.YELLOW + "30 XP"); } if (Level == 3) { list.add(EnumChatFormatting.AQUA + "Next Level at: " + EnumChatFormatting.YELLOW + "65 XP"); } if (Level == 4) { list.add(EnumChatFormatting.AQUA + "Next Level at: " + EnumChatFormatting.YELLOW + "105 XP"); } } else if (isowner == false) { list.add(EnumChatFormatting.RED + "owner: " + owner); } } } }
  11. so while I was waiting for a reply I wrote this code for the cooldown thing and I want to know the errors and flaws about it just so that in the future I can figure this stuff out by myself. also I get this weird bug with checking if the correct owner is the player who is the owner, I started a lan to test it and when the wand transfers from one inventory to another and back to the owners, the owner no longer has access to the spells and info on the wand. why is this ? package com.OlympiansMod.Item; import java.util.List; import com.OlympiansMod.entity.SlownessSpell; import com.OlympiansMod.entity.SpellBombardo; import com.OlympiansMod.entity.SpellChicken; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagLong; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; public class RandomWand extends Item{ //SlownessSpell public int FIRE_RATE = 300; private boolean isOffCooldown(ItemStack stack, World world) { return !stack.hasTagCompound() || (world.getTotalWorldTime() - stack.getTagCompound().getLong("LastUseTime")) >= FIRE_RATE; } private void setLastUseTime(ItemStack stack, long time) { stack.setTagInfo("LastUseTime", new NBTTagLong(time)); } public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { if (!world.isRemote) { itemstack.damageItem(1, player); if (itemstack.getTagCompound() == null) { if(itemstack.hasTagCompound() == false){ itemstack.stackTagCompound = new NBTTagCompound(); itemstack.stackTagCompound.setInteger("Spell", 0); itemstack.stackTagCompound.setInteger("Other", 0); itemstack.stackTagCompound.setInteger("XP", 1); itemstack.stackTagCompound.setInteger("Level", 1); itemstack.stackTagCompound.setInteger("Focus", 0); itemstack.stackTagCompound.setString("owner", player.getDisplayName()); } } int Level = itemstack.stackTagCompound.getInteger("Level"); int Other = itemstack.stackTagCompound.getInteger("Other"); int spell = itemstack.stackTagCompound.getInteger("Spell"); int XP = itemstack.stackTagCompound.getInteger("XP"); int Focus = itemstack.stackTagCompound.getInteger("Focus"); String owner = itemstack.stackTagCompound.getString("owner"); boolean isowner = owner == player.getDisplayName(); boolean offCooldown = isOffCooldown(itemstack, world); if (isowner) { if (player.isSneaking()) { if (spell == 0) { itemstack.stackTagCompound.setInteger("Spell", 1); player.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "Slowness Spell")); } if(spell == 1 && XP >= 20){ itemstack.stackTagCompound.setInteger("Spell", 2); player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Explosive Spell")); }else{ if(spell == 1 && XP <= 20) { itemstack.stackTagCompound.setInteger("Spell", 0); player.addChatMessage(new ChatComponentText(EnumChatFormatting.BOLD + "Wand")); } } if(spell == 2 && XP >= 30){ itemstack.stackTagCompound.setInteger("Spell", 3); player.addChatMessage(new ChatComponentText(EnumChatFormatting.WHITE + "Chicken Spell")); }else{ if(spell == 2 && XP <= 30) { itemstack.stackTagCompound.setInteger("Spell", 0); player.addChatMessage(new ChatComponentText(EnumChatFormatting.BOLD + "Wand")); } } if(spell == 3 && XP >= 65){ itemstack.stackTagCompound.setInteger("Spell", 4); player.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "Healing Spell")); }else{ if(spell == 3 && XP <= 65) { itemstack.stackTagCompound.setInteger("Spell", 0); player.addChatMessage(new ChatComponentText(EnumChatFormatting.BOLD + "Wand")); } } if(spell == 4 && XP >= 65){ itemstack.stackTagCompound.setInteger("Spell", 0); player.addChatMessage(new ChatComponentText(EnumChatFormatting.BOLD + "Wand")); } } if (player.isSneaking()) { }else{ if(XP >= 19 && Other == 0 && offCooldown){ itemstack.stackTagCompound.setInteger("Other", 1); itemstack.stackTagCompound.setInteger("Level", 2); itemstack.stackTagCompound.setInteger("Focus", 10); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "You Have Leveled Up!")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "You have learned a new spell,")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "as well as reduced 10% focus energy")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "for all learned spells ")); } if(spell == 1 && offCooldown){ if(Level == 2 && spell == 1 ){ FIRE_RATE = 270; }else if(Level == 3){ FIRE_RATE = 255; }else if(Level == 4){ FIRE_RATE = 200; } setLastUseTime(itemstack, world.getTotalWorldTime()); player.playSound("fireworks.launch", 1.0f, 1.0f); world.spawnEntityInWorld(new SlownessSpell(world, player)); if(XP > 0){ itemstack.stackTagCompound.setInteger("XP", XP + 1); } }else{ if(spell == 2 && Level == 2){ FIRE_RATE = 550; }else if(spell == 2 && Level == 3){ FIRE_RATE = 495; }else if(spell == 2 && Level == 4){ FIRE_RATE = 300; } if(spell == 3 && Level == 3){ FIRE_RATE = 300; }else if(spell == 3 && Level == 4){ FIRE_RATE = 270; } if(spell == 4 && Level == 4){ FIRE_RATE = 650; } } if(XP >= 29 && Other == 1 && offCooldown){ itemstack.stackTagCompound.setInteger("Other", 2); itemstack.stackTagCompound.setInteger("Focus", Focus + 5); itemstack.stackTagCompound.setInteger("Level", 3); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "You Have Leveled Up!")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "You have learned a new spell,")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "as well as reduced 5% focus energy")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "for all learned spells ")); } if(spell == 2 && offCooldown){ if(Level == 2 && spell == 2 ){ FIRE_RATE = 550; }else if(Level == 3){ FIRE_RATE = 495; }else if(Level == 4){ FIRE_RATE = 300; } setLastUseTime(itemstack, world.getTotalWorldTime()); player.playSound("fireworks.launch", 1.0f, 1.0f); world.spawnEntityInWorld(new SpellBombardo(world, player)); player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Bombarda!")); if(XP > 0){ itemstack.stackTagCompound.setInteger("XP", XP + 2); } }else{ if(spell == 1 && Level == 1){ FIRE_RATE = 300; }else if(spell == 1 && Level == 2){ FIRE_RATE = 270; }else if(spell == 1 && Level == 3){ FIRE_RATE = 255; }else if(spell == 1 && Level == 4){ FIRE_RATE = 200; } if(spell == 3 && Level == 3){ FIRE_RATE = 300; }else if(spell == 3 && Level == 4){ FIRE_RATE = 270; } if(spell == 4 && Level == 4){ FIRE_RATE = 650; } } if(XP >= 64 && Other == 2 && offCooldown){ itemstack.stackTagCompound.setInteger("Other", 5); itemstack.stackTagCompound.setInteger("Focus", Focus + 15); itemstack.stackTagCompound.setInteger("Level", 4); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "You Have Leveled Up!")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "You have learned a new spell,")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "as well as reduced 15% focus energy")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "for all learned spells ")); } if(spell == 3 && offCooldown){ if(Level == 3 && spell == 3 ){ FIRE_RATE = 270; }else if(Level == 4){ FIRE_RATE = 255; //}else if(Level == 5){ // FIRE_RATE = 200; } setLastUseTime(itemstack, world.getTotalWorldTime()); player.playSound("fireworks.launch", 1.0f, 1.0f); world.spawnEntityInWorld(new SpellChicken(world, player)); if(XP > 0){ itemstack.stackTagCompound.setInteger("XP", XP + 1); } }else{ if(spell == 1 && Level == 1){ FIRE_RATE = 300; }else if(spell == 1 && Level == 2){ FIRE_RATE = 270; }else if(spell == 1 && Level == 3){ FIRE_RATE = 255; }else if(spell == 1 && Level == 4){ FIRE_RATE = 200; } if(spell == 2 && Level == 2){ FIRE_RATE = 550; }else if(spell == 2 && Level == 3){ FIRE_RATE = 495; }else if(spell == 2 && Level == 4){ FIRE_RATE = 300; } if(spell == 4 && Level == 4){ FIRE_RATE = 650; } } if(spell == 4 && offCooldown) { if(Level == 4 && spell == 4 ){ FIRE_RATE = 650; //}else if(Level == 4){ //FIRE_RATE = 255; //}else if(Level == 4){ // FIRE_RATE = 200; } setLastUseTime(itemstack, world.getTotalWorldTime()); player.playSound("fireworks.launch", 1.0f, 1.0f); player.heal(3.0f); if(XP > 0){ itemstack.stackTagCompound.setInteger("XP", XP + 2); } }else{ if(spell == 1 && Level == 1){ FIRE_RATE = 300; }else if(spell == 1 && Level == 2){ FIRE_RATE = 270; }else if(spell == 1 && Level == 3){ FIRE_RATE = 255; }else if(spell == 1 && Level == 4){ FIRE_RATE = 200; } if(spell == 2 && Level == 2){ FIRE_RATE = 550; }else if(spell == 2 && Level == 3){ FIRE_RATE = 495; }else if(spell == 2 && Level == 4){ FIRE_RATE = 300; } if(spell == 3 && Level == 3){ FIRE_RATE = 300; }else if(spell == 3 && Level == 4){ FIRE_RATE = 270; } } } }else if(isowner == false){ } } return itemstack; } public boolean isFull3D() { return true; } public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean i) { list.add(EnumChatFormatting.BOLD + "Wand"); list.add(" "); if(stack.hasTagCompound() == true){ int Focus = stack.stackTagCompound.getInteger("Focus"); int Level = stack.stackTagCompound.getInteger("Level"); int spell = stack.stackTagCompound.getInteger("Spell"); String owner = stack.stackTagCompound.getString("owner"); int XP = stack.stackTagCompound.getInteger("XP"); boolean isowner = owner == player.getDisplayName(); if (isowner) { list.add(EnumChatFormatting.GREEN + "owner: " + owner); if(spell == 1) { list.add(EnumChatFormatting.GRAY + "Slowness Spell"); } if(spell == 2) { list.add(EnumChatFormatting.RED + "Explosive Spell"); } if(spell == 3) { list.add(EnumChatFormatting.WHITE + "Chicken Spell"); } if(spell == 4) { list.add(EnumChatFormatting.LIGHT_PURPLE + "Healing Spell"); } if(spell == 0) { list.add(EnumChatFormatting.WHITE + " "); } list.add(EnumChatFormatting.YELLOW + "Current XP: " + XP); list.add(EnumChatFormatting.GOLD + "Level " + Level +":"); list.add(EnumChatFormatting.AQUA + "-" + Focus + "%" +" Focus Energy"); }else if(isowner == false){ list.add(EnumChatFormatting.RED + "owner: " + owner); } } } } aslo for my question earlier: like this? private int getCooldown(ItemStack stack) { int Level = stack.stackTagCompound.getInteger("Level"); int spell = stack.stackTagCompound.getInteger("Spell"); if(Level == 1 && spell == 1){ return 300; } if(Level == 2 && spell == 1){ return 270; } if(Level == 3 && spell == 1){ return 255; } if(Level == 3 && spell == 1){ return 210; } if(Level == 4 && spell == 2){ return 550; } if(Level == 2 && spell == 2){ return 495; } if(Level == 3 && spell == 2){ return 466; } if(Level == 4 && spell == 2){ return 385; } if(Level == 3 && spell == 3){ return 300; } if(Level == 4 && spell == 3){ return 270; } if(Level == 4 && spell == 4){ return 650; } return 0; } private boolean isOffCooldown(ItemStack stack, World world) { return !stack.hasTagCompound() || (world.getTotalWorldTime() - stack.getTagCompound().getLong("LastUseTime")) >= getCooldown(stack); } private void setLastUseTime(ItemStack stack, long time) { stack.setTagInfo("LastUseTime", new NBTTagLong(time)); }
  12. actually and this is final, the cooldown changes depending on what level and type of spell
  13. okay here is one of my attempts , but im pretty sure I failed because this code has pretty much the same effect as the last(The integer is not staying constant therefore a cooldown will effect all of that item :C how do I fix it) package com.OlympiansMod.Item; import java.util.List; import com.OlympiansMod.entity.SlownessSpell; import com.OlympiansMod.entity.SpellBombardo; import com.OlympiansMod.entity.SpellChicken; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagLong; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; public class RandomWand extends Item{ //SlownessSpell public int FIRE_RATE = 300; public static final int FIRE_RATE1 = 600; public static final int FIRE_RATE2 = 900; public static final int Reduced_FIRE_RATEs = 270; public static final int Reduced_FIRE_RATE1s = 255; public static final int Reduced_FIRE_RATE2s = 200; public static final int Reduced_FIRE_RATEb = 270; public static final int Reduced_FIRE_RATE1b = 255; public static final int Reduced_FIRE_RATE2b = 200; public static final int Reduced_FIRE_RATEc = 270; public static final int Reduced_FIRE_RATE1c = 255; public static final int Reduced_FIRE_RATE2c = 200; public static final int FIRE_RATE3 = 2000; private static final int FIRE_RATEhl = 0; private static final int FIRE_RATE1hl = 0; private static final int FIRE_RATE2hl = 0; private static final int FIRE_RATE2ch = 0; private static final int FIRE_RATE1ch = 0; private static final int FIRE_RATEch = 0; private static final int FIRE_RATE2ex = 0; private static final int FIRE_RATE1ex = 0; private static final int FIRE_RATEex = 0; private boolean isOffCooldown(ItemStack stack, World world) { return !stack.hasTagCompound() || (world.getTotalWorldTime() - stack.getTagCompound().getLong("LastUseTime")) >= FIRE_RATE; } private void setLastUseTime(ItemStack stack, long time) { stack.setTagInfo("LastUseTime", new NBTTagLong(time)); } public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { if (!world.isRemote) { itemstack.damageItem(1, player); if (itemstack.getTagCompound() == null) { if(itemstack.hasTagCompound() == false){ itemstack.stackTagCompound = new NBTTagCompound(); itemstack.stackTagCompound.setInteger("Spell", 0); itemstack.stackTagCompound.setInteger("Other", 0); itemstack.stackTagCompound.setInteger("XP", 1); itemstack.stackTagCompound.setInteger("Level", 1); itemstack.stackTagCompound.setInteger("Focus", 0); itemstack.stackTagCompound.setString("owner", player.getDisplayName()); } } int Level = itemstack.stackTagCompound.getInteger("Level"); int Other = itemstack.stackTagCompound.getInteger("Other"); int spell = itemstack.stackTagCompound.getInteger("Spell"); int XP = itemstack.stackTagCompound.getInteger("XP"); int Focus = itemstack.stackTagCompound.getInteger("Focus"); String owner = itemstack.stackTagCompound.getString("owner"); boolean offCooldown = isOffCooldown(itemstack, world); if (owner == player.getDisplayName()) { if (player.isSneaking()) { if (spell == 0) { itemstack.stackTagCompound.setInteger("Spell", 1); player.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "Slowness Spell")); } if(spell == 1 && XP >= 20){ itemstack.stackTagCompound.setInteger("Spell", 2); player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Explosive Spell")); }else{ if(spell == 1 && XP <= 20) { itemstack.stackTagCompound.setInteger("Spell", 0); player.addChatMessage(new ChatComponentText(EnumChatFormatting.BOLD + "Wand")); } } if(spell == 2 && XP >= 30){ itemstack.stackTagCompound.setInteger("Spell", 3); player.addChatMessage(new ChatComponentText(EnumChatFormatting.WHITE + "Chicken Spell")); }else{ if(spell == 2 && XP <= 30) { itemstack.stackTagCompound.setInteger("Spell", 0); player.addChatMessage(new ChatComponentText(EnumChatFormatting.BOLD + "Wand")); } } if(spell == 3 && XP >= 65){ itemstack.stackTagCompound.setInteger("Spell", 4); player.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "Healing Spell")); }else{ if(spell == 3 && XP <= 65) { itemstack.stackTagCompound.setInteger("Spell", 0); player.addChatMessage(new ChatComponentText(EnumChatFormatting.BOLD + "Wand")); } } if(spell == 4 && XP >= 65){ itemstack.stackTagCompound.setInteger("Spell", 0); player.addChatMessage(new ChatComponentText(EnumChatFormatting.BOLD + "Wand")); } } if (player.isSneaking()) { }else{ if(XP >= 19 && Other == 0){ itemstack.stackTagCompound.setInteger("Other", 1); itemstack.stackTagCompound.setInteger("Level", 2); itemstack.stackTagCompound.setInteger("Focus", 10); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "You Have Leveled Up!")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "You have learned a new spell,")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "as well as reduced 10% focus energy")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "for all learned spells ")); if(spell == 1 && offCooldown){ if(Level == 2){ FIRE_RATE = 270; }else if(Level == 3){ FIRE_RATE = 255; }else if(Level == 4){ FIRE_RATE = 200; } setLastUseTime(itemstack, world.getTotalWorldTime()); player.playSound("fireworks.launch", 1.0f, 1.0f); world.spawnEntityInWorld(new SlownessSpell(world, player)); if(XP > 0){ itemstack.stackTagCompound.setInteger("XP", XP + 1); } } } if(XP >= 29 && Other == 1){ itemstack.stackTagCompound.setInteger("Other", 2); itemstack.stackTagCompound.setInteger("Focus", Focus + 5); itemstack.stackTagCompound.setInteger("Level", 3); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "You Have Leveled Up!")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "You have learned a new spell,")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "as well as reduced 5% focus energy")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "for all learned spells ")); } if(spell == 2 && offCooldown){ FIRE_RATE = 550; setLastUseTime(itemstack, world.getTotalWorldTime()); player.playSound("fireworks.launch", 1.0f, 1.0f); world.spawnEntityInWorld(new SpellBombardo(world, player)); player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Bombarda!")); if(XP > 0){ itemstack.stackTagCompound.setInteger("XP", XP + 2); } }else{ if(spell == 1 && Level == 1){ FIRE_RATE = 300; }else if(spell == 1 && Level == 2){ FIRE_RATE = 270; }else if(spell == 1 && Level == 3){ FIRE_RATE = 255; }else if(spell == 1 && Level == 4){ FIRE_RATE = 200; } } if(XP >= 64 && Other == 2){ itemstack.stackTagCompound.setInteger("Other", 5); itemstack.stackTagCompound.setInteger("Focus", Focus + 15); itemstack.stackTagCompound.setInteger("Level", 4); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "You Have Leveled Up!")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "You have learned a new spell,")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "as well as reduced 15% focus energy")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "for all learned spells ")); } if(spell == 3 && offCooldown){ FIRE_RATE = 300; setLastUseTime(itemstack, world.getTotalWorldTime()); player.playSound("fireworks.launch", 1.0f, 1.0f); world.spawnEntityInWorld(new SpellChicken(world, player)); if(XP > 0){ itemstack.stackTagCompound.setInteger("XP", XP + 1); } } if(spell == 4 && offCooldown) { setLastUseTime(itemstack, world.getTotalWorldTime()); player.playSound("fireworks.launch", 1.0f, 1.0f); player.heal(3.0f); if(XP > 0){ itemstack.stackTagCompound.setInteger("XP", XP + 2); } } } }else if(owner != null){ } } return itemstack; } public boolean isFull3D() { return true; } public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean i) { list.add(EnumChatFormatting.BOLD + "Wand"); list.add(" "); if(stack.hasTagCompound() == true){ int Focus = stack.stackTagCompound.getInteger("Focus"); int Level = stack.stackTagCompound.getInteger("Level"); int spell = stack.stackTagCompound.getInteger("Spell"); String owner = stack.stackTagCompound.getString("owner"); int XP = stack.stackTagCompound.getInteger("XP"); if (owner == player.getDisplayName()) { list.add(EnumChatFormatting.GREEN + "owner: " + owner); if(spell == 1) { list.add(EnumChatFormatting.GRAY + "Slowness Spell"); } if(spell == 2) { list.add(EnumChatFormatting.RED + "Explosive Spell"); } if(spell == 3) { list.add(EnumChatFormatting.WHITE + "Chicken Spell"); } if(spell == 4) { list.add(EnumChatFormatting.LIGHT_PURPLE + "Healing Spell"); } if(spell == 0) { list.add(EnumChatFormatting.WHITE + " "); } list.add(EnumChatFormatting.YELLOW + "Current XP: " + XP); list.add(EnumChatFormatting.GOLD + "Level " + Level +":"); list.add(EnumChatFormatting.AQUA + "-" + Focus + "%" +" Focus Energy"); }else if(owner != null){ list.add(EnumChatFormatting.RED + "owner: " + owner); } } } }
  14. I don't get it, do you mean just change the integer when I need it to be changed? all I got from what you said , is that if I want to change the integer some where in the code I should get the players level and use that number instead of the constant. will you show me an example, or explain it in a way that I can understand it . thank you for your time.
  15. how would I decrement and increment the cooldown through out the code??? I want to decrease cooldowns as u level up
  16. this is what i would do: (remember, you can design your own system to fit your needs, this is just what i would do) have a private final field in your item class containing the cooldown time in ticks. (in this example i'll call it cooldown). timer is the value of the timer (don't know if you want to save it to the nbt or as the dmgValue) in opUpdate(): if(timer > 0){ >>> decrement the timer } in onItemUse(): if(timer <= 0){ >>> use spell >>> reset timer to cooldown } you can use this to get an idea of a possible implementation, but you'll have to implement the actual system yourself, so you can make sure it fits your needs Storing any data in a field of your Item class is a Bad Idea. Item s are singletons, so that cooldown will be shared between all occurrences of that Item . If you need a cooldown, use NBT. how do I add a cooldown using the nbt??
  17. here is one of my attempts before I sleep: int XP = itemstack.stackTagCompound.getInteger("XP"); if(XP < 0){ itemstack.stackTagCompound.setInteger("XP", XP + 1); } if(XP == 5){ player.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "HI")); } It doesn't work why?
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.