-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '1.21.x' into CreativeTabSort
- Loading branch information
Showing
45 changed files
with
815 additions
and
55 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
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,34 +1,82 @@ | ||
--- a/net/minecraft/locale/Language.java | ||
+++ b/net/minecraft/locale/Language.java | ||
@@ -37,7 +_,8 @@ | ||
@@ -36,8 +_,10 @@ | ||
private static Language loadDefault() { | ||
Builder<String, String> builder = ImmutableMap.builder(); | ||
BiConsumer<String, String> biconsumer = builder::put; | ||
parseTranslations(biconsumer, "/assets/minecraft/lang/en_us.json"); | ||
- parseTranslations(biconsumer, "/assets/minecraft/lang/en_us.json"); | ||
- final Map<String, String> map = builder.build(); | ||
+ Map<String, net.minecraft.network.chat.Component> componentMap = new java.util.HashMap<>(); | ||
+ parseTranslations(biconsumer, componentMap::put, "/assets/minecraft/lang/en_us.json"); | ||
+ final Map<String, String> map = new java.util.HashMap<>(builder.build()); | ||
+ net.neoforged.neoforge.server.LanguageHook.captureLanguageMap(map); | ||
+ net.neoforged.neoforge.server.LanguageHook.captureLanguageMap(map, componentMap); | ||
return new Language() { | ||
@Override | ||
public String getOrDefault(String p_128127_, String p_265421_) { | ||
@@ -64,6 +_,11 @@ | ||
@@ -64,21 +_,51 @@ | ||
) | ||
.isPresent(); | ||
} | ||
+ | ||
+ @Override | ||
+ public Map<String, String> getLanguageData() { | ||
+ return map; | ||
+ } | ||
+ | ||
+ @Override | ||
+ public @org.jetbrains.annotations.Nullable net.minecraft.network.chat.Component getComponent(String key) { | ||
+ return componentMap.get(key); | ||
+ } | ||
}; | ||
} | ||
|
||
@@ -91,6 +_,9 @@ | ||
+ @Deprecated | ||
private static void parseTranslations(BiConsumer<String, String> p_282031_, String p_283638_) { | ||
+ parseTranslations(p_282031_, (key, value) -> {}, p_283638_); | ||
+ } | ||
+ | ||
+ private static void parseTranslations(BiConsumer<String, String> p_282031_, BiConsumer<String, net.minecraft.network.chat.Component> componentConsumer, String p_283638_) { | ||
try (InputStream inputstream = Language.class.getResourceAsStream(p_283638_)) { | ||
- loadFromJson(inputstream, p_282031_); | ||
+ loadFromJson(inputstream, p_282031_, componentConsumer); | ||
} catch (JsonParseException | IOException ioexception) { | ||
LOGGER.error("Couldn't read strings from {}", p_283638_, ioexception); | ||
} | ||
} | ||
|
||
public static void loadFromJson(InputStream p_128109_, BiConsumer<String, String> p_128110_) { | ||
+ loadFromJson(p_128109_, p_128110_, (key, value) -> {}); | ||
+ } | ||
+ | ||
+ public static void loadFromJson(InputStream p_128109_, BiConsumer<String, String> p_128110_, BiConsumer<String, net.minecraft.network.chat.Component> componentConsumer) { | ||
JsonObject jsonobject = GSON.fromJson(new InputStreamReader(p_128109_, StandardCharsets.UTF_8), JsonObject.class); | ||
|
||
for (Entry<String, JsonElement> entry : jsonobject.entrySet()) { | ||
+ if (entry.getValue().isJsonArray()) { | ||
+ var component = net.minecraft.network.chat.ComponentSerialization.CODEC | ||
+ .parse(com.mojang.serialization.JsonOps.INSTANCE, entry.getValue()) | ||
+ .getOrThrow(msg -> new com.google.gson.JsonParseException("Error parsing translation for " + entry.getKey() + ": " + msg)); | ||
+ | ||
+ p_128110_.accept(entry.getKey(), component.getString()); | ||
+ componentConsumer.accept(entry.getKey(), component); | ||
+ | ||
+ continue; | ||
+ } | ||
+ | ||
String s = UNSUPPORTED_FORMAT_PATTERN.matcher(GsonHelper.convertToString(entry.getValue(), entry.getKey())).replaceAll("%$1s"); | ||
p_128110_.accept(entry.getKey(), s); | ||
} | ||
@@ -90,6 +_,13 @@ | ||
|
||
public static void inject(Language p_128115_) { | ||
instance = p_128115_; | ||
} | ||
+ } | ||
+ | ||
+ // FORGE START | ||
+ public Map<String, String> getLanguageData() { return ImmutableMap.of(); } | ||
+ | ||
+ public @org.jetbrains.annotations.Nullable net.minecraft.network.chat.Component getComponent(String key) { | ||
+ return null; | ||
} | ||
|
||
public String getOrDefault(String p_128111_) { | ||
return this.getOrDefault(p_128111_, p_128111_); |
11 changes: 11 additions & 0 deletions
11
patches/net/minecraft/network/chat/ComponentSerialization.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,11 @@ | ||
--- a/net/minecraft/network/chat/ComponentSerialization.java | ||
+++ b/net/minecraft/network/chat/ComponentSerialization.java | ||
@@ -104,7 +_,7 @@ | ||
|
||
private static Codec<Component> createCodec(Codec<Component> p_304554_) { | ||
ComponentContents.Type<?>[] type = new ComponentContents.Type[]{ | ||
- PlainTextContents.TYPE, TranslatableContents.TYPE, KeybindContents.TYPE, ScoreContents.TYPE, SelectorContents.TYPE, NbtContents.TYPE | ||
+ PlainTextContents.TYPE, TranslatableContents.TYPE, KeybindContents.TYPE, ScoreContents.TYPE, SelectorContents.TYPE, NbtContents.TYPE, net.neoforged.neoforge.common.util.InsertingContents.TYPE | ||
}; | ||
MapCodec<ComponentContents> mapcodec = createLegacyComponentMatcher(type, ComponentContents.Type::codec, ComponentContents::type, "type"); | ||
Codec<Component> codec = RecordCodecBuilder.create( |
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 |
---|---|---|
@@ -1,13 +1,11 @@ | ||
--- a/net/minecraft/world/level/LevelReader.java | ||
+++ b/net/minecraft/world/level/LevelReader.java | ||
@@ -183,6 +_,10 @@ | ||
return this.hasChunkAt(p_46806_.getX(), p_46806_.getZ()); | ||
} | ||
@@ -22,7 +_,7 @@ | ||
import net.minecraft.world.level.levelgen.Heightmap; | ||
import net.minecraft.world.phys.AABB; | ||
|
||
-public interface LevelReader extends BlockAndTintGetter, CollisionGetter, SignalGetter, BiomeManager.NoiseBiomeSource { | ||
+public interface LevelReader extends BlockAndTintGetter, CollisionGetter, SignalGetter, BiomeManager.NoiseBiomeSource, net.neoforged.neoforge.common.extensions.ILevelReaderExtension { | ||
@Nullable | ||
ChunkAccess getChunk(int p_46823_, int p_46824_, ChunkStatus p_330944_, boolean p_46826_); | ||
|
||
+ default boolean isAreaLoaded(BlockPos center, int range) { | ||
+ return this.hasChunksAt(center.offset(-range, -range, -range), center.offset(range, range, range)); | ||
+ } | ||
+ | ||
@Deprecated | ||
default boolean hasChunksAt(BlockPos p_46833_, BlockPos p_46834_) { | ||
return this.hasChunksAt(p_46833_.getX(), p_46833_.getY(), p_46833_.getZ(), p_46834_.getX(), p_46834_.getY(), p_46834_.getZ()); |
11 changes: 11 additions & 0 deletions
11
patches/net/minecraft/world/level/block/AttachedStemBlock.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,11 @@ | ||
--- a/net/minecraft/world/level/block/AttachedStemBlock.java | ||
+++ b/net/minecraft/world/level/block/AttachedStemBlock.java | ||
@@ -84,7 +_,7 @@ | ||
|
||
@Override | ||
protected boolean mayPlaceOn(BlockState p_48863_, BlockGetter p_48864_, BlockPos p_48865_) { | ||
- return p_48863_.is(Blocks.FARMLAND); | ||
+ return p_48863_.getBlock() instanceof net.minecraft.world.level.block.FarmBlock; | ||
} | ||
|
||
@Override |
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.