Advertisement
Guest User

Stuff

a guest
Aug 13th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. package com.smashmod.items;
  2.  
  3. import com.example.examplemod.ExampleMod;
  4.  
  5.  
  6. import net.minecraft.enchantment.Enchantment;
  7. import net.minecraft.entity.Entity;
  8. import net.minecraft.entity.EntityLiving;
  9. import net.minecraft.entity.player.EntityPlayer;
  10. import net.minecraft.item.ItemStack;
  11. import net.minecraft.item.ItemSword;
  12. import net.minecraft.util.BlockPos;
  13. import net.minecraft.util.EnumFacing;
  14. import net.minecraft.util.EnumParticleTypes;
  15. import net.minecraft.world.World;
  16.  
  17. public class MetaSword extends ItemSword {
  18.  
  19. public String name = "METASWORD";
  20.  
  21.  
  22. public MetaSword() {
  23. super(ExampleMod.customToolMaterial2);
  24. this.setUnlocalizedName("METASWORD");
  25. this.setCreativeTab(ExampleMod.smashMod);
  26. this.setMaxStackSize(1);
  27. }
  28.  
  29. public void onUpdate(ItemStack itemstack, World par2World, Entity par3Entity, int par4, boolean par5)
  30. {
  31. if(itemstack.isItemEnchanted()==false){
  32. itemstack.addEnchantment(Enchantment.knockback, 5);
  33. itemstack.addEnchantment(Enchantment.fireAspect, 5);
  34. itemstack.addEnchantment(Enchantment.sharpness, 10);
  35. }
  36. }
  37.  
  38. @Override
  39. public boolean onItemUse(ItemStack stack, EntityPlayer playerIn,
  40. World worldIn, BlockPos pos, EnumFacing side, float hitX,
  41. float hitY, float hitZ) {
  42. // TODO Auto-generated method stub
  43.  
  44.  
  45. return true;
  46. }
  47.  
  48. @Override
  49. public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn,
  50. EntityPlayer playerIn) {
  51. playerIn.swingItem();
  52. //System.out.println("swung");
  53. for (int x = playerIn.getPosition().getX() - 3; x < playerIn.getPosition().getX() + 3; x++){
  54. //System.out.println("inside x");
  55. for (int y = playerIn.getPosition().getY() - 3; y < playerIn.getPosition().getY() + 3;y++){
  56. for (int z = playerIn.getPosition().getZ() - 3; z < playerIn.getPosition().getZ() + 3; z++){
  57. //System.out.println("Inside z");
  58. for (Object o: worldIn.getLoadedEntityList()){
  59. EntityLiving e;
  60. //System.out.println("Inside entity check");
  61. try {
  62. e = (EntityLiving)o;
  63. } catch (Exception ex){
  64. continue;
  65. }
  66. if (e.equals(playerIn)) continue;
  67. if (e.getPosition().getX() == x && e.getPosition().getY() == y && e.getPosition().getZ() == z){
  68. e.performHurtAnimation();
  69. //e.setHealth(e.getHealth() - 8);
  70. e.attackEntityFrom(ExampleMod.metapower, 14);
  71.  
  72.  
  73.  
  74. worldIn.spawnParticle(EnumParticleTypes.CRIT, x, y+2, z, 0, 0, 0, new int [0]);
  75.  
  76. }
  77. }//entities
  78.  
  79. }//z
  80. }//y
  81.  
  82. }//x
  83.  
  84.  
  85. return itemStackIn;
  86. }
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement