13
0
geforkt von Mirrors/Paper

SPIGOT-3126: Make fireballs do a better job of respecting mobGriefing

By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2017-03-15 15:26:36 +11:00
Ursprung 7489812328
Commit d8033d64c6
2 geänderte Dateien mit 45 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityLargeFireball.java --- a/net/minecraft/server/EntityLargeFireball.java
+++ b/net/minecraft/server/EntityLargeFireball.java +++ b/net/minecraft/server/EntityLargeFireball.java
@@ -1,5 +1,7 @@ @@ -1,15 +1,19 @@
package net.minecraft.server; package net.minecraft.server;
+import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit +import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
@ -8,7 +8,19 @@
public class EntityLargeFireball extends EntityFireball { public class EntityLargeFireball extends EntityFireball {
public int yield = 1; public int yield = 1;
@@ -21,7 +23,15 @@
public EntityLargeFireball(World world) {
super(world);
+ isIncendiary = this.world.getGameRules().getBoolean("mobGriefing"); // CraftBukkit
}
public EntityLargeFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) {
super(world, entityliving, d0, d1, d2);
+ isIncendiary = this.world.getGameRules().getBoolean("mobGriefing"); // CraftBukkit
}
protected void a(MovingObjectPosition movingobjectposition) {
@@ -21,7 +25,15 @@
boolean flag = this.world.getGameRules().getBoolean("mobGriefing"); boolean flag = this.world.getGameRules().getBoolean("mobGriefing");
@ -19,13 +31,13 @@
+ +
+ if (!event.isCancelled()) { + if (!event.isCancelled()) {
+ // give 'this' instead of (Entity) null so we know what causes the damage + // give 'this' instead of (Entity) null so we know what causes the damage
+ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), flag); + this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), isIncendiary);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.die(); this.die();
} }
@@ -39,7 +49,8 @@ @@ -39,7 +51,8 @@
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound); super.a(nbttagcompound);
if (nbttagcompound.hasKeyOfType("ExplosionPower", 99)) { if (nbttagcompound.hasKeyOfType("ExplosionPower", 99)) {

Datei anzeigen

@ -8,12 +8,29 @@
public class EntitySmallFireball extends EntityFireball { public class EntitySmallFireball extends EntityFireball {
public EntitySmallFireball(World world) { public EntitySmallFireball(World world) {
@@ -30,7 +32,14 @@ @@ -10,6 +12,11 @@
flag = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 5.0F); public EntitySmallFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) {
if (flag) { super(world, entityliving, d0, d1, d2);
this.setSize(0.3125F, 0.3125F);
+ // CraftBukkit start
+ if (this.shooter != null && this.shooter instanceof EntityInsentient) {
+ isIncendiary = this.world.getGameRules().getBoolean("mobGriefing");
+ }
+ // CraftBukkit end
}
public EntitySmallFireball(World world, double d0, double d1, double d2, double d3, double d4, double d5) {
@@ -27,10 +34,17 @@
if (movingobjectposition.entity != null) {
if (!movingobjectposition.entity.isFireProof()) {
- flag = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 5.0F);
- if (flag) {
+ // CraftBukkit start - Entity damage by entity event + combust event
+ isIncendiary = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 5.0F);
+ if (isIncendiary) {
this.a(this.shooter, movingobjectposition.entity); this.a(this.shooter, movingobjectposition.entity);
- movingobjectposition.entity.setOnFire(5); - movingobjectposition.entity.setOnFire(5);
+ // CraftBukkit start - Entity damage by entity event + combust event
+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), movingobjectposition.entity.getBukkitEntity(), 5); + EntityCombustByEntityEvent event = new EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), movingobjectposition.entity.getBukkitEntity(), 5);
+ movingobjectposition.entity.world.getServer().getPluginManager().callEvent(event); + movingobjectposition.entity.world.getServer().getPluginManager().callEvent(event);
+ +
@ -24,13 +41,18 @@
} }
} }
} else { } else {
@@ -43,7 +52,11 @@ @@ -39,11 +53,15 @@
flag = this.world.getGameRules().getBoolean("mobGriefing");
}
- if (flag) {
+ // CraftBukkit start
+ if (isIncendiary) {
BlockPosition blockposition = movingobjectposition.a().shift(movingobjectposition.direction); BlockPosition blockposition = movingobjectposition.a().shift(movingobjectposition.direction);
if (this.world.isEmpty(blockposition)) { if (this.world.isEmpty(blockposition)) {
- this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); - this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
+ // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) {
+ if (isIncendiary && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) {
+ this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); + this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
+ } + }
+ // CraftBukkit end + // CraftBukkit end