Java Code Examples for net.minecraft.stats.StatList

The following are top voted examples for showing how to use net.minecraft.stats.StatList. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: BaseClient   File: EntityPlayer.java   View source code 7 votes vote down vote up
/**
 * Causes this entity to do an upwards motion (jumping).
 */
public void jump()
{
	if (this == Minecraft.getMinecraft().thePlayer)
	{
	    JumpEvent event = new JumpEvent();
	    event.call();

	    if (event.isCancelled()) return;
	}

    super.jump();
    this.triggerAchievement(StatList.jumpStat);

    if (this.isSprinting())
    {
        this.addExhaustion(0.8F);
    }
    else
    {
        this.addExhaustion(0.2F);
    }
}
 
Example 2
Project: DecompiledMinecraft   File: ItemExpBottle.java   View source code 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        worldIn.spawnEntityInWorld(new EntityExpBottle(worldIn, playerIn));
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
 
Example 3
Project: BaseClient   File: ItemBucketMilk.java   View source code 6 votes vote down vote up
/**
 * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
 * the Item before the action is complete.
 */
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --stack.stackSize;
    }

    if (!worldIn.isRemote)
    {
        playerIn.clearActivePotions();
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return stack.stackSize <= 0 ? new ItemStack(Items.bucket) : stack;
}
 
Example 4
Project: ProgressiveDifficulty   File: BlocksBrokenControl.java   View source code 6 votes vote down vote up
@Override
public int getChangeForSpawn(SpawnEventDetails details) {

    int brokenBlocks = PlayerAreaStatAccumulator.getStatForPlayersInArea(type,details.entity,128,(player)->{
        int accum = 0;
        for(StatBase brokenStat : StatList.MINE_BLOCK_STATS) {
            accum+=player.getStatFile().readStat(brokenStat);
        }
        return accum;
    });

    int contribution = (int)(((double)brokenBlocks * difficultyPerHundredBlocks) / 100);

    if(maxAddedDifficulty>=0){
        contribution = Math.min(contribution,maxAddedDifficulty);
    }

    return contribution;
}
 
Example 5
Project: BaseClient   File: S37PacketStatistics.java   View source code 6 votes vote down vote up
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    int i = buf.readVarIntFromBuffer();
    this.field_148976_a = Maps.<StatBase, Integer>newHashMap();

    for (int j = 0; j < i; ++j)
    {
        StatBase statbase = StatList.getOneShotStat(buf.readStringFromBuffer(32767));
        int k = buf.readVarIntFromBuffer();

        if (statbase != null)
        {
            this.field_148976_a.put(statbase, Integer.valueOf(k));
        }
    }
}
 
Example 6
Project: Uranium   File: CraftStatistic.java   View source code 6 votes vote down vote up
public static net.minecraft.stats.StatBase getMaterialStatistic(org.bukkit.Statistic stat, Material material) {
    try {
        if (stat == Statistic.MINE_BLOCK) {
            return StatList.mineBlockStatArray[material.getId()];
        }
        if (stat == Statistic.CRAFT_ITEM) {
            return StatList.objectCraftStats[material.getId()];
        }
        if (stat == Statistic.USE_ITEM) {
            return StatList.objectUseStats[material.getId()];
        }
        if (stat == Statistic.BREAK_ITEM) {
            return StatList.objectBreakStats[material.getId()];
        }
    } catch (ArrayIndexOutOfBoundsException e) {
        return null;
    }
    return null;
}
 
Example 7
Project: BaseClient   File: S37PacketStatistics.java   View source code 6 votes vote down vote up
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    int i = buf.readVarIntFromBuffer();
    this.field_148976_a = Maps.<StatBase, Integer>newHashMap();

    for (int j = 0; j < i; ++j)
    {
        StatBase statbase = StatList.getOneShotStat(buf.readStringFromBuffer(32767));
        int k = buf.readVarIntFromBuffer();

        if (statbase != null)
        {
            this.field_148976_a.put(statbase, Integer.valueOf(k));
        }
    }
}
 
Example 8
Project: SentinentAImod   File: CoreItemEgg.java   View source code 6 votes vote down vote up
/**
 * Called when the equipped item is right clicked.
 */
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
    ItemStack itemstack = playerIn.getHeldItem(handIn);
		itemstack.shrink(1);

    worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
    		EntityEgg entityegg = new CoreEntityEgg(worldIn, playerIn);
        entityegg.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        worldIn.spawnEntity(entityegg);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
 
