Java 类net.minecraft.world.storage.loot.LootTableManager 实例源码
项目:runesofwizardry-classics
文件:RuneResurrection.java
private List<ItemStack> getEntityLoot_Table(EntityLiving el){
ResourceLocation location = (ResourceLocation)ReflectionHelper.getPrivateValue(EntityLiving.class, el, "deathLootTable","field_184659_bA");
if(location==null){
Method getLT = ReflectionHelper.findMethod(EntityLiving.class,"getLootTable","func_184647_J");
try {
location = (ResourceLocation)getLT.invoke(el);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
RunesofWizardry_Classics.log().error("Exception when trying to get LootTable from entity: "+el.getName(),e);
return getEntityLoot_Hacky(el);
}
}
if(location==null){
RunesofWizardry_Classics.log().warn(el.getName()+" does not have a LootTable. falling back to kill method");
return getEntityLoot_Hacky(el);
}
LootTableManager manager = el.world.getLootTableManager();
LootTable table = manager.getLootTableFromLocation(location);
return LootUtils.tableToItemStacks(table);
}
项目: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);
}
}
项目:UniversalRemote
文件:WorldServerProxy.java
@Override
public LootTableManager getLootTableManager() {
if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) {
return m_proxyWorld.getLootTableManager();
} else if (m_realWorld != null) {
return m_realWorld.getLootTableManager();
} else {
return super.getLootTableManager();
}
}
项目:Loot-Slash-Conquer
文件:CustomLootContext.java
public CustomLootContext(float luck, WorldServer world, LootTableManager manager, @Nullable Entity lootedEntity, @Nullable EntityPlayer player, @Nullable DamageSource damageSource, BlockPos chestPos)
{
super(luck, world, manager, lootedEntity, player, damageSource);
this.chestPos = chestPos;
}
项目:Backmemed
文件:World.java
public LootTableManager getLootTableManager()
{
return this.lootTable;
}
项目:CustomWorldGen
文件:World.java
public LootTableManager getLootTableManager()
{
return this.lootTable;
}
项目:placementpreview
文件:FakeWorld.java
@Override
public LootTableManager getLootTableManager()
{
return this.parent.getLootTableManager();
}
项目:Cyclic
文件:TileEntityFishing.java
@Override
public void update() {
World world = this.getWorld();
Random rand = world.rand;
if (rand.nextDouble() < this.getFishSpeed() &&
isValidPosition() && isEquipmentValid() &&
world instanceof WorldServer && world != null &&
world.getWorldTime() % Const.TICKS_PER_SEC == 0) {
LootContext.Builder lootcontext$builder = new LootContext.Builder((WorldServer) world);
int luck = EnchantmentHelper.getEnchantmentLevel(Enchantments.LUCK_OF_THE_SEA, this.getStackInSlot(toolSlot));
lootcontext$builder.withLuck((float) luck);
// java.lang.NullPointerException: Ticking block entity at com.lothrazar.cyclicmagic.block.tileentity.TileEntityFishing.func_73660_a(TileEntityFishing.java:58)
LootTableManager loot = world.getLootTableManager();
if (loot == null) {
return;
}
LootTable table = loot.getLootTableFromLocation(LootTableList.GAMEPLAY_FISHING);
if (table == null) {
return;
}
LootContext context = lootcontext$builder.build();
if (context == null) {
return;
}
for (ItemStack itemstack : table.generateLootForPools(rand, context)) {
UtilParticle.spawnParticle(world, EnumParticleTypes.WATER_WAKE, pos.up());
//damage phase.
int mending = EnchantmentHelper.getEnchantmentLevel(Enchantments.MENDING, this.getStackInSlot(toolSlot));
if (mending == 0) {
damageTool();
}
else {
if (rand.nextDouble() < 0.25) {//25% chance damage
damageTool();
}
else if (rand.nextDouble() < 0.60) {//60-25 = 40 chance repair
attemptRepairTool();
}
//else do nothing, leave it flat. mimics getting damaged and repaired right away
}
//loot phase
this.sendOutputItem(itemstack);
}
}
}
项目:EnderIO
文件:PickupWorld.java
@Override
public @Nonnull LootTableManager getLootTableManager() {
return wrapped.getLootTableManager();
}