本文整理汇总了Java中openmods.fakeplayer.FakePlayerPool.PlayerUserReturning类的典型用法代码示例。如果您正苦于以下问题:Java PlayerUserReturning类的具体用法?Java PlayerUserReturning怎么用?Java PlayerUserReturning使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayerUserReturning类属于openmods.fakeplayer.FakePlayerPool包,在下文中一共展示了PlayerUserReturning类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getName
import openmods.fakeplayer.FakePlayerPool.PlayerUserReturning; //导入依赖的package包/类
@ScriptCallable(returnTypes = ReturnType.STRING)
public String getName() {
return FakePlayerPool.instance.executeOnPlayer(ownerWorld, new PlayerUserReturning<String>() {
@Override
public String usePlayer(OpenModsFakePlayer fakePlayer) {
return item.getDisplayName(fakePlayer, stack);
}
});
}
示例2: getPages
import openmods.fakeplayer.FakePlayerPool.PlayerUserReturning; //导入依赖的package包/类
@ScriptCallable(returnTypes = ReturnType.TABLE, name = "getAllPages")
public List<ItemStack> getPages() {
return FakePlayerPool.instance.executeOnPlayer(ownerWorld, new PlayerUserReturning<List<ItemStack>>() {
@Override
public List<ItemStack> usePlayer(OpenModsFakePlayer fakePlayer) {
return item.getItems(fakePlayer, stack);
}
});
}
示例3: removePage
import openmods.fakeplayer.FakePlayerPool.PlayerUserReturning; //导入依赖的package包/类
public ItemStack removePage(final ItemStack page) {
return FakePlayerPool.instance.executeOnPlayer(ownerWorld, new PlayerUserReturning<ItemStack>() {
@Override
public ItemStack usePlayer(OpenModsFakePlayer fakePlayer) {
return item.remove(fakePlayer, stack, page);
}
});
}
示例4: addPage
import openmods.fakeplayer.FakePlayerPool.PlayerUserReturning; //导入依赖的package包/类
public ItemStack addPage(final ItemStack page) {
return FakePlayerPool.instance.executeOnPlayer(ownerWorld, new PlayerUserReturning<ItemStack>() {
@Override
public ItemStack usePlayer(OpenModsFakePlayer fakePlayer) {
return item.addPage(fakePlayer, stack, page);
}
});
}
示例5: createByPlayer
import openmods.fakeplayer.FakePlayerPool.PlayerUserReturning; //导入依赖的package包/类
@Override
public EntityBlock createByPlayer(final IEntityBlockFactory factory) {
World world = turtle.getWorld();
if (world instanceof WorldServer) return FakePlayerPool.instance.executeOnPlayer((WorldServer)world, (PlayerUserReturning<EntityBlock>)factory::create);
return null;
}
示例6: dropArrowsAsItems
import openmods.fakeplayer.FakePlayerPool.PlayerUserReturning; //导入依赖的package包/类
private static void dropArrowsAsItems(WorldServer world, BlockPos pos) {
final AxisAlignedBB aabb = BlockUtils.aabbOffset(pos, -0.2, -0.2, -0.2, +1.2, +1.2, +1.2);
final List<EntityArrow> arrows = world.getEntitiesWithinAABB(EntityArrow.class, aabb);
final List<ItemStack> drops = Lists.newArrayList();
int failed = FakePlayerPool.instance.executeOnPlayer(world, (PlayerUserReturning<Integer>)fakePlayer -> {
int failedCount = 0;
for (EntityArrow arrow : arrows) {
if (arrow.pickupStatus == EntityArrow.PickupStatus.CREATIVE_ONLY) {
arrow.setDead();
} else {
try {
arrow.onCollideWithPlayer(fakePlayer);
} catch (Throwable t) {
Log.warn(t, "Failed to collide arrow %s with fake player, returing vanilla one", arrow);
failedCount++;
}
}
}
IInventory inventory = fakePlayer.inventory;
for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack stack = inventory.getStackInSlot(i);
if (!stack.isEmpty())
drops.add(stack);
}
inventory.clear();
return failedCount;
});
for (ItemStack drop : drops)
BlockUtils.dropItemStackInWorld(world, pos, drop);
if (failed > 0) BlockUtils.dropItemStackInWorld(world, pos, new ItemStack(Items.ARROW, failed));
}
示例7: tryPlaceBlock
import openmods.fakeplayer.FakePlayerPool.PlayerUserReturning; //导入依赖的package包/类
private boolean tryPlaceBlock(final WorldServer world, final BlockPos pos) {
return FakePlayerPool.instance.executeOnPlayer(world, (PlayerUserReturning<Boolean>)fakePlayer -> {
if (tryPlaceBlock(fakePlayer, world, pos, EnumFacing.DOWN)) return true;
for (EnumFacing dir : PLACE_DIRECTIONS) {
if (tryPlaceBlock(fakePlayer, world, pos, dir)) return true;
}
return false;
});
}