net.minecraft.entity.item.EntityXPOrb Java Examples

The following examples show how to use net.minecraft.entity.item.EntityXPOrb. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlockFloor.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Deprecated
@Override
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox,
        List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_)
{
    if (state.getValue(TYPE) == FloorType.CRACKED)
    {
        if ((entityIn instanceof EntityItem) == false && (entityIn instanceof EntityXPOrb) == false)
        {
            addCollisionBoxToList(pos, entityBox, collidingBoxes, state.getCollisionBoundingBox(worldIn, pos));
        }
    }
    else
    {
        super.addCollisionBoxToList(state, worldIn, pos, entityBox, collidingBoxes, entityIn, p_185477_7_);
    }
}
 
Example #2
Source File: TrackingRange.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the range an entity should be 'tracked' by players and visible in
 * the client.
 *
 * @param entity
 * @param defaultRange Default range defined by Mojang
 * @return
 */
public static int getEntityTrackingRange(Entity entity, int defaultRange) {
    SpigotWorldConfig config = entity.world.spigotConfig;
    if (entity instanceof EntityPlayer) {
        return config.playerTrackingRange;
    } else if (entity.activationType == 1) {
        return config.monsterTrackingRange;
    } else if (entity instanceof EntityGhast) {
        if (config.monsterTrackingRange > config.monsterActivationRange) {
            return config.monsterTrackingRange;
        } else {
            return config.monsterActivationRange;
        }
    } else if (entity.activationType == 2) {
        return config.animalTrackingRange;
    } else if (entity instanceof EntityItemFrame || entity instanceof EntityPainting || entity instanceof EntityItem || entity instanceof EntityXPOrb) {
        return config.miscTrackingRange;
    } else {
        return config.otherTrackingRange;
    }
}
 
Example #3
Source File: SlotItemHandlerFurnaceOutput.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void onCrafting(ItemStack stack)
{
    stack.onCrafting(this.player.getEntityWorld(), this.player, this.amountCrafted);

    if (this.player.getEntityWorld().isRemote == false)
    {
        int i = this.amountCrafted;
        float f = FurnaceRecipes.instance().getSmeltingExperience(stack);

        if (f == 0.0F)
        {
            i = 0;
        }
        else if (f < 1.0F)
        {
            int j = MathHelper.floor((float)i * f);

            if (j < MathHelper.ceil((float)i * f) && Math.random() < (double)((float)i * f - (float)j))
            {
                ++j;
            }

            i = j;
        }

        while (i > 0)
        {
            int k = EntityXPOrb.getXPSplit(i);
            i -= k;
            this.player.getEntityWorld().spawnEntity(new EntityXPOrb(this.player.getEntityWorld(), this.player.posX, this.player.posY + 0.5D, this.player.posZ + 0.5D, k));
        }
    }

    this.amountCrafted = 0;
    net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerSmeltedEvent(player, stack);
}
 
Example #4
Source File: ToolMetaItemListener.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public static void onXpOrbPickup(PlayerPickupXpEvent event) {
    EntityPlayer player = event.getEntityPlayer();
    EntityXPOrb xpOrb = event.getOrb();
    ItemStack itemStack = EnchantmentHelper.getEnchantedItem(Enchantments.MENDING, player);

    if (!itemStack.isEmpty() && itemStack.getItem() instanceof ToolMetaItem) {
        ToolMetaItem<?> toolMetaItem = (ToolMetaItem<?>) itemStack.getItem();
        int maxDurabilityRegain = xpToDurability(xpOrb.xpValue);
        int durabilityRegained = toolMetaItem.regainItemDurability(itemStack, maxDurabilityRegain);
        xpOrb.xpValue -= durabilityToXp(durabilityRegained);
    }
}
 
Example #5
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public static PlayerItemMendEvent callPlayerItemMendEvent(EntityPlayer entity, EntityXPOrb orb, ItemStack nmsMendedItem, int repairAmount) {
    Player player = (Player) entity.getBukkitEntity();
    org.bukkit.inventory.ItemStack bukkitStack = CraftItemStack.asCraftMirror(nmsMendedItem);
    PlayerItemMendEvent event = new PlayerItemMendEvent(player, bukkitStack, (ExperienceOrb) orb.getBukkitEntity(), repairAmount);
    Bukkit.getPluginManager().callEvent(event);
    return event;
}
 