Example 9
Project: CustomWorldGen   File: ItemEnderPearl.java   View source code 6 votes vote down vote up
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_ENDERPEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
    playerIn.getCooldownTracker().setCooldown(this, 20);

    if (!worldIn.isRemote)
    {
        EntityEnderPearl entityenderpearl = new EntityEnderPearl(worldIn, playerIn);
        entityenderpearl.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        worldIn.spawnEntityInWorld(entityenderpearl);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
 
Example 10
Project: Backmemed   File: BlockCake.java   View source code 6 votes vote down vote up
private boolean eatCake(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
    if (!player.canEat(false))
    {
        return false;
    }
    else
    {
        player.addStat(StatList.CAKE_SLICES_EATEN);
        player.getFoodStats().addStats(2, 0.1F);
        int i = ((Integer)state.getValue(BITES)).intValue();

        if (i < 6)
        {
            worldIn.setBlockState(pos, state.withProperty(BITES, Integer.valueOf(i + 1)), 3);
        }
        else
        {
            worldIn.setBlockToAir(pos);
        }

        return true;
    }
}
 
Example 11
Project: DecompiledMinecraft   File: EntityPlayer.java   View source code 6 votes vote down vote up
/**
 * Adds a value to the player score. Currently not actually used and the entity passed in does nothing. Args:
 * entity, scoreToAdd
 */
public void addToPlayerScore(Entity entityIn, int amount)
{
    this.addScore(amount);
    Collection<ScoreObjective> collection = this.getWorldScoreboard().getObjectivesFromCriteria(IScoreObjectiveCriteria.totalKillCount);

    if (entityIn instanceof EntityPlayer)
    {
        this.triggerAchievement(StatList.playerKillsStat);
        collection.addAll(this.getWorldScoreboard().getObjectivesFromCriteria(IScoreObjectiveCriteria.playerKillCount));
        collection.addAll(this.func_175137_e(entityIn));
    }
    else
    {
        this.triggerAchievement(StatList.mobKillsStat);
    }

    for (ScoreObjective scoreobjective : collection)
    {
        Score score = this.getWorldScoreboard().getValueFromObjective(this.getName(), scoreobjective);
        score.func_96648_a();
    }
}
 
Example 12
Project: CustomWorldGen   File: ItemBucketMilk.java   View source code 6 votes vote down vote up
/**
 * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
 * the Item before the action is complete.
 */
@Nullable
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
    if (entityLiving instanceof EntityPlayer && !((EntityPlayer)entityLiving).capabilities.isCreativeMode)
    {
        --stack.stackSize;
    }

    if (!worldIn.isRemote)
    {
        entityLiving.curePotionEffects(stack);
    }

    if (entityLiving instanceof EntityPlayer)
    {
        ((EntityPlayer)entityLiving).addStat(StatList.getObjectUseStats(this));
    }

    return stack.stackSize <= 0 ? new ItemStack(Items.BUCKET) : stack;
}
 
Example 13
Project: Backmemed   File: ItemLingeringPotion.java   View source code 6 votes vote down vote up
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);
    ItemStack itemstack1 = worldIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1);
    itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_LINGERINGPOTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!itemStackIn.isRemote)
    {
        EntityPotion entitypotion = new EntityPotion(itemStackIn, worldIn, itemstack1);
        entitypotion.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, -20.0F, 0.5F, 1.0F);
        itemStackIn.spawnEntityInWorld(entitypotion);
    }

    worldIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
 
Example 14
Project: CustomWorldGen   File: SPacketStatistics.java   View source code 6 votes vote down vote up
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    int i = buf.readVarIntFromBuffer();
    this.statisticMap = Maps.<StatBase, Integer>newHashMap();

    for (int j = 0; j < i; ++j)
    {
        StatBase statbase = StatList.getOneShotStat(buf.readStringFromBuffer(32767));
        int k = buf.readVarIntFromBuffer();

        if (statbase != null)
        {
            this.statisticMap.put(statbase, Integer.valueOf(k));
        }
    }
}
 
Example 15
Project: CustomWorldGen   File: ItemSplashPotion.java   View source code 6 votes vote down vote up
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SPLASH_POTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        EntityPotion entitypotion = new EntityPotion(worldIn, playerIn, itemStackIn);
        entitypotion.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.5F, 1.0F);
        worldIn.spawnEntityInWorld(entitypotion);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
 
