123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- package me.km.effects.passive;
- import java.util.HashMap;
- import me.km.KajetansMod;
- import me.km.api.Location;
- import me.km.api.Module;
- import me.km.api.ModuleListener;
- import me.km.api.Utils;
- import me.km.effects.EffectBlockChanger;
- import me.km.effects.EffectUtils;
- import me.km.events.PlayerMoveEvent;
- import me.km.snuviscript.ScriptHelper;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.Blocks;
- import net.minecraft.init.MobEffects;
- import net.minecraft.util.DamageSource;
- import net.minecraft.util.math.BlockPos;
- import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
- public class TrapEffects extends ModuleListener
- {
- private final HashMap<Location, Integer> netTraps;
- private final HashMap<Location, Integer> vineTraps;
- private final HashMap<Location, Integer> nailTraps;
-
- public TrapEffects(Module m)
- {
- super(m);
- netTraps = new HashMap<>();
- vineTraps = new HashMap<>();
- nailTraps = new HashMap<>();
- }
-
- public void addNailTraps(Location l, int id)
- {
- l = l.copy();
- l.round();
- for(int x = -1; x <= 1; x++)
- {
- for(int y = -1; y <= 1; y++)
- {
- nailTraps.put(l.copyAdd(x, 0, y), id);
- }
- }
- }
-
- public void addNetTrap(Location l, int id)
- {
- l = l.copy();
- l.round();
- netTraps.put(l, id);
- }
-
- public void addVineTrap(Location l, int id)
- {
- l = l.copy();
- l.round();
- vineTraps.put(l, id);
- }
-
- public void removeVineTrap(Location l)
- {
- l = l.copy();
- l.round();
- vineTraps.remove(l);
- }
-
- @SubscribeEvent
- public void executeTrap(PlayerMoveEvent e)
- {
- EntityPlayer p = e.getEntityPlayer();
- Location l = new Location(p);
- l.round();
- if(netTraps.containsKey(l))
- {
- Integer i = netTraps.get(l);
- if(!(i < 0 && i == -KajetansMod.playerbank.getDataBank().getIdByUUID(p.getUniqueID().toString())) &&
- i != KajetansMod.playerbank.getGuildId(p))
- {
- netTraps.remove(l);
- BlockPos b = l.getBlockPos();
- EffectBlockChanger changer = new EffectBlockChanger(l.getWorld());
- for(int x = -3; x <= 3; x++)
- {
- for(int y = 0; y <= 3; y++)
- {
- for(int z = -3; z <= 3; z++)
- {
- if((Math.abs(x) == 3 ? 1 : 0) + (Math.abs(y) == 3 ? 1 : 0) + (Math.abs(z) == 3 ? 1 : 0) >= 2)
- {
- continue;
- }
- if(Utils.randomInt(1, 10) >= 3)
- {
- changer.addBlock(b.add(x, y, z), Blocks.WEB);
- }
- }
- }
- }
- changer.run(120);
- }
- }
- if(vineTraps.containsKey(l))
- {
- Integer i = vineTraps.get(l);
- if(!(i < 0 && i == -KajetansMod.playerbank.getDataBank().getIdByUUID(p.getUniqueID().toString())) &&
- i != KajetansMod.playerbank.getGuildId(p))
- {
- EffectUtils.addPotionTo(p, MobEffects.POISON, 60, 2);
- }
- }
- if(nailTraps.containsKey(l))
- {
- Integer i = nailTraps.get(l);
- if(!(i < 0 && i == -KajetansMod.playerbank.getDataBank().getIdByUUID(p.getUniqueID().toString())) &&
- i != KajetansMod.playerbank.getGuildId(p))
- {
- nailTraps.remove(l);
- p.attackEntityFrom(DamageSource.GENERIC, 6);
- EffectUtils.addPotionTo(p, MobEffects.SLOWNESS, 200, 1);
- }
- }
- }
- }
|