Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/1.20.x' into 1.20.x
Browse files Browse the repository at this point in the history
  • Loading branch information
XFactHD committed Jan 15, 2024
2 parents a1299f0 + ce7e8de commit 1cb44b8
Show file tree
Hide file tree
Showing 49 changed files with 1,187 additions and 56 deletions.
22 changes: 11 additions & 11 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
Unless noted below, Minecraft Forge, Forge Mod Loader, and all
Unless noted below, NeoForge, NeoForge Mod Loader, and all
parts herein are licensed under the terms of the LGPL 2.1 found
here http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt and
copied below.

Homepage: http://minecraftforge.net/
https://github.com/MinecraftForge/MinecraftForge
Homepage: https://neoforged.net/
https://github.com/neoforged/NeoForge


A note on authorship:
All source artifacts are property of their original author, with
the exclusion of the contents of the patches directory and others
copied from it from time to time. Authorship of the contents of
the patches directory is retained by the Minecraft Forge project.
the patches directory is retained by the NeoForge project.
This is because the patches are partially machine generated
artifacts, and are changed heavily due to the way forge works.
artifacts, and are changed heavily due to the way NeoForge works.
Individual attribution within them is impossible.

Consent:
All contributions to Forge must consent to the release of any
patch content to the Forge project.
All contributions to NeoForge must consent to the release of any
patch content to the NeoForge project.

A note on infectivity:
The LGPL is chosen specifically so that projects may depend on Forge
The LGPL is chosen specifically so that projects may depend on NeoForge
features without being infected with its license. That is the
purpose of the LGPL. Mods and others using this code via ordinary
Java mechanics for referencing libraries are specifically not bound
by Forge's license for the Mod code.
by NeoForge's license for the Mod code.


=== MCP Data ===
Expand All @@ -42,8 +42,8 @@ the minecraft modding community. All contributions to these parts should be lice
License is granted to redistribute the runtime patcher code (src/main/java/net/minecraftforge/fml/common/patcher
and subdirectories) under any alternative open source license as classified by the OSI (http://opensource.org/licenses)

-- ASM transformers --
License is granted to redistribute the ASM transformer code (src/main/java/net/minecraftforge/common/asm/ and subdirectories)
-- Coremods --
License is granted to redistribute the Coremod code (/src/main/resources/coremods)
under any alternative open source license as classified by the OSI (http://opensource.org/licenses)

=========================================================================
Expand Down
11 changes: 11 additions & 0 deletions patches/net/minecraft/client/renderer/GameRenderer.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@
}
}

@@ -919,6 +_,10 @@
return;
}

