Java 类net.minecraft.world.storage.loot.conditions.LootConditionManager 实例源码
项目:BetterThanWeagles
文件:CommonProxy.java
public void init(FMLInitializationEvent event)
{
// Register custom loot tables and auxiliaries
LootConditionManager.registerCondition(new LootIsModLoaded.Serializer());
LootTableList.register(new ResourceLocation(BetterThanWeagles.MODID, "custom/simple_dungeon_chest"));
ModVillagers.registerVillagerTrades();
// Set up integration with other mods
if (Loader.isModLoaded("actuallyadditions"))
{
IntegrationAAdditions.init();
}
if (Loader.isModLoaded("immersiveengineering"))
{
IntegrationIEngineering.init();
}
if (Loader.isModLoaded("tconstruct"))
{
IntegrationTinkers.init();
}
if (Loader.isModLoaded("thermalexpansion"))
{
IntegrationThermal.init();
}
}
项目:Backmemed
文件:LootPool.java
/**
* generates the contents for a single roll.
* The first for loop calculates the sum of all the lootentries
* and the second for loop adds a random item
* with items with higher weights being more probable.
*/
protected void createLootRoll(Collection<ItemStack> stacks, Random rand, LootContext context)
{
List<LootEntry> list = Lists.<LootEntry>newArrayList();
int i = 0;
for (LootEntry lootentry : this.lootEntries)
{
if (LootConditionManager.testAllConditions(lootentry.conditions, rand, context))
{
int j = lootentry.getEffectiveWeight(context.getLuck());
if (j > 0)
{
list.add(lootentry);
i += j;
}
}
}
if (i != 0 && !list.isEmpty())
{
int k = rand.nextInt(i);
for (LootEntry lootentry1 : list)
{
k -= lootentry1.getEffectiveWeight(context.getLuck());
if (k < 0)
{
lootentry1.addLoot(stacks, rand, context);
return;
}
}
}
}
项目:Backmemed
文件:LootPool.java
/**
* generates loot and puts it in an inventory
*/
public void generateLoot(Collection<ItemStack> stacks, Random rand, LootContext context)
{
if (LootConditionManager.testAllConditions(this.poolConditions, rand, context))
{
int i = this.rolls.generateInt(rand) + MathHelper.floor(this.bonusRolls.generateFloat(rand) * context.getLuck());
for (int j = 0; j < i; ++j)
{
this.createLootRoll(stacks, rand, context);
}
}
}
项目:Backmemed
文件:LootEntryItem.java
public void addLoot(Collection<ItemStack> stacks, Random rand, LootContext context)
{
ItemStack itemstack = new ItemStack(this.item);
for (LootFunction lootfunction : this.functions)
{
if (LootConditionManager.testAllConditions(lootfunction.getConditions(), rand, context))
{
itemstack = lootfunction.apply(itemstack, rand, context);
}
}
if (!itemstack.func_190926_b())
{
if (itemstack.func_190916_E() < this.item.getItemStackLimit())
{
stacks.add(itemstack);
}
else
{
int i = itemstack.func_190916_E();
while (i > 0)
{
ItemStack itemstack1 = itemstack.copy();
itemstack1.func_190920_e(Math.min(itemstack.getMaxStackSize(), i));
i -= itemstack1.func_190916_E();
stacks.add(itemstack1);
}
}
}
}
项目:CustomWorldGen
文件:LootPool.java
/**
* generates the contents for a single roll.
* The first for loop calculates the sum of all the lootentries
* and the second for loop adds a random item
* with items with higher weights being more probable.
*/
protected void createLootRoll(Collection<ItemStack> stacks, Random rand, LootContext context)
{
List<LootEntry> list = Lists.<LootEntry>newArrayList();
int i = 0;
for (LootEntry lootentry : this.lootEntries)
{
if (LootConditionManager.testAllConditions(lootentry.conditions, rand, context))
{
int j = lootentry.getEffectiveWeight(context.getLuck());
if (j > 0)
{
list.add(lootentry);
i += j;
}
}
}
if (i != 0 && !list.isEmpty())
{
int k = rand.nextInt(i);
for (LootEntry lootentry1 : list)
{
k -= lootentry1.getEffectiveWeight(context.getLuck());
if (k < 0)
{
lootentry1.addLoot(stacks, rand, context);
return;
}
}
}
}
项目:CustomWorldGen
文件:LootPool.java
/**
* generates loot and puts it in an inventory
*/
public void generateLoot(Collection<ItemStack> stacks, Random rand, LootContext context)
{
if (LootConditionManager.testAllConditions(this.poolConditions, rand, context))
{
int i = this.rolls.generateInt(rand) + MathHelper.floor_float(this.bonusRolls.generateFloat(rand) * context.getLuck());
for (int j = 0; j < i; ++j)
{
this.createLootRoll(stacks, rand, context);
}
}
}
项目:CustomWorldGen
文件:LootEntryItem.java
public void addLoot(Collection<ItemStack> stacks, Random rand, LootContext context)
{
ItemStack itemstack = new ItemStack(this.item);
for (LootFunction lootfunction : this.functions)
{
if (LootConditionManager.testAllConditions(lootfunction.getConditions(), rand, context))
{
itemstack = lootfunction.apply(itemstack, rand, context);
}
}
if (itemstack.stackSize > 0)
{
if (itemstack.stackSize < this.item.getItemStackLimit(itemstack))
{
stacks.add(itemstack);
}
else
{
int i = itemstack.stackSize;
while (i > 0)
{
ItemStack itemstack1 = itemstack.copy();
itemstack1.stackSize = Math.min(itemstack.getMaxStackSize(), i);
i -= itemstack1.stackSize;
stacks.add(itemstack1);
}
}
}
}