当前位置: 首页>>代码示例>>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;未经允许,请勿转载。