2
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
3.2 KiB
Java

package com.zivilon.cinder_loe.items;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import java.util.List;
import lotr.common.LOTRCreativeTabs;
import lotr.common.LOTRLevelData;
import lotr.common.LOTRMod;
import lotr.common.fac.LOTRFaction;
import lotr.common.network.LOTRPacketHandler;
import lotr.common.network.LOTRPacketWeaponFX;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.potion.Potion;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import com.zivilon.cinder_loe.items.WizardStaff;
public class PallandoStaff extends WizardStaff {
public PallandoStaff() {
super();
}
public ItemStack onEaten(ItemStack itemstack, World world, EntityPlayer entityplayer) {
entityplayer.swingItem();
itemstack.damageItem(2, (EntityLivingBase)entityplayer);
world.playSoundAtEntity((Entity)entityplayer, "lotr:elf.woodElf_teleport", 2.0F, (Item.itemRand.nextFloat() - Item.itemRand.nextFloat()) * 0.2F + 1.0F);
LOTRFaction faction = getFaction(entityplayer);
if (!world.isRemote) {
List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, ((Entity)entityplayer).boundingBox.expand(12.0D, 8.0D, 12.0D));
if (!entities.isEmpty())
for (int i = 0; i < entities.size(); i++) {
EntityLivingBase entity = entities.get(i);
if (entity != entityplayer) {
if (entity instanceof EntityLiving) {
EntityLiving entityliving = (EntityLiving)entity;
if (faction.isGoodRelation(LOTRMod.getNPCFaction((Entity)entityliving)))
continue;
}
if (entity instanceof EntityPlayer)
if (!MinecraftServer.getServer().isPVPEnabled() || LOTRLevelData.getData((EntityPlayer)entity).getAlignment(faction) > 0.0F)
continue;
entity.addPotionEffect(new PotionEffect(Potion.weakness.id, 1200, 0));
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 1200, 0));
}
}
LOTRPacketWeaponFX packet = new LOTRPacketWeaponFX(LOTRPacketWeaponFX.Type.MACE_SAURON, (Entity)entityplayer);
LOTRPacketHandler.networkWrapper.sendToAllAround((IMessage)packet, LOTRPacketHandler.nearEntity((Entity)entityplayer, 64.0D));
}
return itemstack;
}
private LOTRFaction getFaction(EntityPlayer player) {
LOTRFaction faction = LOTRLevelData.getData(player).getPledgeFaction();
if (faction == null) {
faction = LOTRFaction.RHUDEL;
}
return faction;
}
}