GoldRiverEffects.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package me.km.effects.passive;
  2. import me.km.KajetansMod;
  3. import me.km.api.Module;
  4. import me.km.api.ModuleListener;
  5. import me.km.api.Utils;
  6. import me.km.effects.Effect;
  7. import me.km.effects.EffectUtils;
  8. import me.km.plots.ProtectionBank;
  9. import me.km.utils.ItemStackBuilder;
  10. import net.minecraft.block.Block;
  11. import net.minecraft.entity.player.EntityPlayer;
  12. import net.minecraft.init.Blocks;
  13. import net.minecraft.init.Items;
  14. import net.minecraft.item.Item;
  15. import net.minecraft.item.ItemSpade;
  16. import net.minecraft.util.EnumHand;
  17. import net.minecraft.util.math.BlockPos;
  18. import net.minecraft.world.World;
  19. import net.minecraftforge.event.entity.player.PlayerInteractEvent;
  20. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  21. public class GoldRiverEffects extends ModuleListener
  22. {
  23. public GoldRiverEffects(Module m)
  24. {
  25. super(m);
  26. }
  27. @SubscribeEvent
  28. public void GoldWashingEvent(PlayerInteractEvent.RightClickBlock e)
  29. {
  30. if(e.getHand() == EnumHand.OFF_HAND || KajetansMod.worldManager.getWorldPreferences(e.getWorld()).skills)
  31. {
  32. return;
  33. }
  34. World w = e.getWorld();
  35. BlockPos pos = e.getPos();
  36. if(!KajetansMod.plots.getDataBank(ProtectionBank.class).hasTag(w, pos, "gold") ||
  37. w.isAirBlock(pos))
  38. {
  39. return;
  40. }
  41. EntityPlayer p = e.getEntityPlayer();
  42. if(!p.isInWater())
  43. {
  44. return;
  45. }
  46. Item item = p.getHeldItemMainhand().getItem();
  47. Block b = w.getBlockState(pos).getBlock();
  48. if(b == Blocks.GOLD_ORE && item == Items.BOWL && EffectUtils.getEffectLevel(p, Effect.GOLD_WASHER) >= 1)
  49. {
  50. new ItemStackBuilder(Items.GOLD_NUGGET, Utils.randomInt(1, 2)).drop(w, pos.add(0, 1, 0));
  51. this.getModule().send(p, "Du hast Gold gefunden!");
  52. if(Utils.randomInt(1, 4) == 1)
  53. {
  54. this.getModule().send(p, "Die Goldader ist erschöpft!");
  55. w.setBlockState(pos, Blocks.STONE.getDefaultState());
  56. }
  57. }
  58. else if(b == Blocks.GOLD_ORE && item instanceof ItemSpade && EffectUtils.getEffectLevel(p, Effect.GOLD_RUSH) >= 1)
  59. {
  60. this.getModule().send(p, "Du hast eine neue Goldader gefunden!");
  61. w.setBlockState(pos, Blocks.GOLD_ORE.getDefaultState());
  62. p.getHeldItemMainhand().damageItem(15, p);
  63. }
  64. }
  65. }