當前位置: 首頁>>代碼示例>>Java>>正文


Java CollideBlockEvent類代碼示例

本文整理匯總了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);
}
 
開發者ID:DenizenScript,項目名稱:Denizen2Sponge,代碼行數:13,代碼來源:EntityCollidesWithBlockScriptEvent.java

示例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);
}
 
開發者ID:DenizenScript,項目名稱:Denizen2Sponge,代碼行數:14,代碼來源:ProjectileImpactsBlockScriptEvent.java

示例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();
}
 
開發者ID:MinecraftPortCentral,項目名稱:GriefPrevention,代碼行數:38,代碼來源:BlockEventHandler.java


注:本文中的org.spongepowered.api.event.block.CollideBlockEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。