Example 16
Project: DecompiledMinecraft   File: ItemEnderPearl.java   View source code 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (playerIn.capabilities.isCreativeMode)
    {
        return itemStackIn;
    }
    else
    {
        --itemStackIn.stackSize;
        worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!worldIn.isRemote)
        {
            worldIn.spawnEntityInWorld(new EntityEnderPearl(worldIn, playerIn));
        }

        playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
        return itemStackIn;
    }
}
 
Example 17
Project: CustomWorldGen   File: ItemExpBottle.java   View source code 6 votes vote down vote up
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_EXPERIENCE_BOTTLE_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        EntityExpBottle entityexpbottle = new EntityExpBottle(worldIn, playerIn);
        entityexpbottle.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.7F, 1.0F);
        worldIn.spawnEntityInWorld(entityexpbottle);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
 
Example 18
Project: BaseClient   File: Block.java   View source code 6 votes vote down vote up
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    player.triggerAchievement(StatList.mineBlockStatArray[getIdFromBlock(this)]);
    player.addExhaustion(0.025F);

    if (this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player))
    {
        ItemStack itemstack = this.createStackedBlock(state);

        if (itemstack != null)
        {
            spawnAsEntity(worldIn, pos, itemstack);
        }
    }
    else
    {
        int i = EnchantmentHelper.getFortuneModifier(player);
        this.dropBlockAsItem(worldIn, pos, state, i);
    }
}
 
Example 19
Project: BaseClient   File: BlockBrewingStand.java   View source code 6 votes vote down vote up
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityBrewingStand)
        {
            playerIn.displayGUIChest((TileEntityBrewingStand)tileentity);
            playerIn.triggerAchievement(StatList.field_181729_M);
        }

        return true;
    }
}
 
Example 20
Project: BaseClient   File: BlockFurnace.java   View source code 6 votes vote down vote up
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityFurnace)
        {
            playerIn.displayGUIChest((TileEntityFurnace)tileentity);
            playerIn.triggerAchievement(StatList.field_181741_Y);
        }

        return true;
    }
}
 
Example 21
Project: Backmemed   File: EntityPlayer.java   View source code 6 votes vote down vote up
/**
 * Adds to the players score.
 */
public void addToPlayerScore(Entity entityIn, int amount)
{
    if (entityIn != this)
    {
        this.addScore(amount);
        Collection<ScoreObjective> collection = this.getWorldScoreboard().getObjectivesFromCriteria(IScoreCriteria.TOTAL_KILL_COUNT);

        if (entityIn instanceof EntityPlayer)
        {
            this.addStat(StatList.PLAYER_KILLS);
            collection.addAll(this.getWorldScoreboard().getObjectivesFromCriteria(IScoreCriteria.PLAYER_KILL_COUNT));
        }
        else
        {
            this.addStat(StatList.MOB_KILLS);
        }

        collection.addAll(this.giveTeamKillScores(entityIn));

        for (ScoreObjective scoreobjective : collection)
        {
            this.getWorldScoreboard().getOrCreateScore(this.getName(), scoreobjective).incrementScore();
        }
    }
}
 
Example 22
Project: BaseClient   File: BlockBeacon.java   View source code 6 votes vote down vote up
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityBeacon)
        {
            playerIn.displayGUIChest((TileEntityBeacon)tileentity);
            playerIn.triggerAchievement(StatList.field_181730_N);
        }

        return true;
    }
}
 
Example 23
Project: BaseClient   File: BlockFurnace.java   View source code 6 votes vote down vote up
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityFurnace)
        {
            playerIn.displayGUIChest((TileEntityFurnace)tileentity);
            playerIn.triggerAchievement(StatList.field_181741_Y);
        }

        return true;
    }
}
 
Example 24
Project: Proyecto-DASI   File: JSONWorldDataHelper.java   View source code 6 votes vote down vote up
/** Builds the basic achievement world data to be used as observation signals by the listener.
 * @param json a JSON object into which the achievement stats will be added.
 */
public static void buildAchievementStats(JsonObject json, EntityPlayerMP player)
{
    StatFileWriter sfw = player.getStatFile();
    json.addProperty("DistanceTravelled", 
            sfw.readStat((StatBase)StatList.distanceWalkedStat) 
            + sfw.readStat((StatBase)StatList.distanceSwumStat) 
            + sfw.readStat((StatBase)StatList.distanceDoveStat) 
            + sfw.readStat((StatBase)StatList.distanceFallenStat) 
            ); // TODO: there are many other ways of moving!
    json.addProperty("TimeAlive", sfw.readStat((StatBase)StatList.timeSinceDeathStat));
    json.addProperty("MobsKilled", sfw.readStat((StatBase)StatList.mobKillsStat));
    json.addProperty("PlayersKilled", sfw.readStat((StatBase)StatList.playerKillsStat));
    json.addProperty("DamageTaken", sfw.readStat((StatBase)StatList.damageTakenStat));

    /* Other potential reinforcement signals that may be worth researching:
    json.addProperty("BlocksDestroyed", sfw.readStat((StatBase)StatList.objectBreakStats) - but objectBreakStats is an array of 32000 StatBase objects - indexed by block type.);
    json.addProperty("Blocked", ev.player.isMovementBlocked()) - but isMovementBlocker() is a protected method (can get round this with reflection)
    */
}
 
