当前位置: 首页>>代码示例>>Java>>正文


Java PlayerUserReturning类代码示例

本文整理汇总了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);
		}
	});
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral-Integration,代码行数:10,代码来源:NotebookWrapper.java

示例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);
		}
	});
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral-Integration,代码行数:10,代码来源:NotebookWrapper.java

示例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);
		}
	});
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral-Integration,代码行数:9,代码来源:NotebookWrapper.java

示例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);
		}
	});
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral-Integration,代码行数:9,代码来源:NotebookWrapper.java

示例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;
}
 
开发者ID:OpenMods,项目名称:OpenBlocks,代码行数:8,代码来源:MagnetControlAdapter.java

示例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));
}
 
开发者ID:OpenMods,项目名称:OpenBlocks,代码行数:41,代码来源:BlockTarget.java

示例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;
	});

}
 
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:12,代码来源:EntityBlock.java


注:本文中的openmods.fakeplayer.FakePlayerPool.PlayerUserReturning类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。