Search in sources :

Example 36 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project EnderIO by SleepyTrousers.

the class TileKillerJoe method hooverXP.

// ------------------------------- XP
private void hooverXP() {
    double maxDist = Math.max(KillerJoeConfig.killerJoeHooverXpHeight.get(), Math.max(KillerJoeConfig.killerJoeHooverXpLength.get(), KillerJoeConfig.killerJoeHooverXpWidth.get()));
    List<EntityXPOrb> xp = world.getEntitiesWithinAABB(EntityXPOrb.class, getHooverBounds(), null);
    for (EntityXPOrb entity : xp) {
        double xDist = (getPos().getX() + 0.5D - entity.posX);
        double yDist = (getPos().getY() + 0.5D - entity.posY);
        double zDist = (getPos().getZ() + 0.5D - entity.posZ);
        double totalDistance = Math.sqrt(xDist * xDist + yDist * yDist + zDist * zDist);
        if (totalDistance < 1.5) {
            hooverXP(entity);
            if (!needsMending()) {
                return;
            }
        } else if (MagnetUtil.shouldAttract(getPos(), entity)) {
            double d = 1 - (Math.max(0.1, totalDistance) / maxDist);
            double speed = 0.01 + (d * 0.02);
            entity.motionX += xDist / totalDistance * speed;
            entity.motionZ += zDist / totalDistance * speed;
            entity.motionY += yDist / totalDistance * speed;
            if (yDist > 0.5) {
                entity.motionY = 0.12;
            }
            // force client sync because this movement is server-side only
            boolean silent = entity.isSilent();
            entity.setSilent(!silent);
            entity.setSilent(silent);
        }
    }
}
Also used : EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 37 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project EnderIO by SleepyTrousers.

the class TileXPVacuum method doHoover.

private void doHoover() {
    boolean pickUpThisTick = xpCon.getFluidAmount() == 0;
    for (EntityXPOrb entity : world.getEntitiesWithinAABB(EntityXPOrb.class, new BoundingBox(getPos()).expand(VacuumConfig.vacuumXPRange.get()), this)) {
        // note the Predicate parameter
        double x = (pos.getX() + 0.5D - entity.posX);
        double y = (pos.getY() + 0.5D - entity.posY);
        double z = (pos.getZ() + 0.5D - entity.posZ);
        double distance = Math.sqrt(x * x + y * y + z * z);
        if (distance < 1.25) {
            if (pickUpThisTick && !world.isRemote && !entity.isDead) {
                int xpValue = entity.getXpValue();
                xpCon.addExperience(xpValue);
                entity.setDead();
            }
        } else {
            double distScale = Math.min(1d, Math.max(0.25d, 1d - distance / VacuumConfig.vacuumXPRange.get()));
            distScale *= distScale;
            entity.motionX += x / distance * distScale * speed;
            if (entity.posY < pos.getY()) {
                entity.motionY += y / distance * distScale * speed + .03;
            } else {
                entity.motionY += y / distance * distScale * speed;
            }
            entity.motionZ += z / distance * distScale * speed;
        }
    }
}
Also used : BoundingBox(com.enderio.core.client.render.BoundingBox) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 38 with EntityXPOrb

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

the class ItemSigilMagnetism method onSigilUpdate.

