2015-12-27 19:38:12 -05:00
|
|
|
package WayofTime.bloodmagic.item.sigil;
|
|
|
|
|
|
|
|
import net.minecraft.entity.item.EntityItem;
|
|
|
|
import net.minecraft.entity.item.EntityXPOrb;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
public class ItemSigilMagnetism extends ItemSigilToggleable
|
|
|
|
{
|
|
|
|
public ItemSigilMagnetism()
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
super("magnetism", 50);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-12-30 15:34:40 -05:00
|
|
|
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
int range = 5;
|
|
|
|
int verticalRange = 5;
|
|
|
|
float posX = Math.round(player.posX);
|
|
|
|
float posY = (float) (player.posY - player.getEyeHeight());
|
|
|
|
float posZ = Math.round(player.posZ);
|
|
|
|
List<EntityItem> entities = player.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.fromBounds(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
|
|
|
|
List<EntityXPOrb> xpOrbs = player.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, AxisAlignedBB.fromBounds(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
|
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
for (EntityItem entity : entities)
|
|
|
|
{
|
|
|
|
if (entity != null && !world.isRemote)
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
entity.onCollideWithPlayer(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
for (EntityXPOrb xpOrb : xpOrbs)
|
|
|
|
{
|
|
|
|
if (xpOrb != null && !world.isRemote)
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
xpOrb.onCollideWithPlayer(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|