本文整理汇总了Java中org.spongepowered.api.event.block.CollideBlockEvent类的典型用法代码示例。如果您正苦于以下问题:Java CollideBlockEvent类的具体用法?Java CollideBlockEvent怎么用?Java CollideBlockEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CollideBlockEvent类属于org.spongepowered.api.event.block包,在下文中一共展示了CollideBlockEvent类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityCollidesWithBlock
import org.spongepowered.api.event.block.CollideBlockEvent; //导入依赖的package包/类
@Listener
public void onEntityCollidesWithBlock(CollideBlockEvent evt) {
EntityCollidesWithBlockScriptEvent event = (EntityCollidesWithBlockScriptEvent) clone();
event.internal = evt;
event.entity = new EntityTag((Entity) evt.getSource());
event.material = new BlockTypeTag(evt.getTargetBlock().getType());
event.location = new LocationTag(evt.getTargetLocation());
event.impact_normal = new LocationTag(evt.getTargetSide().asOffset());
event.cancelled = evt.isCancelled();
event.run();
evt.setCancelled(event.cancelled);
}
示例2: onEntityImpactsBlock
import org.spongepowered.api.event.block.CollideBlockEvent; //导入依赖的package包/类
@Listener
public void onEntityImpactsBlock(CollideBlockEvent.Impact evt) {
ProjectileImpactsBlockScriptEvent event = (ProjectileImpactsBlockScriptEvent) clone();
event.internal = evt;
event.entity = new EntityTag((Entity) evt.getSource());
event.material = new BlockTypeTag(evt.getTargetBlock().getType());
event.location = new LocationTag(evt.getTargetLocation());
event.impact_point = new LocationTag(evt.getImpactPoint());
event.impact_normal = new LocationTag(evt.getTargetSide().asOffset());
event.cancelled = evt.isCancelled();
event.run();
evt.setCancelled(event.cancelled);
}
示例3: onProjectileImpactBlock
import org.spongepowered.api.event.block.CollideBlockEvent; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onProjectileImpactBlock(CollideBlockEvent.Impact event) {
if (!GPFlags.PROJECTILE_IMPACT_BLOCK) {
return;
}
final User user = CauseContextHelper.getEventUser(event);
if (user == null) {
return;
}
if (!GriefPreventionPlugin.instance.claimsEnabledForWorld(event.getImpactPoint().getExtent().getProperties())) {
return;
}
GPTimings.PROJECTILE_IMPACT_BLOCK_EVENT.startTimingIfSync();
final Cause cause = event.getCause();
Object source = cause.root();
Location<World> impactPoint = event.getImpactPoint();
GPClaim targetClaim = null;
GPPlayerData playerData = null;
if (user instanceof Player) {
playerData = GriefPreventionPlugin.instance.dataStore.getOrCreatePlayerData(event.getTargetLocation().getExtent(), user.getUniqueId());
targetClaim = this.dataStore.getClaimAtPlayer(playerData, impactPoint);
} else {
targetClaim = this.dataStore.getClaimAt(impactPoint);
}
Tristate result = GPPermissionHandler.getClaimPermission(event, impactPoint, targetClaim, GPPermissions.PROJECTILE_IMPACT_BLOCK, source, event.getTargetBlock(), user, TrustType.ACCESSOR, true);
if (result == Tristate.FALSE) {
event.setCancelled(true);
GPTimings.PROJECTILE_IMPACT_BLOCK_EVENT.stopTimingIfSync();
return;
}
GPTimings.PROJECTILE_IMPACT_BLOCK_EVENT.stopTimingIfSync();
}