use of org.bukkit.event.entity.EntityCreatePortalEvent in project Glowstone by GlowstoneMC.
the class BlockEnderPortalFrame method createPortal.
/**
* Spawn the portal and call the {@link EntityCreatePortalEvent}.
*/
private void createPortal(GlowPlayer player, GlowBlock center) {
List<BlockState> blocks = new ArrayList<>(9);
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
BlockState state = center.getRelative(i, 0, j).getState();
state.setType(Material.ENDER_PORTAL);
blocks.add(state);
}
}
if (!EventFactory.callEvent(new EntityCreatePortalEvent(player, blocks, PortalType.ENDER)).isCancelled()) {
for (BlockState state : blocks) {
state.update(true);
}
}
}
Aggregations