Java 类net.minecraft.world.storage.loot.LootContext 实例源码

项目:Industrial-Foregoing    文件:WaterResourcesCollectorTile.java   
@Override
public float work() {
    if (WorkUtils.isDisabled(this.getBlockType())) return 0;
    if (this.world.rand.nextBoolean() && this.world.rand.nextBoolean()) return 1;
    List<BlockPos> blockPos = BlockUtils.getBlockPosInAABB(getWorkingArea());
    boolean allWaterSources = true;
    for (BlockPos pos : blockPos) {
        IBlockState state = this.world.getBlockState(pos);
        if (!(state.getBlock().equals(FluidRegistry.WATER.getBlock()) && state.getBlock().getMetaFromState(state) == 0))
            allWaterSources = false;
    }
    if (allWaterSources) {
        LootContext.Builder lootcontext = new LootContext.Builder((WorldServer) this.world);
        List<ItemStack> items = this.world.getLootTableManager().getLootTableFromLocation(LootTableList.GAMEPLAY_FISHING).generateLootForPools(this.world.rand, lootcontext.build());
        for (ItemStack stack : items) {
            ItemHandlerHelper.insertItem(outFish, stack, false);
        }
        return 1;
    }
    return 1;
}
项目:Backmemed    文件:EntityHasProperty.java   
public boolean testCondition(Random rand, LootContext context)
{
    Entity entity = context.getEntity(this.target);

    if (entity == null)
    {
        return false;
    }
    else
    {
        for (EntityProperty entityproperty : this.properties)
        {
            if (!entityproperty.testProperty(rand, entity))
            {
                return false;
            }
        }

        return true;
    }
}
项目:Backmemed    文件:EntityHasScore.java   
public boolean testCondition(Random rand, LootContext context)
{
    Entity entity = context.getEntity(this.target);

    if (entity == null)
    {
        return false;
    }
    else
    {
        Scoreboard scoreboard = entity.world.getScoreboard();

        for (Entry<String, RandomValueRange> entry : this.scores.entrySet())
        {
            if (!this.entityScoreMatch(entity, scoreboard, (String)entry.getKey(), (RandomValueRange)entry.getValue()))
            {
                return false;
            }
        }

        return true;
    }
}
项目:Backmemed    文件:LootConditionManager.java   
public static boolean testAllConditions(@Nullable LootCondition[] conditions, Random rand, LootContext context)
{
    if (conditions == null)
    {
        return true;
    }
    else
    {
        for (LootCondition lootcondition : conditions)
        {
            if (!lootcondition.testCondition(rand, context))
            {
                return false;
            }
        }

        return true;
    }
}
项目:Backmemed    文件:SetAttributes.java   
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    for (SetAttributes.Modifier setattributes$modifier : this.modifiers)
    {
        UUID uuid = setattributes$modifier.uuid;

        if (uuid == null)
        {
            uuid = UUID.randomUUID();
        }

        EntityEquipmentSlot entityequipmentslot = setattributes$modifier.slots[rand.nextInt(setattributes$modifier.slots.length)];
        stack.addAttributeModifier(setattributes$modifier.attributeName, new AttributeModifier(uuid, setattributes$modifier.modifierName, (double)setattributes$modifier.amount.generateFloat(rand), setattributes$modifier.operation), entityequipmentslot);
    }

    return stack;
}
项目:Backmemed    文件:SetNBT.java   
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    NBTTagCompound nbttagcompound = stack.getTagCompound();

    if (nbttagcompound == null)
    {
        nbttagcompound = this.tag.copy();
    }
    else
    {
        nbttagcompound.merge(this.tag);
    }

    stack.setTagCompound(nbttagcompound);
    return stack;
}
项目:Backmemed    文件:Smelt.java   
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(stack);

    if (itemstack.func_190926_b())
    {
        LOGGER.warn("Couldn\'t smelt {} because there is no smelting recipe", new Object[] {stack});
        return stack;
    }
    else
    {
        ItemStack itemstack1 = itemstack.copy();
        itemstack1.func_190920_e(stack.func_190916_E());
        return itemstack1;
    }
}
项目:Backmemed    文件:LootingEnchantBonus.java   
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    Entity entity = context.getKiller();

    if (entity instanceof EntityLivingBase)
    {
        int i = EnchantmentHelper.getLootingModifier((EntityLivingBase)entity);

        if (i == 0)
        {
            return stack;
        }

        float f = (float)i * this.count.generateFloat(rand);
        stack.func_190917_f(Math.round(f));

        if (this.limit != 0 && stack.func_190916_E() > this.limit)
        {
            stack.func_190920_e(this.limit);
        }
    }

    return stack;
}
项目:Mods    文件:RandomWeaponFunction.java   
@Override
public ItemStack apply(ItemStack stack, Random rand, LootContext context) {
    stack= ItemFromData.getRandomWeapon(rand, ItemFromData.VISIBLE_WEAPON);

    if(!stack.isEmpty() && stack.getItem() instanceof ItemWeapon && this.valveWepChance>=rand.nextFloat()){
        stack.getTagCompound().setBoolean("Valve", true);
        TF2Attribute.setAttribute(stack, TF2Attribute.attributes[0], 1.15f);
        TF2Attribute.setAttribute(stack, TF2Attribute.attributes[2], 2.5f);
        TF2Attribute.setAttribute(stack, TF2Attribute.attributes[6], 0.85f);
        TF2Attribute.setAttribute(stack, TF2Attribute.attributes[61], 1.5f);
        TF2Attribute.setAttribute(stack, TF2Attribute.attributes[37], 1f);
        TF2Attribute.setAttribute(stack, TF2Attribute.attributes[45], 5f);
        TF2Attribute.setAttribute(stack, TF2Attribute.attributes[48], 5);
        TF2Attribute.setAttribute(stack, TF2Attribute.attributes[49], 0.85f);
        TF2Attribute.setAttribute(stack, TF2Attribute.attributes[46], 1.15f);
    }
    if(upgradeRange.getMax()>0)
        TF2Attribute.upgradeItemStack(stack, this.upgradeRange.generateInt(rand), rand);
    return stack;
}
项目:CustomWorldGen    文件:EntityHasProperty.java   
public boolean testCondition(Random rand, LootContext context)
{
    Entity entity = context.getEntity(this.target);

    if (entity == null)
    {
        return false;
    }
    else
    {
        for (EntityProperty entityproperty : this.properties)
        {
            if (!entityproperty.testProperty(rand, entity))
            {
                return false;
            }
        }

        return true;
    }
}
项目:CustomWorldGen    文件:EntityHasScore.java   
public boolean testCondition(Random rand, LootContext context)
{
    Entity entity = context.getEntity(this.target);

    if (entity == null)
    {
        return false;
    }
    else
    {
        Scoreboard scoreboard = entity.worldObj.getScoreboard();

        for (Entry<String, RandomValueRange> entry : this.scores.entrySet())
        {
            if (!this.entityScoreMatch(entity, scoreboard, (String)entry.getKey(), (RandomValueRange)entry.getValue()))
            {
                return false;
            }
        }

        return true;
    }
}
项目:CustomWorldGen    文件:LootConditionManager.java   
public static boolean testAllConditions(@Nullable LootCondition[] conditions, Random rand, LootContext context)
{
    if (conditions == null)
    {
        return true;
    }
    else
    {
        for (LootCondition lootcondition : conditions)
        {
            if (!lootcondition.testCondition(rand, context))
            {
                return false;
            }
        }

        return true;
    }
}
项目:CustomWorldGen    文件:SetAttributes.java   
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    for (SetAttributes.Modifier setattributes$modifier : this.modifiers)
    {
        UUID uuid = setattributes$modifier.uuid;

        if (uuid == null)
        {
            uuid = UUID.randomUUID();
        }

        EntityEquipmentSlot entityequipmentslot = setattributes$modifier.slots[rand.nextInt(setattributes$modifier.slots.length)];
        stack.addAttributeModifier(setattributes$modifier.attributeName, new AttributeModifier(uuid, setattributes$modifier.modifierName, (double)setattributes$modifier.amount.generateFloat(rand), setattributes$modifier.operation), entityequipmentslot);
    }

    return stack;
}
项目:CustomWorldGen    文件:SetNBT.java   
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    NBTTagCompound nbttagcompound = stack.getTagCompound();

    if (nbttagcompound == null)
    {
        nbttagcompound = this.tag.copy();
    }
    else
    {
        nbttagcompound.merge(this.tag);
    }

    stack.setTagCompound(nbttagcompound);
    return stack;
}
项目:CustomWorldGen    文件:Smelt.java   
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(stack);

    if (itemstack == null)
    {
        LOGGER.warn("Couldn\'t smelt {} because there is no smelting recipe", new Object[] {stack});
        return stack;
    }
    else
    {
        ItemStack itemstack1 = itemstack.copy();
        itemstack1.stackSize = stack.stackSize;
        return itemstack1;
    }
}
项目:CustomWorldGen    文件:LootingEnchantBonus.java   
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    Entity entity = context.getKiller();

    if (entity instanceof EntityLivingBase)
    {
        int i = context.getLootingModifier();

        if (i == 0)
        {
            return stack;
        }

        float f = (float)i * this.count.generateFloat(rand);
        stack.stackSize += Math.round(f);

        if (this.limit != 0 && stack.stackSize > this.limit)
        {
            stack.stackSize = this.limit;
        }
    }

    return stack;
}
项目:AquaRegia    文件:ItemHandlerLoot.java   
/**
 * Fill this inventory with loot.
 * <p>
 * Does nothing if no loot table has been set, loot has already been generated or this is being called on the client side.
 *
 * @param player The player whose Luck to use when generating loot
 */
public void fillWithLoot(@Nullable EntityPlayer player) {
    final World world = worldContainer.getContainedWorld();
    if (lootTableLocation != null && !world.isRemote) {
        final LootTable lootTable = world.getLootTableManager().getLootTableFromLocation(lootTableLocation);
        lootTableLocation = null;

        final Random random = lootTableSeed == 0 ? new Random() : new Random(lootTableSeed);

        final LootContext.Builder builder = new LootContext.Builder((WorldServer) world);

        if (player != null) {
            builder.withLuck(player.getLuck());
        }

        InventoryUtils.fillItemHandlerWithLoot(this, lootTable, random, builder.build());
    }
}
项目:AquaRegia    文件:InventoryUtils.java   
/**
 * Fill an {@link IItemHandler} with random loot from a {@link LootTable}.
 * <p>
 * Adapted from {@link LootTable#fillInventory}.
 *
 * @param itemHandler The inventory to fill with loot
 * @param lootTable   The LootTable to generate loot from
 * @param random      The Random object to use in the loot generation
 * @param context     The LootContext to use in the loot generation
 */
public static void fillItemHandlerWithLoot(IItemHandler itemHandler, LootTable lootTable, Random random, LootContext context) {
    final List<ItemStack> items = lootTable.generateLootForPools(random, context);
    final List<Integer> emptySlots = getEmptySlotsRandomized(itemHandler, random);

    try {
        SHUFFLE_ITEMS.invoke(lootTable, items, emptySlots.size(), random);
    } catch (Throwable throwable) {
        Throwables.propagate(throwable);
    }

    for (ItemStack itemStack : items) {
        if (emptySlots.isEmpty()) {
            Logger.warn("Tried to over-fill %s while generating loot.");
            return;
        }

        final int slot = emptySlots.remove(emptySlots.size() - 1);
        final ItemStack remainder = itemHandler.insertItem(slot, itemStack, false);
        if (remainder != null) {
            Logger.warn("Couldn't fully insert %s into slot %d of %s, %d items remain.", itemStack, slot, itemHandler, remainder.stackSize);
        }
    }
}
项目:Aura-Cascade    文件:LootTile.java   
@Override
public void onUsePower() {
 //   AuraCascade.analytics.eventDesign("cascaderLoot", AuraUtil.formatLocation(this));
    ItemStack lootStack;
    Random rand = this.getWorld().rand;
    do {
        //TODO TEST THAT THIS WORKS. USES BOTANIA LOONIUM CODE.
        lootStack = this.getWorld().getLootTableManager().getLootTableFromLocation(new ResourceLocation("minecraft", "chests/simple_dungeon")).generateLootForPools(rand, new LootContext.Builder(((WorldServer) this.getWorld())).build()).get(0);
        //OLD CODE: lootStack = ChestGenHooks.getOneItem(ChestGenHooks.DUNGEON_CHEST, new Random());
    } while (IMCManager.isStackBlacklistedFromLoot(lootStack));
    EntityItem entityItem = new EntityItem(worldObj, pos.getX() + .5, pos.getY() + 1.5, pos.getZ() + .5, lootStack);
    entityItem.motionX = 0;
    entityItem.motionY = 0;
    entityItem.motionZ = 0;
    worldObj.spawnEntityInWorld(entityItem);

}
项目:WearableBackpacks    文件:BackpackDataItems.java   
public static void generateLoot(ItemStackHandler items, String tableStr, long seed,
                                World world, EntityPlayer player) {
    Random rnd = new Random(seed);
    double maxFullness = (0.6 + rnd.nextDouble() * 0.2);
    int maxOccupiedSlots = (int)Math.ceil(items.getSlots() * maxFullness);

    LootTableManager manager = world.getLootTableManager();
    LootTable table = manager.getLootTableFromLocation(new ResourceLocation(tableStr));
    LootContext context = new LootContext(((player != null) ? player.getLuck() : 0),
                                          (WorldServer)world, manager, player, null, null);
    List<ItemStack> loot = table.generateLootForPools(rnd, context);
    Collections.shuffle(loot);

    List<Integer> randomizedSlots = new ArrayList<Integer>(items.getSlots());
    for (int i = 0; i < items.getSlots(); i++) randomizedSlots.add(i);
    Collections.shuffle(randomizedSlots);
    for (int i = 0; (i < maxOccupiedSlots) && (i < loot.size()); i++) {
        ItemStack stack = loot.get(i);
        int slot = randomizedSlots.get(i);
        items.setStackInSlot(slot, stack);
    }
}
项目:EnderIO    文件:ItemCapacitor.java   
@Override
public @Nonnull EnumActionResult onItemUseFirst(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side,
    float hitX, float hitY, float hitZ, @Nonnull EnumHand hand) {

  if (world.isRemote || System.getProperty("INDEV") == null || !player.isCreative()) {
    return EnumActionResult.PASS;
  }

  TileEntity te = world.getTileEntity(pos);
  if (te instanceof TileEntityChest) {
    TileEntityChest chest = (TileEntityChest) te;
    chest.clear();

    LootContext.Builder lootcontext$builder = new LootContext.Builder((WorldServer) world);
    lootcontext$builder.withLuck(player.getLuck());

    LootTable loottable = world.getLootTableManager().getLootTableFromLocation(LootTableList.CHESTS_SIMPLE_DUNGEON);
    // LootTable loottable = world.getLootTableManager().getLootTableFromLocation(LootTableList.CHESTS_IGLOO_CHEST);
    loottable.fillInventory(chest, world.rand, lootcontext$builder.build());
    return EnumActionResult.PASS;
  }

  return EnumActionResult.PASS;
}
项目:Loot-Slash-Conquer    文件:CustomLootTable.java   
@Override
public void fillInventory(IInventory inventory, Random rand, LootContext context)
{
    TileEntityChest chest = (TileEntityChest) inventory;
    CustomLootContext.Builder context$builder = new CustomLootContext.Builder((WorldServer) chest.getWorld());
    context$builder.withChestPos(chest.getPos());
    CustomLootContext customContext = context$builder.build();

    List<ItemStack> list = this.generateLootForPools(rand, customContext);
    List<Integer> list1 = this.getEmptySlotsRandomized(inventory, rand);
    this.shuffleItems(list, list1.size(), rand);

    for (ItemStack itemstack : list)
    {
        if (list1.isEmpty())
        {
            LootSlashConquer.LOGGER.warn("Tried to over-fill a container");
            return;
        }

        if (itemstack.isEmpty())
        {
            inventory.setInventorySlotContents(((Integer)list1.remove(list1.size() - 1)).intValue(), ItemStack.EMPTY);
        }
        else
        {
            inventory.setInventorySlotContents(((Integer)list1.remove(list1.size() - 1)).intValue(), itemstack);
        }
    }
}
项目:harshencastle    文件:HarshenUtils.java   
public static List<ItemStack> getItemsFromLootPool(World world, ResourceLocation locationOfTable, String poolName)
{
    LootContext context = new LootContext(1f, (WorldServer) world, world.getLootTableManager(), null, null, DamageSource.MAGIC);
    List<ItemStack> list = Lists.<ItemStack>newArrayList();
    world.getLootTableManager().getLootTableFromLocation(locationOfTable).getPool(poolName).generateLoot(list, new Random(), context);
    return exposeList(list);
}
项目:Backmemed    文件:RandomChanceWithLooting.java   
public boolean testCondition(Random rand, LootContext context)
{
    int i = 0;

    if (context.getKiller() instanceof EntityLivingBase)
    {
        i = EnchantmentHelper.getLootingModifier((EntityLivingBase)context.getKiller());
    }

    return rand.nextFloat() < this.chance + (float)i * this.lootingMultiplier;
}
项目:Backmemed    文件:EntityHasProperty.java   
public EntityHasProperty deserialize(JsonObject json, JsonDeserializationContext context)
{
    Set<Entry<String, JsonElement>> set = JsonUtils.getJsonObject(json, "properties").entrySet();
    EntityProperty[] aentityproperty = new EntityProperty[set.size()];
    int i = 0;

    for (Entry<String, JsonElement> entry : set)
    {
        aentityproperty[i++] = EntityPropertyManager.getSerializerForName(new ResourceLocation((String)entry.getKey())).deserialize((JsonElement)entry.getValue(), context);
    }

    return new EntityHasProperty(aentityproperty, (LootContext.EntityTarget)JsonUtils.deserializeClass(json, "entity", context, LootContext.EntityTarget.class));
}
项目:Backmemed    文件:EntityHasScore.java   
public EntityHasScore deserialize(JsonObject json, JsonDeserializationContext context)
{
    Set<Entry<String, JsonElement>> set = JsonUtils.getJsonObject(json, "scores").entrySet();
    Map<String, RandomValueRange> map = Maps.<String, RandomValueRange>newLinkedHashMap();

    for (Entry<String, JsonElement> entry : set)
    {
        map.put(entry.getKey(), JsonUtils.deserializeClass((JsonElement)entry.getValue(), "score", context, RandomValueRange.class));
    }

    return new EntityHasScore(map, (LootContext.EntityTarget)JsonUtils.deserializeClass(json, "entity", context, LootContext.EntityTarget.class));
}
项目:Backmemed    文件:SetMetadata.java   
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    if (stack.isItemStackDamageable())
    {
        LOGGER.warn("Couldn\'t set data of loot item {}", new Object[] {stack});
    }
    else
    {
        stack.setItemDamage(this.metaRange.generateInt(rand));
    }

    return stack;
}
项目:Backmemed    文件:SetDamage.java   
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    if (stack.isItemStackDamageable())
    {
        float f = 1.0F - this.damageRange.generateFloat(rand);
        stack.setItemDamage(MathHelper.floor(f * (float)stack.getMaxDamage()));
    }
    else
    {
        LOGGER.warn("Couldn\'t set damage of loot item {}", new Object[] {stack});
    }

    return stack;
}
项目:Backmemed    文件:EntityLiving.java   
/**
 * drops the loot of this entity upon death
 */
protected void dropLoot(boolean wasRecentlyHit, int lootingModifier, DamageSource source)
{
    ResourceLocation resourcelocation = this.deathLootTable;

    if (resourcelocation == null)
    {
        resourcelocation = this.getLootTable();
    }

    if (resourcelocation != null)
    {
        LootTable loottable = this.world.getLootTableManager().getLootTableFromLocation(resourcelocation);
        this.deathLootTable = null;
        LootContext.Builder lootcontext$builder = (new LootContext.Builder((WorldServer)this.world)).withLootedEntity(this).withDamageSource(source);

        if (wasRecentlyHit && this.attackingPlayer != null)
        {
            lootcontext$builder = lootcontext$builder.withPlayer(this.attackingPlayer).withLuck(this.attackingPlayer.getLuck());
        }

        for (ItemStack itemstack : loottable.generateLootForPools(this.deathLootTableSeed == 0L ? this.rand : new Random(this.deathLootTableSeed), lootcontext$builder.build()))
        {
            this.entityDropItem(itemstack, 0.0F);
        }

        this.dropEquipment(wasRecentlyHit, lootingModifier);
    }
    else
    {
        super.dropLoot(wasRecentlyHit, lootingModifier, source);
    }
}
项目:Mods    文件:EntityBuildingFunction.java   
@Override
public ItemStack apply(ItemStack stack, Random rand, LootContext context) {
    Entity entity = context.getEntity(EntityTarget.THIS);
    if (entity != null && entity instanceof EntityTF2Character)
        stack.setItemDamage(18 + rand.nextInt(3) * 2 + ((EntityTF2Character) entity).getEntTeam());
    return stack;
}
项目:Mods    文件:KilledByTeam.java   
@Override
public boolean testCondition(Random rand, LootContext context) {

    Entity player = this.team ? context.getKiller() : context.getKillerPlayer();
    if(player instanceof IEntityOwnable && ((IEntityOwnable)player).getOwner() instanceof EntityPlayer)
        player = ((IEntityOwnable)player).getOwner();
    return player != null && player.getTeam() != null && !player.isOnSameTeam(context.getLootedEntity());
}
项目:CustomWorldGen    文件:EntityHasProperty.java   
public EntityHasProperty deserialize(JsonObject json, JsonDeserializationContext context)
{
    Set<Entry<String, JsonElement>> set = JsonUtils.getJsonObject(json, "properties").entrySet();
    EntityProperty[] aentityproperty = new EntityProperty[set.size()];
    int i = 0;

    for (Entry<String, JsonElement> entry : set)
    {
        aentityproperty[i++] = EntityPropertyManager.getSerializerForName(new ResourceLocation((String)entry.getKey())).deserialize((JsonElement)entry.getValue(), context);
    }

    return new EntityHasProperty(aentityproperty, (LootContext.EntityTarget)JsonUtils.deserializeClass(json, "entity", context, LootContext.EntityTarget.class));
}
项目:CustomWorldGen    文件:EntityHasScore.java   
public EntityHasScore deserialize(JsonObject json, JsonDeserializationContext context)
{
    Set<Entry<String, JsonElement>> set = JsonUtils.getJsonObject(json, "scores").entrySet();
    Map<String, RandomValueRange> map = Maps.<String, RandomValueRange>newLinkedHashMap();

    for (Entry<String, JsonElement> entry : set)
    {
        map.put(entry.getKey(), JsonUtils.deserializeClass((JsonElement)entry.getValue(), "score", context, RandomValueRange.class));
    }

    return new EntityHasScore(map, (LootContext.EntityTarget)JsonUtils.deserializeClass(json, "entity", context, LootContext.EntityTarget.class));
}
项目:CustomWorldGen    文件:LootConditionManager.java   
public static boolean testAllConditions(Iterable<LootCondition> conditions, Random rand, LootContext context)
{
    if (conditions == null) return true;
    for (LootCondition cond : conditions)
       if (!cond.testCondition(rand, context))
            return false;
    return true;
}
项目:CustomWorldGen    文件:SetMetadata.java   
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    if (stack.isItemStackDamageable())
    {
        LOGGER.warn("Couldn\'t set data of loot item {}", new Object[] {stack});
    }
    else
    {
        stack.setItemDamage(this.metaRange.generateInt(rand));
    }

    return stack;
}
项目:CustomWorldGen    文件:SetDamage.java   
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    if (stack.isItemStackDamageable())
    {
        float f = 1.0F - this.damageRange.generateFloat(rand);
        stack.setItemDamage(MathHelper.floor_float(f * (float)stack.getMaxDamage()));
    }
    else
    {
        LOGGER.warn("Couldn\'t set damage of loot item {}", new Object[] {stack});
    }

    return stack;
}
项目:CustomWorldGen    文件:EntityLiving.java   
/**
 * drops the loot of this entity upon death
 */