@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
    if (PlayerHelper.isFakePlayer(player))
        return;
    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.getEntityWorld().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(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.getEntityWorld().getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(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.isDead) {
            entity.onCollideWithPlayer(player);
        }
    }
    for (EntityXPOrb xpOrb : xpOrbs) {
        if (xpOrb != null && !world.isRemote) {
            xpOrb.onCollideWithPlayer(player);
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityItem(net.minecraft.entity.item.EntityItem) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 39 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project MorePlanets by SteveKunG.

the class EntityBlackHoleStorage method onUpdate.

@Override
public void onUpdate() {
    super.onUpdate();
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    this.move(MoverType.SELF, 0.0D, 0.0D, 0.0D);
    if (this.mainTilePos != null) {
        TileEntity tile = this.world.getTileEntity(this.mainTilePos);
        if (tile == null || !(tile instanceof TileEntityBlackHoleStorage)) {
            this.setDead();
        }
    }
    if (!this.isDisable()) {
        boolean collectAll = this.getCollectMode().equals("item_and_xp");
        if (this.getCollectMode().equals("item") || collectAll) {
            int range = 12;
            for (EntityItem entity : this.world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(this.posX - range, this.posY - range, this.posZ - range, this.posX + range, this.posY + range, this.posZ + range))) {
                double motionX = this.posX - entity.posX;
                double motionY = this.posY - entity.posY + 0.5D;
                double motionZ = this.posZ - entity.posZ;
                entity.motionX = motionX * 0.1F;
                entity.motionY = motionY * 0.1F;
                entity.motionZ = motionZ * 0.1F;
            }
        }
        if (this.getCollectMode().equals("xp") || collectAll) {
            int range = 12;
            for (EntityXPOrb entity : this.world.getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(this.posX - range, this.posY - range, this.posZ - range, this.posX + range, this.posY + range, this.posZ + range))) {
                double motionX = this.posX - entity.posX;
                double motionY = this.posY - entity.posY + 0.5D;
                double motionZ = this.posZ - entity.posZ;
                entity.motionX = motionX * 0.1F;
                entity.motionY = motionY * 0.1F;
                entity.motionZ = motionZ * 0.1F;
                entity.delayBeforeCanPickup = 5;
            }
        }
        if (this.world.isRemote) {
            for (int i = 0; i < 16; ++i) {
                double d0 = this.posX + this.rand.nextFloat();
                double d1 = this.posY + this.rand.nextFloat();
                double d2 = this.posZ + this.rand.nextFloat();
                double d3 = (this.rand.nextFloat() - 0.5D) * 0.5D;
                double d4 = (this.rand.nextFloat() - 0.5D) * 0.5D;
                double d5 = (this.rand.nextFloat() - 0.5D) * 0.5D;
                int j = this.rand.nextInt(2) * 2 - 1;
                d0 = this.posX + 0.25D * j;
                d3 = this.rand.nextFloat() * 2.0F * j;
                d2 = this.posZ + 0.25D * j;
                d5 = this.rand.nextFloat() * 2.0F * j;
                MorePlanetsMod.PROXY.spawnParticle(EnumParticleTypesMP.DARK_PORTAL, d0, d1, d2, d3, d4, d5);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityItem(net.minecraft.entity.item.EntityItem) TileEntityBlackHoleStorage(stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 40 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project MorePlanets by SteveKunG.

the class EntityMiniVeinFloater method onDeathUpdate.

@Override
protected void onDeathUpdate() {
    ++this.deathTicks;
    if (this.deathTicks >= 180 && this.deathTicks <= 200) {
        float f = (this.rand.nextFloat() - 0.5F) * 5.5F;
        float f1 = (this.rand.nextFloat() - 0.5F) * 28.0F;
        float f2 = (this.rand.nextFloat() - 0.5F) * 5.5F;
        this.world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.posX + f, this.posY + 2.0D + f1, this.posZ + f2, 0.0D, 0.0D, 0.0D);
    }
    int i;
    int j;
    if (!this.world.isRemote) {
        if (this.deathTicks >= 180 && this.deathTicks % 5 == 0) {
            GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(EnumSimplePacket.C_PLAY_SOUND_EXPLODE, GCCoreUtil.getDimensionID(this.world), new Object[] {}), new TargetPoint(GCCoreUtil.getDimensionID(this.world), this.posX, this.posY, this.posZ, 40.0D));
        }
        if (this.deathTicks > 150 && this.deathTicks % 5 == 0) {
            i = 200;
            while (i > 0) {
                j = EntityXPOrb.getXPSplit(i);
                i -= j;
                this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY, this.posZ, j));
            }
        }
        if (this.deathTicks == 40) {
            GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(EnumSimplePacket.C_PLAY_SOUND_BOSS_DEATH, GCCoreUtil.getDimensionID(this.world), new Object[] { this.getSoundPitch() - 0.1F }), new TargetPoint(GCCoreUtil.getDimensionID(this.world), this.posX, this.posY, this.posZ, 40.0D));
        }
    }
    if (this.deathTicks == 200 && !this.world.isRemote) {
        i = 200;
        while (i > 0) {
            j = EntityXPOrb.getXPSplit(i);
            i -= j;
            this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY, this.posZ, j));
        }
        TileEntityTreasureChestMP chest = null;
        if (this.spawner != null && this.spawner.getChestPos() != null) {
            TileEntity chestTest = this.world.getTileEntity(this.spawner.getChestPos());
            if (chestTest != null && chestTest instanceof TileEntityTreasureChestMP) {
                chest = (TileEntityTreasureChestMP) chestTest;
            }
        }
        if (chest == null) {
            chest = TileEntityTreasureChestMP.findClosest(this, MPItems.NIBIRU_DUNGEON_KEY);
        }
        if (chest != null) {
            double dist = this.getDistanceSq(chest.getPos().getX() + 0.5, chest.getPos().getY() + 0.5, chest.getPos().getZ() + 0.5);
            if (dist < 1000 * 1000) {
                if (!chest.locked) {
                    chest.locked = true;
                }
                int slot = this.rand.nextInt(chest.getSizeInventory());
                chest.setLootTable(MPLootTables.COMMON_SPACE_DUNGEON, this.rand.nextLong());
                chest.setInventorySlotContents(slot, MPLootTables.getTieredKey(this.rand, 4));
            }
        }
        this.entityDropItem(new ItemStack(MPItems.NIBIRU_DUNGEON_KEY_BOW), 0.5F);
        this.setDead();
        if (this.spawner != null) {
            this.spawner.isBossDefeated = true;
            this.spawner.boss = null;
            this.spawner.spawned = false;
        }
    }
}
Also used : TileEntityTreasureChestMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityTreasureChestMP) TileEntity(net.minecraft.tileentity.TileEntity) PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) ItemStack(net.minecraft.item.ItemStack) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) 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