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


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by SerpentDagger

  1. For spawning particles within a sphere, you could find randomized positions within a cube of the right size, then not use any position whose distance from the center block is greater than the radius. You can check distance from the center block by using the Pythagorean theorem (a^2 + b^2 + c^2 = d^2 for 3D). A mock-up to find the spawning position: while (!valid) { x = ran.nextFloat(mag * 2) - mag; y = ran.nextFloat(mag * 2) - mag; z = ran.nextFloat(mag * 2) - mag; if ((x*x) + (y*y) + (z*z) > (mag*mag)) { valid = false; } else valid = true; } As for the speed thing, I'm not sure whether or not you can change the velocity of a particle that's already spawned (at least I don't know how to). Regardless, you could set its velocity to (the radius minus the distance from the center block in x y or z) times (some scale factor to get the speeds to look good), either on spawning, or periodically if it's possible. You'll probably then have to kill the particle somehow or it'll slide off the center block when they collide. There might be a way around that, though.
  2. True, though an even easier way of getting rid of attack damage would be to override onLeftClickEntity and return true after the potion effect methods. @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { if (entity instanceof EntityLivingBase) ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 8 * 20, 0)); return true; } That doesn't deal any damage at all, not even fist damage. It doesn't apply knockback, though, so extending ItemSword would still be the way to go if they wanted that. Come to think of it, would the attackDamage correspond to total damage dealt, or additional damage dealt? Meaning, would giving it a value of 0 result in 0 damage + fist damage, or 0 overall, negating the fist damage?
  3. It doesn't have to extend ItemSword specifically, just Item.
  4. If your class extends Item, and you override hitEntity and add the potion effect methods, then the potion effect methods should run when an entity is hit with the item. If you want the extra sword functionalities that the base Item class doesn't have, you should extend ItemSword and do nothing different with hitEntity. If not, you can just keep it as a simple extension of Item.
  5. So you have two items here, one is a miscellaneous sword, and the other is a sword/other with a hit effect? You can get some extra sword-related methods and functionality by extending ItemSword (which in turn extends Item) instead of simply Item, but you can easily make the basic functionalities you're asking about in either, as hitEntity is a method for Items, not specifically ItemSwords. If you want some, but not all of the ItemSword features, you could just re-write some of it in your class. In other words, the extensions are fine, but you may want more functionalities, which could be gotten from the ItemSword class. I'd suggest you take a look at its methods to get a better idea of what it can do. You can just add another of these. E.G: this inside the hitEntity method. target.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 8 * 20, 0)); target.addPotionEffect(new PotionEffect(MobEffects.SPEED, 8 * 20, 0)); If you wanted a flexible, easily expandable set of potion effects, you could also do something like this. Potion[] effectList = new Potion[] { MobEffects.STRENGTH, MobEffects.SPEED }; Iterating through the list in hitEntity. @Override public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { for (Potion current : effectList) { target.addPotionEffect(new PotionEffect(current, 8 * 20, 0)); } stack.damageItem(1, attacker); return true; }
  6. Looking at the EntityAIAttackRanged class, it doesn't seem that what you've done there should cause anything odd to happen. Are the mobs trying (and failing) to attack from abnormally far away, or just in the normal way where they're only missing by a few blocks? If they're going at it from absurdly far, perhaps you could try setting mobs outside their maximum attack range to move toward the player first, then only when they're within it, use setAttackTarget. That could help if they're doing the normal failures too, in that you could check with a distance short enough that they'll never be out of range.
  7. You'll want to override hitEntity inside your sword class, and apply the potion effect inside the overridden method. At the "target.addPotionEffect", you may want to give the effect to the attacker, rather than the target, I'm not sure. @Override public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { target.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 8 * 20, 0)); stack.damageItem(1, attacker); return true; } As for the illegal character... What you were trying to do there was call a method inside the parameters taken in by hitEntity. The parameters are variables fed into hitEntity for it to do things with. When it's called, the stuff int the {} happens. When you hit an entity with your sword, hitEntity is called. The parameters are fed into the method, and the {} happens. Also, EntityLivingBase#addPotionEffect means "the addPotionEffect within instances of EntityLivingBase", rather than being an actual line of executable code. That's why I call it here on the target object, since target is an instance of EntityLivingBase.
  8. That's correct, I'm using 1.12.2. I didn't think those methods would have changed between versions, but it's possible that they did. If so, I'm sorry about the confusion. You may still need to override the two of them, but if it's significantly different in 1.14, then you should take my advice with a grain of salt.
  9. For a similar effect in my mod (translucent crystal), I override isOpaqueCube and getBlockLayer in my block class. @Override public boolean isOpaqueCube(IBlockState state) { return false; } @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.TRANSLUCENT; }
  10. Here are a few sources that I find useful: Forge Documentation: https://mcforge.readthedocs.io/en/latest/ Jabelar's Tutorials: http://jabelarminecraft.blogspot.com/ GreyMinecraftCoder's Tutorials: https://greyminecraftcoder.blogspot.com/ ShadowFacts' Tutorials: http://shadowfacts.net/tutorials/ TheGreyGhost's Example Mod: https://github.com/TheGreyGhost/MinecraftByExample Some of them are for earlier versions, so keep an eye out for that, but they still contain some useful information nonetheless. There are also more sites recommended on the Jabelar's Tutorials page. I haven't looked at them all personally, but a couple that I did check seemed promising. McJty SupperGerrie2 EMX Dark TheGreyGhost CoolAlias TheXFactor117
  • Create New...

Important Information

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