Search in sources :

Example 41 with EntityXPOrb

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

the class EntityVeinFloater 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));
        }
        this.entityDropItem(new ItemStack(MPItems.NIBIRU_DUNGEON_KEY_BLADE), 0.5F);
        this.setDead();
        if (this.spawner != null) {
            this.spawner.isBossDefeated = true;
            this.spawner.boss = null;
            this.spawner.spawned = false;
        }
    }
}
Also used : 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)

Example 42 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project BetterWithAddons by DaedalusGame.

the class SoulSandHandler method handleXP.

private void handleXP() {
    if (TrackedItemsIterator == null || !TrackedItemsIterator.hasNext()) {
        TrackedItems.addAll(TrackedItemsAdd);
        TrackedItemsAdd.clear();
        TrackedItemsIterator = TrackedItems.iterator();
    } else {
        EntityXPOrb entity = TrackedItemsIterator.next();
        World world = entity.world;
        int xpValue = entity.getXpValue();
        BlockPos pos = entity.getPosition();
        boolean remove = false;
        if (entity.isDead)
            remove = true;
        else {
            IBlockState state = world.getBlockState(pos);
            if (state.getBlock() != BWMBlocks.AESTHETIC || state.getValue(BlockAesthetic.blockType) != BlockAesthetic.EnumType.DUNG)
                return;
            if (!isValidInfusionWall(world, pos.up(), EnumFacing.DOWN) || !isValidInfusionWall(world, pos.down(), EnumFacing.UP) || !isValidInfusionWall(world, pos.south(), EnumFacing.NORTH) || !isValidInfusionWall(world, pos.north(), EnumFacing.SOUTH) || !isValidInfusionWall(world, pos.west(), EnumFacing.EAST) || !isValidInfusionWall(world, pos.east(), EnumFacing.WEST))
                return;
            AxisAlignedBB aabb = new AxisAlignedBB(pos);
            List<EntityXPOrb> orbs = world.getEntitiesWithinAABB(EntityXPOrb.class, aabb);
            int totalxp = 0;
            for (EntityXPOrb orb : orbs) {
                totalxp += orb.getXpValue();
                orb.setDead();
            }
            if (world.rand.nextInt(50) < totalxp) {
                world.setBlockState(pos, Blocks.SOUL_SAND.getDefaultState());
                for (int i = 0; i < 3; i++) world.playEvent(2004, pos, 0);
            // TODO: burn everybody
            }
        }
        if (remove)
            TrackedItemsIterator.remove();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 43 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project RFTools by McJty.

the class BuilderTileEntity method collectItems.

private void collectItems(World world) {
    // Collect item mode
    collectCounter--;
    if (collectCounter > 0) {
        return;
    }
    collectCounter = BuilderConfiguration.collectTimer;
    if (!loopMode) {
        scan = null;
    }
    int rf = getEnergyStored();
    float area = (maxBox.getX() - minBox.getX() + 1) * (maxBox.getY() - minBox.getY() + 1) * (maxBox.getZ() - minBox.getZ() + 1);
    float infusedFactor = (4.0f - getInfusedFactor()) / 4.0f;
    int rfNeeded = (int) (BuilderConfiguration.collectRFPerTickPerArea * area * infusedFactor) * BuilderConfiguration.collectTimer;
    if (rfNeeded > rf) {
        // Not enough energy.
        return;
    }
    consumeEnergy(rfNeeded);
    AxisAlignedBB bb = new AxisAlignedBB(minBox.getX() - .8, minBox.getY() - .8, minBox.getZ() - .8, maxBox.getX() + .8, maxBox.getY() + .8, maxBox.getZ() + .8);
    List<Entity> items = world.getEntitiesWithinAABB(Entity.class, bb);
    for (Entity entity : items) {
        if (entity instanceof EntityItem) {
            if (collectItem(world, infusedFactor, (EntityItem) entity)) {
                return;
            }
        } else if (entity instanceof EntityXPOrb) {
            if (collectXP(world, infusedFactor, (EntityXPOrb) entity)) {
                return;
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) GenericEnergyReceiverTileEntity(mcjty.lib.entity.GenericEnergyReceiverTileEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntityItem(net.minecraft.entity.item.EntityItem) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 44 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project Random-Things by lumien231.

the class ItemIngredient method onItemUseFinish.

@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
    if (getIngredient(stack) == ItemIngredient.INGREDIENT.LOTUS_BLOSSOM) {
        if (entityLiving instanceof EntityPlayer) {
            EntityPlayer entityplayer = (EntityPlayer) entityLiving;
            if (!worldIn.isRemote) {
                int i = 3 + worldIn.rand.nextInt(5) + worldIn.rand.nextInt(5);
                while (i > 0) {
                    int j = EntityXPOrb.getXPSplit(i);
                    i -= j;
                    worldIn.spawnEntity(new EntityXPOrb(worldIn, entityplayer.posX, entityplayer.posY, entityplayer.posZ, j));
                }
            }
        }
        stack.shrink(1);
        return stack;
    }
    return super.onItemUseFinish(stack, worldIn, entityLiving);
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 45 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project Pearcel-Mod by MiningMark48.

the class TileEntityPedestal method update.

@Override
public void update() {
    World world = getWorld();
    BlockPos pos = getPos();
    int x = pos.getX();
    int y = pos.getY();
    int z = pos.getZ();
    int range = ConfigurationHandler.pearcelMagnetRange;
    float pullSpeed = ConfigurationHandler.pearcelMagnetPullSpeed;
    if (world.getBlockState(pos.up()).getBlock().equals(ModBlocks.ender_pearcel_block)) {
        List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
        List<EntityXPOrb> xp = world.getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
        for (EntityItem e : items) {
            // Attracts
            e.addVelocity((x - e.posX + 0.5) * pullSpeed, (y - e.posY + 0.5) * pullSpeed, (z - e.posZ + 0.5) * pullSpeed);
            if (ConfigurationHandler.pearcelMagnetParticles) {
                world.spawnParticle(EnumParticleTypes.SPELL_INSTANT, e.posX, e.posY + 0.3, e.posZ, 0.0D, 0.0D, 0.0D);
            }
        }
        for (EntityXPOrb e : xp) {
            // Attracts
            e.addVelocity((x - e.posX + 0.5) * pullSpeed, (y - e.posY + 0.5) * pullSpeed, (z - e.posZ + 0.5) * pullSpeed);
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) EntityItem(net.minecraft.entity.item.EntityItem) 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