本文整理匯總了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();
}