本文整理汇总了Java中org.spongepowered.api.world.LocatableBlock类的典型用法代码示例。如果您正苦于以下问题:Java LocatableBlock类的具体用法?Java LocatableBlock怎么用?Java LocatableBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LocatableBlock类属于org.spongepowered.api.world包,在下文中一共展示了LocatableBlock类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: notifyNeighbors
import org.spongepowered.api.world.LocatableBlock; //导入依赖的package包/类
@Listener
public void notifyNeighbors(final NotifyNeighborBlockEvent event, @First LocatableBlock cause) {
final LockManager lockManager = Latch.getLockManager();
event.getNeighbors().entrySet().removeIf(neighbor -> {
final Optional<Lock> optionalLock = lockManager.getLock(cause.getLocation().getBlockRelative(neighbor.getKey()));
if (optionalLock.isPresent()) {
final Lock lock = optionalLock.get();
if (!lock.getProtectFromRedstone()) {
return false;
}
final Optional<Player> optionalPlayer = event.getCause().first(Player.class);
//noinspection OptionalIsPresent
return !optionalPlayer.isPresent() || !lock.canAccess(optionalPlayer.get().getUniqueId());
}
return false;
});
}
开发者ID:ichorpowered,项目名称:latch,代码行数:22,代码来源:NotifyNeighborListener.java
示例2: onPreBlockChange
import org.spongepowered.api.world.LocatableBlock; //导入依赖的package包/类
@Listener
public void onPreBlockChange(final ChangeBlockEvent.Pre event, @First LocatableBlock block) {
final BlockType type = block.getBlockState().getType();
if (type.equals(BlockTypes.PISTON) || type.equals(BlockTypes.STICKY_PISTON) || type.equals(BlockTypes.PISTON_EXTENSION) || type
.equals(BlockTypes.PISTON_HEAD)) {
//noinspection OptionalGetWithoutIsPresent
final Location<World> location = block.getLocation().getBlockRelative(block.get(Keys.DIRECTION).get());
final LockManager lockManager = Latch.getLockManager();
if (lockManager.getLock(location).isPresent() || (lockManager.getLock(location.getBlockRelative(Direction.UP)).isPresent() && lockManager
.isProtectBelowBlocks(location.getBlockRelative(Direction.UP).getBlockType()))) {
event.setCancelled(true);
}
}
}
开发者ID:ichorpowered,项目名称:latch,代码行数:18,代码来源:ChangeBlockListener.java
示例3: toString
import org.spongepowered.api.world.LocatableBlock; //导入依赖的package包/类
public String toString(boolean unks) {
if (remAs != null) {
return "shared/" + remAs;
}
if (internal instanceof MainPlayerInventory) {
return "player/" + ((PlayerInventory) (internal).parent()).getCarrier().get().getUniqueId().toString();
}
else if (internal instanceof CarriedInventory) {
Object o = ((CarriedInventory) internal).getCarrier().orElse(null);
if (o == null) {
return "((UNKNOWN INVENTORY TYPE))";
}
if (o instanceof Entity) {
return "entity/" + ((Entity) o).getUniqueId().toString();
}
else if (o instanceof TileEntityCarrier) {
LocatableBlock lb = ((TileEntityCarrier) o).getLocatableBlock();
return "block/" + new LocationTag(new UtilLocation(lb.getPosition(), lb.getWorld()));
}
}
if (!unks) {
// TODO: Handle all inventory types somehow???
throw new RuntimeException("Inventory type not known to the system!");
}
else {
return "((UNKNOWN INVENTORY TYPE))";
}
}
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:29,代码来源:InventoryTag.java
示例4: getSourceClaim
import org.spongepowered.api.world.LocatableBlock; //导入依赖的package包/类
public GPClaim getSourceClaim(Cause cause) {
BlockSnapshot blockSource = cause.first(BlockSnapshot.class).orElse(null);
LocatableBlock locatableBlock = null;
TileEntity tileEntitySource = null;
Entity entitySource = null;
if (blockSource == null) {
locatableBlock = cause.first(LocatableBlock.class).orElse(null);
if (locatableBlock == null) {
entitySource = cause.first(Entity.class).orElse(null);
}
if (locatableBlock == null && entitySource == null) {
tileEntitySource = cause.first(TileEntity.class).orElse(null);
}
}
GPClaim sourceClaim = null;
if (blockSource != null) {
sourceClaim = this.dataStore.getClaimAt(blockSource.getLocation().get());
} else if (locatableBlock != null) {
sourceClaim = this.dataStore.getClaimAt(locatableBlock.getLocation());
} else if (tileEntitySource != null) {
sourceClaim = this.dataStore.getClaimAt(tileEntitySource.getLocation());
} else if (entitySource != null) {
Entity entity = entitySource;
if (entity instanceof Player) {
Player player = (Player) entity;
GPPlayerData playerData = GriefPreventionPlugin.instance.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
sourceClaim = this.dataStore.getClaimAtPlayer(playerData, player.getLocation());
} else {
sourceClaim = this.dataStore.getClaimAt(entity.getLocation());
}
}
return sourceClaim;
}
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:36,代码来源:BlockEventHandler.java
示例5: onPreChangeBlock
import org.spongepowered.api.world.LocatableBlock; //导入依赖的package包/类
@Listener
public void onPreChangeBlock(ChangeBlockEvent.Pre event, @Root LocatableBlock block)
{
for (Location<World> loc : event.getLocations()) {
if (loc.getBlockType() != BlockTypes.AIR && loc.getBlockType() != block.getBlockState().getType()) {
List<Region> regionsAt = manager.getRegionsAt(loc);
if (this.checkSetting(event, null, regionsAt, () -> null, s -> s.blockDamage.block.getOrDefault(block.getBlockState().getType() , UNDEFINED), UNDEFINED) == FALSE)
{
return;
}
}
}
}
开发者ID:CubeEngine,项目名称:modules-main,代码行数:15,代码来源:SettingsListener.java
示例6: onRedstoneChangeNotify
import org.spongepowered.api.world.LocatableBlock; //导入依赖的package包/类
@Listener
public void onRedstoneChangeNotify(NotifyNeighborBlockEvent event, @Root LocatableBlock block)
{
for (Map.Entry<Direction, BlockState> entry : event.getOriginalNeighbors().entrySet())
{
Location<World> loc = block.getLocation().getRelative(entry.getKey());
List<Region> regionsAt = manager.getRegionsAt(loc);
if (isRedstoneChange(entry.getValue()))
{
// Redstone is disabled entirely?
if (checkSetting(event, null, regionsAt, () -> null, s -> s.deadCircuit, UNDEFINED) == FALSE)
{
return;
}
if (true)
{
// TODO this check is spammed way too often (also with wrong notifier mabye?)
return;
}
// Redstone is disabled for player?
Optional<Player> player = event.getCause().getContext().get(EventContextKeys.NOTIFIER).filter(p -> p instanceof Player).map(Player.class::cast);
if (player.isPresent())
{
if (checkSetting(event, player.get(), regionsAt, () -> usePermission.get(UseType.REDSTONE), s -> s.use.all.redstone, UNDEFINED) == FALSE)
{
return;
}
}
}
}
}
开发者ID:CubeEngine,项目名称:modules-main,代码行数:32,代码来源:SettingsListener.java
示例7: getLocatableBlock
import org.spongepowered.api.world.LocatableBlock; //导入依赖的package包/类
@Override
public LocatableBlock getLocatableBlock() {
return null;
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:LanternTileEntity.java
示例8: isCausedbyFire
import org.spongepowered.api.world.LocatableBlock; //导入依赖的package包/类
private boolean isCausedbyFire(ChangeBlockEvent event) {
Optional<LocatableBlock> optLocatableBlock = event.getCause().get(NamedCause.SOURCE, LocatableBlock.class);
return optLocatableBlock.filter(locatableBlock -> locatableBlock.getBlockState().getType() == BlockTypes.FIRE).isPresent();
}
开发者ID:Skelril,项目名称:Skree,代码行数:5,代码来源:CursedMineListener.java
注:本文中的org.spongepowered.api.world.LocatableBlock类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论