mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-18 12:48:53 +01:00
da7138233f
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: ed0ec489 SPIGOT-7965: Unknown TransformReason for Hoglins 9db03457 SPIGOT-7964: Fix typo in Deprecation annotation d14119af PR-1082: Add "since" to Deprecation annotations e8a318d4 PR-1067: Add method to get Advancement requirements CraftBukkit Changes: 40dd796db SPIGOT-7971: NotSerializableException on serialize CraftUseCooldownComponent fa85c5e0a SPIGOT-7968: ProjectileHitEvent not trigerred when arrow hits entity b75b792ec SPIGOT-7970: World#getMaxHeight() returning incorrect value 2b9a094bb SPIGOT-7965: Unknown TransformReason for Hoglins fd3f5a380 SPIGOT-7966: Some trees do not generate with #generateTree f2822317c PR-1515: Add a Class reader and Class node argument provider 07abf6852 PR-1514: Add a test case for ClassTraverser a7577cb24 Fix Inventory#addItem not respecting max stack size 066a74e74 PR-1490: Add method to get Advancement requirements 4a1df30e4 PR-1512: Test Art class based on specific values instead of the implementation, to better catch implementation changes 53254c56f PR-1503: Simplify CAS loop to getAndSet e9447dc5e Make BlockDataMeta#setBlockData hide unspecified states dd08a7120 SPIGOT-7960: Fix inconsistency between natural item drop coordinates e9e8ed753 SPIGOT-7960: Improve natural item drop methods Spigot Changes: 60c9969b Rebuild patches
87 lines
6.7 KiB
Diff
87 lines
6.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Wed, 20 Jun 2018 23:17:24 -0400
|
|
Subject: [PATCH] Expand Explosions API
|
|
|
|
Add Entity as a Source capability, and add more API choices, and on Location.
|
|
|
|
Co-authored-by: Esoteric Enderman <90862990+EsotericEnderman@users.noreply.github.com>
|
|
Co-authored-by: Bjarne Koll <git@lynxplay.dev>
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index 03161ef12960cab3b9c81c190dd808a9c5c476e1..f0fc08bcc2988277b6a5e3107e6fc5c89bb67b93 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1424,6 +1424,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
}
|
|
|
|
public ServerExplosion explode0(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Level.ExplosionInteraction world_a, ParticleOptions particleparam, ParticleOptions particleparam1, Holder<SoundEvent> holder) {
|
|
+ // Paper start - Allow explosions to damage source
|
|
+ return this.explode0(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, world_a, particleparam, particleparam1, holder, null);
|
|
+ }
|
|
+ public ServerExplosion explode0(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Level.ExplosionInteraction world_a, ParticleOptions particleparam, ParticleOptions particleparam1, Holder<SoundEvent> holder, java.util.function.Consumer<ServerExplosion> configurator) {
|
|
+ // Paper end - Allow explosions to damage source
|
|
// CraftBukkit end
|
|
Explosion.BlockInteraction explosion_effect;
|
|
|
|
@@ -1455,6 +1460,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
Explosion.BlockInteraction explosion_effect1 = explosion_effect;
|
|
Vec3 vec3d = new Vec3(d0, d1, d2);
|
|
ServerExplosion serverexplosion = new ServerExplosion(this, entity, damagesource, explosiondamagecalculator, vec3d, f, flag, explosion_effect1);
|
|
+ if (configurator != null) configurator.accept(serverexplosion);// Paper - Allow explosions to damage source
|
|
|
|
serverexplosion.explode();
|
|
// CraftBukkit start
|
|
diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java
|
|
index 9f37d7284c81d529551107e2836627977efabd65..d1878f597c3d8119e9b248f4fe8af435ce8c9710 100644
|
|
--- a/src/main/java/net/minecraft/world/level/ServerExplosion.java
|
|
+++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java
|
|
@@ -63,6 +63,7 @@ public class ServerExplosion implements Explosion {
|
|
public boolean wasCanceled = false;
|
|
public float yield;
|
|
// CraftBukkit end
|
|
+ public boolean excludeSourceFromDamage = true; // Paper - Allow explosions to damage source
|
|
|
|
public ServerExplosion(ServerLevel world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, Vec3 pos, float power, boolean createFire, Explosion.BlockInteraction destructionType) {
|
|
this.level = world;
|
|
@@ -185,7 +186,7 @@ public class ServerExplosion implements Explosion {
|
|
int l = Mth.floor(this.center.y + (double) f + 1.0D);
|
|
int i1 = Mth.floor(this.center.z - (double) f - 1.0D);
|
|
int j1 = Mth.floor(this.center.z + (double) f + 1.0D);
|
|
- List<Entity> list = this.level.getEntities(this.source, new AABB((double) i, (double) k, (double) i1, (double) j, (double) l, (double) j1), (com.google.common.base.Predicate<Entity>) entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities
|
|
+ List<Entity> list = this.level.getEntities(excludeSourceFromDamage ? this.source : null, new AABB((double) i, (double) k, (double) i1, (double) j, (double) l, (double) j1), (com.google.common.base.Predicate<Entity>) entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source
|
|
Iterator iterator = list.iterator();
|
|
|
|
while (iterator.hasNext()) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index bb407fe2a2f65d8bb73024b3c33025808a50f6e3..ec32a4c6d55784c27390ccdf3f90362eacd15eb2 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -777,6 +777,11 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
@Override
|
|
public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source) {
|
|
+ // Paper start - expand explosion API
|
|
+ return this.createExplosion(x, y, z, power, setFire, breakBlocks, source, null);
|
|
+ }
|
|
+ public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source, Consumer<net.minecraft.world.level.ServerExplosion> configurator) {
|
|
+ // Paper end - expand explosion API
|
|
net.minecraft.world.level.Level.ExplosionInteraction explosionType;
|
|
if (!breakBlocks) {
|
|
explosionType = net.minecraft.world.level.Level.ExplosionInteraction.NONE; // Don't break blocks
|
|
@@ -787,8 +792,14 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
}
|
|
|
|
net.minecraft.world.entity.Entity entity = (source == null) ? null : ((CraftEntity) source).getHandle();
|
|
- return !this.world.explode0(entity, Explosion.getDefaultDamageSource(this.world, entity), null, x, y, z, power, setFire, explosionType, ParticleTypes.EXPLOSION, ParticleTypes.EXPLOSION_EMITTER, SoundEvents.GENERIC_EXPLODE).wasCanceled;
|
|
+ return !this.world.explode0(entity, Explosion.getDefaultDamageSource(this.world, entity), null, x, y, z, power, setFire, explosionType, ParticleTypes.EXPLOSION, ParticleTypes.EXPLOSION_EMITTER, SoundEvents.GENERIC_EXPLODE, configurator).wasCanceled; // Paper - expand explosion API
|
|
}
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public boolean createExplosion(Entity source, Location loc, float power, boolean setFire, boolean breakBlocks, boolean excludeSourceFromDamage) {
|
|
+ return this.createExplosion(loc.x(), loc.getY(), loc.getZ(), power, setFire, breakBlocks, source, e -> e.excludeSourceFromDamage = excludeSourceFromDamage);
|
|
+ }
|
|
+ // Paper end
|
|
|
|
@Override
|
|
public boolean createExplosion(Location loc, float power) {
|