Example #6
Source File: EntityTofuGandlem.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@Override
protected void onDeathUpdate() {
    this.renderYawOffset = this.rotationYaw;

    ++this.deathTicks;

    if (this.deathTicks >= 60 && this.deathTicks <= 80) {
        float f = (this.rand.nextFloat() - 0.5F) * 4.0F;
        float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F;
        float f2 = (this.rand.nextFloat() - 0.5F) * 4.0F;
        this.world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.posX + (double) f, this.posY + 2.0D + (double) f1, this.posZ + (double) f2, 0.0D, 0.0D, 0.0D);
    }

    if (this.deathTicks == 80) {
        if (!this.world.isRemote && (this.isPlayer() || this.recentlyHit > 0 && this.canDropLoot() && this.world.getGameRules().getBoolean("doMobLoot"))) {
            int i = this.getExperiencePoints(this.attackingPlayer);
            i = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.attackingPlayer, i);
            while (i > 0) {
                int j = EntityXPOrb.getXPSplit(i);
                i -= j;
                this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY, this.posZ, j));
            }
        }

        this.setDead();
    }
}
 
Example #7
Source File: TrackingRange.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the range an entity should be 'tracked' by players and visible in
 * the client.
 *
 * @param entity
 * @param defaultRange Default range defined by Mojang
 * @return
 */
public static int getEntityTrackingRange(Entity entity, int defaultRange)
{
    SpigotWorldConfig config = entity.worldObj.getSpigotConfig(); // Cauldron
    int range = defaultRange;
    if ( entity instanceof EntityPlayerMP )
    {
        range = config.playerTrackingRange;
    } else if ( entity.defaultActivationState || entity instanceof EntityGhast )
    {
        range = defaultRange;
    } else if ( entity.activationType == 1 )
    {
        range = config.monsterTrackingRange;
    } else if ( entity.activationType == 2 )
    {
        range = config.animalTrackingRange;
    } else if ( entity instanceof EntityItemFrame || entity instanceof EntityPainting || entity instanceof EntityItem || entity instanceof EntityXPOrb )
    {
        range = config.miscTrackingRange;
    }
    // Cauldron start - allow for 0 to disable tracking ranges
    if (range == 0)
    {
        return defaultRange;
    }
    // Cauldron end

    return Math.min( config.maxTrackingRange, range );
}
 
Example #8
Source File: ModEnchantments.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
public static void onPlayerPickupXP(PlayerPickupXpEvent event) {
	EntityPlayer player = event.entityPlayer;
	EntityXPOrb orb = event.orb;
	if (player.worldObj.isRemote)
		return;
	if (!EtFuturum.enableMending)
		return;

	ItemStack[] stacks = new ItemStack[5];
	stacks[0] = player.getCurrentEquippedItem(); // held
	stacks[1] = player.getEquipmentInSlot(1); // boots
	stacks[2] = player.getEquipmentInSlot(2); // leggings
	stacks[3] = player.getEquipmentInSlot(3); // chestplate
	stacks[4] = player.getEquipmentInSlot(4); // helmet

	for (ItemStack stack : stacks)
		if (stack != null && stack.getItemDamage() > 0 && EnchantmentHelper.getEnchantmentLevel(mending.effectId, stack) > 0) {
			int xp = orb.xpValue;
			while (xp > 0 && stack.getItemDamage() > 0) {
				stack.setItemDamage(stack.getItemDamage() - 2);
				xp--;
			}
			if (xp <= 0) {
				orb.setDead();
				event.setCanceled(true);
				return;
			}
		}
}
 
Example #9
Source File: CraftExperienceOrb.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftExperienceOrb(CraftServer server, EntityXPOrb entity) {
    super(server, entity);
}
 
Example #10
Source File: EntityDrone.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void addExperience(int amount){
    Vec3 pos = drone.getPosition();
    EntityXPOrb orb = new EntityXPOrb(drone.getWorld(), pos.xCoord, pos.yCoord, pos.zCoord, amount);
    drone.getWorld().spawnEntityInWorld(orb);
}
 
Example #11
Source File: SlotFirepitOutput.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
/**
 * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
 */
@Override
protected void onCrafting(ItemStack stack)
{
	stack.onCrafting(this.player.world, this.player, this.removeCount);

	if (!this.player.world.isRemote)
	{
		int i = this.removeCount;
		float f = FurnaceRecipes.instance().getSmeltingExperience(stack);

		if (f == 0.0F)
		{
			i = 0;
		}
		else if (f < 1.0F)
		{
			int j = MathHelper.floor((float)i * f);

			if (j < MathHelper.ceil((float)i * f) && Math.random() < (double)((float)i * f - (float)j))
			{
				++j;
			}

			i = j;
		}

		while (i > 0)
		{
			int k = EntityXPOrb.getXPSplit(i);
			i -= k;
			this.player.world.spawnEntity(new EntityXPOrb(this.player.world, this.player.posX, this.player.posY + 0.5D, this.player.posZ + 0.5D, k));
		}
	}

	this.removeCount = 0;

	net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerSmeltedEvent(player, stack);

	if (stack.getItem() == Items.IRON_INGOT)
	{
		this.player.addStat(AchievementList.ACQUIRE_IRON);
	}

	if (stack.getItem() == Items.COOKED_FISH)
	{
		this.player.addStat(AchievementList.COOK_FISH);
	}
}
 
