當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。