diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/damagesource/DamageSource.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/damagesource/DamageSource.java.patch | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/damagesource/DamageSource.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/damagesource/DamageSource.java.patch new file mode 100644 index 0000000000..131e2a4a8d --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/damagesource/DamageSource.java.patch @@ -0,0 +1,183 @@ +--- a/net/minecraft/world/damagesource/DamageSource.java ++++ b/net/minecraft/world/damagesource/DamageSource.java +@@ -12,6 +12,7 @@ + import net.minecraft.world.phys.Vec3; + + public class DamageSource { ++ + private final Holder<DamageType> type; + @Nullable + private final Entity causingEntity; +@@ -19,8 +20,39 @@ + private final Entity directEntity; + @Nullable + private final Vec3 damageSourcePosition; ++ // CraftBukkit start ++ private boolean sweep; ++ private boolean melting; ++ private boolean poison; + +- @Override ++ public boolean isSweep() { ++ return sweep; ++ } ++ ++ public DamageSource sweep() { ++ this.sweep = true; ++ return this; ++ } ++ ++ public boolean isMelting() { ++ return melting; ++ } ++ ++ public DamageSource melting() { ++ this.melting = true; ++ return this; ++ } ++ ++ public boolean isPoison() { ++ return poison; ++ } ++ ++ public DamageSource poison() { ++ this.poison = true; ++ return this; ++ } ++ // CraftBukkit end ++ + public String toString() { + return "DamageSource (" + this.type().msgId() + ")"; + } +@@ -41,11 +73,11 @@ + } + + public DamageSource(Holder<DamageType> type, @Nullable Entity directEntity, @Nullable Entity causingEntity) { +- this(type, directEntity, causingEntity, null); ++ this(type, directEntity, causingEntity, (Vec3) null); + } + + public DamageSource(Holder<DamageType> type, Vec3 damageSourcePosition) { +- this(type, null, null, damageSourcePosition); ++ this(type, (Entity) null, (Entity) null, damageSourcePosition); + } + + public DamageSource(Holder<DamageType> type, @Nullable Entity entity) { +@@ -53,7 +85,7 @@ + } + + public DamageSource(Holder<DamageType> type) { +- this(type, null, null, null); ++ this(type, (Entity) null, (Entity) null, (Vec3) null); + } + + @Nullable +@@ -67,19 +99,29 @@ + } + + public Component getLocalizedDeathMessage(LivingEntity livingEntity) { +- String string = "death.attack." + this.type().msgId(); ++ String s = "death.attack." + this.type().msgId(); ++ + if (this.causingEntity == null && this.directEntity == null) { +- LivingEntity killCredit = livingEntity.getKillCredit(); +- String string1 = string + ".player"; +- return killCredit != null +- ? Component.translatable(string1, livingEntity.getDisplayName(), killCredit.getDisplayName()) +- : Component.translatable(string, livingEntity.getDisplayName()); ++ LivingEntity entityliving1 = livingEntity.getKillCredit(); ++ String s1 = s + ".player"; ++ ++ return entityliving1 != null ? Component.translatable(s1, livingEntity.getDisplayName(), entityliving1.getDisplayName()) : Component.translatable(s, livingEntity.getDisplayName()); + } else { +- Component component = this.causingEntity == null ? this.directEntity.getDisplayName() : this.causingEntity.getDisplayName(); +- ItemStack itemStack = this.causingEntity instanceof LivingEntity livingEntity1 ? livingEntity1.getMainHandItem() : ItemStack.EMPTY; +- return !itemStack.isEmpty() && itemStack.hasCustomHoverName() +- ? Component.translatable(string + ".item", livingEntity.getDisplayName(), component, itemStack.getDisplayName()) +- : Component.translatable(string, livingEntity.getDisplayName(), component); ++ Component ichatbasecomponent = this.causingEntity == null ? this.directEntity.getDisplayName() : this.causingEntity.getDisplayName(); ++ Entity entity = this.causingEntity; ++ ItemStack itemstack; ++ ++ if (entity instanceof LivingEntity) { ++ LivingEntity entityliving2 = (LivingEntity) entity; ++ ++ itemstack = entityliving2.getMainHandItem(); ++ } else { ++ itemstack = ItemStack.EMPTY; ++ } ++ ++ ItemStack itemstack1 = itemstack; ++ ++ return !itemstack1.isEmpty() && itemstack1.hasCustomHoverName() ? Component.translatable(s + ".item", livingEntity.getDisplayName(), ichatbasecomponent, itemstack1.getDisplayName()) : Component.translatable(s, livingEntity.getDisplayName(), ichatbasecomponent); + } + } + +@@ -88,28 +130,45 @@ + } + + public boolean scalesWithDifficulty() { +- return switch (this.type().scaling()) { +- case NEVER -> false; +- case WHEN_CAUSED_BY_LIVING_NON_PLAYER -> this.causingEntity instanceof LivingEntity && !(this.causingEntity instanceof Player); +- case ALWAYS -> true; +- }; ++ boolean flag; ++ ++ switch (this.type().scaling()) { ++ case NEVER: ++ flag = false; ++ break; ++ case WHEN_CAUSED_BY_LIVING_NON_PLAYER: ++ flag = this.causingEntity instanceof LivingEntity && !(this.causingEntity instanceof Player); ++ break; ++ case ALWAYS: ++ flag = true; ++ break; ++ default: ++ throw new IncompatibleClassChangeError(); ++ } ++ ++ return flag; + } + + public boolean isCreativePlayer() { +- if (this.getEntity() instanceof Player player && player.getAbilities().instabuild) { +- return true; ++ Entity entity = this.getEntity(); ++ boolean flag; ++ ++ if (entity instanceof Player) { ++ Player entityhuman = (Player) entity; ++ ++ if (entityhuman.getAbilities().instabuild) { ++ flag = true; ++ return flag; ++ } + } + +- return false; ++ flag = false; ++ return flag; + } + + @Nullable + public Vec3 getSourcePosition() { +- if (this.damageSourcePosition != null) { +- return this.damageSourcePosition; +- } else { +- return this.directEntity != null ? this.directEntity.position() : null; +- } ++ return this.damageSourcePosition != null ? this.damageSourcePosition : (this.directEntity != null ? this.directEntity.position() : null); + } + + @Nullable +@@ -126,7 +185,7 @@ + } + + public DamageType type() { +- return this.type.value(); ++ return (DamageType) this.type.value(); + } + + public Holder<DamageType> typeHolder() { |