Search in sources :

Example 26 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project Gaia-Dimension by Andromander.

the class SlotPurify method onCrafting.

@Override
protected void onCrafting(ItemStack par1ItemStack) {
    par1ItemStack.onCrafting(thePlayer.world, thePlayer, stackSize);
    if (!thePlayer.world.isRemote) {
        int i = stackSize;
        float f = PurifierRecipes.instance().getExperience(par1ItemStack);
        int j;
        if (f == 0.0F)
            i = 0;
        else if (f < 1.0F) {
            j = MathHelper.floor(i * f);
            if (j < MathHelper.ceil(i * f) && (float) Math.random() < i * f - j)
                ++j;
            i = j;
        }
        while (i > 0) {
            j = EntityXPOrb.getXPSplit(i);
            i -= j;
            thePlayer.world.spawnEntity(new EntityXPOrb(thePlayer.world, thePlayer.posX, thePlayer.posY + 0.5D, thePlayer.posZ + 0.5D, j));
        }
    }
    stackSize = 0;
    MinecraftForge.EVENT_BUS.post(new GDEvents.ItemPurifiedEvent(thePlayer, par1ItemStack));
}
Also used : GDEvents(androsa.gaiadimension.registry.GDEvents) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 27 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project DefiledLands by Lykrast.

the class EntityDestroyer method dropExperience.

private void dropExperience(int p_184668_1_) {
    while (p_184668_1_ > 0) {
        int i = EntityXPOrb.getXPSplit(p_184668_1_);
        p_184668_1_ -= i;
        this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY, this.posZ, i));
    }
}
Also used : EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 28 with EntityXPOrb

use of net.minecraft.entity.item.EntityXPOrb in project DefiledLands by Lykrast.

the class EntityMourner method dropExperience.

private void dropExperience(int p_184668_1_) {
    while (p_184668_1_ > 0) {
        int i = EntityXPOrb.getXPSplit(p_184668_1_);
        p_184668_1_ -= i;
        this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY, this.posZ, i));
    }
}
Also used : EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 29 with EntityXPOrb

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

the class EntityBossBase method onDeathUpdate.

@Override
protected void onDeathUpdate() {
    ++this.deathTicks;
    if (this.deathTicks >= 180 && this.deathTicks <= 200) {
        final float x = (this.rand.nextFloat() - 0.5F) * this.width;
        final float y = (this.rand.nextFloat() - 0.5F) * (this.height / 2.0F);
        final float z = (this.rand.nextFloat() - 0.5F) * this.width;
        this.world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.posX + x, this.posY + 2.0D + y, this.posZ + z, 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(PacketSimple.EnumSimplePacket.C_PLAY_SOUND_EXPLODE, GCCoreUtil.getDimensionID(this.world), new Object[] {}), new NetworkRegistry.TargetPoint(GCCoreUtil.getDimensionID(this.world), this.posX, this.posY, this.posZ, 40.0D));
        }
        if (this.deathTicks > 150 && this.deathTicks % 5 == 0) {
            i = 30;
            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 == 200 && !this.world.isRemote) {
        i = 20;
        while (i > 0) {
            j = EntityXPOrb.getXPSplit(i);
            i -= j;
            this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY, this.posZ, j));
        }
        TileEntityTreasureChest chest = null;
        if (this.spawner != null && this.spawner.getChestPos() != null) {
            TileEntity chestTest = this.world.getTileEntity(this.spawner.getChestPos());
            if (chestTest != null && chestTest instanceof TileEntityTreasureChest) {
                chest = (TileEntityTreasureChest) chestTest;
            }
        }
        if (chest == null) {
            // Fallback to finding closest chest
            chest = TileEntityTreasureChest.findClosest(this, this.getChestTier());
        }
        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;
                }
                for (int k = 0; k < chest.getSizeInventory(); k++) {
                    chest.setInventorySlotContents(k, ItemStack.EMPTY);
                }
                chest.fillWithLoot(null);
                // ChestGenHooks info = ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST);
                // 
                // // Generate twice, since it's an extra special chest
                // WeightedRandomChestContent.generateChestContents(this.rand, info.getItems(this.rand), chest, info.getCount(this.rand));
                // WeightedRandomChestContent.generateChestContents(this.rand, info.getItems(this.rand), chest, info.getCount(this.rand));
                ItemStack schematic = this.getGuaranteedLoot(this.rand);
                int slot = this.rand.nextInt(chest.getSizeInventory());
                chest.setInventorySlotContents(slot, schematic);
            }
        }
        this.dropKey();
        super.setDead();
        if (this.spawner != null) {
            // Note: spawner.isBossDefeated is true, so it's properly dead
            this.spawner.isBossDefeated = true;
            this.spawner.boss = null;
            this.spawner.spawned = false;
            if (!this.world.isRemote) {
                this.spawner.lastKillTime = MinecraftServer.getCurrentTimeMillis();
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) NetworkRegistry(net.minecraftforge.fml.common.network.NetworkRegistry) TileEntityTreasureChest(micdoodle8.mods.galacticraft.core.tile.TileEntityTreasureChest) PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) ItemStack(net.minecraft.item.ItemStack) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

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

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