mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 03:48:01 +01:00
net.minecraft.world.damagesource
This commit is contained in:
parent
5eb4ceb6a4
commit
7d70dbf927
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/damagesource/DamageSource.java
|
||||
+++ b/net/minecraft/world/damagesource/DamageSource.java
|
||||
@@ -21,7 +21,106 @@
|
||||
@@ -20,6 +_,105 @@
|
||||
private final Entity directEntity;
|
||||
@Nullable
|
||||
private final Vec3 damageSourcePosition;
|
||||
@ -14,7 +14,7 @@
|
||||
+ private boolean poison = false;
|
||||
+ @Nullable
|
||||
+ private Entity customEventDamager = null; // This field is a helper for when causing entity damage is not set by vanilla // Paper - fix DamageSource API
|
||||
|
||||
+
|
||||
+ public DamageSource sweep() {
|
||||
+ this.sweep = true;
|
||||
+ return this;
|
||||
@ -103,11 +103,10 @@
|
||||
+ return damageSource;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DamageSource (" + this.type().msgId() + ")";
|
||||
}
|
||||
@@ -163,4 +262,18 @@
|
||||
@@ -134,4 +_,18 @@
|
||||
public Holder<DamageType> typeHolder() {
|
||||
return this.type;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/damagesource/DamageSources.java
|
||||
+++ b/net/minecraft/world/damagesource/DamageSources.java
|
||||
@@ -43,9 +43,15 @@
|
||||
@@ -42,9 +_,15 @@
|
||||
private final DamageSource stalagmite;
|
||||
private final DamageSource outsideBorder;
|
||||
private final DamageSource genericKill;
|
||||
@ -8,20 +8,18 @@
|
||||
+ private final DamageSource melting;
|
||||
+ private final DamageSource poison;
|
||||
|
||||
public DamageSources(RegistryAccess registryManager) {
|
||||
this.damageTypes = registryManager.lookupOrThrow(Registries.DAMAGE_TYPE);
|
||||
public DamageSources(RegistryAccess registry) {
|
||||
this.damageTypes = registry.lookupOrThrow(Registries.DAMAGE_TYPE);
|
||||
+ this.melting = this.source(DamageTypes.ON_FIRE).melting();
|
||||
+ this.poison = this.source(DamageTypes.MAGIC).poison();
|
||||
+ // CraftBukkit end
|
||||
this.inFire = this.source(DamageTypes.IN_FIRE);
|
||||
this.campfire = this.source(DamageTypes.CAMPFIRE);
|
||||
this.lightningBolt = this.source(DamageTypes.LIGHTNING_BOLT);
|
||||
@@ -83,7 +89,17 @@
|
||||
@@ -84,6 +_,16 @@
|
||||
return new DamageSource(this.damageTypes.getOrThrow(damageTypeKey), causingEntity, directEntity);
|
||||
}
|
||||
|
||||
private DamageSource source(ResourceKey<DamageType> key, @Nullable Entity source, @Nullable Entity attacker) {
|
||||
return new DamageSource(this.damageTypes.getOrThrow(key), source, attacker);
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public DamageSource melting() {
|
||||
+ return this.melting;
|
||||
@ -29,34 +27,24 @@
|
||||
+
|
||||
+ public DamageSource poison() {
|
||||
+ return this.poison;
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
public DamageSource inFire() {
|
||||
return this.inFire;
|
||||
@@ -254,7 +270,7 @@
|
||||
}
|
||||
|
||||
public DamageSource explosion(@Nullable Entity source, @Nullable Entity attacker) {
|
||||
- return this.source(attacker != null && source != null ? DamageTypes.PLAYER_EXPLOSION : DamageTypes.EXPLOSION, source, attacker);
|
||||
+ return this.source(attacker != null && source != null ? DamageTypes.PLAYER_EXPLOSION : DamageTypes.EXPLOSION, source, attacker); // Paper - revert to vanilla
|
||||
}
|
||||
|
||||
public DamageSource sonicBoom(Entity attacker) {
|
||||
@@ -262,9 +278,15 @@
|
||||
@@ -261,7 +_,13 @@
|
||||
}
|
||||
|
||||
public DamageSource badRespawnPointExplosion(Vec3 position) {
|
||||
- return new DamageSource(this.damageTypes.getOrThrow(DamageTypes.BAD_RESPAWN_POINT), position);
|
||||
+ // CraftBukkit start
|
||||
+ return this.badRespawnPointExplosion(position, null);
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ public DamageSource badRespawnPointExplosion(Vec3 vec3d, org.bukkit.block.BlockState blockState) {
|
||||
+ return new DamageSource(this.damageTypes.getOrThrow(DamageTypes.BAD_RESPAWN_POINT), vec3d).directBlockState(blockState);
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+
|
||||
public DamageSource outOfBorder() {
|
||||
return this.outsideBorder;
|
||||
}
|
||||
|
||||
public DamageSource outOfBorder() {
|
Loading…
Reference in New Issue
Block a user