org.bukkit.entity.FallingBlock Java Examples
The following examples show how to use
org.bukkit.entity.FallingBlock.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlockEventTracker.java From GriefDefender with MIT License | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockFalling(EntitySpawnEvent event) { final Entity entity = event.getEntity(); final World world = entity.getWorld(); if (entity instanceof FallingBlock) { // add owner final Location location = entity.getLocation(); final Block block = world.getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()); final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(location.getWorld().getUID()); final GDChunk gdChunk = claimWorldManager.getChunk(location.getChunk()); final UUID ownerUniqueId = gdChunk.getBlockOwnerUUID(block.getLocation()); if (ownerUniqueId != null) { final GDEntity gdEntity = new GDEntity(event.getEntity().getEntityId()); gdEntity.setOwnerUUID(ownerUniqueId); gdEntity.setNotifierUUID(ownerUniqueId); EntityTracker.addTempEntity(gdEntity); } } }
Example #2
Source File: Molotov.java From ce with GNU Lesser General Public License v3.0 | 6 votes |
@SuppressWarnings("deprecation") @Override public void effect(Event e, ItemStack item, final int level) { if(e instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; Entity target = event.getEntity(); World world = target.getWorld(); world.playEffect(target.getLocation(), Effect.POTION_BREAK, 10); double boundaries = 0.1*level; for(double x = boundaries; x >= -boundaries; x-=0.1) for(double z = boundaries; z >= -boundaries; z-=0.1) { FallingBlock b = world.spawnFallingBlock(target.getLocation(), Material.FIRE.getId(), (byte) 0x0); b.setVelocity(new Vector(x, 0.1, z)); b.setDropItem(false); } } }
Example #3
Source File: DefaultComparators.java From Skript with GNU General Public License v3.0 | 6 votes |
@Override public Relation compare(final DamageCause dc, final EntityData e) { switch (dc) { case ENTITY_ATTACK: return Relation.get(e.isSupertypeOf(EntityData.fromClass(Entity.class))); case PROJECTILE: return Relation.get(e.isSupertypeOf(EntityData.fromClass(Projectile.class))); case WITHER: return Relation.get(e.isSupertypeOf(EntityData.fromClass(Wither.class))); case FALLING_BLOCK: return Relation.get(e.isSupertypeOf(EntityData.fromClass(FallingBlock.class))); //$CASES-OMITTED$ default: return Relation.NOT_EQUAL; } }
Example #4
Source File: FallingBlocksMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@SuppressWarnings("deprecation") private void fall(long pos, @Nullable ParticipantState breaker) { // Block must be removed BEFORE spawning the FallingBlock, or it will not appear on the client // https://bugs.mojang.com/browse/MC-72248 Block block = blockAt(this.getMatch().getWorld(), pos); BlockState oldState = block.getState(); block.setType(Material.AIR, false); FallingBlock fallingBlock = oldState.spawnFallingBlock(); BlockFallEvent event = new BlockFallEvent(block, fallingBlock); getMatch().callEvent(breaker == null ? new BlockTransformEvent(event, block, Material.AIR) : new ParticipantBlockTransformEvent(event, block, Material.AIR, breaker)); if(event.isCancelled()) { fallingBlock.remove(); oldState.update(true, false); // Restore the old block if the fall is cancelled } else { // This is already air, but physics have not been applied yet, so do that now block.simulateChangeForNeighbors(oldState.getMaterialData(), new MaterialData(Material.AIR)); } }
Example #5
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public Entity spawnFallingBlock(Location loc, Material mat, boolean damage) { FallingBlock block = loc.getWorld().spawnFallingBlock(loc, mat, (byte) 0); block.setDropItem(false); EntityFallingBlock fb = ((CraftFallingSand) block).getHandle(); fb.a(damage); return block; }
Example #6
Source File: MagicBlockCompat.java From Skript with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public BlockState fallingBlockToState(FallingBlock entity) { BlockState state = entity.getWorld().getBlockAt(0, 0, 0).getState(); state.setType(entity.getMaterial()); try { setRawDataMethod.invokeExact(state, (byte) getBlockDataMethod.invokeExact(entity)); } catch (Throwable e) { Skript.exception(e); } return state; }
Example #7
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public Entity spawnFallingBlock(Location loc, Material mat, boolean damage) { FallingBlock block = loc.getWorld().spawnFallingBlock(loc, mat, (byte) 0); block.setDropItem(false); EntityFallingBlock fb = ((CraftFallingSand) block).getHandle(); fb.a(damage); return block; }
Example #8
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public boolean checkMaterial(FallingBlock fb, Material mat) { if (fb.getMaterial().equals(mat)) { return true; } return false; }
Example #9
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public Entity spawnFallingBlock(Location loc, Material mat, boolean damage) { FallingBlock block = loc.getWorld().spawnFallingBlock(loc, mat, (byte) 0); block.setDropItem(false); EntityFallingBlock fb = ((CraftFallingBlock) block).getHandle(); fb.a(damage); return block; }
Example #10
Source File: BlockEventTracker.java From GriefDefender with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockSpawnFalling(EntityChangeBlockEvent event) { final Entity entity = event.getEntity(); if (entity instanceof FallingBlock) { final GDEntity gdEntity = EntityTracker.getCachedEntity(event.getEntity().getEntityId()); if (gdEntity != null) { final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(gdEntity.getOwnerUUID()); final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(event.getBlock().getWorld().getUID()); final GDChunk gdChunk = claimWorldManager.getChunk(event.getBlock().getChunk()); gdChunk.addTrackedBlockPosition(event.getBlock(), user.getUniqueId(), PlayerTracker.Type.OWNER); } } }
Example #11
Source File: AsyncWorld.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public FallingBlock spawnFallingBlock(Location location, MaterialData data) throws IllegalArgumentException { return TaskManager.IMP.sync(new RunnableVal<FallingBlock>() { @Override public void run(FallingBlock value) { this.value = parent.spawnFallingBlock(location, data); } }); }
Example #12
Source File: BlockDropsMatchModule.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onFallingBlockLand(BlockTransformEvent event) { if (event.getCause() instanceof EntityChangeBlockEvent) { Entity entity = ((EntityChangeBlockEvent) event.getCause()).getEntity(); if (entity instanceof FallingBlock && this.fallingBlocksThatWillNotLand.remove(entity)) { event.setCancelled(true); } } }
Example #13
Source File: AsyncWorld.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override @Deprecated public FallingBlock spawnFallingBlock(final Location location, final int blockId, final byte blockData) throws IllegalArgumentException { return TaskManager.IMP.sync(new RunnableVal<FallingBlock>() { @Override public void run(FallingBlock value) { this.value = parent.spawnFallingBlock(location, blockId, blockData); } }); }
Example #14
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public boolean checkMaterial(FallingBlock fb, Material mat) { if (fb.getMaterial().equals(mat)) { return true; } return false; }
Example #15
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public boolean checkMaterial(FallingBlock fb, Material mat) { if (fb.getMaterial().equals(mat)) { return true; } return false; }
Example #16
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public Entity spawnFallingBlock(Location loc, Material mat, boolean damage) { FallingBlock block = loc.getWorld().spawnFallingBlock(loc, mat, (byte) 0); block.setDropItem(false); EntityFallingBlock fb = ((CraftFallingSand) block).getHandle(); fb.a(damage); return block; }
Example #17
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public boolean checkMaterial(FallingBlock fb, Material mat) { if (fb.getMaterial().equals(mat)) { return true; } return false; }
Example #18
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public Entity spawnFallingBlock(Location loc, Material mat, boolean damage) { FallingBlock block = loc.getWorld().spawnFallingBlock(loc, mat, (byte) 0); block.setDropItem(false); EntityFallingBlock fb = ((CraftFallingSand) block).getHandle(); fb.a(damage); return block; }
Example #19
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public boolean checkMaterial(FallingBlock fb, Material mat) { if (fb.getMaterial().equals(mat)) { return true; } return false; }
Example #20
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public boolean checkMaterial(FallingBlock fb, Material mat) { if (fb.getMaterial().equals(mat)) { return true; } return false; }
Example #21
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public Entity spawnFallingBlock(Location loc, Material mat, boolean damage) { FallingBlock block = loc.getWorld().spawnFallingBlock(loc, mat, (byte) 0); block.setDropItem(false); EntityFallingBlock fb = ((CraftFallingSand) block).getHandle(); fb.a(damage); return block; }
Example #22
Source File: BlockPhysicsListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockFall(EntityChangeBlockEvent e) { if (e.getEntity().getType() == EntityType.FALLING_BLOCK && BlockStorage.hasBlockInfo(e.getBlock())) { e.setCancelled(true); FallingBlock block = (FallingBlock) e.getEntity(); if (block.getDropItem()) { block.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(block.getBlockData().getMaterial(), 1)); } } }
Example #23
Source File: FallingBlockData.java From Skript with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override @Nullable public FallingBlock spawn(final Location loc) { final ItemType t = CollectionUtils.getRandom(types); assert t != null; final ItemStack i = t.getRandom(); if (i == null || i.getType() == Material.AIR || !i.getType().isBlock()) { assert false : i; return null; } return loc.getWorld().spawnFallingBlock(loc, i.getType(), (byte) i.getDurability()); }
Example #24
Source File: FallingBlockData.java From Skript with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override protected boolean match(final FallingBlock entity) { if (types != null) { for (final ItemType t : types) { if (t.isOfType(BlockCompat.INSTANCE.fallingBlockToState(entity))) return true; } return false; } return true; }
Example #25
Source File: FallingBlockData.java From Skript with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override protected boolean init(final @Nullable Class<? extends FallingBlock> c, final @Nullable FallingBlock e) { if (e != null) // TODO material data support types = new ItemType[] {new ItemType(BlockCompat.INSTANCE.fallingBlockToState(e))}; return true; }
Example #26
Source File: SeismicAxe.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@Override public ItemUseHandler getItemHandler() { return e -> { Player p = e.getPlayer(); List<Block> blocks = p.getLineOfSight(null, RANGE); for (int i = 2; i < blocks.size(); i++) { Block ground = findGround(blocks.get(i)); Location groundLocation = ground.getLocation(); ground.getWorld().playEffect(groundLocation, Effect.STEP_SOUND, ground.getType()); if (ground.getRelative(BlockFace.UP).getType() == Material.AIR) { Location loc = ground.getRelative(BlockFace.UP).getLocation().add(0.5, 0.0, 0.5); FallingBlock block = ground.getWorld().spawnFallingBlock(loc, ground.getBlockData()); block.setDropItem(false); block.setVelocity(new Vector(0, 0.4 + i * 0.01, 0)); block.setMetadata("seismic_axe", new FixedMetadataValue(SlimefunPlugin.instance, "fake_block")); } for (Entity n : ground.getChunk().getEntities()) { if (n instanceof LivingEntity && n.getType() != EntityType.ARMOR_STAND && n.getLocation().distance(groundLocation) <= 2.0D && !n.getUniqueId().equals(p.getUniqueId())) { pushEntity(p, n); } } } for (int i = 0; i < 4; i++) { damageItem(p, e.getItem()); } }; }
Example #27
Source File: EntityTracker.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
public PhysicalInfo createEntity(Entity entity, @Nullable ParticipantState owner) { if(entity instanceof ThrownPotion) { return new ThrownPotionInfo((ThrownPotion) entity, owner); } else if(entity instanceof FallingBlock) { return new FallingBlockInfo((FallingBlock) entity, owner); } else if(entity instanceof LivingEntity) { return new MobInfo((LivingEntity) entity, owner); } else { return new EntityInfo(entity, owner); } }
Example #28
Source File: FallingBlocksMatchModule.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") private void fall(long pos, @Nullable ParticipantState breaker) { // Block must be removed BEFORE spawning the FallingBlock, or it will not appear on the client // https://bugs.mojang.com/browse/MC-72248 Block block = blockAt(match.getWorld(), pos); BlockState oldState = block.getState(); block.setType(Material.AIR, false); FallingBlock fallingBlock = block .getWorld() .spawnFallingBlock(block.getLocation(), oldState.getType(), oldState.getRawData()); BlockFallEvent event = new BlockFallEvent(block, fallingBlock); match.callEvent( breaker == null ? new BlockTransformEvent(event, block, Material.AIR) : new ParticipantBlockTransformEvent(event, block, Material.AIR, breaker)); if (event.isCancelled()) { fallingBlock.remove(); oldState.update(true, false); // Restore the old block if the fall is cancelled } else { block.setType( Material.AIR, true); // This is already air, but physics have not been applied yet, so do that now } }
Example #29
Source File: Bombardment.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public void effect(Event e, ItemStack item, final int level) { if(e instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; Entity target = event.getEntity(); final World world = target.getWorld(); Vector vec = new Vector(0, -5, 0); Location spawnLocation = new Location(world, target.getLocation().getX(), 255, target.getLocation().getZ()); final FallingBlock b = world.spawnFallingBlock(spawnLocation, 46, (byte) 0x0); b.setVelocity(vec); new BukkitRunnable() { Location l = b.getLocation(); @Override public void run() { l = b.getLocation(); if(b.isDead()) { l.getBlock().setType(Material.AIR); for(int i = 0; i <= TNTAmount + level; i++) { TNTPrimed tnt = world.spawn(l, TNTPrimed.class); tnt.setFuseTicks(0); if(!Main.createExplosions) tnt.setMetadata("ce.explosive", new FixedMetadataValue(getPlugin(), null)); } this.cancel(); } EffectManager.playSound(l, "ENTITY_ENDERDRAGON_GROWL", Volume, 2f); } }.runTaskTimer(getPlugin(), 0l, 5l); } }
Example #30
Source File: BlockDropsMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onFallingBlockLand(BlockTransformEvent event) { if(event.getCause() instanceof EntityChangeBlockEvent) { Entity entity = ((EntityChangeBlockEvent) event.getCause()).getEntity(); if(entity instanceof FallingBlock && this.fallingBlocksThatWillNotLand.remove(entity)) { event.setCancelled(true); } } }