本文整理汇总了Java中org.spongepowered.api.block.BlockSnapshot.getState方法的典型用法代码示例。如果您正苦于以下问题:Java BlockSnapshot.getState方法的具体用法?Java BlockSnapshot.getState怎么用?Java BlockSnapshot.getState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.block.BlockSnapshot
的用法示例。
在下文中一共展示了BlockSnapshot.getState方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockPlace
import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
@Listener
public void onBlockPlace(ChangeBlockEvent.Place event, @Root Player player) {
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
for (Transaction<BlockSnapshot> transaction : transactions) {
BlockSnapshot snapshot = transaction.getFinal();
BlockState blockState = snapshot.getState();
String blockTypeId = blockState.getType().getId();
String blockStateId = blockState.getId();
PermHandler ph = PermHandler.getInstance();
if (!ph.checkPerm(player, "protectionperms.block.place." + blockTypeId,
"protectionperms.block.place." + blockStateId)) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR,
Text.of(TextColors.RED, "You don't have permission to place " + blockState.getName() + '!'));
break;
}
}
}
示例2: onBlockBreak
import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @Root Player player) {
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
for (Transaction<BlockSnapshot> transaction : transactions) {
BlockSnapshot snapshot = transaction.getOriginal();
BlockState blockState = snapshot.getState();
String blockTypeId = blockState.getType().getId();
String blockStateId = blockState.getId();
PermHandler ph = PermHandler.getInstance();
if (!ph.checkPerm(player, "protectionperms.block.break." + blockTypeId,
"protectionperms.block.break." + blockStateId)) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR,
Text.of(TextColors.RED, "You don't have permission to break " + blockState.getName() + '!'));
break;
}
}
}
示例3: onBlockBreakGlobal
import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onBlockBreakGlobal(ChangeBlockEvent.Break e, @First Player p) {
RedProtect.get().logger.debug("default","RPGlobalListener - Is BlockBreakEvent event! Cancelled? " + e.isCancelled());
BlockSnapshot bt = e.getTransactions().get(0).getOriginal();
BlockState b = bt.getState();
World w = bt.getLocation().get().getExtent();
Region r = RedProtect.get().rm.getTopRegion(bt.getLocation().get());
if (r != null){
return;
}
if (!RPUtil.canBuildNear(p, bt.getLocation().get())){
e.setCancelled(true);
return;
}
if (!bypassBuild(p, bt, 2)){
e.setCancelled(true);
}
}
示例4: onFireSpread
import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onFireSpread(NotifyNeighborBlockEvent e, @First BlockSnapshot source){
Map<Direction, BlockState> dirs = e.getNeighbors();
for (Direction dir:dirs.keySet()){
BlockSnapshot b = source.getLocation().get().getRelative(dir).createSnapshot();
BlockState bstate = source.getState();
Region r = RedProtect.get().rm.getTopRegion(b.getLocation().get());
if (r != null){
return;
}
if ((bstate.getType().equals(BlockTypes.FIRE) || bstate.getType().getName().contains("lava")) &&
!RedProtect.get().cfgs.getGlobalFlag(b.getLocation().get().getExtent().getName(),"fire-spread")){
e.setCancelled(true);
return;
}
}
}
示例5: onPlayerClick
import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
@Listener
public void onPlayerClick(InteractBlockEvent.Secondary event, @First Player player) {
if (state.equals(State.CLICK) && player.getUniqueId().equals(getParent().getUUID())) {
BlockSnapshot snapshot = event.getTargetBlock();
// Make sure the block was clicked twice
if (doubleClickCurrent == null) {
doubleClickTick = Sponge.getServer().getRunningTimeTicks();
doubleClickCurrent = snapshot;
} else {
if (doubleClickCurrent.equals(snapshot) && Sponge.getServer().getRunningTimeTicks() - doubleClickTick > 5) {
doubleClickCurrent = null;
doubleClickTick = 0;
player.sendMessage(messages.getMessage("creation.breakcurrency"));
blockState = snapshot.getState();
state = State.CURRENCY;
} else {
doubleClickTick = Sponge.getServer().getRunningTimeTicks();
doubleClickCurrent = snapshot;
}
}
}
}
示例6: onPlayerClick
import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
@Listener
public void onPlayerClick(InteractBlockEvent event, @First Player player) {
if (state.equals(State.CLICK) && player.getUniqueId().equals(getParent().getUUID())) {
BlockSnapshot snapshot = event.getTargetBlock();
// Make sure the block was clicked twice
if (doubleClickCurrent == null) {
doubleClickTick = Sponge.getServer().getRunningTimeTicks();
doubleClickCurrent = snapshot;
} else {
if (doubleClickCurrent.equals(snapshot) && Sponge.getServer().getRunningTimeTicks() - doubleClickTick > 5) {
doubleClickCurrent = null;
doubleClickTick = 0;
player.sendMessage(messages.getMessage("creation.placecurrency"));
blockState = snapshot.getState();
state = State.CURRENCY;
} else {
doubleClickTick = Sponge.getServer().getRunningTimeTicks();
doubleClickCurrent = snapshot;
}
}
}
}
示例7: BlockSnapshotView
import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
public BlockSnapshotView(BlockSnapshot value) {
super(value);
this.creator = value.getCreator().orElse(null);
this.location = value.getLocation().orElse(null);
this.state = value.getState();
}
示例8: onBlockBreak
import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @Named(NamedCause.SOURCE) Entity srcEnt) {
if (!isApplicable(srcEnt)) {
return;
}
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
for (Transaction<BlockSnapshot> block : transactions) {
BlockSnapshot original = block.getOriginal();
if (original.getCreator().isPresent()) {
continue;
}
Optional<Location<World>> optLoc = original.getLocation();
if (!optLoc.isPresent()) {
continue;
}
Location<World> loc = optLoc.get();
BlockState state = original.getState();
// Prevent item dupe glitch by removing the position before subsequent breaks
markedOrePoints.remove(loc);
if (config.getDropModification().blocks(state)) {
markedOrePoints.add(loc);
}
}
}