Harvest.java 1.4 KB

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