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
376 changed files
with
5,537 additions
and
1,362 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
tasks.named('licenseFormat').get().mustRunAfter generatePackageInfos | ||
tasks.named('spotlessApply').get().mustRunAfter generatePackageInfos | ||
tasks.named('spotlessApply').get().mustRunAfter tasks.named('licenseFormat').get() | ||
|
||
tasks.register('applyAllFormatting', Task) { | ||
dependsOn generatePackageInfos | ||
dependsOn tasks.named('licenseFormat').get() | ||
dependsOn tasks.named('spotlessApply').get() | ||
} |
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,27 @@ | ||
import java.util.regex.Matcher | ||
|
||
def generatePackageInfos = tasks.register('generatePackageInfos', Task) { | ||
doLast { | ||
fileTree('src/main/java').each { javaFile -> | ||
def packageInfoFile = new File(javaFile.parent, 'package-info.java') | ||
if (!packageInfoFile.exists()) { | ||
def pkgName = javaFile.toString().replaceAll(Matcher.quoteReplacement(File.separator), '/') | ||
pkgName = pkgName.substring(pkgName.indexOf('net/neoforged/'), pkgName.lastIndexOf('/')) | ||
pkgName = pkgName.replaceAll('/', '.') | ||
|
||
def pkgInfoText = """ | ||
|@FieldsAreNonnullByDefault | ||
|@MethodsReturnNonnullByDefault | ||
|@ParametersAreNonnullByDefault | ||
|package $pkgName; | ||
| | ||
|import javax.annotation.ParametersAreNonnullByDefault; | ||
|import net.minecraft.FieldsAreNonnullByDefault; | ||
|import net.minecraft.MethodsReturnNonnullByDefault; | ||
""".stripMargin().trim() | ||
|
||
packageInfoFile.text = pkgInfoText | ||
} | ||
} | ||
} | ||
} |
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,25 @@ | ||
spotless { | ||
java { | ||
endWithNewline() | ||
indentWithSpaces() | ||
removeUnusedImports() | ||
toggleOffOn() | ||
eclipse().configFile rootProject.file('codeformat/formatter-config.xml') | ||
importOrder() | ||
|
||
// courtesy of diffplug/spotless#240 | ||
// https://github.com/diffplug/spotless/issues/240#issuecomment-385206606 | ||
custom 'noWildcardImports', { String fileContents -> | ||
if (fileContents.contains('*;\n')) { | ||
throw new GradleException('No wildcard imports are allowed!') | ||
} | ||
} | ||
|
||
custom 'noNotNull', { String fileContents -> | ||
if (fileContents.contains('@NotNull') || fileContents.contains('@Nonnull')) { | ||
throw new GradleException('@NotNull and @Nonnull are disallowed.') | ||
} | ||
} | ||
bumpThisNumberIfACustomStepChanges(2) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- a/net/minecraft/core/Holder.java | ||
+++ b/net/minecraft/core/Holder.java | ||
@@ -11,7 +_,7 @@ | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.tags.TagKey; | ||
|
||
-public interface Holder<T> { | ||
+public interface Holder<T> extends net.neoforged.neoforge.registries.datamaps.IWithData<T> { | ||
T value(); | ||
|
||
boolean isBound(); | ||
@@ -201,6 +_,14 @@ | ||
} else { | ||
this.value = p_249418_; | ||
} | ||
+ } | ||
+ | ||
+ @org.jetbrains.annotations.Nullable | ||
+ public <A> A getData(net.neoforged.neoforge.registries.datamaps.DataMapType<T, A> type) { | ||
+ if (owner instanceof HolderLookup.RegistryLookup<T> lookup) { | ||
+ return lookup.getData(type, key()); | ||
+ } | ||
+ return null; | ||
} | ||
|
||
public void bindTags(Collection<TagKey<T>> p_205770_) { |
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,27 @@ | ||
--- a/net/minecraft/core/HolderLookup.java | ||
+++ b/net/minecraft/core/HolderLookup.java | ||
@@ -117,6 +_,11 @@ | ||
: this); | ||
} | ||
|
||
+ @org.jetbrains.annotations.Nullable | ||
+ default <A> A getData(net.neoforged.neoforge.registries.datamaps.DataMapType<T, A> attachment, ResourceKey<T> key) { | ||
+ return null; | ||
+ } | ||
+ | ||
public abstract static class Delegate<T> implements HolderLookup.RegistryLookup<T> { | ||
protected abstract HolderLookup.RegistryLookup<T> parent(); | ||
|
||
@@ -148,6 +_,12 @@ | ||
@Override | ||
public Stream<HolderSet.Named<T>> listTags() { | ||
return this.parent().listTags(); | ||
+ } | ||
+ | ||
+ @Override | ||
+ @org.jetbrains.annotations.Nullable | ||
+ public <A> A getData(net.neoforged.neoforge.registries.datamaps.DataMapType<T, A> attachment, ResourceKey<T> key) { | ||
+ return parent().getData(attachment, key); | ||
} | ||
} | ||
} |
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
13 changes: 0 additions & 13 deletions
13
patches/net/minecraft/data/recipes/packs/BundleRecipeProvider.java.patch
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
patches/net/minecraft/data/recipes/packs/UpdateOneTwentyOneRecipeProvider.java.patch
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
patches/net/minecraft/data/recipes/packs/VanillaRecipeProvider.java.patch
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
patches/net/minecraft/server/level/ServerPlayer.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
8 changes: 6 additions & 2 deletions
8
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 |
---|---|---|
@@ -1,12 +1,16 @@ | ||
--- a/net/minecraft/world/effect/PoisonMobEffect.java | ||
+++ b/net/minecraft/world/effect/PoisonMobEffect.java | ||
@@ -11,7 +_,8 @@ | ||
@@ -11,7 +_,12 @@ | ||
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); | ||
+ // Fallback to minecraft:magic in client code when connecting to a vanilla server. | ||
+ // LivingEntity#hurt(DamageSource) will no-op in client code immediately, but the holder is resolved before the no-op. | ||
+ var dTypeReg = p_296276_.damageSources().damageTypes; | ||
+ var dType = dTypeReg.getHolder(net.neoforged.neoforge.common.NeoForgeMod.POISON_DAMAGE).orElse(dTypeReg.getHolderOrThrow(net.minecraft.world.damagesource.DamageTypes.MAGIC)); | ||
+ p_296276_.hurt(new net.minecraft.world.damagesource.DamageSource(dType), 1.0F); | ||
} | ||
} | ||
|
Oops, something went wrong.