Search in sources :

Example 6 with ExperienceOrbEntity

use of net.minecraft.entity.item.ExperienceOrbEntity in project Fragile-Glass by fredtargaryen.

the class SugarCauldronBlock method onBlockActivated.

@Override
public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
    ItemStack heldItemStack = player.inventory.getCurrentItem();
    Item heldItem = heldItemStack.getItem();
    if (w.isRemote) {
        if (state.get(AGE_0_7).equals(1) && heldItem == FragileGlassBase.ITEM_SUGAR_BLOCK) {
            this.splash(w, pos.getX(), pos.getY(), pos.getZ());
        }
        return ActionResultType.SUCCESS;
    } else {
        int i1 = state.get(AGE_0_7);
        if (i1 == 0) {
            if (heldItem == Items.WATER_BUCKET) {
                if (!player.abilities.isCreativeMode) {
                    player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.BUCKET));
                }
                w.playSound(null, pos, SoundEvents.ENTITY_FISHING_BOBBER_SPLASH, SoundCategory.BLOCKS, 1.0F, 1.0F);
                w.setBlockState(pos, state.with(AGE_0_7, 1));
                return ActionResultType.SUCCESS;
            }
        } else if (i1 == 1) {
            if (heldItem == FragileGlassBase.ITEM_SUGAR_BLOCK) {
                if (!player.abilities.isCreativeMode) {
                    ItemStack newStack = heldItemStack.copy();
                    newStack.grow(-1);
                    player.inventory.setInventorySlotContents(player.inventory.currentItem, newStack);
                }
                w.playSound(null, pos, SoundEvents.ENTITY_FISHING_BOBBER_SPLASH, SoundCategory.BLOCKS, 1.0F, 1.0F);
                w.setBlockState(pos, state.with(AGE_0_7, 2), 3);
                return ActionResultType.CONSUME;
            }
        } else if (i1 == 6) {
            w.addEntity(new ItemEntity(w, (double) pos.getX() + 0.5D, (double) pos.getY() + 1.0D, (double) pos.getZ() + 0.5D, new ItemStack(FragileGlassBase.FRAGILE_GLASS, WorldgenConfig.GLASS_YIELD.get())));
            w.addEntity(new ExperienceOrbEntity(w, (double) pos.getX() + 0.5D, (double) pos.getY() + 1.0D, (double) pos.getZ() + 0.5D, 4));
            w.setBlockState(pos, state.with(AGE_0_7, 0), 3);
            return ActionResultType.SUCCESS;
        }
    }
    return ActionResultType.FAIL;
}
Also used : Item(net.minecraft.item.Item) ItemEntity(net.minecraft.entity.item.ItemEntity) ItemStack(net.minecraft.item.ItemStack) ExperienceOrbEntity(net.minecraft.entity.item.ExperienceOrbEntity)

Example 7 with ExperienceOrbEntity

use of net.minecraft.entity.item.ExperienceOrbEntity in project SophisticatedBackpacks by P3pp3rF1y.

the class MagnetUpgradeWrapper method pickupXpOrbs.

