geforkt von Mirrors/Paper
#1362: Include Creeper igniter in causing entity for damage events
By: Doc <nachito94@msn.com>
Dieser Commit ist enthalten in:
Ursprung
779b5137f8
Commit
84d43ef379
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/damagesource/DamageSource.java
|
||||
+++ b/net/minecraft/world/damagesource/DamageSource.java
|
||||
@@ -20,6 +20,81 @@
|
||||
@@ -20,6 +20,86 @@
|
||||
private final Entity directEntity;
|
||||
@Nullable
|
||||
private final Vec3D damageSourcePosition;
|
||||
@ -44,6 +44,11 @@
|
||||
+ }
|
||||
+
|
||||
+ public DamageSource customCausingEntity(Entity entity) {
|
||||
+ // This method is not intended for change the causing entity if is already set
|
||||
+ // also is only necessary if the entity passed is not the direct entity or different from the current causingEntity
|
||||
+ if (this.customCausingEntity != null || this.directEntity == entity || this.causingEntity == entity) {
|
||||
+ return this;
|
||||
+ }
|
||||
+ DamageSource damageSource = this.cloneInstance();
|
||||
+ damageSource.customCausingEntity = entity;
|
||||
+ return damageSource;
|
||||
@ -82,7 +87,7 @@
|
||||
|
||||
public String toString() {
|
||||
return "DamageSource (" + this.type().msgId() + ")";
|
||||
@@ -33,7 +108,7 @@
|
||||
@@ -33,7 +113,7 @@
|
||||
return this.causingEntity != this.directEntity;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,15 @@
|
||||
public class EntityCreeper extends EntityMonster implements PowerableMob {
|
||||
|
||||
private static final DataWatcherObject<Integer> DATA_SWELL_DIR = DataWatcher.defineId(EntityCreeper.class, DataWatcherRegistry.INT);
|
||||
@@ -218,9 +225,20 @@
|
||||
@@ -53,6 +60,7 @@
|
||||
public int maxSwell = 30;
|
||||
public int explosionRadius = 3;
|
||||
private int droppedSkulls;
|
||||
+ private EntityHuman entityIgniter; // CraftBukkit
|
||||
|
||||
public EntityCreeper(EntityTypes<? extends EntityCreeper> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -218,9 +226,20 @@
|
||||
@Override
|
||||
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
|
||||
super.thunderHit(worldserver, entitylightning);
|
||||
@ -35,16 +43,18 @@
|
||||
@Override
|
||||
protected EnumInteractionResult mobInteract(EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
||||
@@ -231,7 +249,7 @@
|
||||
@@ -230,8 +249,9 @@
|
||||
|
||||
this.level().playSound(entityhuman, this.getX(), this.getY(), this.getZ(), soundeffect, this.getSoundSource(), 1.0F, this.random.nextFloat() * 0.4F + 0.8F);
|
||||
if (!this.level().isClientSide) {
|
||||
+ this.entityIgniter = entityhuman; // CraftBukkit
|
||||
this.ignite();
|
||||
- if (!itemstack.isDamageableItem()) {
|
||||
+ if (itemstack.getItem().getMaxDamage() == 0) { // CraftBukkit - fix MC-264285: unbreakable flint and steels are completely consumed when igniting a creeper
|
||||
itemstack.shrink(1);
|
||||
} else {
|
||||
itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
|
||||
@@ -250,10 +268,19 @@
|
||||
@@ -250,10 +270,19 @@
|
||||
if (!this.level().isClientSide) {
|
||||
float f = this.isPowered() ? 2.0F : 1.0F;
|
||||
|
||||
@ -55,7 +65,7 @@
|
||||
this.dead = true;
|
||||
- this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, World.a.MOB);
|
||||
- this.discard();
|
||||
+ this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); // CraftBukkit
|
||||
+ this.level().explode(this, net.minecraft.world.level.Explosion.getDefaultDamageSource(this.level(), this).customCausingEntity(this.entityIgniter), null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); // CraftBukkit
|
||||
+ this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
|
||||
this.spawnLingeringCloud();
|
||||
+ // CraftBukkit start
|
||||
@ -66,7 +76,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -264,6 +291,7 @@
|
||||
@@ -264,6 +293,7 @@
|
||||
if (!collection.isEmpty()) {
|
||||
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ());
|
||||
|
||||
@ -74,7 +84,7 @@
|
||||
entityareaeffectcloud.setRadius(2.5F);
|
||||
entityareaeffectcloud.setRadiusOnUse(-0.5F);
|
||||
entityareaeffectcloud.setWaitTime(10);
|
||||
@@ -277,7 +305,7 @@
|
||||
@@ -277,7 +307,7 @@
|
||||
entityareaeffectcloud.addEffect(new MobEffect(mobeffect));
|
||||
}
|
||||
|
||||
|
@ -940,7 +940,7 @@ public class CraftEventFactory {
|
||||
|
||||
private static EntityDamageEvent handleEntityDamageEvent(Entity entity, DamageSource source, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled) {
|
||||
CraftDamageSource bukkitDamageSource = new CraftDamageSource(source);
|
||||
Entity damager = source.getCausingEntity();
|
||||
Entity damager = (bukkitDamageSource.isIndirect() && source.getDirectEntity() != null) ? source.getDirectEntity() : source.getCausingEntity();
|
||||
if (source.is(DamageTypeTags.IS_EXPLOSION)) {
|
||||
if (damager == null) {
|
||||
return callEntityDamageEvent(source.getDirectBlock(), entity, DamageCause.BLOCK_EXPLOSION, bukkitDamageSource, modifiers, modifierFunctions, cancelled);
|
||||
@ -950,10 +950,6 @@ public class CraftEventFactory {
|
||||
} else if (damager != null || source.getDirectEntity() != null) {
|
||||
DamageCause cause = (source.isSweep()) ? DamageCause.ENTITY_SWEEP_ATTACK : DamageCause.ENTITY_ATTACK;
|
||||
|
||||
if (bukkitDamageSource.isIndirect() && source.getDirectEntity() != null) {
|
||||
damager = source.getDirectEntity();
|
||||
}
|
||||
|
||||
if (damager instanceof IProjectile) {
|
||||
if (damager.getBukkitEntity() instanceof ThrownPotion) {
|
||||
cause = DamageCause.MAGIC;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren