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

项目: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;
}
项目:BetterBeginningsReborn    文件:BBEventHandler.java   
private static void replaceCookedWithCharred(LootPool targetPool, Item targetItem, ItemStack replacementStack, int minCount, int maxCount)
   {
List<LootFunction> charredFunctions = Lists.newArrayList();
if(replacementStack.getItemDamage() != 0) charredFunctions.add(LootUtil.createSetMetadata(replacementStack.getItemDamage()));
if(replacementStack.getTagCompound() != null) charredFunctions.add(LootUtil.createSetNBT(replacementStack.getTagCompound()));
charredFunctions.add(LootUtil.createCountFunction(minCount, maxCount));
charredFunctions.add(LootUtil.createLootingFunc(0, 1));

LootCondition notOnFire = new EntityHasProperty(new EntityProperty[] {new EntityOnFire(false)}, EntityTarget.THIS);
LootCondition onFire = new EntityHasProperty(new EntityProperty[] {new EntityOnFire(true)}, EntityTarget.THIS);

targetPool.removeEntry(targetItem.getRegistryName().toString());
targetPool.addEntry(new LootEntryItem(targetItem, 1, 1, new LootFunction[] {LootUtil.createCountFunction(1, 3), LootUtil.createLootingFunc(0, 1)}, new LootCondition[] {notOnFire}, targetItem.getRegistryName().toString()));
targetPool.addEntry(new LootEntryItem(replacementStack.getItem(), 1, 1, charredFunctions.toArray(new LootFunction[charredFunctions.size()]), new LootCondition[] {onFire}, ModMain.MODID + ":charred_+" + targetItem.getRegistryName().getResourcePath().toString()));
   }
项目:BetterBeginningsReborn    文件:BBEventHandler.java   
private void removeSmeltFunction(LootPool pool, Item targetItem, Item replacement, int minCount, int maxCount)
   {
LootCondition notOnFire = new EntityHasProperty(new EntityProperty[] {new EntityOnFire(false)}, EntityTarget.THIS);
LootCondition onFire = new EntityHasProperty(new EntityProperty[] {new EntityOnFire(true)}, EntityTarget.THIS);

pool.removeEntry(targetItem.getRegistryName().toString());
pool.addEntry(new LootEntryItem(targetItem, 1, 1, new LootFunction[] {LootUtil.createCountFunction(1, 3), LootUtil.createLootingFunc(0, 1)}, new LootCondition[] {notOnFire}, targetItem.getRegistryName().toString()));
pool.addEntry(new LootEntryItem(replacement, 1, 1, new LootFunction[] {LootUtil.createCountFunction(1, 3), LootUtil.createLootingFunc(0, 1)}, new LootCondition[] {onFire}, replacement.getRegistryName().toString()));
   }
项目: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;
}