forked from neoforged/NeoForge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/1.20.x' into 1.20.x
- Loading branch information
Showing
49 changed files
with
1,187 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
patches/net/minecraft/world/damagesource/CombatTracker.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- a/net/minecraft/world/damagesource/CombatTracker.java | ||
+++ b/net/minecraft/world/damagesource/CombatTracker.java | ||
@@ -90,6 +_,11 @@ | ||
DamageSource damagesource = combatentry.source(); | ||
CombatEntry combatentry1 = this.getMostSignificantFall(); | ||
DeathMessageType deathmessagetype = damagesource.type().deathMessageType(); | ||
+ // Neo: Implement IDeathMessageProvider#getDeathMessage | ||
+ // Vanilla logic is replicated in IDeathMessageProvider.DEFAULT | ||
+ if (true) { | ||
+ return deathmessagetype.getMessageFunction().getDeathMessage(this.mob, combatentry, combatentry1); | ||
+ } | ||
if (deathmessagetype == DeathMessageType.FALL_VARIANTS && combatentry1 != null) { | ||
return this.getFallMessage(combatentry1, damagesource.getEntity()); | ||
} else if (deathmessagetype == DeathMessageType.INTENTIONAL_GAME_DESIGN) { |
60 changes: 60 additions & 0 deletions
60
patches/net/minecraft/world/damagesource/DamageEffects.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- a/net/minecraft/world/damagesource/DamageEffects.java | ||
+++ b/net/minecraft/world/damagesource/DamageEffects.java | ||
@@ -5,7 +_,7 @@ | ||
import net.minecraft.sounds.SoundEvents; | ||
import net.minecraft.util.StringRepresentable; | ||
|
||
-public enum DamageEffects implements StringRepresentable { | ||
+public enum DamageEffects implements StringRepresentable, net.neoforged.neoforge.common.IExtensibleEnum { | ||
HURT("hurt", SoundEvents.PLAYER_HURT), | ||
THORNS("thorns", SoundEvents.THORNS_HIT), | ||
DROWNING("drowning", SoundEvents.PLAYER_HURT_DROWN), | ||
@@ -13,13 +_,13 @@ | ||
POKING("poking", SoundEvents.PLAYER_HURT_SWEET_BERRY_BUSH), | ||
FREEZING("freezing", SoundEvents.PLAYER_HURT_FREEZE); | ||
|
||
- public static final Codec<DamageEffects> CODEC = StringRepresentable.fromEnum(DamageEffects::values); | ||
+ public static final Codec<DamageEffects> CODEC = net.minecraft.util.ExtraCodecs.lazyInitializedCodec(() -> StringRepresentable.fromEnum(DamageEffects::values)); | ||
private final String id; | ||
+ @Deprecated // Neo: Always set to null. Use the getter. | ||
private final SoundEvent sound; | ||
|
||
private DamageEffects(String p_270875_, SoundEvent p_270383_) { | ||
- this.id = p_270875_; | ||
- this.sound = p_270383_; | ||
+ this(p_270875_, () -> p_270383_); | ||
} | ||
|
||
@Override | ||
@@ -28,6 +_,30 @@ | ||
} | ||
|
||
public SoundEvent sound() { | ||
- return this.sound; | ||
+ return this.soundSupplier.get(); | ||
+ } | ||
+ | ||
+ private final java.util.function.Supplier<SoundEvent> soundSupplier; | ||
+ | ||
+ private DamageEffects(String id, java.util.function.Supplier<SoundEvent> sound) { | ||
+ this.id = id; | ||
+ this.soundSupplier = sound; | ||
+ this.sound = null; | ||
+ } | ||
+ | ||
+ /** | ||
+ * Creates a new DamageEffects with the specified ID and sound.<br> | ||
+ * Example usage: | ||
+ * <code><pre> | ||
+ * public static final DamageEffects ELECTRIFYING = DamageEffects.create("MYMOD_ELECTRIFYING", "mymod:electrifying", MySounds.ELECTRIFYING); | ||
+ * </pre></code> | ||
+ * @param name The {@linkplain Enum#name() true enum name}. Prefix this with your modid. | ||
+ * @param id The {@linkplain StringRepresentable#getSerializedName() serialized name}. Prefix this with your modid and `:` | ||
+ * @param sound The sound event that will play when a damage type with this effect deals damage to a player. | ||
+ * @return A newly created DamageEffects. Store this result in a static final field. | ||
+ * @apiNote This method must be called as early as possible, as if {@link #CODEC} is resolved before this is called, it will be unusable. | ||
+ */ | ||
+ public static DamageEffects create(String name, String id, java.util.function.Supplier<SoundEvent> sound) { | ||
+ throw new IllegalStateException("Enum not extended"); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
patches/net/minecraft/world/damagesource/DamageScaling.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- a/net/minecraft/world/damagesource/DamageScaling.java | ||
+++ b/net/minecraft/world/damagesource/DamageScaling.java | ||
@@ -3,20 +_,51 @@ | ||
import com.mojang.serialization.Codec; | ||
import net.minecraft.util.StringRepresentable; | ||
|
||
-public enum DamageScaling implements StringRepresentable { | ||
+public enum DamageScaling implements StringRepresentable, net.neoforged.neoforge.common.IExtensibleEnum { | ||
NEVER("never"), | ||
WHEN_CAUSED_BY_LIVING_NON_PLAYER("when_caused_by_living_non_player"), | ||
ALWAYS("always"); | ||
|
||
- public static final Codec<DamageScaling> CODEC = StringRepresentable.fromEnum(DamageScaling::values); | ||
+ public static final Codec<DamageScaling> CODEC = net.minecraft.util.ExtraCodecs.lazyInitializedCodec(() -> StringRepresentable.fromEnum(DamageScaling::values)); | ||
private final String id; | ||
|
||
private DamageScaling(String p_270266_) { | ||
- this.id = p_270266_; | ||
+ this(p_270266_, net.neoforged.neoforge.common.damagesource.IScalingFunction.DEFAULT); | ||
} | ||
|
||
@Override | ||
public String getSerializedName() { | ||
return this.id; | ||
+ } | ||
+ | ||
+ private final net.neoforged.neoforge.common.damagesource.IScalingFunction scaling; | ||
+ | ||
+ private DamageScaling(String id, net.neoforged.neoforge.common.damagesource.IScalingFunction scaling) { | ||
+ this.id = id; | ||
+ this.scaling = scaling; | ||
+ } | ||
+ | ||
+ /** | ||
+ * The scaling function is used when a player is hurt by a damage type with this type of scaling. | ||
+ * @return The {@link net.neoforged.neoforge.common.damagesource.IScalingFunction} associated with this damage scaling. | ||
+ */ | ||
+ public net.neoforged.neoforge.common.damagesource.IScalingFunction getScalingFunction() { | ||
+ return this.scaling; | ||
+ } | ||
+ | ||
+ /** | ||
+ * Creates a new DamageScaling with the specified ID and scaling function.<br> | ||
+ * Example usage: | ||
+ * <code><pre> | ||
+ * public static final DamageScaling CUSTOM_SCALING = DamageEffects.create("MYMOD_CUSTOM", "mymod:custom", MyMod.CUSTOM_SCALING_FUNCTION); | ||
+ * </pre></code> | ||
+ * @param name The {@linkplain Enum#name() true enum name}. Prefix this with your modid. | ||
+ * @param id The {@linkplain StringRepresentable#getSerializedName() serialized name}. Prefix this with your modid and `:` | ||
+ * @param scaling The scaling function that will be used when a player is hurt by a damage type with this type of scaling. | ||
+ * @return A newly created DamageScaling. Store this result in a static final field. | ||
+ * @apiNote This method must be called as early as possible, as if {@link #CODEC} is resolved before this is called, it will be unusable. | ||
+ */ | ||
+ public static DamageScaling create(String name, String id, net.neoforged.neoforge.common.damagesource.IScalingFunction scaling) { | ||
+ throw new IllegalStateException("Enum not extended"); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
patches/net/minecraft/world/damagesource/DamageSource.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- a/net/minecraft/world/damagesource/DamageSource.java | ||
+++ b/net/minecraft/world/damagesource/DamageSource.java | ||
@@ -88,6 +_,10 @@ | ||
return this.type().msgId(); | ||
} | ||
|
||
+ /** | ||
+ * @deprecated Use {@link DamageScaling#getScalingFunction()} | ||
+ */ | ||
+ @Deprecated(since = "1.20.1") | ||
public boolean scalesWithDifficulty() { | ||
return switch(this.type().scaling()) { | ||
case NEVER -> false; |
57 changes: 57 additions & 0 deletions
57
patches/net/minecraft/world/damagesource/DeathMessageType.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- a/net/minecraft/world/damagesource/DeathMessageType.java | ||
+++ b/net/minecraft/world/damagesource/DeathMessageType.java | ||
@@ -3,20 +_,51 @@ | ||
import com.mojang.serialization.Codec; | ||
import net.minecraft.util.StringRepresentable; | ||
|
||
-public enum DeathMessageType implements StringRepresentable { | ||
+public enum DeathMessageType implements StringRepresentable, net.neoforged.neoforge.common.IExtensibleEnum { | ||
DEFAULT("default"), | ||
FALL_VARIANTS("fall_variants"), | ||
INTENTIONAL_GAME_DESIGN("intentional_game_design"); | ||
|
||
- public static final Codec<DeathMessageType> CODEC = StringRepresentable.fromEnum(DeathMessageType::values); | ||
+ public static final Codec<DeathMessageType> CODEC = net.minecraft.util.ExtraCodecs.lazyInitializedCodec(() -> StringRepresentable.fromEnum(DeathMessageType::values)); | ||
private final String id; | ||
|
||
private DeathMessageType(String p_270201_) { | ||
- this.id = p_270201_; | ||
+ this(p_270201_, net.neoforged.neoforge.common.damagesource.IDeathMessageProvider.DEFAULT); | ||
} | ||
|
||
@Override | ||
public String getSerializedName() { | ||
return this.id; | ||
+ } | ||
+ | ||
+ private final net.neoforged.neoforge.common.damagesource.IDeathMessageProvider msgFunction; | ||
+ | ||
+ private DeathMessageType(String id, net.neoforged.neoforge.common.damagesource.IDeathMessageProvider msgFunction) { | ||
+ this.id = id; | ||
+ this.msgFunction = msgFunction; | ||
+ } | ||
+ | ||
+ /** | ||
+ * The death message function is used when an entity dies to a damage type with this death message type. | ||
+ * @return The {@link net.neoforged.neoforge.common.damagesource.IDeathMessageProvider} associated with this death message type. | ||
+ */ | ||
+ public net.neoforged.neoforge.common.damagesource.IDeathMessageProvider getMessageFunction() { | ||
+ return this.msgFunction; | ||
+ } | ||
+ | ||
+ /** | ||
+ * Creates a new DeathMessageType with the specified ID and death message provider.<br> | ||
+ * Example usage: | ||
+ * <code><pre> | ||
+ * public static final DeathMessageType CUSTOM_FUNCTION = DeathMessageType.create("MYMOD_CUSTOM", "mymod:custom", MyMod.CUSTOM_MESSAGE_PROVIDER); | ||
+ * </pre></code> | ||
+ * @param name The {@linkplain Enum#name() true enum name}. Prefix this with your modid. | ||
+ * @param id The {@linkplain StringRepresentable#getSerializedName() serialized name}. Prefix this with your modid and `:` | ||
+ * @param scaling The scaling function that will be used when a player is hurt by a damage type with this type of scaling. | ||
+ * @return A newly created DamageScaling. Store this result in a static final field. | ||
+ * @apiNote This method must be called as early as possible, as if {@link #CODEC} is resolved before this is called, it will be unusable. | ||
+ */ | ||
+ public static DeathMessageType create(String name, String id, net.neoforged.neoforge.common.damagesource.IDeathMessageProvider msgFunction) { | ||
+ throw new IllegalStateException("Enum not extended"); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
patches/net/minecraft/world/effect/PoisonMobEffect.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- a/net/minecraft/world/effect/PoisonMobEffect.java | ||
+++ b/net/minecraft/world/effect/PoisonMobEffect.java | ||
@@ -11,7 +_,8 @@ | ||
public void applyEffectTick(LivingEntity p_296276_, int p_296233_) { | ||
super.applyEffectTick(p_296276_, p_296233_); | ||
if (p_296276_.getHealth() > 1.0F) { | ||
- p_296276_.hurt(p_296276_.damageSources().magic(), 1.0F); | ||
+ // Neo: Replace DamageSources#magic() with neoforge:poison to allow differentiating poison damage. | ||
+ p_296276_.hurt(p_296276_.damageSources().source(net.neoforged.neoforge.common.NeoForgeMod.POISON_DAMAGE), 1.0F); | ||
} | ||
} | ||
|
20 changes: 20 additions & 0 deletions
20
patches/net/minecraft/world/entity/ai/goal/RangedCrossbowAttackGoal.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.