diff --git a/src/com/massivecraft/mcore5/InternalListener.java b/src/com/massivecraft/mcore5/InternalListener.java index 4d5fc937..25bab54a 100644 --- a/src/com/massivecraft/mcore5/InternalListener.java +++ b/src/com/massivecraft/mcore5/InternalListener.java @@ -8,6 +8,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByBlockEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -19,6 +21,7 @@ import com.massivecraft.mcore5.event.MCoreAfterPlayerTeleportEvent; import com.massivecraft.mcore5.event.MCorePlayerLeaveEvent; import com.massivecraft.mcore5.store.Coll; import com.massivecraft.mcore5.store.PlayerColl; +import com.massivecraft.mcore5.util.SmokeUtil; public class InternalListener implements Listener { @@ -48,6 +51,24 @@ public class InternalListener implements Listener } }*/ + // -------------------------------------------- // + // EXPLOSION FX + // -------------------------------------------- // + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void explosionFx(EntityDamageByBlockEvent event) + { + // If an entity is taking damage from a block explosion ... + DamageCause cause = event.getCause(); + if (cause != DamageCause.BLOCK_EXPLOSION) return; + + // ... and that explosion is a fake ... + if (SmokeUtil.fakeExplosion == false) return; + + // ... then cancel the event and the damage. + event.setCancelled(true); + } + // -------------------------------------------- // // AFTER EVENTS // -------------------------------------------- // diff --git a/src/com/massivecraft/mcore5/util/SmokeUtil.java b/src/com/massivecraft/mcore5/util/SmokeUtil.java index e8eabdd3..7d3ec6e0 100644 --- a/src/com/massivecraft/mcore5/util/SmokeUtil.java +++ b/src/com/massivecraft/mcore5/util/SmokeUtil.java @@ -1,19 +1,10 @@ package com.massivecraft.mcore5.util; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; import java.util.Random; -import net.minecraft.server.v1_4_5.ChunkPosition; -import net.minecraft.server.v1_4_5.MinecraftServer; -import net.minecraft.server.v1_4_5.Packet60Explosion; - -import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_4_5.CraftServer; -import org.bukkit.craftbukkit.v1_4_5.CraftWorld; // http://mc.kev009.com/Protocol // ----------------------------- @@ -92,18 +83,27 @@ public class SmokeUtil } // Fake Explosion ======== + public static void fakeExplosion(Location location) { - fakeExplosion(location, (Bukkit.getViewDistance()+1)*16*2); + fakeExplosion(location, 4F); } + public static Boolean fakeExplosion = false; + public static void fakeExplosion(Location location, float power) + { + synchronized (fakeExplosion) + { + fakeExplosion = true; + location.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), power, false, false); + fakeExplosion = false; + } + } + + @Deprecated public static void fakeExplosion(Location location, int viewDistance) { - List chunkPositions = new ArrayList(); - Packet60Explosion packet = new Packet60Explosion(location.getX(),location.getY(), location.getZ(), 0.1f, chunkPositions, null); - CraftServer craftServer = (CraftServer) Bukkit.getServer(); - MinecraftServer minecraftServer = craftServer.getServer(); - minecraftServer.getServerConfigurationManager().sendPacketNearby(location.getX(), location.getY(), location.getZ(), viewDistance, ((CraftWorld)location.getWorld()).getHandle().dimension, packet); + fakeExplosion(location); } // -------------------------------------------- //