Search in sources :

Example 6 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, 6);
        }
        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, 5));
            }
        }
        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 : TileEntityTreasureChestMP(stevekung.mods.moreplanets.util.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)

Example 7 with EntityXPOrb

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

the class EntityCheeseCubeEyeBoss method onDeathUpdate.

@Override
protected void onDeathUpdate() {
    ++this.deathTicks;
    if (this.deathTicks >= 180 && this.deathTicks <= 200) {
        float f = (this.rand.nextFloat() - 0.5F) * 1.5F;
        float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F;
        float f2 = (this.rand.nextFloat() - 0.5F) * 1.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 = 150;
            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));
        }
    }
    this.move(MoverType.SELF, 0.0D, -0.10000000149011612D, 0.0D);
    if (this.deathTicks == 200 && !this.world.isRemote) {
        i = 150;
        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, 5);
        }
        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, 5));
            }
        }
        this.entityDropItem(new ItemStack(ChalosItems.CHALOS_DUNGEON_KEY, 1, 0), 0.5F);
        super.setDead();
        if (this.spawner != null) {
            this.spawner.isBossDefeated = true;
            this.spawner.boss = null;
            this.spawner.spawned = false;
        }
    }
}
Also used : TileEntityTreasureChestMP(stevekung.mods.moreplanets.util.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)

Example 8 with EntityXPOrb

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

the class EntitySpaceFishHook method handleHookRetraction.

@Override
public int handleHookRetraction() {
    if (!this.world.isRemote && this.angler != null) {
        int i = 0;
        if (this.caughtEntity != null) {
            this.bringInHookedEntity();
            this.world.setEntityState(this, (byte) 31);
            i = this.caughtEntity instanceof EntityItem ? 3 : 5;
        } else if (this.ticksCatchable > 0) {
            LootContext.Builder lootcontext$builder = new LootContext.Builder((WorldServer) this.world);
            lootcontext$builder.withLuck(this.luck + this.angler.getLuck());
            double x = MathHelper.floor(this.posX);
            double y = MathHelper.floor(this.getEntityBoundingBox().minY) + 1.0F;
            double z = MathHelper.floor(this.posZ);
            Block block = this.world.getBlockState(new BlockPos(x, y - 1, z)).getBlock();
            ResourceLocation resource = block instanceof IFishableLiquidBlock ? ((IFishableLiquidBlock) block).getLootTable() : this.world.provider instanceof IGalacticraftWorldProvider ? MPLootTables.SPACE_FISHING : LootTableList.GAMEPLAY_FISHING;
            List<ItemStack> result = this.world.getLootTableManager().getLootTableFromLocation(resource).generateLootForPools(this.rand, lootcontext$builder.build());
            for (ItemStack itemstack : result) {
                EntityItem entityitem = new EntityItem(this.world, this.posX, this.posY, this.posZ, itemstack);
                double d0 = this.angler.posX - this.posX;
                double d1 = this.angler.posY - this.posY;
                double d2 = this.angler.posZ - this.posZ;
                double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
                entityitem.motionX = d0 * 0.1D;
                entityitem.motionY = d1 * 0.1D + MathHelper.sqrt(d3) * 0.08D;
                entityitem.motionZ = d2 * 0.1D;
                this.world.spawnEntity(entityitem);
                this.angler.world.spawnEntity(new EntityXPOrb(this.angler.world, this.angler.posX, this.angler.posY + 0.5D, this.angler.posZ + 0.5D, this.rand.nextInt(6) + 1));
                Item item = itemstack.getItem();
                if (item == Items.FISH || item == Items.COOKED_FISH) {
                    this.angler.addStat(StatList.FISH_CAUGHT, 1);
                }
            }
            i = 1;
        }
        if (this.inGround) {
            i = 2;
        }
        this.setDead();
        return i;
    } else {
        return 0;
    }
}
Also used : IFishableLiquidBlock(stevekung.mods.moreplanets.util.blocks.IFishableLiquidBlock) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) LootContext(net.minecraft.world.storage.loot.LootContext) WorldServer(net.minecraft.world.WorldServer) Item(net.minecraft.item.Item) EntityItem(net.minecraft.entity.item.EntityItem) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) IFishableLiquidBlock(stevekung.mods.moreplanets.util.blocks.IFishableLiquidBlock) StatList(net.minecraft.stats.StatList) LootTableList(net.minecraft.world.storage.loot.LootTableList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 9 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project NetherEx by LogicTechCorp.

the class EntityPigtificate method useRecipe.

@Override
public void useRecipe(MerchantRecipe recipe) {
    recipe.incrementToolUses();
    livingSoundTime = -getTalkInterval();
    int i = 3 + rand.nextInt(4);
    if (recipe.getToolUses() == 1 || rand.nextInt(5) == 0) {
        timeUntilRestock = 40;
        needsInitialization = true;
        willingToMate = true;
        if (getCustomer() != null) {
            lastCustomer = getCustomer().getUniqueID();
        } else {
            lastCustomer = null;
        }
        i += 5;
    }
    if (recipe.getRewardsExp()) {
        world.spawnEntity(new EntityXPOrb(world, posX, posY + 0.5D, posZ, i));
    }
}
Also used : EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 10 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)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