Jump to content

Monstrous_Apple

Members
  • Posts

    217
  • Joined

  • Last visited

Everything posted by Monstrous_Apple

  1. Okay I'll say what I need to do at this moment, I need it so that when I am not holding the item, the potion effect goes completely, even if it starts at 4 seconds, ends at 0 seconds, and currently is on 2 seconds duration left, it will disappear. I also need it so that when holding the item the duration of the potion effect still ticks even while holding the item, so that regeneration will work, so for example I hold the gem it gives 4 seconds of regeneration, it ticks down to 0 and then refreshes to 4 again, but of course if the item is not held at any point, the regeneration effect completely goes even if it's not reached 0 seconds yet. This is what my code looks like at the moment: package com.MonstrousApple.mod.gemstones; import com.MonstrousApple.mod.MAGlobal; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.stats.StatList; import net.minecraft.world.World; public class MAVitalityGemstone extends Item { public MAVitalityGemstone(String unlocalizedName) { super(); this.setUnlocalizedName(unlocalizedName); this.setCreativeTab(MAGlobal.maCreativeTabGemstones); this.setMaxStackSize(1); } public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag) { if (entity instanceof EntityPlayer) { EntityPlayer Player = (EntityPlayer) entity; if(Player.getCurrentEquippedItem() != null && Player.getCurrentEquippedItem().getItem() instanceof MAVitalityGemstone) { Player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 50, 1 - 1)); } else { Player.removePotionEffect(i); } } } } }
  2. This doesn't need changing because at the moment if I am not holding my item the effect goes, well at least I don't think it needs changing? Why? Or at least clarify what you mean? No it's not useless because what I want to happen is only give the effect when held, so that means it can still be in your inventory and then it will not give the effect. Was testing something lol
  3. This doesn't need changing because at the moment if I am not holding my item the effect goes, well at least I don't think it needs changing? Why? Or at least clarify what you mean? No it's not useless because what I want to happen is only give the effect when held, so that means it can still be in your inventory and then it will not give the effect. Was testing something lol
  4. Okay now I have it so that when you hold the item then you will have the potion effects but now I need the timer to tick down so I can effects like regeneration to work, how would I do this? Here's my code: package com.MonstrousApple.mod.gemstones; import com.MonstrousApple.mod.MAGlobal; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.stats.StatList; import net.minecraft.world.World; public class MAVitalityGemstone extends Item { public MAVitalityGemstone(String unlocalizedName) { super(); this.setUnlocalizedName(unlocalizedName); this.setCreativeTab(MAGlobal.maCreativeTabGemstones); this.setMaxStackSize(1); } private void effectPlayer(EntityPlayer player, Potion potion, int amplifier) { if (player.getActivePotionEffect(potion)== null || player.getActivePotionEffect(potion).getDuration() <=40) player.addPotionEffect(new PotionEffect(potion.id, 40 /** Duration */, amplifier, true, true)); } public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag) { if (entity instanceof EntityPlayer) { EntityPlayer Player = (EntityPlayer) entity; if(Player.getCurrentEquippedItem() != null && Player.getCurrentEquippedItem().getItem() instanceof MAVitalityGemstone) { Player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 1 - 1)); } else { Player.removePotionEffect(i); } } /**@Override public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if(stack.getItem() == MAGemstones.VitalityGemstone) { effectPlayer(entityIn, Potion.regeneration, 1 - 1); super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected); } } private void effectPlayer(Entity entityIn, Potion potion, int amplifier) { //((EntityLivingBase) entityIn).addPotionEffect(new PotionEffect(potion.id, 40, amplifier, true, true)); EntityLivingBase player = (EntityLivingBase) entityIn; if (player.getActivePotionEffect(potion)== null || player.getActivePotionEffect(potion).getDuration() <=0) player.addPotionEffect(new PotionEffect(potion.id, 40 /** Duration *///, amplifier, true, true)); } }
  5. Okay thanks both I'll try and find it using both your methods.
  6. Okay thanks for your help.
  7. Sorry small question, can anyone tell me where in my IDE I can find the emerald ore world generation class? This is so I can make my custom ores generate only in the Extreme Hills biome and with the same spawn chances, etc.
  8. Can I ask why "sort of..."? It seems to work perfectly fine, what would go wrong if I didn't change it? Just so I know please
  9. So is this how I do it? I had a look at the minecraft code itself (I couldn't find it before) and I used this code and changed it so that it does my ores instead. @Override public int getExpDrop(net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) { IBlockState state = world.getBlockState(pos); Random rand = world instanceof World ? ((World)world).rand : new Random(); if (this.getItemDropped(state, rand, fortune) != Item.getItemFromBlock(this)) { int i = 0; if (this == MAGems.SapphireOre) { i = MathHelper.getRandomIntegerInRange(rand, 1, 3); } else if (this == MAGems.RubyOre) { i = MathHelper.getRandomIntegerInRange(rand, 30, 40); } return i; } return 0; } public int getDamageValue(World worldIn, BlockPos pos) { return 0; }
  10. If I don't call super then what do I call? When I call super it makes my ore drop exp, even if it's a set amount (instead of a random amount like 3-7) but if I take away super it doesn't drop exp so it may not be the best way but at least it's making my exp drop...
  11. Is this correct so far then? @Override public int getExpDrop(IBlockAccess world, BlockPos metadata, int fortune) { super.getExpDrop(world, metadata, fortune); MathHelper.getRandomIntegerInRange(rand, 3, 7); //return 20; }
  12. So what should I do? And also once I get the set amount of exp done, could you help me with making it so that its like emerald ore where it drops a random amount?
  13. This was the only way to make it drop 2 exp though for me I mean, also yeah I still need to drop random amounts (same as emeralds) Edit: Wait I changed "super." to "this." will that be better then? Edit 2: Never mind changing it to this makes me drop no exp, why shouldn't I be using super though? It seems to make it work?
  14. Sorry just as you sent that I figured it out, well at least this works and gives me exp, would you say this is the correct way to do it? @Override public int getExpDrop(IBlockAccess world, BlockPos metadata, int fortune) { super.getExpDrop(world, metadata, fortune); return 2; }
  15. This tells me to remove the @override? Am I going in the right direction though? @Override public int getExpDrop(IBlockAccess world, int metadata, int fortune) { return 2; }
  16. Okay I know this isn't correct, there's no errors but I tested it and I don't get exp drops, could you explain what I did wrong please? public void getExpDrop(World world, BlockPos pos, IBlockState state, EntityPlayer player, int fortune) { this.getExpDrop(world, pos, 3 + world.rand.nextInt(5)); }
  17. Would I have to change public class MAGem extends Block { to public class MAGem extends BlockOre { ?
  18. Okay I have three problems: 1). When mining my sapphire/ruby ore using a silk touch pickaxe it DOES drop the ore instead of gem however it still grants exp, how can I cancel that out? 2). When breaking a sapphire/ruby ore whilst in gamemode creative it still grants exp, how can I stop that? 3). The sapphire and ruby can only be mined using a iron or higher pickaxe, and normally using a stone or lower pickaxe would mean no drop for the player, however when doing this with silk touch it still grants exp with no ore or gem drop, how do I stop the exp? Sorry if that doesn't make much sense. package com.MonstrousApple.mod.gems; import java.util.Random; import com.MonstrousApple.mod.MAGlobal; import com.MonstrousApple.mod.items.MAItems; import com.MonstrousApple.mod.ores.MAOres; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.util.BlockPos; import net.minecraft.world.World; public class MAGem extends Block { public MAGem(String unlocalizedName, Material material, float hardness, float resistance) { super(material); this.setCreativeTab(MAGlobal.maCreativeTabOres); this.setUnlocalizedName(unlocalizedName); this.setHardness(hardness); this.setResistance(resistance); } @Override public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) { this.dropXpOnBlockBreak(world, pos, 3 + world.rand.nextInt(5)); } @Override public Item getItemDropped(IBlockState state, Random random, int fortune) { if (this == MAGems.SapphireOre) { return MAItems.Sapphire; } else if (this == MAGems.RubyOre) { return MAItems.Ruby; } else { return null; } } public int quantityDropped(Random random) { return 1; } public int quantityDroppedWithBonus(int fortune, Random random) { if (fortune > 0) { int j = random.nextInt(fortune + 2) - 1; if (j < 0) { j = 0; } return quantityDropped(random) * (j + 1); } else { return quantityDropped(random); } } /**public int quantityDropped(IBlockState state, int fortune, Random random) { if (this == MAGems.SapphireOre) { return 1 + random.nextInt(1); } else if (this == MAGems.RubyOre) { return 1 + random.nextInt(1); } else { return 0; } }*/ }
  19. No it does regenerate but I want it to only work if holding it in your hand rather than in your inventory without being selected, if that makes sense? No it does regenerate but I want it to only work if holding it in your hand rather than in your inventory without being selected, if that makes sense? Yeah but it still gives regeneration 1 even when not selected how do I change this? Also I would update to 1.9 but I just don't like the combat system changes just my preference haha thanks though.
  20. Okay so at the moment my gemstone gives the person regeneration 1 while it's in their inventory but what I want to happen is only while the player is holding the gemstone it will give the potion effect, does anyone know how to do this? package com.MonstrousApple.mod.gemstones; import com.MonstrousApple.mod.MAGlobal; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.stats.StatList; import net.minecraft.world.World; public class MAVitalityGemstone extends Item { public MAVitalityGemstone(String unlocalizedName) { super(); this.setUnlocalizedName(unlocalizedName); this.setCreativeTab(MAGlobal.maCreativeTabGemstones); this.setMaxStackSize(1); } @Override public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if(stack.getItem() == MAGemstones.VitalityGemstone) { effectPlayer(entityIn, Potion.regeneration, 1 - 1); super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected); } } private void effectPlayer(Entity entityIn, Potion potion, int amplifier) { //((EntityLivingBase) entityIn).addPotionEffect(new PotionEffect(potion.id, 40, amplifier, true, true)); EntityLivingBase player = (EntityLivingBase) entityIn; if (player.getActivePotionEffect(potion)== null || player.getActivePotionEffect(potion).getDuration() <=0) player.addPotionEffect(new PotionEffect(potion.id, 40 /** Duration */, amplifier, true, true)); } }
  21. Okay but I need it the exact same effect as on diamond ore?
  22. So like this? Or is there more to add? package com.MonstrousApple.mod.gems; import java.util.Random; import com.MonstrousApple.mod.MAGlobal; import com.MonstrousApple.mod.items.MAItems; import com.MonstrousApple.mod.ores.MAOres; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Items; import net.minecraft.item.Item; public class MAGem extends Block { public MAGem(String unlocalizedName, Material material, float hardness, float resistance) { super(material); this.setCreativeTab(MAGlobal.maCreativeTabOres); this.setUnlocalizedName(unlocalizedName); this.setHardness(hardness); this.setResistance(resistance); } @Override public Item getItemDropped(IBlockState state, Random random, int fortune) { if (this == MAGems.SapphireOre) { return MAItems.Sapphire; } else if (this == MAGems.RubyOre) { return MAItems.Ruby; } else if (this == MAGems.DiamondOre) { return Items.diamond; } else { return null; } } public int quantityDropped(IBlockState state, int fortune, Random random) { if (this == MAGems.SapphireOre) { return 4 + random.nextInt(5); } else if (this == MAGems.RubyOre) { return 4 + random.nextInt(5); } else { return 0; } } }
  23. So I have this code which makes it so that my ores drop an item rather than themselves (like Diamond Ore does) but I can't get it to drop more with fortune, how would I make it so that they multiply with fortune like diamond ore does? package com.MonstrousApple.mod.gems; import java.util.Random; import com.MonstrousApple.mod.MAGlobal; import com.MonstrousApple.mod.items.MAItems; import com.MonstrousApple.mod.ores.MAOres; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Items; import net.minecraft.item.Item; public class MAGem extends Block { public MAGem(String unlocalizedName, Material material, float hardness, float resistance) { super(material); this.setCreativeTab(MAGlobal.maCreativeTabOres); this.setUnlocalizedName(unlocalizedName); this.setHardness(hardness); this.setResistance(resistance); } public Item getItemDropped(IBlockState state, Random rand, int fortune) { if (this == MAGems.SapphireOre) { return MAItems.Sapphire; } else if (this == MAGems.RubyOre) { return MAItems.Ruby; } else { return null; } } public int quantityDropped(Random random) { if (this == MAGems.SapphireOre) { return 4 + random.nextInt(5); } else if (this == MAGems.RubyOre) { return 4 + random.nextInt(5); } else { return 0; } } }
  24. Is there a way to change the vanilla armor values without removing the vanilla versions and remaking them myself? For example I want to change it so that diamond armor gives a total of 8 out of 10 armor slots rather than 10/10, is there a way to do this?
×
×
  • Create New...

Important Information

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