private int pickupXpOrbs(@Nullable LivingEntity entity, World world, BlockPos pos) {
    List<ExperienceOrbEntity> xpEntities = world.getEntitiesOfClass(ExperienceOrbEntity.class, new AxisAlignedBB(pos).inflate(upgradeItem.getRadius()), e -> true);
    if (xpEntities.isEmpty()) {
        return COOLDOWN_TICKS;
    }
    int cooldown = COOLDOWN_TICKS;
    for (ExperienceOrbEntity xpOrb : xpEntities) {
        if (xpOrb.isAlive() && !canNotPickup(xpOrb, entity) && !tryToFillTank(xpOrb, entity, world)) {
            cooldown = FULL_COOLDOWN_TICKS;
            break;
        }
    }
    return cooldown;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ExperienceOrbEntity(net.minecraft.entity.item.ExperienceOrbEntity)

Example 8 with ExperienceOrbEntity

use of net.minecraft.entity.item.ExperienceOrbEntity in project endergetic by team-abnormals.

the class BoofloBreedGoal method impregnateBooflo.

protected void impregnateBooflo() {
    final BabyEntitySpawnEvent event = new net.minecraftforge.event.entity.living.BabyEntitySpawnEvent(this.booflo, this.mate, null);
    final boolean cancelled = MinecraftForge.EVENT_BUS.post(event);
    if (cancelled) {
        this.booflo.resetInLove();
        this.mate.resetInLove();
        return;
    }
    ServerPlayerEntity serverplayerentity = this.booflo.getLoveCause();
    if (serverplayerentity == null && this.mate.getLoveCause() != null) {
        serverplayerentity = this.mate.getLoveCause();
    }
    if (serverplayerentity != null) {
        serverplayerentity.awardStat(Stats.ANIMALS_BRED);
        EECriteriaTriggers.BRED_BOOFLO.trigger(serverplayerentity);
    }
    if (!this.mate.isPregnant()) {
        this.booflo.setPregnant(true);
    }
    this.booflo.resetInLove();
    this.mate.resetInLove();
    this.booflo.breedDelay = 1400;
    this.mate.breedDelay = 1400;
    this.booflo.level.broadcastEntityEvent(this.booflo, (byte) 18);
    if (this.booflo.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
        this.booflo.level.addFreshEntity(new ExperienceOrbEntity(this.booflo.level, this.booflo.getX(), this.booflo.getY(), this.booflo.getZ(), this.booflo.getRandom().nextInt(7) + 1));
    }
}
Also used : BabyEntitySpawnEvent(net.minecraftforge.event.entity.living.BabyEntitySpawnEvent) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) ExperienceOrbEntity(net.minecraft.entity.item.ExperienceOrbEntity)

Example 9 with ExperienceOrbEntity

use of net.minecraft.entity.item.ExperienceOrbEntity in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityCQRNetherDragon method dropExperience.

private void dropExperience(int p_184668_1_, double x, double y, double z) {
    while (p_184668_1_ > 0) {
        int i = ExperienceOrbEntity.getExperienceValue(p_184668_1_);
        p_184668_1_ -= i;
        ExperienceOrbEntity xp = new ExperienceOrbEntity(this.level, x, y, z, i);
        xp.setInvulnerable(true);
        this.level.addFreshEntity(xp);
    }
}
Also used : ExperienceOrbEntity(net.minecraft.entity.item.ExperienceOrbEntity)

Example 10 with ExperienceOrbEntity

use of net.minecraft.entity.item.ExperienceOrbEntity in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityCQRWalkerKing method dropExperience.

private void dropExperience(int p_184668_1_) {
    while (p_184668_1_ > 0) {
        int i = ExperienceOrbEntity.getExperienceValue(p_184668_1_);
        p_184668_1_ -= i;
        this.level.addFreshEntity(new ExperienceOrbEntity(this.level, this.getX(), this.getY(), this.getZ(), i));
    }
}
Also used : ExperienceOrbEntity(net.minecraft.entity.item.ExperienceOrbEntity)

Aggregations

ExperienceOrbEntity (net.minecraft.entity.item.ExperienceOrbEntity)26 ItemStack (net.minecraft.item.ItemStack)12 ItemEntity (net.minecraft.entity.item.ItemEntity)10 Overwrite (org.spongepowered.asm.mixin.Overwrite)8 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)6 List (java.util.List)5 ServerWorld (net.minecraft.world.server.ServerWorld)5 LootContext (net.minecraft.loot.LootContext)4 LootTable (net.minecraft.loot.LootTable)4 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)4 World (net.minecraft.world.World)4 PlayerEntity (net.minecraft.entity.player.PlayerEntity)3 Item (net.minecraft.item.Item)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 EntityBridge (io.izzel.arclight.common.bridge.entity.EntityBridge)2 ServerPlayerEntityBridge (io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge)2 Entity (net.minecraft.entity.Entity)2 ActionResultType (net.minecraft.util.ActionResultType)2 Hand (net.minecraft.util.Hand)2 PacketItemInfo (com.supermartijn642.simplemagnets.packets.magnet.PacketItemInfo)1