mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 18:31:29 +01:00
fixes some explosion events to stop accessing null entities.
Placed some tags against some spammy events.
This commit is contained in:
parent
e93061be48
commit
8bbb0749ef
@ -218,6 +218,7 @@ public abstract class Entity {
|
|||||||
} else {
|
} else {
|
||||||
if (Z % 20 == 0) {
|
if (Z % 20 == 0) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
|
// TODO: this event spams!
|
||||||
if(this instanceof EntityLiving) {
|
if(this instanceof EntityLiving) {
|
||||||
CraftServer server = ((WorldServer) l).getServer();
|
CraftServer server = ((WorldServer) l).getServer();
|
||||||
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
|
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
|
||||||
@ -254,8 +255,10 @@ public abstract class Entity {
|
|||||||
protected void s() {
|
protected void s() {
|
||||||
if (!ae) {
|
if (!ae) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
|
// TODO: this event spams!
|
||||||
if(this instanceof EntityLiving) {
|
if(this instanceof EntityLiving) {
|
||||||
CraftServer server = ((WorldServer) l).getServer();
|
CraftServer server = ((WorldServer) l).getServer();
|
||||||
|
// TODO: shouldn't be sending null for the block.
|
||||||
org.bukkit.block.Block damager = null;//((WorldServer) l).getWorld().getBlockAt(i, j, k);
|
org.bukkit.block.Block damager = null;//((WorldServer) l).getWorld().getBlockAt(i, j, k);
|
||||||
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
|
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
|
||||||
DamageCause damageType = EntityDamageEvent.DamageCause.LAVA;
|
DamageCause damageType = EntityDamageEvent.DamageCause.LAVA;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
@ -11,8 +9,6 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
|||||||
|
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
|
||||||
|
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
@ -120,16 +116,15 @@ public class Explosion {
|
|||||||
|
|
||||||
// CraftBukkit start - explosion damage hook
|
// CraftBukkit start - explosion damage hook
|
||||||
CraftServer server = ((WorldServer) i).getServer();
|
CraftServer server = ((WorldServer) i).getServer();
|
||||||
org.bukkit.entity.Entity damagee = null;
|
org.bukkit.entity.Entity damagee = (entity == null)?null:entity.getBukkitEntity();
|
||||||
DamageCause damageType;
|
DamageCause damageType;
|
||||||
int damageDone = (int) (((d14 * d14 + d14) / 2D) * 8D * (double) f + 1.0D);
|
int damageDone = (int) (((d14 * d14 + d14) / 2D) * 8D * (double) f + 1.0D);
|
||||||
|
|
||||||
if(entity instanceof EntityLiving) {
|
|
||||||
damagee = entity.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e == null) { // Block explosion
|
if(damagee == null){
|
||||||
// Craftbukkit TODO: get the x/y/z of the tnt block?
|
// nothing was hurt
|
||||||
|
} else if (e == null) { // Block explosion
|
||||||
|
// TODO: get the x/y/z of the tnt block?
|
||||||
|
// does this even get called ever? @see EntityTNTPrimed - not BlockTNT or whatever
|
||||||
damageType = EntityDamageEvent.DamageCause.BLOCK_EXPLOSION;
|
damageType = EntityDamageEvent.DamageCause.BLOCK_EXPLOSION;
|
||||||
EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(null, damagee, damageType, damageDone);
|
EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(null, damagee, damageType, damageDone);
|
||||||
server.getPluginManager().callEvent(edbbe);
|
server.getPluginManager().callEvent(edbbe);
|
||||||
@ -137,30 +132,22 @@ public class Explosion {
|
|||||||
entity.a(e, edbbe.getDamage());
|
entity.a(e, edbbe.getDamage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CraftEntity damager = null;
|
org.bukkit.entity.Entity damager = e.getBukkitEntity();
|
||||||
//TODO org.bukkit.entity.Entity damager = e.getBukkitEntity();
|
damageType = EntityDamageEvent.DamageCause.ENTITY_EXPLOSION;
|
||||||
if (e instanceof EntityPlayerMP) {
|
|
||||||
// not possible in normal operations
|
|
||||||
damager = new CraftPlayer(server, (EntityPlayerMP) e);
|
|
||||||
} else if (e instanceof EntityLiving) {
|
|
||||||
damager = new CraftLivingEntity(server, (EntityLiving) e);
|
|
||||||
}
|
|
||||||
damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
|
|
||||||
|
|
||||||
EntityDamageByEntityEvent edbbe = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
|
EntityDamageByEntityEvent edbbe = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
|
||||||
server.getPluginManager().callEvent(edbbe);
|
server.getPluginManager().callEvent(edbbe);
|
||||||
|
|
||||||
if (!edbbe.isCancelled()) {
|
if (!edbbe.isCancelled()) {
|
||||||
entity.a(e, edbbe.getDamage());
|
entity.a(e, edbbe.getDamage());
|
||||||
|
double d15 = d14;
|
||||||
|
|
||||||
|
entity.s += d6 * d15;
|
||||||
|
entity.t += d8 * d15;
|
||||||
|
entity.u += d10 * d15;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Craftbukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
double d15 = d14;
|
|
||||||
|
|
||||||
entity.s += d6 * d15;
|
|
||||||
entity.t += d8 * d15;
|
|
||||||
entity.u += d10 * d15;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,65 +177,62 @@ public class Explosion {
|
|||||||
|
|
||||||
((List) (arraylist)).addAll(((java.util.Collection) (g)));
|
((List) (arraylist)).addAll(((java.util.Collection) (g)));
|
||||||
|
|
||||||
// Craftbukkit start
|
// CraftBukkit start
|
||||||
CraftServer servr = ((WorldServer) i).getServer();
|
Server server = ((WorldServer) i).getServer();
|
||||||
CraftWorld wrld = ((WorldServer) i).getWorld();
|
CraftWorld world = ((WorldServer) i).getWorld();
|
||||||
org.bukkit.entity.Entity splode;
|
org.bukkit.entity.Entity splode = (e == null) ? null : e.getBukkitEntity();
|
||||||
if (this.e instanceof EntityCreeper) {
|
|
||||||
splode = new CraftLivingEntity(servr, (EntityLiving) e);
|
List<org.bukkit.block.Block> blocklist = new ArrayList<org.bukkit.block.Block>();
|
||||||
} else {
|
for (int j = arraylist.size() - 1; j >= 0; j--) {
|
||||||
splode = (org.bukkit.entity.Entity) this.e;
|
ChunkPosition cpos = (ChunkPosition) arraylist.get(j);
|
||||||
}
|
org.bukkit.block.Block blox = world.getBlockAt(cpos.a, cpos.b, cpos.c);
|
||||||
ArrayList blocklist = new ArrayList();
|
|
||||||
for (int j = ((List) (arraylist)).size() - 1; j >= 0; j--) {
|
|
||||||
ChunkPosition cpos = (ChunkPosition) ((List) (arraylist)).get(j);
|
|
||||||
org.bukkit.craftbukkit.block.CraftBlock blox = new org.bukkit.craftbukkit.block.CraftBlock(wrld, cpos.a, cpos.b, cpos.c, wrld.getBlockTypeIdAt(cpos.a, cpos.b, cpos.c), wrld.getBlockAt(cpos.a, cpos.b, cpos.c).getData());
|
|
||||||
if (!blox.getType().equals(org.bukkit.Material.AIR)) {
|
if (!blox.getType().equals(org.bukkit.Material.AIR)) {
|
||||||
blocklist.add(blox);
|
blocklist.add(blox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityExplodeEvent eee = new EntityExplodeEvent(EntityExplodeEvent.Type.ENTITY_EXPLODE, splode, blocklist);
|
org.bukkit.event.Event.Type eventType = EntityExplodeEvent.Type.ENTITY_EXPLODE;
|
||||||
servr.getPluginManager().callEvent(eee);
|
EntityExplodeEvent eee = new EntityExplodeEvent(eventType, splode, blocklist);
|
||||||
if (!(eee.isCancelled())) {
|
server.getPluginManager().callEvent(eee);
|
||||||
// Notch start
|
|
||||||
for (int j = ((List) (arraylist)).size() - 1; j >= 0; j--) {
|
if (eee.isCancelled()) {
|
||||||
ChunkPosition chunkposition = (ChunkPosition) ((List) (arraylist)).get(j);
|
return;
|
||||||
int k = chunkposition.a;
|
}
|
||||||
int l = chunkposition.b;
|
// CraftBukkit end
|
||||||
int i1 = chunkposition.c;
|
for (int j = ((List) (arraylist)).size() - 1; j >= 0; j--) {
|
||||||
int j1 = i.a(k, l, i1);
|
ChunkPosition chunkposition = (ChunkPosition) ((List) (arraylist)).get(j);
|
||||||
|
int k = chunkposition.a;
|
||||||
for (int k1 = 0; k1 < 1; k1++) {
|
int l = chunkposition.b;
|
||||||
double d1 = (float) k + i.l.nextFloat();
|
int i1 = chunkposition.c;
|
||||||
double d2 = (float) l + i.l.nextFloat();
|
int j1 = i.a(k, l, i1);
|
||||||
double d3 = (float) i1 + i.l.nextFloat();
|
|
||||||
double d4 = d1 - b;
|
for (int k1 = 0; k1 < 1; k1++) {
|
||||||
double d5 = d2 - c;
|
double d1 = (float) k + i.l.nextFloat();
|
||||||
double d6 = d3 - d;
|
double d2 = (float) l + i.l.nextFloat();
|
||||||
double d7 = MathHelper.a(d4 * d4 + d5 * d5 + d6 * d6);
|
double d3 = (float) i1 + i.l.nextFloat();
|
||||||
|
double d4 = d1 - b;
|
||||||
d4 /= d7;
|
double d5 = d2 - c;
|
||||||
d5 /= d7;
|
double d6 = d3 - d;
|
||||||
d6 /= d7;
|
double d7 = MathHelper.a(d4 * d4 + d5 * d5 + d6 * d6);
|
||||||
double d8 = 0.5D / (d7 / (double) f + 0.10000000000000001D);
|
|
||||||
|
d4 /= d7;
|
||||||
d8 *= i.l.nextFloat() * i.l.nextFloat() + 0.3F;
|
d5 /= d7;
|
||||||
d4 *= d8;
|
d6 /= d7;
|
||||||
d5 *= d8;
|
double d8 = 0.5D / (d7 / (double) f + 0.10000000000000001D);
|
||||||
d6 *= d8;
|
|
||||||
i.a("explode", (d1 + b * 1.0D) / 2D, (d2 + c * 1.0D) / 2D, (d3 + d * 1.0D) / 2D, d4, d5, d6);
|
d8 *= i.l.nextFloat() * i.l.nextFloat() + 0.3F;
|
||||||
i.a("smoke", d1, d2, d3, d4, d5, d6);
|
d4 *= d8;
|
||||||
}
|
d5 *= d8;
|
||||||
|
d6 *= d8;
|
||||||
if (j1 > 0) {
|
i.a("explode", (d1 + b * 1.0D) / 2D, (d2 + c * 1.0D) / 2D, (d3 + d * 1.0D) / 2D, d4, d5, d6);
|
||||||
Block.m[j1].a(i, k, l, i1, i.b(k, l, i1), 0.3F);
|
i.a("smoke", d1, d2, d3, d4, d5, d6);
|
||||||
i.e(k, l, i1, 0);
|
}
|
||||||
Block.m[j1].a_(i, k, l, i1);
|
|
||||||
}
|
if (j1 > 0) {
|
||||||
}
|
Block.m[j1].a(i, k, l, i1, i.b(k, l, i1), 0.3F);
|
||||||
// Notch end
|
i.e(k, l, i1, 0);
|
||||||
|
Block.m[j1].a_(i, k, l, i1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//Craftbukkit end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user