Example 25
Project: CustomWorldGen   File: Bootstrap.java   View source code 6 votes vote down vote up
/**
 * Registers blocks, items, stats, etc.
 */
public static void register()
{
    if (!alreadyRegistered)
    {
        alreadyRegistered = true;

        if (LOGGER.isDebugEnabled())
        {
            redirectOutputToLog();
        }

        SoundEvent.registerSounds();
        Block.registerBlocks();
        BlockFire.init();
        Potion.registerPotions();
        Enchantment.registerEnchantments();
        Item.registerItems();
        PotionType.registerPotionTypes();
        PotionHelper.init();
        StatList.init();
        Biome.registerBiomes();
        registerDispenserBehaviors();
        net.minecraftforge.fml.common.registry.GameData.vanillaSnapshot();
    }
}
 
Example 26
Project: DecompiledMinecraft   File: Block.java   View source code 6 votes vote down vote up
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    player.triggerAchievement(StatList.mineBlockStatArray[getIdFromBlock(this)]);
    player.addExhaustion(0.025F);

    if (this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player))
    {
        ItemStack itemstack = this.createStackedBlock(state);

        if (itemstack != null)
        {
            spawnAsEntity(worldIn, pos, itemstack);
        }
    }
    else
    {
        int i = EnchantmentHelper.getFortuneModifier(player);
        this.dropBlockAsItem(worldIn, pos, state, i);
    }
}
 
Example 27
Project: BaseClient   File: ItemSnowball.java   View source code 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        worldIn.spawnEntityInWorld(new EntitySnowball(worldIn, playerIn));
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
 
Example 28
Project: BaseClient   File: ItemEnderPearl.java   View source code 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (playerIn.capabilities.isCreativeMode)
    {
        return itemStackIn;
    }
    else
    {
        --itemStackIn.stackSize;
        worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!worldIn.isRemote)
        {
            worldIn.spawnEntityInWorld(new EntityEnderPearl(worldIn, playerIn));
        }

        playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
        return itemStackIn;
    }
}
 
Example 29
Project: DecompiledMinecraft   File: BlockDoublePlant.java   View source code 6 votes vote down vote up
private boolean onHarvest(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
    BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)state.getValue(VARIANT);

    if (blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS)
    {
        return false;
    }
    else
    {
        player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
        int i = (blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.GRASS ? BlockTallGrass.EnumType.GRASS : BlockTallGrass.EnumType.FERN).getMeta();
        spawnAsEntity(worldIn, pos, new ItemStack(Blocks.tallgrass, 2, i));
        return true;
    }
}
 
Example 30
Project: BaseClient   File: ItemEgg.java   View source code 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        worldIn.spawnEntityInWorld(new EntityEgg(worldIn, playerIn));
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
 
Example 31
Project: Backmemed   File: ItemEgg.java   View source code 6 votes vote down vote up
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);

    if (!worldIn.capabilities.isCreativeMode)
    {
        itemstack.func_190918_g(1);
    }

    itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!itemStackIn.isRemote)
    {
        EntityEgg entityegg = new EntityEgg(itemStackIn, worldIn);
        entityegg.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        itemStackIn.spawnEntityInWorld(entityegg);
    }

    worldIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
 
Example 32
Project: DecompiledMinecraft   File: BlockBeacon.java   View source code 6 votes vote down vote up
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityBeacon)
        {
            playerIn.displayGUIChest((TileEntityBeacon)tileentity);
            playerIn.triggerAchievement(StatList.field_181730_N);
        }

        return true;
    }
}
 