protected void dropLoot(boolean wasRecentlyHit, int lootingModifier, DamageSource source)
{
    ResourceLocation resourcelocation = this.deathLootTable;

    if (resourcelocation == null)
    {
        resourcelocation = this.getLootTable();
    }

    if (resourcelocation != null)
    {
        LootTable loottable = this.worldObj.getLootTableManager().getLootTableFromLocation(resourcelocation);
        this.deathLootTable = null;
        LootContext.Builder lootcontext$builder = (new LootContext.Builder((WorldServer)this.worldObj)).withLootedEntity(this).withDamageSource(source);

        if (wasRecentlyHit && this.attackingPlayer != null)
        {
            lootcontext$builder = lootcontext$builder.withPlayer(this.attackingPlayer).withLuck(this.attackingPlayer.getLuck());
        }

        for (ItemStack itemstack : loottable.generateLootForPools(this.deathLootTableSeed == 0L ? this.rand : new Random(this.deathLootTableSeed), lootcontext$builder.build()))
        {
            this.entityDropItem(itemstack, 0.0F);
        }

        this.dropEquipment(wasRecentlyHit, lootingModifier);
    }
    else
    {
        super.dropLoot(wasRecentlyHit, lootingModifier, source);
    }
}
项目:CrystalMod    文件:EventHandler.java   
@Override
public boolean testCondition(Random rand, LootContext context) {
    Entity entity = context.getEntity(EntityTarget.THIS);
    if(entity == null)return false;
    World world = context.getWorld();
    Biome biome = world.getBiomeForCoordsBody(new BlockPos(entity));
    if(BiomeDictionary.hasType(biome, Type.COLD) || BiomeDictionary.hasType(biome, Type.SNOWY)){
        return true;
    }
    return false;
}
项目:Fyrestone    文件:LootHandler.java   
public void generateLoot(Collection<ItemStack> stacks, Random random, LootContext contect)
{
    for (LootPoolEntry entry : items)
    {
        if (random.nextDouble() < entry.chance)
        {
            stacks.add(entry.createStack(random));
        }
    }
}
项目:Bookshelf    文件:SetColor.java   
@Override
public ItemStack apply (ItemStack stack, Random rand, LootContext context) {

    final MCColor colorToApply = this.color == null ? MCColor.getRandomColor(rand) : this.color;
    colorToApply.writeToStack(StackUtils.prepareStack(stack));
    return stack;
}