Search in sources :

Example 11 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 12 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.TYPE) != 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 13 with EntityXPOrb

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

the class EntityNibiruVillager 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;
        this.isWillingToMate = true;
        if (this.buyingPlayer != null) {
            this.lastBuyingPlayer = this.buyingPlayer.getUniqueID();
        } 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)

Example 14 with EntityXPOrb

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

the class EntityVeinFloater method onDeathUpdate.

@Override
protected void onDeathUpdate() {
    this.world.playEvent(1010, this.getPosition(), 0);
    ++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(NibiruItems.NIBIRU_DUNGEON_KEY, 1, this.rand.nextBoolean() ? 1 : 2), 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 15 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;
            List<EntityItem> entitiesAroundBH = 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));
            for (EntityItem entity : entitiesAroundBH) {
                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;
            List<EntityXPOrb> entitiesAroundBH = 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));
            for (EntityXPOrb entity : entitiesAroundBH) {
                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;
                MorePlanetsCore.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)

Aggregations

EntityXPOrb (net.minecraft.entity.item.EntityXPOrb)16 EntityItem (net.minecraft.entity.item.EntityItem)6 ItemStack (net.minecraft.item.ItemStack)5 TileEntity (net.minecraft.tileentity.TileEntity)5 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)4 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)4 TargetPoint (net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 TileEntityTreasureChestMP (stevekung.mods.moreplanets.util.tileentity.TileEntityTreasureChestMP)3 EntityLiving (net.minecraft.entity.EntityLiving)2 BlockPos (net.minecraft.util.math.BlockPos)2 World (net.minecraft.world.World)2 NotNull (org.jetbrains.annotations.NotNull)2 List (java.util.List)1 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 Entity (net.minecraft.entity.Entity)1 EntityAnimal (net.minecraft.entity.passive.EntityAnimal)1 EntityVillager (net.minecraft.entity.passive.EntityVillager)1