+ // Neo: Prevent screen shake if the damage type is marked as "forge:no_flinch"
+ var lastSrc = livingentity.getLastDamageSource();
+ if (lastSrc != null && lastSrc.is(net.neoforged.neoforge.common.Tags.DamageTypes.NO_FLINCH)) return;
+
float f3 = f2 / (float)livingentity.hurtDuration;
float f4 = Mth.sin(f3 * f3 * f3 * f3 * (float) Math.PI);
float f5 = livingentity.getHurtDir();
@@ -1074,13 +_,13 @@
(float)((double)window.getHeight() / window.getGuiScale()),
0.0F,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@
);
}
} catch (Throwable throwable) {
@@ -90,6 +_,7 @@

public void renderLiquid(BlockPos p_234364_, BlockAndTintGetter p_234365_, VertexConsumer p_234366_, BlockState p_234367_, FluidState p_234368_) {
try {
+ if (net.neoforged.neoforge.client.extensions.common.IClientFluidTypeExtensions.of(p_234368_).renderFluid(p_234368_, p_234365_, p_234364_, p_234366_, p_234367_)) return;
this.liquidBlockRenderer.tesselate(p_234365_, p_234364_, p_234366_, p_234367_, p_234368_);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Tesselating liquid in world");
@@ -107,7 +_,11 @@
return this.blockModelShaper.getBlockModel(p_110911_);
}
Expand Down Expand Up @@ -101,3 +109,13 @@
}
}
}
@@ -140,5 +_,9 @@
@Override
public void onResourceManagerReload(ResourceManager p_110909_) {
this.liquidBlockRenderer.setupSprites();
+ }
+
+ public LiquidBlockRenderer getLiquidBlockRenderer() {
+ return this.liquidBlockRenderer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,16 @@
- this.vertex(p_234372_, d5, d2 + (double)f45, d6, f37, f38, f39, f32, f34, j);
- this.vertex(p_234372_, d5, d2 + (double)f17, d6, f37, f38, f39, f32, f35, j);
- this.vertex(p_234372_, d3, d2 + (double)f17, d4, f37, f38, f39, f53, f35, j);
+ this.vertex(p_234372_, d3, d2 + (double)f44, d4, f37, f38, f39, alpha, f53, f33, j);
+ this.vertex(p_234372_, d5, d2 + (double)f45, d6, f37, f38, f39, alpha, f32, f34, j);
+ this.vertex(p_234372_, d5, d2 + (double)f17, d6, f37, f38, f39, alpha, f32, f35, j);
+ this.vertex(p_234372_, d3, d2 + (double)f17, d4, f37, f38, f39, alpha, f53, f35, j);
if (textureatlassprite2 != this.waterOverlay) {
- if (textureatlassprite2 != this.waterOverlay) {
- this.vertex(p_234372_, d3, d2 + (double)f17, d4, f37, f38, f39, f53, f35, j);
- this.vertex(p_234372_, d5, d2 + (double)f17, d6, f37, f38, f39, f32, f35, j);
- this.vertex(p_234372_, d5, d2 + (double)f45, d6, f37, f38, f39, f32, f34, j);
- this.vertex(p_234372_, d3, d2 + (double)f44, d4, f37, f38, f39, f53, f33, j);
+ this.vertex(p_234372_, d3, d2 + (double)f44, d4, f37, f38, f39, alpha, f53, f33, j);
+ this.vertex(p_234372_, d5, d2 + (double)f45, d6, f37, f38, f39, alpha, f32, f34, j);
+ this.vertex(p_234372_, d5, d2 + (double)f17, d6, f37, f38, f39, alpha, f32, f35, j);
+ this.vertex(p_234372_, d3, d2 + (double)f17, d4, f37, f38, f39, alpha, f53, f35, j);
+ if (textureatlassprite2 != atextureatlassprite[2]) {
+ this.vertex(p_234372_, d3, d2 + (double)f17, d4, f37, f38, f39, alpha, f53, f35, j);
+ this.vertex(p_234372_, d5, d2 + (double)f17, d6, f37, f38, f39, alpha, f32, f35, j);
+ this.vertex(p_234372_, d5, d2 + (double)f45, d6, f37, f38, f39, alpha, f32, f34, j);
Expand Down
2 changes: 1 addition & 1 deletion patches/net/minecraft/server/MinecraftServer.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
this.profiler.popPush("players");
this.playerList.tick();
- if (SharedConstants.IS_RUNNING_IN_IDE && this.tickRateManager.runsNormally()) {
+ if (net.neoforged.neoforge.gametest.GameTestHooks.isGametestEnabled()) {
+ if (net.neoforged.neoforge.gametest.GameTestHooks.isGametestEnabled() && this.tickRateManager.runsNormally()) {
GameTestTicker.SINGLETON.tick();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/dedicated/ServerWatchdog.java
+++ b/net/minecraft/server/dedicated/ServerWatchdog.java
@@ -48,7 +_,7 @@
@@ -48,14 +_,14 @@
ThreadMXBean threadmxbean = ManagementFactory.getThreadMXBean();
ThreadInfo[] athreadinfo = threadmxbean.dumpAllThreads(true, true);
StringBuilder stringbuilder = new StringBuilder();
Expand All @@ -9,3 +9,11 @@

for(ThreadInfo threadinfo : athreadinfo) {
if (threadinfo.getThreadId() == this.server.getRunningThread().getId()) {
error.setStackTrace(threadinfo.getStackTrace());
}

- stringbuilder.append(threadinfo);
+ stringbuilder.append(net.neoforged.neoforge.logging.ThreadInfoUtil.getEntireStacktrace(threadinfo));
stringbuilder.append("\n");
}

14 changes: 14 additions & 0 deletions patches/net/minecraft/world/damagesource/CombatTracker.java.patch
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 patches/net/minecraft/world/damagesource/DamageEffects.java.patch
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 patches/net/minecraft/world/damagesource/DamageScaling.java.patch
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 patches/net/minecraft/world/damagesource/DamageSource.java.patch
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;
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 patches/net/minecraft/world/effect/PoisonMobEffect.java.patch
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);
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
--- a/net/minecraft/world/entity/ai/goal/RangedCrossbowAttackGoal.java
+++ b/net/minecraft/world/entity/ai/goal/RangedCrossbowAttackGoal.java
@@ -12,7 +_,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;

-public class RangedCrossbowAttackGoal<T extends Monster & RangedAttackMob & CrossbowAttackMob> extends Goal {
+public class RangedCrossbowAttackGoal<T extends net.minecraft.world.entity.Mob & CrossbowAttackMob> extends Goal {
public static final UniformInt PATHFINDING_DELAY_RANGE = TimeUtil.rangeOfSeconds(1, 2);
private final T mob;
private RangedCrossbowAttackGoal.CrossbowState crossbowState = RangedCrossbowAttackGoal.CrossbowState.UNCHARGED;
@@ -22,6 +_,10 @@
private int attackDelay;
private int updatePathDelay;

+ public <M extends Monster & CrossbowAttackMob> RangedCrossbowAttackGoal(M p_25814_, double p_25815_, float p_25816_) {
+ this((T) p_25814_, p_25815_, p_25816_);
+ }
+
public RangedCrossbowAttackGoal(T p_25814_, double p_25815_, float p_25816_) {
this.mob = p_25814_;
this.speedModifier = p_25815_;
@@ -35,7 +_,7 @@
}

Expand Down
Loading

0 comments on commit 1cb44b8

Please sign in to comment.