本文整理汇总了Java中org.spongepowered.api.block.tileentity.carrier.Chest类的典型用法代码示例。如果您正苦于以下问题:Java Chest类的具体用法?Java Chest怎么用?Java Chest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Chest类属于org.spongepowered.api.block.tileentity.carrier包,在下文中一共展示了Chest类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: applyContents
import org.spongepowered.api.block.tileentity.carrier.Chest; //导入依赖的package包/类
private void applyContents(Location<World> location, Backpack inv) {
if ( ! location.getTileEntity().isPresent()) {
// re run later
SilkTouch.get().getTaskBuilder().execute(
() -> this.applyContents(location, inv))
.async().delay(20, TimeUnit.MILLISECONDS)
.name("SilkTouch - (backpack) apply contents delay").submit(SilkTouch.get().getPlugin());
return;
}
Chest chest = (Chest) location.getTileEntity().get();
Inventory inventory = chest.getInventory().first();
}
开发者ID:redstone,项目名称:SilkTouch,代码行数:18,代码来源:CriteriaBackpackListener.java
示例2: getConnectedChests
import org.spongepowered.api.block.tileentity.carrier.Chest; //导入依赖的package包/类
@Override
public Set<Chest> getConnectedChests() {
if (!isValid()) {
return Collections.emptySet();
}
final Location<World> location = getLocation();
final Set<Chest> chests = new HashSet<>();
for (Direction directionToCheck : HORIZONTAL_DIRECTIONS) {
final Location<World> loc = location.getRelative(directionToCheck);
if (loc.getBlock().getType() != getBlock().getType()) {
continue;
}
final Optional<TileEntity> optTileEntity = location.getRelative(directionToCheck).getTileEntity();
if (optTileEntity.isPresent() && optTileEntity.get() instanceof LanternChest) {
chests.add((Chest) optTileEntity.get());
}
}
return Collections.unmodifiableSet(chests);
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:20,代码来源:LanternChest.java
示例3: validateOpenableSpace
import org.spongepowered.api.block.tileentity.carrier.Chest; //导入依赖的package包/类
@SuppressWarnings("ConstantConditions")
@Override
protected boolean validateOpenableSpace(BehaviorContext context, Location<World> location, List<Runnable> tasks) {
final TileEntity tileEntity = location.getTileEntity().get();
if (tileEntity instanceof Chest) {
final Set<Chest> chests = new HashSet<>(((Chest) tileEntity).getConnectedChests());
chests.add((Chest) tileEntity);
for (Chest chest : chests) {
final Location<World> loc = chest.getLocation();
if (!validateOpenableChestSpace(context, loc, tasks)) {
return false;
}
}
}
return true;
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:17,代码来源:ChestInteractionBehavior.java
示例4: transferToStorage
import org.spongepowered.api.block.tileentity.carrier.Chest; //导入依赖的package包/类
private void transferToStorage(Inventory inventory, List<ItemStack> filters)
{
if (!filters.isEmpty()) // Only allow to extract items in the filter
{
inventory = queryFiltered(filters, inventory); // TODO more filters
}
for (Location<World> targetLoc : storage)
{
TileEntity te = targetLoc.getTileEntity().get();
Inventory target = ((Carrier) te).getInventory();
if (te instanceof Chest)
{
target = ((Chest) te).getDoubleChestInventory().orElse(target);
}
doTransfer(inventory, target);
}
}
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:18,代码来源:Network.java
示例5: pullFromStorage
import org.spongepowered.api.block.tileentity.carrier.Chest; //导入依赖的package包/类
private void pullFromStorage(Inventory inventory, List<ItemStack> filters)
{
for (Location<World> targetLoc : storage)
{
TileEntity te = targetLoc.getTileEntity().get();
Inventory pollFrom = ((Carrier) te).getInventory();
if (te instanceof Chest)
{
pollFrom = ((Chest) te).getDoubleChestInventory().orElse(pollFrom);
}
if (!filters.isEmpty()) // Only allow to extract items in the filter
{
pollFrom = queryFiltered(filters, inventory); // TODO more filters
}
doTransfer(pollFrom, inventory);
}
}
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:19,代码来源:Network.java
示例6: getInventoryFrom
import org.spongepowered.api.block.tileentity.carrier.Chest; //导入依赖的package包/类
@Override
protected Optional<Inventory> getInventoryFrom(TileEntity tileEntity) {
if (tileEntity instanceof Chest) {
final Optional<Inventory> optDouble = ((Chest) tileEntity).getDoubleChestInventory();
if (optDouble.isPresent()) {
return optDouble;
}
}
return super.getInventoryFrom(tileEntity);
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:11,代码来源:ChestInteractionBehavior.java
示例7: execute
import org.spongepowered.api.block.tileentity.carrier.Chest; //导入依赖的package包/类
@Override
public void execute(SurvivalGame survivalGame) throws TextMessageException {
String worldName =
getOrThrow(survivalGame.getConfig().getWorldName(), CommandKeys.WORLD_NAME);
World world = getOrThrow(Sponge.getServer().getWorld(worldName), CommandKeys.WORLD_NAME);
Integer chestMidpoint =
getOrThrow(survivalGame.getConfig().getChestMidpoint(), CommandKeys.CHEST_MIDPOINT);
Integer chestRange =
getOrThrow(survivalGame.getConfig().getChestRange(), CommandKeys.CHEST_RANGE);
world.getTileEntities()
.forEach(
tileEntity -> {
if (tileEntity instanceof Chest) {
Chest chest = (Chest) tileEntity;
chest.getInventory().clear();
if (!survivalGame
.getConfig()
.getItemConfig()
.getItems()
.isEmpty()) {
double itemCount =
(chestMidpoint
+ ((RANDOM.nextDouble() * chestRange)
* (RANDOM.nextDouble() > 0.5
? 1
: -1)));
for (int i = 0; i < itemCount; i++) {
ItemStackSnapshot stackSnapshot =
survivalGame
.getConfig()
.getItemConfig()
.getItems()
.get(
RANDOM.nextInt(
survivalGame
.getConfig()
.getItemConfig()
.getItems()
.size()));
chest.getInventory().offer(stackSnapshot.createStack());
}
}
}
});
}
开发者ID:m0pt0pmatt,项目名称:SurvivalGames,代码行数:50,代码来源:FillChestsTask.java
示例8: activate
import org.spongepowered.api.block.tileentity.carrier.Chest; //导入依赖的package包/类
public void activate(Inventory inventory, List<ItemStack> filters)
{
if (isStorage())
{
pullFromStorage(inventory, filters);
return;
}
for (Map.Entry<Location<World>, DuctData> entry : exitPoints.entrySet())
{
Inventory pollFrom = inventory;
Location<World> loc = entry.getKey();
DuctData data = entry.getValue();
Direction dir = loc.get(Keys.DIRECTION).orElse(Direction.NONE).getOpposite();
Location<World> targetLoc = loc.getRelative(dir.getOpposite());
TileEntity te = targetLoc.getTileEntity().get();
Inventory target = ((Carrier) te).getInventory();
if (te instanceof Dropper)
{
Network nw = manager.findNetwork(targetLoc);
nw.transferToStorage(queryFiltered(filters, inventory), data.get(dir).get());
continue;
}
if (te instanceof Chest)
{
target = ((Chest) te).getDoubleChestInventory().orElse(target);
}
Optional<List<ItemStack>> targetFilter = data.get(dir);
if (targetFilter.isPresent())
{
if (!filters.isEmpty()) // Only allow to extract items in the filter
{
pollFrom = queryFiltered(filters, inventory); // TODO more filters
}
Inventory pollFromTo = pollFrom;
if (!targetFilter.get().isEmpty()) // Only allow to insert items in the filter
{
pollFromTo = queryFiltered(targetFilter.get(), inventory); // TODO more filters
}
// For all filtered slots
doTransfer(pollFromTo, target);
}
}
}
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:45,代码来源:Network.java
示例9: of
import org.spongepowered.api.block.tileentity.carrier.Chest; //导入依赖的package包/类
public static PoreChest of(Chest handle) {
return WrapperConverter.of(PoreChest.class, handle);
}
开发者ID:LapisBlue,项目名称:Pore,代码行数:4,代码来源:PoreChest.java
示例10: PoreChest
import org.spongepowered.api.block.tileentity.carrier.Chest; //导入依赖的package包/类
protected PoreChest(Chest handle) {
super(handle);
}
开发者ID:LapisBlue,项目名称:Pore,代码行数:4,代码来源:PoreChest.java
示例11: getTileEntity
import org.spongepowered.api.block.tileentity.carrier.Chest; //导入依赖的package包/类
@Override
Chest getTileEntity() {
return (Chest) super.getTileEntity();
}
开发者ID:LapisBlue,项目名称:Pore,代码行数:5,代码来源:PoreChest.java
注:本文中的org.spongepowered.api.block.tileentity.carrier.Chest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论