Harvest.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package me.km.effects.active;
  2. import me.km.KajetansMod;
  3. import me.km.api.Location;
  4. import me.km.api.Module;
  5. import me.km.effects.ActiveEffectBase;
  6. import net.minecraft.block.BlockCrops;
  7. import net.minecraft.block.state.IBlockState;
  8. import net.minecraft.entity.player.EntityPlayerMP;
  9. import net.minecraft.util.math.BlockPos;
  10. import net.minecraft.world.World;
  11. public class Harvest extends ActiveEffectBase
  12. {
  13. @Override
  14. protected boolean executeEffect(EntityPlayerMP p, int power)
  15. {
  16. int radius = 1 + 2 * power;
  17. World w = p.world;
  18. BlockPos pos = p.getPosition();
  19. BlockPos pos2;
  20. IBlockState b;
  21. for(int x = -radius; x <= radius; x++)
  22. {
  23. for(int y = -radius; y <= radius; y++)
  24. {
  25. for(int z = -radius; z <= radius; z++)
  26. {
  27. pos2 = pos.add(x, y, z);
  28. b = w.getBlockState(pos2);
  29. if(b.getBlock() instanceof BlockCrops && b.getValue(BlockCrops.AGE) == 7)
  30. {
  31. b.getBlock().dropBlockAsItem(w, pos2, b, 0);
  32. w.setBlockState(pos2, b.withProperty(BlockCrops.AGE, 0));
  33. }
  34. }
  35. }
  36. }
  37. KajetansMod.effects.send(p, "Die Pflanzen in deiner Umgebung wurden geerntet!");
  38. return true;
  39. }
  40. @Override
  41. protected int getManaCost(int manaFactor)
  42. {
  43. return 5 * manaFactor;
  44. }
  45. }