Search in sources :

Example 46 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project Railcraft by Railcraft.

the class TradeStationLogic method absorbExperience.

private void absorbExperience() {
    double x = getX();
    double y = getY();
    double z = getZ();
    AABBFactory area = AABBFactory.start().setBounds(x, y - 3, z, x + 1, y + 3, z + 1).expandHorizontally(10);
    List<EntityXPOrb> orbs = EntitySearcher.find(EntityXPOrb.class).around(area).in(theWorldAsserted());
    xpCollected += orbs.stream().mapToInt(EntityXPOrb::getXpValue).sum();
    for (EntityXPOrb orb : orbs) {
        SoundHelper.playSoundForEntity(orb, SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1f);
        orb.setDead();
    }
}
Also used : AABBFactory(mods.railcraft.common.util.misc.AABBFactory) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 47 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project MineFactoryReloaded by powercrystals.

the class TileEntitySewer method updateEntity.

@Override
public void updateEntity() {
    super.updateEntity();
    if (worldObj.isRemote) {
        return;
    }
    _tick++;
    if (_nextSewerCheckTick <= worldObj.getTotalWorldTime()) {
        Area a = new Area(BlockPosition.fromFactoryTile(this), _areaManager.getRadius(), 0, 0);
        _jammed = false;
        for (BlockPosition bp : a.getPositionsBottomFirst()) {
            if (worldObj.getBlockId(bp.x, bp.y, bp.z) == MineFactoryReloadedCore.machineBlocks.get(0).blockID && worldObj.getBlockMetadata(bp.x, bp.y, bp.z) == Machine.Sewer.getMeta() && !(bp.x == xCoord && bp.y == yCoord && bp.z == zCoord)) {
                _jammed = true;
                break;
            }
        }
        _nextSewerCheckTick = worldObj.getTotalWorldTime() + 800 + worldObj.rand.nextInt(800);
    }
    if (_tick >= 31 && !_jammed) {
        _tick = 0;
        List<?> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, _areaManager.getHarvestArea().toAxisAlignedBB());
        double massFound = 0;
        for (Object o : entities) {
            if (o instanceof EntityAnimal || o instanceof EntityVillager) {
                massFound += Math.pow(((EntityLiving) o).boundingBox.getAverageEdgeLength(), 2);
            } else if (o instanceof EntityPlayer && ((EntityPlayer) o).isSneaking()) {
                massFound += Math.pow(((EntityLiving) o).boundingBox.getAverageEdgeLength(), 2);
            }
        }
        if (massFound > 0) {
            _tank.fill(LiquidDictionary.getLiquid("sewage", (int) (25 * massFound)), true);
        } else // TODO: add a second tank to the sewer for essence
        if (_tank.getLiquid() == null || _tank.getLiquid().isLiquidEqual(LiquidDictionary.getLiquid("mobEssence", 1))) {
            int maxAmount = Math.max(_tank.getCapacity() - (_tank.getLiquid() != null ? _tank.getLiquid().amount : 0), 0);
            if (maxAmount < 0) {
                return;
            }
            entities = worldObj.getEntitiesWithinAABB(EntityXPOrb.class, _areaManager.getHarvestArea().toAxisAlignedBB());
            for (Object o : entities) {
                Entity e = (Entity) o;
                if (e != null & e instanceof EntityXPOrb && !e.isDead) {
                    EntityXPOrb orb = (EntityXPOrb) o;
                    int found = Math.min(orb.xpValue, maxAmount);
                    orb.xpValue -= found;
                    if (orb.xpValue <= 0) {
                        orb.setDead();
                        found = Math.max(found, 0);
                    }
                    if (found > 0) {
                        found = (int) (found * 66.66666667f);
                        maxAmount -= found;
                        _tank.fill(LiquidDictionary.getLiquid("mobEssence", found), true);
                        if (maxAmount <= 0) {
                            break;
                        }
                    }
                }
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) Area(powercrystals.core.position.Area) EntityLiving(net.minecraft.entity.EntityLiving) BlockPosition(powercrystals.core.position.BlockPosition) EntityVillager(net.minecraft.entity.passive.EntityVillager) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityAnimal(net.minecraft.entity.passive.EntityAnimal) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 48 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project BloodMagic by WayofTime.

the class SigilOfMagnetism method onArmourUpdate.

@Override
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack) {
    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.getBoundingBox(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.getBoundingBox(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
    for (EntityItem entity : entities) {
        if (entity != null && !world.isRemote) {
            entity.onCollideWithPlayer(player);
        }
    }
    for (EntityXPOrb xpOrb : xpOrbs) {
        if (xpOrb != null && !world.isRemote) {
            xpOrb.onCollideWithPlayer(player);
        }
    }
}
Also used : EntityItem(net.minecraft.entity.item.EntityItem) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 49 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project BloodMagic by WayofTime.

the class SigilOfMagnetism method onUpdate.

@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
    if (!(par3Entity instanceof EntityPlayer)) {
        return;
    }
    EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
    if (par1ItemStack.getTagCompound() == null) {
        par1ItemStack.setTagCompound(new NBTTagCompound());
    }
    if (par1ItemStack.getTagCompound().getBoolean("isActive")) {
        if (par2World.getWorldTime() % tickDelay == par1ItemStack.getTagCompound().getInteger("worldTimeDelay")) {
            if (!EnergyItems.syphonBatteries(par1ItemStack, (EntityPlayer) par3Entity, getEnergyUsed())) {
                par1ItemStack.getTagCompound().setBoolean("isActive", false);
            }
        }
        int range = 5;
        int verticalRange = 5;
        float posX = Math.round(par3Entity.posX);
        float posY = (float) (par3Entity.posY - par3Entity.getEyeHeight());
        float posZ = Math.round(par3Entity.posZ);
        List<EntityItem> entities = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(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 = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, AxisAlignedBB.getBoundingBox(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
        for (EntityItem entity : entities) {
            if (entity != null && !par2World.isRemote) {
                entity.onCollideWithPlayer(par3EntityPlayer);
            }
        }
        for (EntityXPOrb xpOrb : xpOrbs) {
            if (xpOrb != null && !par2World.isRemote) {
                xpOrb.onCollideWithPlayer(par3EntityPlayer);
            }
        }
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityItem(net.minecraft.entity.item.EntityItem) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 50 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project Galacticraft by micdoodle8.

the class EntityAlienVillager method useRecipe.

@Override
public void useRecipe(MerchantRecipe recipe) {
    recipe.incrementToolUses();
    this.livingSoundTime = -this.getTalkInterval();
    this.playSound(SoundEvents.ENTITY_VILLAGER_YES, this.getSoundVolume(), this.getSoundPitch());
    int i = 3 + this.rand.nextInt(4);
    if (recipe.getToolUses() == 1 || this.rand.nextInt(5) == 0) {
        this.timeUntilReset = 40;
        this.needsInitilization = true;
        if (this.buyingPlayer != null) {
            this.lastBuyingPlayer = this.buyingPlayer.getName();
        } else {
            this.lastBuyingPlayer = null;
        }
        i += 5;
    }
    if (recipe.getItemToBuy().getItem() == Items.EMERALD) {
        this.wealth += recipe.getItemToBuy().getCount();
    }
    if (recipe.getRewardsExp()) {
        this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY + 0.5D, this.posZ, i));
    }
}
Also used : EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Aggregations

EntityXPOrb (net.minecraft.entity.item.EntityXPOrb)50 EntityItem (net.minecraft.entity.item.EntityItem)17 ItemStack (net.minecraft.item.ItemStack)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)12 TileEntity (net.minecraft.tileentity.TileEntity)11 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)9 TargetPoint (net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)8 ArrayList (java.util.ArrayList)5 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)5 BlockPos (net.minecraft.util.math.BlockPos)5 Entity (org.spongepowered.api.entity.Entity)5 Entity (net.minecraft.entity.Entity)4 User (org.spongepowered.api.entity.living.player.User)4 SpawnEntityEvent (org.spongepowered.api.event.entity.SpawnEntityEvent)4 Vector3d (com.flowpowered.math.vector.Vector3d)3 Player (org.spongepowered.api.entity.living.player.Player)3 Projectile (org.spongepowered.api.entity.projectile.Projectile)3 CauseStackManager (org.spongepowered.api.event.CauseStackManager)3 GDEvents (androsa.gaiadimension.registry.GDEvents)2 Collection (java.util.Collection)2