package me.km.effects.passive; import me.km.KajetansMod; import me.km.api.Module; import me.km.api.ModuleListener; import me.km.api.Utils; import me.km.effects.Effect; import me.km.effects.EffectUtils; import me.km.plots.ProtectionBank; import me.km.utils.ItemStackBuilder; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemSpade; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class GoldRiverEffects extends ModuleListener { public GoldRiverEffects(Module m) { super(m); } @SubscribeEvent public void GoldWashingEvent(PlayerInteractEvent.RightClickBlock e) { if(e.getHand() == EnumHand.OFF_HAND || KajetansMod.worldManager.getWorldPreferences(e.getWorld()).skills) { return; } World w = e.getWorld(); BlockPos pos = e.getPos(); if(!KajetansMod.plots.getDataBank(ProtectionBank.class).hasTag(w, pos, "gold") || w.isAirBlock(pos)) { return; } EntityPlayer p = e.getEntityPlayer(); if(!p.isInWater()) { return; } Item item = p.getHeldItemMainhand().getItem(); Block b = w.getBlockState(pos).getBlock(); if(b == Blocks.GOLD_ORE && item == Items.BOWL && EffectUtils.getEffectLevel(p, Effect.GOLD_WASHER) >= 1) { new ItemStackBuilder(Items.GOLD_NUGGET, Utils.randomInt(1, 2)).drop(w, pos.add(0, 1, 0)); this.getModule().send(p, "Du hast Gold gefunden!"); if(Utils.randomInt(1, 4) == 1) { this.getModule().send(p, "Die Goldader ist erschöpft!"); w.setBlockState(pos, Blocks.STONE.getDefaultState()); } } else if(b == Blocks.GOLD_ORE && item instanceof ItemSpade && EffectUtils.getEffectLevel(p, Effect.GOLD_RUSH) >= 1) { this.getModule().send(p, "Du hast eine neue Goldader gefunden!"); w.setBlockState(pos, Blocks.GOLD_ORE.getDefaultState()); p.getHeldItemMainhand().damageItem(15, p); } } }