Example 33
Project: Mods   File: EntitySaxtonHale.java   View source code 6 votes vote down vote up
@Override
public boolean processInteract(EntityPlayer player, EnumHand hand) {
	if (!(player.getHeldItemMainhand() != null
			&& player.getHeldItemMainhand().getItem() instanceof ItemMonsterPlacerPlus)
			&& this.getAttackTarget() == null && this.isEntityAlive() && !this.isTrading() && !this.isChild()
			&& !player.isSneaking()) {
		if (this.world.isRemote && player.getTeam() == null && !player.isCreative())
			ClientProxy.displayScreenJoinTeam();
		else if (!this.world.isRemote && (player.getTeam() != null || player.isCreative())
				&& (this.tradeOffers == null || !this.tradeOffers.isEmpty())) {
			this.setCustomer(player);
			player.displayVillagerTradeGui(this);
		}

		player.addStat(StatList.TALKED_TO_VILLAGER);
		return true;
	} else
		return super.processInteract(player, hand);
}
 
Example 34
Project: Backmemed   File: ItemBucketMilk.java   View source code 6 votes vote down vote up
/**
 * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
 * the Item before the action is complete.
 */
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
    if (entityLiving instanceof EntityPlayer && !((EntityPlayer)entityLiving).capabilities.isCreativeMode)
    {
        stack.func_190918_g(1);
    }

    if (!worldIn.isRemote)
    {
        entityLiving.clearActivePotions();
    }

    if (entityLiving instanceof EntityPlayer)
    {
        ((EntityPlayer)entityLiving).addStat(StatList.getObjectUseStats(this));
    }

    return stack.func_190926_b() ? new ItemStack(Items.BUCKET) : stack;
}
 
Example 35
Project: DecompiledMinecraft   File: BlockFurnace.java   View source code 6 votes vote down vote up
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityFurnace)
        {
            playerIn.displayGUIChest((TileEntityFurnace)tileentity);
            playerIn.triggerAchievement(StatList.field_181741_Y);
        }

        return true;
    }
}
 
Example 36
Project: CustomWorldGen   File: BlockCake.java   View source code 6 votes vote down vote up
private void eatCake(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
    if (player.canEat(false))
    {
        player.addStat(StatList.CAKE_SLICES_EATEN);
        player.getFoodStats().addStats(2, 0.1F);
        int i = ((Integer)state.getValue(BITES)).intValue();

        if (i < 6)
        {
            worldIn.setBlockState(pos, state.withProperty(BITES, Integer.valueOf(i + 1)), 3);
        }
        else
        {
            worldIn.setBlockToAir(pos);
        }
    }
}
 
Example 37
Project: BaseClient   File: EntityVillager.java   View source code 6 votes vote down vote up
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();
    boolean flag = itemstack != null && itemstack.getItem() == Items.spawn_egg;

    if (!flag && this.isEntityAlive() && !this.isTrading() && !this.isChild())
    {
        if (!this.worldObj.isRemote && (this.buyingList == null || this.buyingList.size() > 0))
        {
            this.setCustomer(player);
            player.displayVillagerTradeGui(this);
        }

        player.triggerAchievement(StatList.timesTalkedToVillagerStat);
        return true;
    }
    else
    {
        return super.interact(player);
    }
}
 
Example 38
Project: DecompiledMinecraft   File: ItemBucketMilk.java   View source code 6 votes vote down vote up
/**
 * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
 * the Item before the action is complete.
 */
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --stack.stackSize;
    }

    if (!worldIn.isRemote)
    {
        playerIn.clearActivePotions();
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return stack.stackSize <= 0 ? new ItemStack(Items.bucket) : stack;
}
 
Example 39
Project: DecompiledMinecraft   File: ItemRecord.java   View source code 6 votes vote down vote up
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() == Blocks.jukebox && !((Boolean)iblockstate.getValue(BlockJukebox.HAS_RECORD)).booleanValue())
    {
        if (worldIn.isRemote)
        {
            return true;
        }
        else
        {
            ((BlockJukebox)Blocks.jukebox).insertRecord(worldIn, pos, iblockstate, stack);
            worldIn.playAuxSFXAtEntity((EntityPlayer)null, 1005, pos, Item.getIdFromItem(this));
            --stack.stackSize;
            playerIn.triggerAchievement(StatList.field_181740_X);
            return true;
        }
    }
    else
    {
        return false;
    }
}
 
Example 40
Project: DecompiledMinecraft   File: Bootstrap.java   View source code 6 votes vote down vote up
/**
 * Registers blocks, items, stats, etc.
 */
public static void register()
{
    if (!alreadyRegistered)
    {
        alreadyRegistered = true;

        if (LOGGER.isDebugEnabled())
        {
            redirectOutputToLog();
        }

        Block.registerBlocks();
        BlockFire.init();
        Item.registerItems();
        StatList.init();
        registerDispenserBehaviors();
    }
}