2015-12-28 00:38:12 +00:00
|
|
|
package WayofTime.bloodmagic.item.sigil;
|
|
|
|
|
2018-02-16 02:49:01 +00:00
|
|
|
import WayofTime.bloodmagic.util.PleaseStopUsingMe;
|
|
|
|
import WayofTime.bloodmagic.util.helper.PlayerHelper;
|
2015-12-28 00:38:12 +00:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2016-03-18 19:38:26 +00:00
|
|
|
import net.minecraft.init.MobEffects;
|
2015-12-28 00:38:12 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.potion.PotionEffect;
|
2016-10-22 20:11:30 +00:00
|
|
|
import net.minecraft.util.math.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
2015-12-28 00:38:12 +00:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class ItemSigilFastMiner extends ItemSigilToggleableBase {
|
|
|
|
public ItemSigilFastMiner() {
|
2017-08-16 23:39:57 +00:00
|
|
|
super("fast_miner", 100);
|
2015-12-28 00:38:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-16 04:30:48 +00:00
|
|
|
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
2016-11-12 00:57:50 +00:00
|
|
|
if (PlayerHelper.isFakePlayer(player))
|
|
|
|
return;
|
2016-04-24 17:06:28 +00:00
|
|
|
player.addPotionEffect(new PotionEffect(MobEffects.HASTE, 2, 0, true, false));
|
2015-12-28 00:38:12 +00:00
|
|
|
}
|
2016-10-22 20:11:30 +00:00
|
|
|
|
|
|
|
@Override
|
2017-08-16 04:30:48 +00:00
|
|
|
public boolean performArrayEffect(World world, BlockPos pos) {
|
2016-10-22 20:11:30 +00:00
|
|
|
double radius = 10;
|
|
|
|
int ticks = 600;
|
2018-02-28 02:19:41 +00:00
|
|
|
int potionPotency = 2;
|
2016-10-22 20:11:30 +00:00
|
|
|
|
2017-08-16 03:21:54 +00:00
|
|
|
AxisAlignedBB bb = new AxisAlignedBB(pos).grow(radius);
|
2016-10-22 20:11:30 +00:00
|
|
|
List<EntityPlayer> playerList = world.getEntitiesWithinAABB(EntityPlayer.class, bb);
|
2017-08-16 04:30:48 +00:00
|
|
|
for (EntityPlayer player : playerList) {
|
|
|
|
if (!player.isPotionActive(MobEffects.HASTE) || (player.isPotionActive(MobEffects.HASTE) && player.getActivePotionEffect(MobEffects.HASTE).getAmplifier() < potionPotency)) {
|
2016-10-22 20:11:30 +00:00
|
|
|
player.addPotionEffect(new PotionEffect(MobEffects.HASTE, ticks, potionPotency));
|
2017-08-16 04:30:48 +00:00
|
|
|
if (!player.capabilities.isCreativeMode) {
|
2016-10-22 20:11:30 +00:00
|
|
|
player.hurtResistantTime = 0;
|
2018-02-16 02:49:01 +00:00
|
|
|
player.attackEntityFrom(PleaseStopUsingMe.damageSource, 1.0F);
|
2016-10-22 20:11:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-16 04:30:48 +00:00
|
|
|
public boolean hasArrayEffect() {
|
2016-10-22 20:11:30 +00:00
|
|
|
return true;
|
|
|
|
}
|
2015-12-28 00:38:12 +00:00
|
|
|
}
|