本文整理匯總了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;
});
}