Example #12
Source File: EntityRespawnedDragon.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
protected void onDeathUpdate() {
	deathTicks++;

	if (deathTicks >= 180 && deathTicks <= 200) {
		float f = (rand.nextFloat() - 0.5F) * 8.0F;
		float f1 = (rand.nextFloat() - 0.5F) * 4.0F;
		float f2 = (rand.nextFloat() - 0.5F) * 8.0F;
		worldObj.spawnParticle("hugeexplosion", posX + f, posY + 2.0D + f1, posZ + f2, 0.0D, 0.0D, 0.0D);
	}

	int i;
	int j;

	if (!worldObj.isRemote) {
		if (deathTicks > 150 && deathTicks % 5 == 0) {
			i = 1000;

			while (i > 0) {
				j = EntityXPOrb.getXPSplit(i);
				i -= j;
				worldObj.spawnEntityInWorld(new EntityXPOrb(worldObj, posX, posY, posZ, j));
			}
		}

		if (deathTicks == 1)
			worldObj.playBroadcastSound(1018, (int) posX, (int) posY, (int) posZ, 0);
	}

	moveEntity(0.0D, 0.10000000149011612D, 0.0D);
	renderYawOffset = rotationYaw += 20.0F;

	if (deathTicks == 200 && !worldObj.isRemote) {
		i = 2000;

		while (i > 0) {
			j = EntityXPOrb.getXPSplit(i);
			i -= j;
			worldObj.spawnEntityInWorld(new EntityXPOrb(worldObj, posX, posY, posZ, j));
		}

		setDead();
	}
}
 
Example #13
Source File: CraftExperienceOrb.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityXPOrb getHandle() {
    return (EntityXPOrb) entity;
}
 
Example #14
Source File: CraftExperienceOrb.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityXPOrb getHandle() {
    return (EntityXPOrb) entity;
}
 
Example #15
Source File: CraftExperienceOrb.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftExperienceOrb(CraftServer server, EntityXPOrb entity) {
    super(server, entity);
}
 
Example #16
Source File: SlotSaltFurnace.java    From TofuCraftReload with MIT License 4 votes vote down vote up
/**
 * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
 */
@Override
protected void onCrafting(ItemStack par1ItemStack)
{
    par1ItemStack.onCrafting(this.thePlayer.world, this.thePlayer, this.field_75228_b);

    if (!this.thePlayer.world.isRemote)
    {
        int i = this.field_75228_b;
        float f = par1ItemStack.getItem() == ItemLoader.material ? 0.2f : par1ItemStack.getItem() == ItemLoader.nigari ? 0.3f : 0.0f;
        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;
            this.thePlayer.world.spawnEntity(new EntityXPOrb(this.thePlayer.world, this.thePlayer.posX, this.thePlayer.posY + 0.5D, this.thePlayer.posZ + 0.5D, j));
        }
    }

    this.field_75228_b = 0;


    if (par1ItemStack.getItem() == ItemLoader.material)
    {
        TofuAdvancements.grantAdvancement(this.thePlayer, "getsalt");
    }
    else if (par1ItemStack.getItem() == ItemLoader.nigari)
    {
        TofuAdvancements.grantAdvancement(this.thePlayer, "getnigari");
    }
}
 
Example #17
Source File: EntityTofunian.java    From TofuCraftReload with MIT License 4 votes vote down vote up
@Override
public void useRecipe(MerchantRecipe recipe) {

    recipe.incrementToolUses();
    this.livingSoundTime = -this.getTalkInterval();
    this.playSound(TofuSounds.TOFUNIAN_YES, this.getSoundVolume(), this.getSoundPitch());
    int i = 3 + this.rand.nextInt(4);

    if (recipe.getToolUses() == 1 || this.rand.nextInt(5) == 0) {
        this.tofunianTimeUntilReset = 40;
        this.needsInitilization = true;
        this.isWillingToMate = true;

        //update TofunianTrade
        if (this.tofunianCareerLevel != 0) {

            ++this.tofunianCareerLevel;

        } else {

            this.tofunianCareerLevel = 2;

        }


        if (this.buyingPlayer != null) {
            this.lastBuyingPlayer = this.buyingPlayer.getUniqueID();
        } else {
            this.lastBuyingPlayer = null;
        }

        i += 5;
    }

    if (recipe.getItemToBuy().getItem() == ItemLoader.zundaruby) {
        this.wealth += recipe.getItemToBuy().getCount();
    }

    if (recipe.getRewardsExp()) {
        this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY + 0.5D, this.posZ, i));
    }

}