diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts index 0bb215e441..4c59a543d0 100644 --- a/.teamcity/settings.kts +++ b/.teamcity/settings.kts @@ -37,7 +37,7 @@ project { params { text("docker_jdk_version", "17", label = "Gradle version", description = "The version of the JDK to use during execution of tasks in a JDK.", display = ParameterDisplay.HIDDEN, allowEmpty = false) - text("docker_gradle_version", "7.4", label = "Gradle version", description = "The version of Gradle to use during execution of Gradle tasks.", display = ParameterDisplay.HIDDEN, allowEmpty = false) + text("docker_gradle_version", "7.5.1", label = "Gradle version", description = "The version of Gradle to use during execution of Gradle tasks.", display = ParameterDisplay.HIDDEN, allowEmpty = false) text("git_main_branch", "1.19.x", label = "Git Main Branch", description = "The git main or default branch to use in VCS operations.", display = ParameterDisplay.HIDDEN, allowEmpty = false) text("git_branch_spec", """ +:refs/heads/(main*) @@ -155,7 +155,7 @@ object PullRequestChecks : BuildType({ enableStacktrace = true dockerImage = "%docker_gradle_image%" dockerRunParameters = """ - -v "/opt/cache/agent/gradle:/home/gradle/.gradle" + -v "/opt/cache/agent/gradle:/home/gradle/.gradle" -v "/opt/cache/shared/gradle:/home/gradle/rocache:ro" --network=host -u 1000:1000 @@ -189,7 +189,7 @@ object PullRequestCompatibility : BuildType({ enableStacktrace = true dockerImage = "%docker_gradle_image%" dockerRunParameters = """ - -v "/opt/cache/agent/gradle:/home/gradle/.gradle" + -v "/opt/cache/agent/gradle:/home/gradle/.gradle" -v "/opt/cache/shared/gradle:/home/gradle/rocache:ro" --network=host -u 1000:1000 diff --git a/build.gradle b/build.gradle index 1546061424..5b1d4350a3 100644 --- a/build.gradle +++ b/build.gradle @@ -36,10 +36,10 @@ ext { ] } MAPPING_CHANNEL = 'official' - MAPPING_VERSION = '1.19.2' - MC_VERSION = '1.19.2' + MAPPING_VERSION = '1.19.3' + MC_VERSION = '1.19.3' MC_NEXT_VERSION = '1.20' - MCP_VERSION = '20220805.130853' + MCP_VERSION = '20221207.122022' SPI_VERSION = '6.0.0' ACCESSTRANSFORMERS_VERSION = '8.0.4' COREMODS_VERSION = '5.0.1' @@ -56,17 +56,17 @@ ext { JETBRAINS_ANNOTATIONS_VERSION = '23.0.0' SLF4J_API_VERSION = '1.8.0-beta4' APACHE_MAVEN_ARTIFACT_VERSION = '3.8.5' + JARJAR_VERSION = '0.3.18' // These versions should be kept in sync with the version manifest JSON // To use a version newer than the version manifest JSON, the dependency must be added to the installer configuration - MOJANG_LOGGING_VERSION = '1.0.0' - LOG4J_VERSION = '2.17.0' - GUAVA_VERSION = '31.0.1-jre' - GSON_VERSION = '2.8.9' + MOJANG_LOGGING_VERSION = '1.1.1' + LOG4J_VERSION = '2.19.0' + GUAVA_VERSION = '31.1-jre' + GSON_VERSION = '2.10' APACHE_COMMONS_LANG3_VERSION = '3.12.0' JOPT_SIMPLE_VERSION = '5.0.4' COMMONS_IO_VERSION = '2.11.0' - JARJAR_VERSION = '0.3.16' GIT_INFO = gradleutils.gitInfo VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, '[0-9]', MC_VERSION) diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/ModLoader.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoader.java index 05cbe0c34d..e9f519a2c2 100644 --- a/fmlcore/src/main/java/net/minecraftforge/fml/ModLoader.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoader.java @@ -22,13 +22,7 @@ import net.minecraftforge.forgespi.locating.IModFile; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; import java.util.concurrent.Executor; @@ -256,10 +250,22 @@ public class ModLoader .filter(Objects::nonNull) .collect(Collectors.toList()); if (containers.size() != modInfoMap.size()) { + var modIds = modInfoMap.values().stream().map(IModInfo::getModId).sorted().collect(Collectors.toList()); + var containerIds = containers.stream().map(c -> c != null ? c.getModId() : "(null)").sorted().collect(Collectors.toList()); + LOGGER.fatal(LOADING,"File {} constructed {} mods: {}, but had {} mods specified: {}", modFile.getFilePath(), - containers.size(), containers.stream().map(c -> c != null ? c.getModId() : "(null)").sorted().collect(Collectors.toList()), - modInfoMap.size(), modInfoMap.values().stream().map(IModInfo::getModId).sorted().collect(Collectors.toList())); + containers.size(), containerIds, + modInfoMap.size(), modIds); + + var missingClasses = new ArrayList<>(modIds); + missingClasses.removeAll(containerIds); + LOGGER.fatal(LOADING, "The following classes are missing, but are reported in the mods.toml: {}", missingClasses); + + var missingMods = new ArrayList<>(containerIds); + missingMods.removeAll(modIds); + LOGGER.fatal(LOADING, "The following mods are missing, but have classes in the jar: {}", missingMods); + loadingExceptions.add(new ModLoadingException(null, ModLoadingStage.CONSTRUCT, "fml.modloading.missingclasses", null, modFile.getFilePath())); } // remove errored mod containers @@ -305,6 +311,14 @@ public class ModLoader } ModList.get().forEachModInOrder(mc -> mc.acceptEvent(e)); } + public T postEventWithReturn(T e) { + if (!loadingStateValid) { + LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName()); + return e; + } + ModList.get().forEachModInOrder(mc -> mc.acceptEvent(e)); + return e; + } public void postEventWithWrapInModOrder(T e, BiConsumer pre, BiConsumer post) { if (!loadingStateValid) { LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName()); diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/toposort/CyclePresentException.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/toposort/CyclePresentException.java index a94a9bc497..e3167e3f5f 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/toposort/CyclePresentException.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/toposort/CyclePresentException.java @@ -19,6 +19,7 @@ public final class CyclePresentException extends IllegalArgumentException { * @param cycles the cycles present */ CyclePresentException(Set> cycles) { + super("Cycles present in graph: " + cycles); this.cycles = cycles; } diff --git a/mdk/build.gradle b/mdk/build.gradle index 1c1b219f1d..2f1f2bdf36 100644 --- a/mdk/build.gradle +++ b/mdk/build.gradle @@ -132,8 +132,6 @@ dependencies { minecraft '@FORGE_GROUP@:@FORGE_NAME@:@FORGE_VERSION@' // Real mod deobf dependency examples - these get remapped to your current mappings - // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency - // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency // Examples using mod jars from ./libs diff --git a/mdk/src/main/java/com/example/examplemod/ExampleMod.java b/mdk/src/main/java/com/example/examplemod/ExampleMod.java index 803db879eb..e4013ff48b 100644 --- a/mdk/src/main/java/com/example/examplemod/ExampleMod.java +++ b/mdk/src/main/java/com/example/examplemod/ExampleMod.java @@ -3,7 +3,7 @@ package com.example.examplemod; import com.mojang.logging.LogUtils; import net.minecraft.client.Minecraft; import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; @@ -11,15 +11,13 @@ import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.material.Material; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.CreativeModeTabEvent; +import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.InterModComms; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; -import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; -import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -42,7 +40,7 @@ public class ExampleMod // Creates a new Block with the id "examplemod:example_block", combining the namespace and path public static final RegistryObject EXAMPLE_BLOCK = BLOCKS.register("example_block", () -> new Block(BlockBehaviour.Properties.of(Material.STONE))); // Creates a new BlockItem with the id "examplemod:example_block", combining the namespace and path - public static final RegistryObject EXAMPLE_BLOCK_ITEM = ITEMS.register("example_block", () -> new BlockItem(EXAMPLE_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_BUILDING_BLOCKS))); + public static final RegistryObject EXAMPLE_BLOCK_ITEM = ITEMS.register("example_block", () -> new BlockItem(EXAMPLE_BLOCK.get(), new Item.Properties())); public ExampleMod() { @@ -58,6 +56,10 @@ public class ExampleMod // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); + + // Register the item to a creative tab + modEventBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS, + EXAMPLE_BLOCK_ITEM.get())); } private void commonSetup(final FMLCommonSetupEvent event) diff --git a/mdk/src/main/resources/pack.mcmeta b/mdk/src/main/resources/pack.mcmeta index b643e13f88..aa7bb5db9f 100644 --- a/mdk/src/main/resources/pack.mcmeta +++ b/mdk/src/main/resources/pack.mcmeta @@ -1,8 +1,8 @@ { "pack": { "description": "examplemod resources", - "pack_format": 9, - "forge:resource_pack_format": 9, + "pack_format": 12, + "forge:resource_pack_format": 12, "forge:data_pack_format": 10 } } diff --git a/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch b/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch index 778dda74e2..3ffab13337 100644 --- a/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/platform/GlStateManager.java +++ b/com/mojang/blaze3d/platform/GlStateManager.java -@@ -539,9 +_,16 @@ +@@ -510,9 +_,16 @@ f_84077_[f_84076_].f_84800_ = false; } diff --git a/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch b/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch index e3f1563820..240d6002a8 100644 --- a/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch @@ -9,7 +9,7 @@ if (monitor != null) { VideoMode videomode = monitor.m_84948_(this.f_85355_ ? this.f_85354_ : Optional.empty()); this.f_85350_ = this.f_85357_ = monitor.m_84951_() + videomode.m_85332_() / 2 - this.f_85359_ / 2; -@@ -303,6 +_,7 @@ +@@ -263,6 +_,7 @@ GLFW.glfwGetFramebufferSize(this.f_85349_, aint, aint1); this.f_85361_ = aint[0] > 0 ? aint[0] : 1; this.f_85362_ = aint1[0] > 0 ? aint1[0] : 1; diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/BufferBuilder.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/BufferBuilder.java.patch index 8bb62af698..4beead2555 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/BufferBuilder.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/BufferBuilder.java.patch @@ -1,7 +1,7 @@ --- a/com/mojang/blaze3d/vertex/BufferBuilder.java +++ b/com/mojang/blaze3d/vertex/BufferBuilder.java @@ -486,4 +_,14 @@ - this.f_166822_ = p_166829_; + this.f_166822_ = p_254368_; } } + diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/PoseStack.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/PoseStack.java.patch index 6964bb8eeb..5f6265ad6f 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/PoseStack.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/PoseStack.java.patch @@ -1,11 +1,11 @@ --- a/com/mojang/blaze3d/vertex/PoseStack.java +++ b/com/mojang/blaze3d/vertex/PoseStack.java @@ -11,7 +_,7 @@ - import net.minecraftforge.api.distmarker.OnlyIn; + import org.joml.Quaternionf; @OnlyIn(Dist.CLIENT) -public class PoseStack { +public class PoseStack implements net.minecraftforge.client.extensions.IForgePoseStack { private final Deque f_85834_ = Util.m_137469_(Queues.newArrayDeque(), (p_85848_) -> { Matrix4f matrix4f = new Matrix4f(); - matrix4f.m_27624_(); + Matrix3f matrix3f = new Matrix3f(); diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch index 40ad7dee0e..87c6ad23f7 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch @@ -20,7 +20,7 @@ float[] afloat = new float[]{p_85998_[0], p_85998_[1], p_85998_[2], p_85998_[3]}; int[] aint = new int[]{p_86002_[0], p_86002_[1], p_86002_[2], p_86002_[3]}; int[] aint1 = p_85997_.m_111303_(); -@@ -101,12 +_,14 @@ +@@ -99,11 +_,13 @@ f5 = afloat[k] * p_86001_; } @@ -28,12 +28,11 @@ + int l = applyBakedLighting(p_86002_[k], bytebuffer); float f9 = bytebuffer.getFloat(16); float f10 = bytebuffer.getFloat(20); - Vector4f vector4f = new Vector4f(f, f1, f2, 1.0F); - vector4f.m_123607_(matrix4f); -- this.m_5954_(vector4f.m_123601_(), vector4f.m_123615_(), vector4f.m_123616_(), f3, f4, f5, 1.0F, f9, f10, p_86003_, l, vector3f.m_122239_(), vector3f.m_122260_(), vector3f.m_122269_()); -+ applyBakedNormals(vector3f, bytebuffer, p_85996_.m_85864_()); + Vector4f vector4f = matrix4f.transform(new Vector4f(f, f1, f2, 1.0F)); +- this.m_5954_(vector4f.x(), vector4f.y(), vector4f.z(), f3, f4, f5, 1.0F, f9, f10, p_86003_, l, vector3f.x(), vector3f.y(), vector3f.z()); ++ applyBakedNormals(vector3f, bytebuffer, p_85996_.m_252943_()); + float vertexAlpha = p_86004_ ? alpha * (float) (bytebuffer.get(15) & 255) / 255.0F : alpha; -+ this.m_5954_(vector4f.m_123601_(), vector4f.m_123615_(), vector4f.m_123616_(), f3, f4, f5, vertexAlpha, f9, f10, p_86003_, l, vector3f.m_122239_(), vector3f.m_122260_(), vector3f.m_122269_()); ++ this.m_5954_(vector4f.x(), vector4f.y(), vector4f.z(), f3, f4, f5, vertexAlpha, f9, f10, p_86003_, l, vector3f.x(), vector3f.y(), vector3f.z()); } - } catch (Throwable throwable1) { - if (memorystack != null) { + } + diff --git a/patches/minecraft/com/mojang/math/Matrix3f.java.patch b/patches/minecraft/com/mojang/math/Matrix3f.java.patch deleted file mode 100644 index cff8694e6e..0000000000 --- a/patches/minecraft/com/mojang/math/Matrix3f.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/com/mojang/math/Matrix3f.java -+++ b/com/mojang/math/Matrix3f.java -@@ -588,4 +_,10 @@ - public Matrix3f m_8183_() { - return new Matrix3f(this); - } -+ -+ public void multiplyBackward(Matrix3f other) { -+ Matrix3f copy = other.m_8183_(); -+ copy.m_8178_(this); -+ this.m_8169_(copy); -+ } - } diff --git a/patches/minecraft/com/mojang/math/Matrix4f.java.patch b/patches/minecraft/com/mojang/math/Matrix4f.java.patch deleted file mode 100644 index 634ccbc3a6..0000000000 --- a/patches/minecraft/com/mojang/math/Matrix4f.java.patch +++ /dev/null @@ -1,43 +0,0 @@ ---- a/com/mojang/math/Matrix4f.java -+++ b/com/mojang/math/Matrix4f.java -@@ -559,4 +_,40 @@ - matrix4f.f_27614_ = p_27656_; - return matrix4f; - } -+ -+ // Forge start -+ public Matrix4f(float[] values) { -+ f_27603_ = values[0]; -+ f_27604_ = values[1]; -+ f_27605_ = values[2]; -+ f_27606_ = values[3]; -+ f_27607_ = values[4]; -+ f_27608_ = values[5]; -+ f_27609_ = values[6]; -+ f_27610_ = values[7]; -+ f_27611_ = values[8]; -+ f_27612_ = values[9]; -+ f_27613_ = values[10]; -+ f_27614_ = values[11]; -+ f_27615_ = values[12]; -+ f_27616_ = values[13]; -+ f_27617_ = values[14]; -+ f_27618_ = values[15]; -+ } -+ -+ public void multiplyBackward(Matrix4f other) { -+ Matrix4f copy = other.m_27658_(); -+ copy.m_27644_(this); -+ this.m_162210_(copy); -+ } -+ -+ public void setTranslation(float x, float y, float z) { -+ this.f_27603_ = 1.0F; -+ this.f_27608_ = 1.0F; -+ this.f_27613_ = 1.0F; -+ this.f_27618_ = 1.0F; -+ this.f_27606_ = x; -+ this.f_27610_ = y; -+ this.f_27614_ = z; -+ } - } diff --git a/patches/minecraft/com/mojang/math/Transformation.java.patch b/patches/minecraft/com/mojang/math/Transformation.java.patch index 5188bb8569..334eda319d 100644 --- a/patches/minecraft/com/mojang/math/Transformation.java.patch +++ b/patches/minecraft/com/mojang/math/Transformation.java.patch @@ -1,15 +1,15 @@ --- a/com/mojang/math/Transformation.java +++ b/com/mojang/math/Transformation.java -@@ -6,7 +_,7 @@ - import net.minecraft.Util; - import org.apache.commons.lang3.tuple.Triple; +@@ -12,7 +_,7 @@ + import org.joml.Vector3f; + import org.joml.Vector3fc; -public final class Transformation { +public final class Transformation implements net.minecraftforge.client.extensions.IForgeTransformation { private final Matrix4f f_121078_; private boolean f_121079_; @Nullable -@@ -145,6 +_,19 @@ +@@ -139,6 +_,19 @@ public int hashCode() { return Objects.hash(this.f_121078_); } @@ -22,10 +22,10 @@ + private void checkNormalTransform() { + if (normalTransform == null) { + normalTransform = new Matrix3f(f_121078_); -+ normalTransform.m_8187_(); -+ normalTransform.m_8155_(); ++ normalTransform.invert(); ++ normalTransform.transpose(); + } + } public Transformation m_175937_(Transformation p_175938_, float p_175939_) { - Vector3f vector3f = this.m_175940_(); + Vector3f vector3f = this.m_252829_(); diff --git a/patches/minecraft/com/mojang/math/Vector3f.java.patch b/patches/minecraft/com/mojang/math/Vector3f.java.patch deleted file mode 100644 index 5fce3b3cf3..0000000000 --- a/patches/minecraft/com/mojang/math/Vector3f.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/com/mojang/math/Vector3f.java -+++ b/com/mojang/math/Vector3f.java -@@ -138,7 +_,7 @@ - - public boolean m_122278_() { - float f = this.f_122228_ * this.f_122228_ + this.f_122229_ * this.f_122229_ + this.f_122230_ * this.f_122230_; -- if ((double)f < 1.0E-5D) { -+ if (f < Float.MIN_NORMAL) { //Forge: Fix MC-239212 - return false; - } else { - float f1 = Mth.m_14195_(f); -@@ -207,4 +_,16 @@ - public String toString() { - return "[" + this.f_122228_ + ", " + this.f_122229_ + ", " + this.f_122230_ + "]"; - } -+ -+ public Vector3f(float[] values) { -+ set(values); -+ } -+ public void set(float[] values) { -+ this.f_122228_ = values[0]; -+ this.f_122229_ = values[1]; -+ this.f_122230_ = values[2]; -+ } -+ public void setX(float x) { this.f_122228_ = x; } -+ public void setY(float y) { this.f_122229_ = y; } -+ public void setZ(float z) { this.f_122230_ = z; } - } diff --git a/patches/minecraft/com/mojang/math/Vector4f.java.patch b/patches/minecraft/com/mojang/math/Vector4f.java.patch deleted file mode 100644 index 30c3e4dfc4..0000000000 --- a/patches/minecraft/com/mojang/math/Vector4f.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/com/mojang/math/Vector4f.java -+++ b/com/mojang/math/Vector4f.java -@@ -147,4 +_,15 @@ - public String toString() { - return "[" + this.f_123589_ + ", " + this.f_123590_ + ", " + this.f_123591_ + ", " + this.f_123592_ + "]"; - } -+ -+ public void set(float[] values) { -+ this.f_123589_ = values[0]; -+ this.f_123590_ = values[1]; -+ this.f_123591_ = values[2]; -+ this.f_123592_ = values[3]; -+ } -+ public void setX(float x) { this.f_123589_ = x; } -+ public void setY(float y) { this.f_123590_ = y; } -+ public void setZ(float z) { this.f_123591_ = z; } -+ public void setW(float w) { this.f_123592_ = w; } - } diff --git a/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch b/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch index bb10887590..fddf8f70ab 100644 --- a/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch +++ b/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch @@ -13,6 +13,6 @@ + return super.m_7933_(key, scanCode, modifiers); + } + - public void m_6305_(PoseStack p_88679_, int p_88680_, int p_88681_, float p_88682_) { + public void m_86412_(PoseStack p_88679_, int p_88680_, int p_88681_, float p_88682_) { this.m_7333_(p_88679_); m_93215_(p_88679_, this.f_96547_, this.f_200947_.getFirst(), this.f_96543_ / 2, 80, 16777215); diff --git a/patches/minecraft/net/minecraft/SharedConstants.java.patch b/patches/minecraft/net/minecraft/SharedConstants.java.patch index 80d721fc0b..7145ef6610 100644 --- a/patches/minecraft/net/minecraft/SharedConstants.java.patch +++ b/patches/minecraft/net/minecraft/SharedConstants.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/SharedConstants.java +++ b/net/minecraft/SharedConstants.java -@@ -211,6 +_,7 @@ +@@ -214,6 +_,7 @@ } static { diff --git a/patches/minecraft/net/minecraft/Util.java.patch b/patches/minecraft/net/minecraft/Util.java.patch index b6f4bf720c..93e6856bd0 100644 --- a/patches/minecraft/net/minecraft/Util.java.patch +++ b/patches/minecraft/net/minecraft/Util.java.patch @@ -12,7 +12,7 @@ public static ExecutorService m_183988_() { return f_137443_; } -@@ -248,7 +_,7 @@ +@@ -242,7 +_,7 @@ try { type = DataFixers.m_14512_().getSchema(DataFixUtils.makeKey(SharedConstants.m_183709_().getWorldVersion())).getChoiceType(p_137552_, p_137553_); } catch (IllegalArgumentException illegalargumentexception) { @@ -21,13 +21,3 @@ if (SharedConstants.f_136183_) { throw illegalargumentexception; } -@@ -692,7 +_,8 @@ - - public static Function m_143827_(final Function p_143828_) { - return new Function() { -- private final Map f_211548_ = Maps.newHashMap(); -+ // FORGE: Allow using memoized functions from multiple threads. -+ private final Map f_211548_ = Maps.newConcurrentMap(); - - public R apply(T p_214691_) { - return this.f_211548_.computeIfAbsent(p_214691_, p_143828_); diff --git a/patches/minecraft/net/minecraft/advancements/critereon/ItemPredicate.java.patch b/patches/minecraft/net/minecraft/advancements/critereon/ItemPredicate.java.patch index dfcae00b2f..bea6c2f864 100644 --- a/patches/minecraft/net/minecraft/advancements/critereon/ItemPredicate.java.patch +++ b/patches/minecraft/net/minecraft/advancements/critereon/ItemPredicate.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/advancements/critereon/ItemPredicate.java +++ b/net/minecraft/advancements/critereon/ItemPredicate.java -@@ -28,6 +_,8 @@ +@@ -29,6 +_,8 @@ import net.minecraft.world.level.ItemLike; public class ItemPredicate { @@ -9,7 +9,7 @@ public static final ItemPredicate f_45028_ = new ItemPredicate(); @Nullable private final TagKey f_45029_; -@@ -80,7 +_,7 @@ +@@ -81,7 +_,7 @@ return false; } else { if (this.f_45033_.length > 0) { @@ -18,7 +18,7 @@ for(EnchantmentPredicate enchantmentpredicate : this.f_45033_) { if (!enchantmentpredicate.m_30476_(map)) { -@@ -107,6 +_,11 @@ +@@ -108,6 +_,11 @@ public static ItemPredicate m_45051_(@Nullable JsonElement p_45052_) { if (p_45052_ != null && !p_45052_.isJsonNull()) { JsonObject jsonobject = GsonHelper.m_13918_(p_45052_, "item"); @@ -30,7 +30,7 @@ MinMaxBounds.Ints minmaxbounds$ints = MinMaxBounds.Ints.m_55373_(jsonobject.get("count")); MinMaxBounds.Ints minmaxbounds$ints1 = MinMaxBounds.Ints.m_55373_(jsonobject.get("durability")); if (jsonobject.has("data")) { -@@ -214,6 +_,14 @@ +@@ -215,6 +_,14 @@ } else { return new ItemPredicate[0]; } diff --git a/patches/minecraft/net/minecraft/client/Camera.java.patch b/patches/minecraft/net/minecraft/client/Camera.java.patch index 3e2fdda50f..ad990b4550 100644 --- a/patches/minecraft/net/minecraft/client/Camera.java.patch +++ b/patches/minecraft/net/minecraft/client/Camera.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Camera.java +++ b/net/minecraft/client/Camera.java -@@ -211,6 +_,18 @@ +@@ -206,6 +_,18 @@ this.f_90549_ = false; } diff --git a/patches/minecraft/net/minecraft/client/ClientRecipeBook.java.patch b/patches/minecraft/net/minecraft/client/ClientRecipeBook.java.patch index 08b7920b96..3bfe868c4e 100644 --- a/patches/minecraft/net/minecraft/client/ClientRecipeBook.java.patch +++ b/patches/minecraft/net/minecraft/client/ClientRecipeBook.java.patch @@ -9,12 +9,12 @@ if (s.isEmpty()) { map.computeIfAbsent(recipebookcategories, (p_90645_) -> { return Lists.newArrayList(); -@@ -103,6 +_,8 @@ - } else if (recipetype == RecipeType.f_44113_) { - return RecipeBookCategories.SMITHING; - } else { -+ RecipeBookCategories categories = net.minecraftforge.client.RecipeBookManager.findCategories((RecipeType) recipetype, p_90647_); -+ if (categories != null) return categories; - f_90618_.warn("Unknown recipe category: {}/{}", LogUtils.defer(() -> { - return Registry.f_122864_.m_7981_(p_90647_.m_6671_()); - }), LogUtils.defer(p_90647_::m_6423_)); +@@ -138,6 +_,8 @@ + } else if (recipetype == RecipeType.f_44113_) { + return RecipeBookCategories.SMITHING; + } else { ++ RecipeBookCategories categories = net.minecraftforge.client.RecipeBookManager.findCategories((RecipeType) recipetype, p_90647_); ++ if (categories != null) return categories; + f_90618_.warn("Unknown recipe category: {}/{}", LogUtils.defer(() -> { + return BuiltInRegistries.f_256990_.m_7981_(p_90647_.m_6671_()); + }), LogUtils.defer(p_90647_::m_6423_)); diff --git a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch index 8e7870365a..1abb83aa27 100644 --- a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch +++ b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/KeyboardHandler.java +++ b/net/minecraft/client/KeyboardHandler.java -@@ -299,7 +_,9 @@ +@@ -298,7 +_,9 @@ } Screen screen = this.f_90867_.f_91080_; @@ -11,7 +11,7 @@ if (this.f_90867_.f_91066_.f_92105_.m_90832_(p_90895_, p_90896_)) { this.f_90867_.m_91268_().m_85438_(); this.f_90867_.f_91066_.m_231829_().m_231514_(this.f_90867_.m_91268_().m_85440_()); -@@ -317,6 +_,8 @@ +@@ -316,6 +_,8 @@ }); return; } @@ -20,9 +20,9 @@ } if (this.f_90867_.m_240477_().m_93316_()) { -@@ -339,11 +_,15 @@ +@@ -338,11 +_,15 @@ Screen.m_96579_(() -> { - if (p_90897_ != 1 && (p_90897_ != 2 || !this.f_90868_)) { + if (p_90897_ != 1 && p_90897_ != 2) { if (p_90897_ == 0) { - aboolean[0] = screen.m_7920_(p_90895_, p_90896_, p_90898_); + aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleasedPre(screen, p_90895_, p_90896_, p_90898_); @@ -38,7 +38,7 @@ } }, "keyPressed event handler", screen.getClass().getCanonicalName()); -@@ -396,22 +_,26 @@ +@@ -395,22 +_,26 @@ } } } diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 32e874c34a..ff6ea3fe0e 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Minecraft.java +++ b/net/minecraft/client/Minecraft.java -@@ -244,7 +_,7 @@ +@@ -245,7 +_,7 @@ import org.slf4j.Logger; @OnlyIn(Dist.CLIENT) @@ -9,16 +9,7 @@ static Minecraft f_90981_; private static final Logger f_90982_ = LogUtils.getLogger(); public static final boolean f_91002_ = Util.m_137581_() == Util.OS.OSX; -@@ -398,7 +_,7 @@ - this.f_91029_ = p_91084_.f_101908_.f_101928_; - this.f_90986_ = p_91084_.f_101905_.f_101944_; - this.f_91037_ = new ClientPackSource(new File(this.f_91069_, "server-resource-packs"), p_91084_.f_101907_.m_101925_()); -- this.f_91038_ = new PackRepository(Minecraft::m_167933_, this.f_91037_, new FolderRepositorySource(this.f_90985_, PackSource.f_10527_)); -+ this.f_91038_ = new PackRepository(Minecraft::createClientPackAdapter, this.f_91037_, new FolderRepositorySource(this.f_90985_, PackSource.f_10527_)); - this.f_91030_ = p_91084_.f_101905_.f_101945_; - this.f_231338_ = new YggdrasilAuthenticationService(this.f_91030_); - this.f_91048_ = this.f_231338_.createMinecraftSessionService(); -@@ -406,7 +_,6 @@ +@@ -410,7 +_,6 @@ this.f_231339_ = SignatureValidator.m_216358_(this.f_231338_.getServicesKey()); this.f_90998_ = p_91084_.f_101905_.f_101942_; f_90982_.info("Setting user: {}", (Object)this.f_90998_.m_92546_()); @@ -26,7 +17,7 @@ this.f_91033_ = p_91084_.f_101908_.f_101926_; this.f_91034_ = !p_91084_.f_101908_.f_101929_; this.f_91035_ = !p_91084_.f_101908_.f_101930_; -@@ -458,7 +_,7 @@ +@@ -459,7 +_,7 @@ this.f_90990_.m_85380_(this.f_91066_.m_232035_().m_231551_()); this.f_91067_ = new MouseHandler(this); @@ -35,28 +26,30 @@ this.f_91068_ = new KeyboardHandler(this); this.f_91068_.m_90887_(this.f_90990_.m_85439_()); RenderSystem.m_69580_(this.f_91066_.f_92035_, false); -@@ -466,6 +_,7 @@ +@@ -467,6 +_,7 @@ this.f_91042_.m_83931_(0.0F, 0.0F, 0.0F, 0.0F); this.f_91042_.m_83954_(f_91002_); this.f_91036_ = new ReloadableResourceManager(PackType.CLIENT_RESOURCES); -+ net.minecraftforge.client.loading.ClientModLoader.begin(this, this.f_91038_, this.f_91036_, this.f_91037_); ++ net.minecraftforge.client.loading.ClientModLoader.begin(this, this.f_91038_, this.f_91036_); this.f_91038_.m_10506_(); this.f_91066_.m_92145_(this.f_91038_); this.f_91039_ = new LanguageManager(this.f_91066_.f_92075_); -@@ -510,10 +_,12 @@ +@@ -511,10 +_,13 @@ this.f_91063_ = new GameRenderer(this, this.f_90994_.m_234586_(), this.f_91036_, this.f_90993_); - this.f_91036_.m_7217_(this.f_91063_); + this.f_91036_.m_7217_(this.f_91063_.m_247116_()); this.f_91060_ = new LevelRenderer(this, this.f_90994_, this.f_167845_, this.f_90993_); + net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.RenderLevelStageEvent.RegisterStageEvent()); this.f_91036_.m_7217_(this.f_91060_); - this.m_91271_(); +- this.m_91271_(); ++ // Forge: We delay this to allow registration of modded creative mode tabs ++ // this.createSearchTrees(); this.f_91036_.m_7217_(this.f_90997_); this.f_91061_ = new ParticleEngine(this.f_91073_, this.f_90987_); + net.minecraftforge.client.ForgeHooksClient.onRegisterParticleProviders(f_91061_); this.f_91036_.m_7217_(this.f_91061_); this.f_91053_ = new PaintingTextureManager(this.f_90987_); this.f_91036_.m_7217_(this.f_91053_); -@@ -522,7 +_,9 @@ +@@ -523,7 +_,9 @@ this.f_91047_ = new GpuWarnlistManager(); this.f_91036_.m_7217_(this.f_91047_); this.f_91036_.m_7217_(this.f_205120_); @@ -67,7 +60,7 @@ this.f_91064_ = new DebugRenderer(this); this.f_238717_ = new RealmsDataFetcher(RealmsClient.m_239151_(this)); RenderSystem.m_69900_(this::m_91113_); -@@ -541,6 +_,21 @@ +@@ -542,6 +_,21 @@ TinyFileDialogs.tinyfd_messageBox("Minecraft", stringbuilder.toString(), "ok", "error", false); } @@ -89,14 +82,15 @@ this.f_90990_.m_85409_(this.f_91066_.m_231817_().m_231551_()); this.f_90990_.m_85424_(this.f_91066_.m_232123_().m_231551_()); this.f_90990_.m_85426_(); -@@ -563,23 +_,23 @@ +@@ -565,24 +_,24 @@ } this.f_167847_.m_168556_(); + if (net.minecraftforge.client.loading.ClientModLoader.completeModLoading()) return; // Do not overwrite the error screen + // FORGE: Move opening initial screen to after startup and events are enabled. + if (s != null) { -+ ConnectScreen.m_169267_(new TitleScreen(), this, new ServerAddress(s, i), (ServerData)null); ++ ServerAddress serveraddress = new ServerAddress(s, i); ++ ConnectScreen.m_169267_(new TitleScreen(), this, serveraddress, new ServerData(I18n.m_118938_("selectServer.defaultName"), serveraddress.toString(), false)); + } else if (this.m_239929_()) { + this.m_91152_(BanNoticeScreen.m_239967_((p_238185_) -> { + if (p_238185_) { @@ -111,8 +105,9 @@ }); }, false)); - if (s != null) { +- ServerAddress serveraddress = new ServerAddress(s, i); - reloadinstance.m_7237_().thenRunAsync(() -> { -- ConnectScreen.m_169267_(new TitleScreen(), this, new ServerAddress(s, i), (ServerData)null); +- ConnectScreen.m_169267_(new TitleScreen(), this, serveraddress, new ServerData(I18n.m_118938_("selectServer.defaultName"), serveraddress.toString(), false)); - }, this); - } else if (this.m_239929_()) { - this.m_91152_(BanNoticeScreen.m_239967_((p_238185_) -> { @@ -128,7 +123,7 @@ } -@@ -622,6 +_,8 @@ +@@ -634,6 +_,8 @@ private UserApiService m_193585_(YggdrasilAuthenticationService p_193586_, GameConfig p_193587_) { try { @@ -137,7 +132,7 @@ return p_193586_.createUserApiService(p_193587_.f_101905_.f_101942_.m_92547_()); } catch (AuthenticationException authenticationexception) { f_90982_.error("Failed to verify authentication", (Throwable)authenticationexception); -@@ -634,7 +_,7 @@ +@@ -646,7 +_,7 @@ } private void m_91239_(Throwable p_91240_) { @@ -146,7 +141,45 @@ this.m_91241_(p_91240_, (Component)null); } else { Util.m_137559_(p_91240_); -@@ -792,13 +_,13 @@ +@@ -723,7 +_,10 @@ + } + + public void m_91271_() { +- this.f_90997_.m_235232_(SearchRegistry.f_119941_, (p_231451_) -> { ++ var nameSearchKeys = net.minecraftforge.client.CreativeModeTabSearchRegistry.getNameSearchKeys(); ++ var tagSearchKeys = net.minecraftforge.client.CreativeModeTabSearchRegistry.getTagSearchKeys(); ++ for (var nameSearchKey : nameSearchKeys.values()) ++ this.f_90997_.m_235232_(nameSearchKey, (p_231451_) -> { + return new FullTextSearchTree<>((p_210797_) -> { + return p_210797_.m_41651_((Player)null, TooltipFlag.Default.f_256752_.m_257777_()).stream().map((p_210807_) -> { + return ChatFormatting.m_126649_(p_210807_.getString()).trim(); +@@ -734,7 +_,8 @@ + return Stream.of(BuiltInRegistries.f_257033_.m_7981_(p_91317_.m_41720_())); + }, p_231451_); + }); +- this.f_90997_.m_235232_(SearchRegistry.f_119942_, (p_231430_) -> { ++ for (var tagSearchKey : tagSearchKeys.values()) ++ this.f_90997_.m_235232_(tagSearchKey, (p_231430_) -> { + return new IdSearchTree<>((p_231353_) -> { + return p_231353_.m_204131_().map(TagKey::f_203868_); + }, p_231430_); +@@ -754,9 +_,12 @@ + }); + }, p_231389_); + }); +- CreativeModeTabs.m_258007_().m_257882_((p_255439_) -> { +- this.m_231374_(SearchRegistry.f_119941_, p_255439_); +- this.m_231374_(SearchRegistry.f_119942_, p_255439_); ++ nameSearchKeys.forEach((tab, nameSearchKey) -> { ++ var tagSearchKey = tagSearchKeys.get(tab); ++ tab.m_257882_(contents -> { ++ this.m_231374_(nameSearchKey, contents); ++ this.m_231374_(tagSearchKey, contents); ++ }); + }); + } + +@@ -808,13 +_,13 @@ Bootstrap.m_135875_(p_91333_.m_127526_()); if (p_91333_.m_127527_() != null) { Bootstrap.m_135875_("#@!@# Game crashed! Crash report saved to: #@!@# " + p_91333_.m_127527_()); @@ -163,7 +196,7 @@ } } -@@ -922,10 +_,6 @@ +@@ -932,10 +_,6 @@ f_90982_.error("setScreen called from non-game thread"); } @@ -174,7 +207,7 @@ if (p_91153_ == null && this.f_91073_ == null) { p_91153_ = new TitleScreen(); } else if (p_91153_ == null && this.f_91074_.m_21224_()) { -@@ -936,6 +_,19 @@ +@@ -946,6 +_,19 @@ } } @@ -194,7 +227,7 @@ this.f_91080_ = p_91153_; BufferUploader.m_166835_(); if (p_91153_ != null) { -@@ -1079,11 +_,14 @@ +@@ -1091,11 +_,14 @@ RenderSystem.m_69481_(); this.f_91026_.m_7238_(); if (!this.f_91079_) { @@ -209,7 +242,7 @@ } if (this.f_91056_ != null) { -@@ -1210,10 +_,12 @@ +@@ -1223,10 +_,12 @@ this.f_90990_.m_85378_((double)i); if (this.f_91080_ != null) { this.f_91080_.m_6574_(this, this.f_90990_.m_85445_(), this.f_90990_.m_85446_()); @@ -222,7 +255,7 @@ this.f_91063_.m_109097_(this.f_90990_.m_85441_(), this.f_90990_.m_85442_()); this.f_91067_.m_91599_(); } -@@ -1491,6 +_,7 @@ +@@ -1499,6 +_,7 @@ } public void m_91395_() { @@ -230,7 +263,7 @@ this.f_91019_ = false; } -@@ -1520,10 +_,18 @@ +@@ -1528,10 +_,18 @@ if (p_91387_ && this.f_91077_ != null && this.f_91077_.m_6662_() == HitResult.Type.BLOCK) { BlockHitResult blockhitresult = (BlockHitResult)this.f_91077_; BlockPos blockpos = blockhitresult.m_82425_(); @@ -252,41 +285,41 @@ this.f_91074_.m_6674_(InteractionHand.MAIN_HAND); } } -@@ -1548,14 +_,20 @@ - return false; - } else { - boolean flag = false; -- switch (this.f_91077_.m_6662_()) { -+ var inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(0, this.f_91066_.f_92096_, InteractionHand.MAIN_HAND); -+ HitResult.Type hitType = this.f_91077_.m_6662_(); -+ if(this.f_91077_ instanceof EntityHitResult entityHit) { // Forge: Perform attack range checks here, instead of in GameRenderer#pick, so extended-reach interactions work. -+ if(!f_91074_.canHit(entityHit.m_82443_(), 0)) hitType = HitResult.Type.MISS; // No padding in client code. -+ } -+ if (!inputEvent.isCanceled()) -+ switch(hitType) { - case ENTITY: - this.f_91072_.m_105223_(this.f_91074_, ((EntityHitResult)this.f_91077_).m_82443_()); - break; - case BLOCK: - BlockHitResult blockhitresult = (BlockHitResult)this.f_91077_; - BlockPos blockpos = blockhitresult.m_82425_(); -- if (!this.f_91073_.m_8055_(blockpos).m_60795_()) { -+ if (!this.f_91073_.m_46859_(blockpos)) { - this.f_91072_.m_105269_(blockpos, blockhitresult.m_82434_()); - if (this.f_91073_.m_8055_(blockpos).m_60795_()) { - flag = true; -@@ -1568,8 +_,10 @@ - } +@@ -1560,14 +_,20 @@ + return false; + } else { + boolean flag = false; +- switch (this.f_91077_.m_6662_()) { ++ var inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(0, this.f_91066_.f_92096_, InteractionHand.MAIN_HAND); ++ HitResult.Type hitType = this.f_91077_.m_6662_(); ++ if (this.f_91077_ instanceof EntityHitResult entityHit) { // Forge: Perform attack range checks here, instead of in GameRenderer#pick, so extended-reach interactions work. ++ if (!f_91074_.canHit(entityHit.m_82443_(), 0)) hitType = HitResult.Type.MISS; // No padding in client code. ++ } ++ if (!inputEvent.isCanceled()) ++ switch(hitType) { + case ENTITY: + this.f_91072_.m_105223_(this.f_91074_, ((EntityHitResult)this.f_91077_).m_82443_()); + break; + case BLOCK: + BlockHitResult blockhitresult = (BlockHitResult)this.f_91077_; + BlockPos blockpos = blockhitresult.m_82425_(); +- if (!this.f_91073_.m_8055_(blockpos).m_60795_()) { ++ if (!this.f_91073_.m_46859_(blockpos)) { + this.f_91072_.m_105269_(blockpos, blockhitresult.m_82434_()); + if (this.f_91073_.m_8055_(blockpos).m_60795_()) { + flag = true; +@@ -1580,8 +_,10 @@ + } - this.f_91074_.m_36334_(); -+ net.minecraftforge.common.ForgeHooks.onEmptyLeftClick(this.f_91074_); + this.f_91074_.m_36334_(); ++ net.minecraftforge.common.ForgeHooks.onEmptyLeftClick(this.f_91074_); + } + ++ if (inputEvent.shouldSwingHand()) + this.f_91074_.m_6674_(InteractionHand.MAIN_HAND); + return flag; } - -+ if (inputEvent.shouldSwingHand()) - this.f_91074_.m_6674_(InteractionHand.MAIN_HAND); - return flag; - } -@@ -1584,6 +_,11 @@ +@@ -1597,6 +_,11 @@ } for(InteractionHand interactionhand : InteractionHand.values()) { @@ -296,9 +329,9 @@ + return; + } ItemStack itemstack = this.f_91074_.m_21120_(interactionhand); - if (this.f_91077_ != null) { - switch (this.f_91077_.m_6662_()) { -@@ -1594,13 +_,14 @@ + if (!itemstack.m_246617_(this.f_91073_.m_246046_())) { + return; +@@ -1611,13 +_,14 @@ return; } @@ -314,7 +347,7 @@ this.f_91074_.m_6674_(interactionhand); } -@@ -1612,7 +_,7 @@ +@@ -1629,7 +_,7 @@ int i = itemstack.m_41613_(); InteractionResult interactionresult1 = this.f_91072_.m_233732_(this.f_91074_, interactionhand, blockhitresult); if (interactionresult1.m_19077_()) { @@ -323,7 +356,7 @@ this.f_91074_.m_6674_(interactionhand); if (!itemstack.m_41619_() && (itemstack.m_41613_() != i || this.f_91072_.m_105290_())) { this.f_91063_.f_109055_.m_109320_(interactionhand); -@@ -1628,6 +_,9 @@ +@@ -1645,6 +_,9 @@ } } @@ -333,7 +366,7 @@ if (!itemstack.m_41619_()) { InteractionResult interactionresult2 = this.f_91072_.m_233721_(this.f_91074_, interactionhand); if (interactionresult2.m_19077_()) { -@@ -1654,6 +_,8 @@ +@@ -1671,6 +_,8 @@ --this.f_91011_; } @@ -342,7 +375,7 @@ this.f_91026_.m_6180_("gui"); this.f_240378_.m_240688_(); this.f_91065_.m_193832_(this.f_91012_); -@@ -1783,6 +_,8 @@ +@@ -1800,6 +_,8 @@ this.f_91026_.m_6182_("keyboard"); this.f_91068_.m_90931_(); this.f_91026_.m_7238_(); @@ -351,7 +384,7 @@ } private boolean m_91278_() { -@@ -1978,6 +_,7 @@ +@@ -1996,6 +_,7 @@ } public void m_91156_(ClientLevel p_91157_) { @@ -359,7 +392,7 @@ ProgressScreen progressscreen = new ProgressScreen(true); progressscreen.m_6309_(Component.m_237115_("connect.joining")); this.m_91362_(progressscreen); -@@ -2011,10 +_,12 @@ +@@ -2029,10 +_,12 @@ IntegratedServer integratedserver = this.f_91007_; this.f_91007_ = null; this.f_91063_.m_109150_(); @@ -372,15 +405,15 @@ if (integratedserver != null) { this.f_91026_.m_6180_("waitForServer"); -@@ -2029,6 +_,7 @@ +@@ -2046,6 +_,7 @@ + this.f_243981_.m_246151_(); this.f_91065_.m_93089_(); - this.f_91008_ = null; this.f_91010_ = false; + net.minecraftforge.client.ForgeHooksClient.handleClientLevelClosing(f_91073_); this.f_91004_.m_90740_(); } -@@ -2124,6 +_,7 @@ +@@ -2153,6 +_,7 @@ private void m_91280_() { if (this.f_91077_ != null && this.f_91077_.m_6662_() != HitResult.Type.MISS) { @@ -388,7 +421,7 @@ boolean flag = this.f_91074_.m_150110_().f_35937_; BlockEntity blockentity = null; HitResult.Type hitresult$type = this.f_91077_.m_6662_(); -@@ -2136,10 +_,7 @@ +@@ -2165,10 +_,7 @@ } Block block = blockstate.m_60734_(); @@ -400,7 +433,7 @@ if (flag && Screen.m_96637_() && blockstate.m_155947_()) { blockentity = this.f_91073_.m_7702_(blockpos); -@@ -2150,7 +_,7 @@ +@@ -2179,7 +_,7 @@ } Entity entity = ((EntityHitResult)this.f_91077_).m_82443_(); @@ -409,27 +442,7 @@ if (itemstack == null) { return; } -@@ -2688,8 +_,8 @@ - return this.f_90993_; - } - -- private static Pack m_167933_(String p_167934_, Component p_167935_, boolean p_167936_, Supplier p_167937_, PackMetadataSection p_167938_, Pack.Position p_167939_, PackSource p_167940_) { -- int i = p_167938_.m_10374_(); -+ private static Pack createClientPackAdapter(String p_167934_, Component p_167935_, boolean p_167936_, Supplier p_167937_, PackMetadataSection p_167938_, Pack.Position p_167939_, PackSource p_167940_, boolean hidden) { -+ int i = p_167938_.getPackFormat(PackType.CLIENT_RESOURCES); - Supplier supplier = p_167937_; - if (i <= 3) { - supplier = m_91330_(p_167937_); -@@ -2699,7 +_,7 @@ - supplier = m_91352_(supplier); - } - -- return new Pack(p_167934_, p_167935_, p_167936_, supplier, p_167938_, PackType.CLIENT_RESOURCES, p_167939_, p_167940_); -+ return new Pack(p_167934_, p_167935_, p_167936_, supplier, p_167938_, PackType.CLIENT_RESOURCES, p_167939_, p_167940_, hidden); - } - - private static Supplier m_91330_(Supplier p_91331_) { -@@ -2716,6 +_,19 @@ +@@ -2721,6 +_,19 @@ public void m_91312_(int p_91313_) { this.f_91051_.m_119410_(p_91313_); diff --git a/patches/minecraft/net/minecraft/client/Options.java.patch b/patches/minecraft/net/minecraft/client/Options.java.patch index f2c738c4fc..cbb162e479 100644 --- a/patches/minecraft/net/minecraft/client/Options.java.patch +++ b/patches/minecraft/net/minecraft/client/Options.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Options.java +++ b/net/minecraft/client/Options.java -@@ -539,7 +_,8 @@ +@@ -507,7 +_,8 @@ }, new OptionInstance.LazyEnum<>(() -> { return Stream.concat(Stream.of(""), Minecraft.m_91087_().m_91106_().m_194525_().stream()).toList(); }, (p_232011_) -> { @@ -10,7 +10,7 @@ }, Codec.STRING), "", (p_231994_) -> { SoundManager soundmanager = Minecraft.m_91087_().m_91106_(); soundmanager.m_194526_(); -@@ -796,6 +_,7 @@ +@@ -788,6 +_,7 @@ } public Options(Minecraft p_92138_, File p_92139_) { @@ -18,9 +18,9 @@ this.f_92060_ = p_92138_; this.f_92110_ = new File(p_92139_, "options.txt"); boolean flag = p_92138_.m_91103_(); -@@ -910,11 +_,20 @@ - p_168428_.m_213982_("chatPreview", this.f_231796_); - p_168428_.m_213982_("onlyShowSecureChat", this.f_231798_); +@@ -904,11 +_,20 @@ + p_168428_.m_213982_("panoramaScrollSpeed", this.f_244402_); + p_168428_.m_213982_("telemetryOptInExtra", this.f_260461_); + processOptionsForge(p_168428_); + } @@ -41,7 +41,7 @@ } } -@@ -935,6 +_,9 @@ +@@ -927,6 +_,9 @@ } public void m_92140_() { @@ -51,7 +51,7 @@ try { if (!this.f_92110_.exists()) { return; -@@ -979,7 +_,8 @@ +@@ -955,7 +_,8 @@ } } @@ -61,15 +61,15 @@ @Nullable private String m_168458_(String p_168459_) { return compoundtag1.m_128441_(p_168459_) ? compoundtag1.m_128461_(p_168459_) : null; -@@ -1082,6 +_,7 @@ +@@ -1118,6 +_,7 @@ } - public void m_92169_() { + public void m_92172_() { + if (net.minecraftforge.client.loading.ClientModLoader.isLoading()) return; //Don't save settings before mods add keybindigns and the like to prevent them from being deleted. - try { - final PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.f_92110_), StandardCharsets.UTF_8)); + if (this.f_92060_.f_91074_ != null) { + int i = 0; -@@ -1229,6 +_,23 @@ +@@ -1182,6 +_,23 @@ } p_92146_.m_10509_(set); diff --git a/patches/minecraft/net/minecraft/client/RecipeBookCategories.java.patch b/patches/minecraft/net/minecraft/client/RecipeBookCategories.java.patch index 254604ce81..5536566107 100644 --- a/patches/minecraft/net/minecraft/client/RecipeBookCategories.java.patch +++ b/patches/minecraft/net/minecraft/client/RecipeBookCategories.java.patch @@ -18,14 +18,16 @@ private final List f_92261_; private RecipeBookCategories(ItemStack... p_92267_) { -@@ -54,11 +_,15 @@ - case SMOKER: - return f_92256_; +@@ -59,7 +_,7 @@ + list = f_92256_; + break; default: -- return ImmutableList.of(); +- throw new IncompatibleClassChangeError(); + return net.minecraftforge.client.RecipeBookManager.getCustomCategoriesOrEmpty(p_92270_); } - } + + return list; +@@ -67,5 +_,9 @@ public List m_92268_() { return this.f_92261_; diff --git a/patches/minecraft/net/minecraft/client/Screenshot.java.patch b/patches/minecraft/net/minecraft/client/Screenshot.java.patch index 75a7c23c8d..854c138e20 100644 --- a/patches/minecraft/net/minecraft/client/Screenshot.java.patch +++ b/patches/minecraft/net/minecraft/client/Screenshot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Screenshot.java +++ b/net/minecraft/client/Screenshot.java -@@ -55,13 +_,23 @@ +@@ -56,13 +_,23 @@ file2 = new File(file1, p_92307_); } diff --git a/patches/minecraft/net/minecraft/client/color/block/BlockColors.java.patch b/patches/minecraft/net/minecraft/client/color/block/BlockColors.java.patch index 4deb5b3795..7fd181a6f7 100644 --- a/patches/minecraft/net/minecraft/client/color/block/BlockColors.java.patch +++ b/patches/minecraft/net/minecraft/client/color/block/BlockColors.java.patch @@ -19,7 +19,7 @@ } public int m_92582_(BlockState p_92583_, Level p_92584_, BlockPos p_92585_) { -- BlockColor blockcolor = this.f_92571_.m_7942_(Registry.f_122824_.m_7447_(p_92583_.m_60734_())); +- BlockColor blockcolor = this.f_92571_.m_7942_(BuiltInRegistries.f_256975_.m_7447_(p_92583_.m_60734_())); + BlockColor blockcolor = this.f_92571_.get(net.minecraftforge.registries.ForgeRegistries.BLOCKS.getDelegateOrThrow(p_92583_.m_60734_())); if (blockcolor != null) { return blockcolor.m_92566_(p_92583_, (BlockAndTintGetter)null, (BlockPos)null, 0); @@ -28,7 +28,7 @@ } public int m_92577_(BlockState p_92578_, @Nullable BlockAndTintGetter p_92579_, @Nullable BlockPos p_92580_, int p_92581_) { -- BlockColor blockcolor = this.f_92571_.m_7942_(Registry.f_122824_.m_7447_(p_92578_.m_60734_())); +- BlockColor blockcolor = this.f_92571_.m_7942_(BuiltInRegistries.f_256975_.m_7447_(p_92578_.m_60734_())); + BlockColor blockcolor = this.f_92571_.get(net.minecraftforge.registries.ForgeRegistries.BLOCKS.getDelegateOrThrow(p_92578_.m_60734_())); return blockcolor == null ? -1 : blockcolor.m_92566_(p_92578_, p_92579_, p_92580_, p_92581_); } @@ -37,7 +37,7 @@ + @Deprecated public void m_92589_(BlockColor p_92590_, Block... p_92591_) { for(Block block : p_92591_) { -- this.f_92571_.m_122664_(p_92590_, Registry.f_122824_.m_7447_(block)); +- this.f_92571_.m_122664_(p_92590_, BuiltInRegistries.f_256975_.m_7447_(block)); + this.f_92571_.put(net.minecraftforge.registries.ForgeRegistries.BLOCKS.getDelegateOrThrow(block), p_92590_); } diff --git a/patches/minecraft/net/minecraft/client/color/item/ItemColors.java.patch b/patches/minecraft/net/minecraft/client/color/item/ItemColors.java.patch index 8e62d2f28b..d627583e3d 100644 --- a/patches/minecraft/net/minecraft/client/color/item/ItemColors.java.patch +++ b/patches/minecraft/net/minecraft/client/color/item/ItemColors.java.patch @@ -19,7 +19,7 @@ } public int m_92676_(ItemStack p_92677_, int p_92678_) { -- ItemColor itemcolor = this.f_92674_.m_7942_(Registry.f_122827_.m_7447_(p_92677_.m_41720_())); +- ItemColor itemcolor = this.f_92674_.m_7942_(BuiltInRegistries.f_257033_.m_7447_(p_92677_.m_41720_())); + ItemColor itemcolor = this.f_92674_.get(net.minecraftforge.registries.ForgeRegistries.ITEMS.getDelegateOrThrow(p_92677_.m_41720_())); return itemcolor == null ? -1 : itemcolor.m_92671_(p_92677_, p_92678_); } diff --git a/patches/minecraft/net/minecraft/client/gui/Gui.java.patch b/patches/minecraft/net/minecraft/client/gui/Gui.java.patch index f2a7cdc534..c8e5eb3dd8 100644 --- a/patches/minecraft/net/minecraft/client/gui/Gui.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/Gui.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/Gui.java +++ b/net/minecraft/client/gui/Gui.java -@@ -389,6 +_,7 @@ +@@ -392,6 +_,7 @@ if (this.f_92986_.f_91076_ != null && this.f_92986_.f_91076_ instanceof LivingEntity && f >= 1.0F) { flag = this.f_92986_.f_91074_.m_36333_() > 5.0F; flag &= this.f_92986_.f_91076_.m_6084_(); @@ -8,7 +8,7 @@ } int j = this.f_92978_ / 2 - 7 + 16; -@@ -441,6 +_,10 @@ +@@ -444,6 +_,10 @@ for(MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) { MobEffect mobeffect = mobeffectinstance.m_19544_(); @@ -19,7 +19,7 @@ if (mobeffectinstance.m_19575_()) { int i = this.f_92977_; int j = 1; -@@ -469,6 +_,7 @@ +@@ -472,6 +_,7 @@ } } @@ -27,7 +27,7 @@ TextureAtlasSprite textureatlassprite = mobeffecttexturemanager.m_118732_(mobeffect); int l = i; int i1 = j; -@@ -598,12 +_,13 @@ +@@ -603,12 +_,13 @@ public void m_93069_(PoseStack p_93070_) { this.f_92986_.m_91307_().m_6180_("selectedItemName"); if (this.f_92993_ > 0 && !this.f_92994_.m_41619_()) { @@ -43,7 +43,7 @@ int j = (this.f_92977_ - i) / 2; int k = this.f_92978_ - 59; if (!this.f_92986_.f_91072_.m_105205_()) { -@@ -619,7 +_,13 @@ +@@ -624,7 +_,13 @@ RenderSystem.m_69478_(); RenderSystem.m_69453_(); m_93172_(p_93070_, j - 2, k - 2, j + i + 2, k + 9 + 2, this.f_92986_.f_91066_.m_92143_(0)); @@ -58,7 +58,7 @@ RenderSystem.m_69461_(); } } -@@ -1133,7 +_,7 @@ +@@ -1138,7 +_,7 @@ ItemStack itemstack = this.f_92986_.f_91074_.m_150109_().m_36056_(); if (itemstack.m_41619_()) { this.f_92993_ = 0; diff --git a/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch b/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch index 2c2122ccfb..4abbeaf088 100644 --- a/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch @@ -6,5 +6,5 @@ if (!p_93294_ || mapdecoration.m_77809_()) { + if (mapdecoration.render(k)) { k++; continue; } p_93292_.m_85836_(); - p_93292_.m_85837_((double)(0.0F + (float)mapdecoration.m_77804_() / 2.0F + 64.0F), (double)(0.0F + (float)mapdecoration.m_77805_() / 2.0F + 64.0F), (double)-0.02F); - p_93292_.m_85845_(Vector3f.f_122227_.m_122240_((float)(mapdecoration.m_77806_() * 360) / 16.0F)); + p_93292_.m_252880_(0.0F + (float)mapdecoration.m_77804_() / 2.0F + 64.0F, 0.0F + (float)mapdecoration.m_77805_() / 2.0F + 64.0F, -0.02F); + p_93292_.m_252781_(Axis.f_252403_.m_252977_((float)(mapdecoration.m_77806_() * 360) / 16.0F)); diff --git a/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch b/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch index e582815e1a..e4acb16f72 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/client/gui/components/AbstractWidget.java +++ b/net/minecraft/client/gui/components/AbstractWidget.java -@@ -85,7 +_,7 @@ - this.m_93228_(p_93676_, this.f_93620_, this.f_93621_, 0, 46 + i * 20, this.f_93618_ / 2, this.f_93619_); - this.m_93228_(p_93676_, this.f_93620_ + this.f_93618_ / 2, this.f_93621_, 200 - this.f_93618_ / 2, 46 + i * 20, this.f_93618_ / 2, this.f_93619_); +@@ -130,7 +_,7 @@ + this.m_93228_(p_93676_, this.m_252754_(), this.m_252907_(), 0, 46 + i * 20, this.f_93618_ / 2, this.f_93619_); + this.m_93228_(p_93676_, this.m_252754_() + this.f_93618_ / 2, this.m_252907_(), 200 - this.f_93618_ / 2, 46 + i * 20, this.f_93618_ / 2, this.f_93619_); this.m_7906_(p_93676_, minecraft, p_93677_, p_93678_); - int j = this.f_93623_ ? 16777215 : 10526880; + int j = getFGColor(); - m_93215_(p_93676_, font, this.m_6035_(), this.f_93620_ + this.f_93618_ / 2, this.f_93621_ + (this.f_93619_ - 8) / 2, j | Mth.m_14167_(this.f_93625_ * 255.0F) << 24); + m_93215_(p_93676_, font, this.m_6035_(), this.m_252754_() + this.f_93618_ / 2, this.m_252907_() + (this.f_93619_ - 8) / 2, j | Mth.m_14167_(this.f_93625_ * 255.0F) << 24); } -@@ -180,6 +_,10 @@ +@@ -222,6 +_,10 @@ this.f_93618_ = p_93675_; } @@ -20,7 +20,7 @@ public void m_93650_(float p_93651_) { this.f_93625_ = p_93651_; } -@@ -202,6 +_,19 @@ +@@ -244,6 +_,19 @@ protected void m_93692_(boolean p_93693_) { this.f_93616_ = p_93693_; diff --git a/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch index 08759aa86b..74947126b3 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch @@ -3,7 +3,7 @@ @@ -409,6 +_,7 @@ list.add(""); list.add(ChatFormatting.UNDERLINE + "Targeted Entity"); - list.add(String.valueOf((Object)Registry.f_122826_.m_7981_(entity.m_6095_()))); + list.add(String.valueOf((Object)BuiltInRegistries.f_256780_.m_7981_(entity.m_6095_()))); + entity.m_6095_().m_204041_().m_203616_().forEach(t -> list.add("#" + t.f_203868_())); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/DeathScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/DeathScreen.java.patch deleted file mode 100644 index 5b7d111e14..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screens/DeathScreen.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/client/gui/screens/DeathScreen.java -+++ b/net/minecraft/client/gui/screens/DeathScreen.java -@@ -36,6 +_,7 @@ - }))); - this.f_169295_.add(this.m_142416_(new Button(this.f_96543_ / 2 - 100, this.f_96544_ / 4 + 96, 200, 20, Component.m_237115_("deathScreen.titleScreen"), (p_95925_) -> { - if (this.f_95908_) { -+ m_95931_(true); - this.m_95934_(); - } else { - ConfirmScreen confirmscreen = new ConfirmScreen(this::m_95931_, Component.m_237115_("deathScreen.quit.confirm"), CommonComponents.f_237098_, Component.m_237115_("deathScreen.titleScreen"), Component.m_237115_("deathScreen.respawn")); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch index 3fd6dfddbe..eb571f0e2f 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/LoadingOverlay.java +++ b/net/minecraft/client/gui/screens/LoadingOverlay.java -@@ -119,6 +_,7 @@ +@@ -121,6 +_,7 @@ int k1 = (int)((double)this.f_96163_.m_91268_().m_85446_() * 0.8325D); float f6 = this.f_96164_.m_7750_(); this.f_96167_ = Mth.m_14036_(this.f_96167_ * 0.95F + f6 * 0.050000012F, 0.0F, 1.0F); @@ -8,7 +8,7 @@ if (f < 1.0F) { this.m_96182_(p_96178_, i / 2 - j1, k1 - 5, i / 2 + j1, k1 + 5, 1.0F - Mth.m_14036_(f, 0.0F, 1.0F)); } -@@ -128,6 +_,7 @@ +@@ -130,6 +_,7 @@ } if (this.f_96168_ == -1L && this.f_96164_.m_7746_() && (!this.f_96166_ || f1 >= 2.0F)) { @@ -16,7 +16,7 @@ try { this.f_96164_.m_7748_(); this.f_96165_.accept(Optional.empty()); -@@ -135,7 +_,6 @@ +@@ -137,7 +_,6 @@ this.f_96165_.accept(Optional.of(throwable)); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/MenuScreens.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/MenuScreens.java.patch index beff574d78..366ec53b4e 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/MenuScreens.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/MenuScreens.java.patch @@ -13,7 +13,7 @@ } else { @@ -47,9 +_,10 @@ if (screenconstructor == null) { - f_96195_.warn("Failed to create screen for menu type: {}", (Object)Registry.f_122863_.m_7981_(p_96202_)); + f_96195_.warn("Failed to create screen for menu type: {}", (Object)BuiltInRegistries.f_256818_.m_7981_(p_96202_)); } else { - screenconstructor.m_96209_(p_96205_, p_96202_, p_96203_, p_96204_); + return java.util.Optional.of(screenconstructor); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch index dbfd441b0b..1c7a7f0d79 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch @@ -1,10 +1,9 @@ --- a/net/minecraft/client/gui/screens/OptionsScreen.java +++ b/net/minecraft/client/gui/screens/OptionsScreen.java -@@ -140,4 +_,12 @@ - m_93215_(p_96249_, this.f_96547_, this.f_96539_, this.f_96543_ / 2, 15, 16777215); - super.m_6305_(p_96249_, p_96250_, p_96251_, p_96252_); +@@ -168,6 +_,14 @@ + super.m_86412_(p_96249_, p_96250_, p_96251_, p_96252_); } -+ + + @Override + public void m_7379_() { + // We need to consider 2 potential parent screens here: @@ -12,4 +11,7 @@ + // 2. From the pause menu, in which case exit back to game + this.f_96541_.m_91152_(this.f_96235_ instanceof PauseScreen ? null : this.f_96235_); + } - } ++ + private Button m_260993_(Component p_261565_, Supplier p_262119_) { + return Button.m_253074_(p_261565_, (p_261361_) -> { + this.f_96541_.m_91152_(p_262119_.get()); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch index 767cfbea47..c8cf5c4265 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/Screen.java +++ b/net/minecraft/client/gui/screens/Screen.java -@@ -126,7 +_,7 @@ +@@ -143,7 +_,7 @@ } public void m_7379_() { @@ -8,8 +8,8 @@ + this.f_96541_.popGuiLayer(); } - protected T m_142416_(T p_169406_) { -@@ -163,15 +_,29 @@ + protected T m_142416_(T p_169406_) { +@@ -180,15 +_,29 @@ this.f_169368_.clear(); } @@ -40,16 +40,16 @@ - list.add(1, ClientTooltipComponent.m_169950_(p_169399_)); - }); + List list = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, p_169390_, p_169391_, p_169392_, f_96543_, f_96544_, this.tooltipFont, this.f_96547_); - this.m_169383_(p_169389_, list, p_169392_, p_169393_); + this.m_262809_(p_169389_, list, p_169392_, p_169393_, DefaultTooltipPositioner.f_262752_); } -@@ -184,20 +_,44 @@ +@@ -201,24 +_,48 @@ } public void m_96597_(PoseStack p_96598_, List p_96599_, int p_96600_, int p_96601_) { - this.m_96617_(p_96598_, Lists.transform(p_96599_, Component::m_7532_), p_96600_, p_96601_); + List components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, p_96599_, p_96600_, f_96543_, f_96544_, this.tooltipFont, this.f_96547_); -+ this.m_169383_(p_96598_, components, p_96600_, p_96601_); ++ this.m_262809_(p_96598_, components, p_96600_, p_96601_, DefaultTooltipPositioner.f_262752_); + } + public void renderComponentTooltip(PoseStack poseStack, List tooltips, int mouseX, int mouseY, ItemStack stack) { + this.renderComponentTooltip(poseStack, tooltips, mouseX, mouseY, null, stack); @@ -62,13 +62,13 @@ + this.tooltipFont = font; + this.tooltipStack = stack; + List components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(stack, tooltips, mouseX, f_96543_, f_96544_, this.tooltipFont, this.f_96547_); -+ this.m_169383_(poseStack, components, mouseX, mouseY); ++ this.m_262809_(poseStack, components, mouseX, mouseY, DefaultTooltipPositioner.f_262752_); + this.tooltipFont = null; + this.tooltipStack = ItemStack.f_41583_; } public void m_96617_(PoseStack p_96618_, List p_96619_, int p_96620_, int p_96621_) { - this.m_169383_(p_96618_, p_96619_.stream().map(ClientTooltipComponent::m_169948_).collect(Collectors.toList()), p_96620_, p_96621_); + this.m_262809_(p_96618_, p_96619_.stream().map(ClientTooltipComponent::m_169948_).collect(Collectors.toList()), p_96620_, p_96621_, DefaultTooltipPositioner.f_262752_); } + public void renderTooltip(PoseStack poseStack, List lines, int x, int y, Font font) { @@ -77,81 +77,68 @@ + this.tooltipFont = null; + } + - private void m_169383_(PoseStack p_169384_, List p_169385_, int p_169386_, int p_169387_) { - if (!p_169385_.isEmpty()) { -+ net.minecraftforge.client.event.RenderTooltipEvent.Pre preEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipPre(this.tooltipStack, p_169384_, p_169386_, p_169387_, f_96543_, f_96544_, p_169385_, this.tooltipFont, this.f_96547_); + private void m_262835_(PoseStack p_263080_, Screen.DeferredTooltipRendering p_262968_, int p_263034_, int p_263076_) { + this.m_262809_(p_263080_, p_262968_.f_262736_().stream().map(ClientTooltipComponent::m_169948_).collect(Collectors.toList()), p_263034_, p_263076_, p_262968_.f_262758_()); + } + + private void m_262809_(PoseStack p_263064_, List p_262990_, int p_263065_, int p_262996_, ClientTooltipPositioner p_262920_) { + if (!p_262990_.isEmpty()) { ++ net.minecraftforge.client.event.RenderTooltipEvent.Pre preEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipPre(this.tooltipStack, p_263064_, p_263065_, p_262996_, f_96543_, f_96544_, p_262990_, this.tooltipFont, this.f_96547_); + if (preEvent.isCanceled()) return; int i = 0; - int j = p_169385_.size() == 1 ? -2 : 0; + int j = p_262990_.size() == 1 ? -2 : 0; - for(ClientTooltipComponent clienttooltipcomponent : p_169385_) { + for(ClientTooltipComponent clienttooltipcomponent : p_262990_) { - int k = clienttooltipcomponent.m_142069_(this.f_96547_); + int k = clienttooltipcomponent.m_142069_(preEvent.getFont()); if (k > i) { i = k; } -@@ -205,8 +_,8 @@ +@@ -226,8 +_,8 @@ j += clienttooltipcomponent.m_142103_(); } -- int j2 = p_169386_ + 12; -- int k2 = p_169387_ - 12; -+ int j2 = preEvent.getX() + 12; -+ int k2 = preEvent.getY() - 12; - if (j2 + i > this.f_96543_) { - j2 -= 28 + i; - } -@@ -227,15 +_,16 @@ +- int k1 = p_263065_ + 12; +- int l1 = p_262996_ - 12; ++ int k1 = preEvent.getX() + 12; ++ int l1 = preEvent.getY() - 12; + Vector2ic vector2ic = p_262920_.m_262814_(this, k1, l1, i, j); + k1 = vector2ic.x(); + l1 = vector2ic.y(); +@@ -240,6 +_,8 @@ RenderSystem.m_157427_(GameRenderer::m_172811_); bufferbuilder.m_166779_(VertexFormat.Mode.QUADS, DefaultVertexFormat.f_85815_); - Matrix4f matrix4f = p_169384_.m_85850_().m_85861_(); -- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 4, j2 + i + 3, k2 - 3, 400, -267386864, -267386864); -- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 + j + 3, j2 + i + 3, k2 + j + 4, 400, -267386864, -267386864); -- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 + j + 3, 400, -267386864, -267386864); -- m_93123_(matrix4f, bufferbuilder, j2 - 4, k2 - 3, j2 - 3, k2 + j + 3, 400, -267386864, -267386864); -- m_93123_(matrix4f, bufferbuilder, j2 + i + 3, k2 - 3, j2 + i + 4, k2 + j + 3, 400, -267386864, -267386864); -- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + j + 3 - 1, 400, 1347420415, 1344798847); -- m_93123_(matrix4f, bufferbuilder, j2 + i + 2, k2 - 3 + 1, j2 + i + 3, k2 + j + 3 - 1, 400, 1347420415, 1344798847); -- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 - 3 + 1, 400, 1347420415, 1347420415); -- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 + j + 2, j2 + i + 3, k2 + j + 3, 400, 1344798847, 1344798847); -+ net.minecraftforge.client.event.RenderTooltipEvent.Color colorEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipColor(this.tooltipStack, p_169384_, j2, k2, preEvent.getFont(), p_169385_); -+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 4, j2 + i + 3, k2 - 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundStart()); -+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 + j + 3, j2 + i + 3, k2 + j + 4, 400, colorEvent.getBackgroundEnd(), colorEvent.getBackgroundEnd()); -+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 + j + 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundEnd()); -+ m_93123_(matrix4f, bufferbuilder, j2 - 4, k2 - 3, j2 - 3, k2 + j + 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundEnd()); -+ m_93123_(matrix4f, bufferbuilder, j2 + i + 3, k2 - 3, j2 + i + 4, k2 + j + 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundEnd()); -+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + j + 3 - 1, 400, colorEvent.getBorderStart(), colorEvent.getBorderEnd()); -+ m_93123_(matrix4f, bufferbuilder, j2 + i + 2, k2 - 3 + 1, j2 + i + 3, k2 + j + 3 - 1, 400, colorEvent.getBorderStart(), colorEvent.getBorderEnd()); -+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 - 3 + 1, 400, colorEvent.getBorderStart(), colorEvent.getBorderStart()); -+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 + j + 2, j2 + i + 3, k2 + j + 3, 400, colorEvent.getBorderEnd(), colorEvent.getBorderEnd()); - RenderSystem.m_69482_(); - RenderSystem.m_69472_(); - RenderSystem.m_69478_(); -@@ -249,7 +_,7 @@ + Matrix4f matrix4f = p_263064_.m_85850_().m_252922_(); ++ // TODO 1.19.3: Tooltip rendering changed, rethink the color event. ++ // net.minecraftforge.client.event.RenderTooltipEvent.Color colorEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipColor(this.tooltipStack, p_263064_, k1, l1, preEvent.getFont(), p_262990_); + TooltipRenderUtil.m_262796_((p_262872_, p_262873_, p_262874_, p_262875_, p_262876_, p_262877_, p_262878_, p_262879_, p_262880_) -> { + GuiComponent.m_93123_(p_262872_, p_262873_, p_262874_, p_262875_, p_262876_, p_262877_, p_262878_, p_262879_, p_262880_); + }, matrix4f, bufferbuilder, k1, l1, i, j, 400); +@@ -256,7 +_,7 @@ - for(int i2 = 0; i2 < p_169385_.size(); ++i2) { - ClientTooltipComponent clienttooltipcomponent1 = p_169385_.get(i2); -- clienttooltipcomponent1.m_142440_(this.f_96547_, j2, l1, matrix4f, multibuffersource$buffersource); -+ clienttooltipcomponent1.m_142440_(preEvent.getFont(), j2, l1, matrix4f, multibuffersource$buffersource); - l1 += clienttooltipcomponent1.m_142103_() + (i2 == 0 ? 2 : 0); + for(int j1 = 0; j1 < p_262990_.size(); ++j1) { + ClientTooltipComponent clienttooltipcomponent1 = p_262990_.get(j1); +- clienttooltipcomponent1.m_142440_(this.f_96547_, k1, i1, matrix4f, multibuffersource$buffersource); ++ clienttooltipcomponent1.m_142440_(preEvent.getFont(), k1, i1, matrix4f, multibuffersource$buffersource); + i1 += clienttooltipcomponent1.m_142103_() + (j1 == 0 ? 2 : 0); } -@@ -259,7 +_,7 @@ +@@ -266,7 +_,7 @@ - for(int l2 = 0; l2 < p_169385_.size(); ++l2) { - ClientTooltipComponent clienttooltipcomponent2 = p_169385_.get(l2); -- clienttooltipcomponent2.m_183452_(this.f_96547_, j2, l1, p_169384_, this.f_96542_, 400); -+ clienttooltipcomponent2.m_183452_(preEvent.getFont(), j2, l1, p_169384_, this.f_96542_, 400); - l1 += clienttooltipcomponent2.m_142103_() + (l2 == 0 ? 2 : 0); + for(int i2 = 0; i2 < p_262990_.size(); ++i2) { + ClientTooltipComponent clienttooltipcomponent2 = p_262990_.get(i2); +- clienttooltipcomponent2.m_183452_(this.f_96547_, k1, i1, p_263064_, this.f_96542_, 400); ++ clienttooltipcomponent2.m_183452_(preEvent.getFont(), k1, i1, p_263064_, this.f_96542_, 400); + i1 += clienttooltipcomponent2.m_142103_() + (i2 == 0 ? 2 : 0); } -@@ -361,9 +_,19 @@ +@@ -368,9 +_,19 @@ this.f_96547_ = p_96607_.f_91062_; this.f_96543_ = p_96608_; this.f_96544_ = p_96609_; + java.util.function.Consumer add = (b) -> { -+ if (b instanceof Widget w) -+ this.f_169369_.add(w); ++ if (b instanceof Renderable r) ++ this.f_169369_.add(r); + if (b instanceof NarratableEntry ne) + this.f_169368_.add(ne); + f_96540_.add(b); @@ -165,7 +152,7 @@ } protected void m_232761_() { -@@ -392,6 +_,7 @@ +@@ -399,6 +_,7 @@ public void m_96558_(PoseStack p_96559_, int p_96560_) { if (this.f_96541_.f_91073_ != null) { this.m_93179_(p_96559_, 0, 0, this.f_96543_, this.f_96544_, -1072689136, -804253680); @@ -173,7 +160,7 @@ } else { this.m_96626_(p_96560_); } -@@ -411,6 +_,7 @@ +@@ -418,6 +_,7 @@ bufferbuilder.m_5483_((double)this.f_96543_, 0.0D, 0.0D).m_7421_((float)this.f_96543_ / 32.0F, (float)p_96627_).m_6122_(64, 64, 64, 255).m_5752_(); bufferbuilder.m_5483_(0.0D, 0.0D, 0.0D).m_7421_(0.0F, (float)p_96627_).m_6122_(64, 64, 64, 255).m_5752_(); tesselator.m_85914_(); @@ -181,7 +168,7 @@ } public boolean m_7043_() { -@@ -496,6 +_,10 @@ +@@ -503,6 +_,10 @@ } public void m_7400_(List p_96591_) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch index 9ba643ff96..2f0d593f17 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch @@ -8,7 +8,7 @@ public TitleScreen() { this(false); -@@ -112,11 +_,16 @@ +@@ -112,11 +_,15 @@ int j = this.f_96543_ - i - 2; int k = 24; int l = this.f_96544_ / 4 + 48; @@ -17,32 +17,31 @@ this.m_96772_(l, 24); } else { this.m_96763_(l, 24); -+ modButton = this.m_142416_(new Button(this.f_96543_ / 2 - 100, l + 24 * 2, 98, 20, Component.m_237115_("fml.menu.mods"), button -> { -+ this.f_96541_.m_91152_(new net.minecraftforge.client.gui.ModListScreen(this)); -+ })); ++ modButton = this.m_142416_(Button.m_253074_(Component.m_237115_("fml.menu.mods"), button -> this.f_96541_.m_91152_(new net.minecraftforge.client.gui.ModListScreen(this))) ++ .m_252794_(this.f_96543_ / 2 - 100, l + 24 * 2).m_253046_(98, 20).m_253136_()); } + modUpdateNotification = net.minecraftforge.client.gui.TitleScreenModUpdateIndicator.init(this, modButton); this.m_142416_(new ImageButton(this.f_96543_ / 2 - 124, l + 72 + 12, 20, 20, 0, 106, 20, Button.f_93617_, 256, 256, (p_96791_) -> { this.f_96541_.m_91152_(new LanguageSelectScreen(this, this.f_96541_.f_91066_, this.f_96541_.m_91102_())); -@@ -167,7 +_,7 @@ - Screen screen = (Screen)(this.f_96541_.f_91066_.f_92083_ ? new JoinMultiplayerScreen(this) : new SafetyScreen(this)); - this.f_96541_.m_91152_(screen); - }, button$ontooltip))).f_93623_ = flag; -- (this.m_142416_(new Button(this.f_96543_ / 2 - 100, p_96764_ + p_96765_ * 2, 200, 20, Component.m_237115_("menu.online"), (p_210872_) -> { -+ (this.m_142416_(new Button(this.f_96543_ / 2 + 2, p_96764_ + p_96765_ * 2, 98, 20, Component.m_237115_("menu.online"), (p_96771_) -> { +@@ -161,7 +_,7 @@ + }).m_252987_(this.f_96543_ / 2 - 100, p_96764_ + p_96765_ * 1, 200, 20).m_257505_(tooltip).m_253136_())).f_93623_ = flag; + (this.m_142416_(Button.m_253074_(Component.m_237115_("menu.online"), (p_210872_) -> { this.m_96793_(); - }, button$ontooltip))).f_93623_ = flag; +- }).m_252987_(this.f_96543_ / 2 - 100, p_96764_ + p_96765_ * 2, 200, 20).m_257505_(tooltip).m_253136_())).f_93623_ = flag; ++ }).m_252987_(this.f_96543_ / 2 + 2, p_96764_ + p_96765_ * 2, 98, 20).m_257505_(tooltip).m_253136_())).f_93623_ = flag; } -@@ -310,6 +_,7 @@ + + @Nullable +@@ -267,6 +_,7 @@ this.f_232768_.m_232790_(p_96739_, l); } + net.minecraftforge.client.ForgeHooksClient.renderMainMenu(this, p_96739_, this.f_96547_, this.f_96543_, this.f_96544_, l); if (this.f_96721_ != null) { p_96739_.m_85836_(); - p_96739_.m_85837_((double)(this.f_96543_ / 2 + 90), 70.0D, 0.0D); -@@ -332,7 +_,14 @@ + p_96739_.m_252880_((float)(this.f_96543_ / 2 + 90), 70.0F, 0.0F); +@@ -289,7 +_,14 @@ s = s + I18n.m_118938_("menu.modded"); } @@ -58,11 +57,11 @@ for(GuiEventListener guieventlistener : this.m_6702_()) { if (guieventlistener instanceof AbstractWidget) { -@@ -345,6 +_,7 @@ +@@ -302,6 +_,7 @@ RenderSystem.m_69482_(); - this.f_96726_.m_6305_(p_96739_, p_96740_, p_96741_, p_96742_); + this.f_96726_.m_86412_(p_96739_, p_96740_, p_96741_, p_96742_); } -+ if (f1 >= 1.0f) modUpdateNotification.m_6305_(p_96739_, p_96740_, p_96741_, p_96742_); ++ if (f1 >= 1.0f) modUpdateNotification.m_86412_(p_96739_, p_96740_, p_96741_, p_96742_); } } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch index 8412f7b554..788213ac72 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch @@ -8,7 +8,7 @@ public AdvancementsScreen(ClientAdvancements p_97340_) { super(GameNarrator.f_93310_); -@@ -57,7 +_,13 @@ +@@ -57,7 +_,15 @@ } else { this.f_97334_.m_104401_(this.f_97336_ == null ? null : this.f_97336_.m_97182_(), true); } @@ -16,8 +16,10 @@ + if (this.f_97335_.size() > AdvancementTabType.MAX_TABS) { + int guiLeft = (this.f_96543_ - 252) / 2; + int guiTop = (this.f_96544_ - 140) / 2; -+ m_142416_(new net.minecraft.client.gui.components.Button(guiLeft, guiTop - 50, 20, 20, Component.m_237113_("<"), b -> tabPage = Math.max(tabPage - 1, 0 ))); -+ m_142416_(new net.minecraft.client.gui.components.Button(guiLeft + 252 - 20, guiTop - 50, 20, 20, Component.m_237113_(">"), b -> tabPage = Math.min(tabPage + 1, maxPages))); ++ m_142416_(net.minecraft.client.gui.components.Button.m_253074_(Component.m_237113_("<"), b -> tabPage = Math.max(tabPage - 1, 0 )) ++ .m_252794_(guiLeft, guiTop - 50).m_253046_(20, 20).m_253136_()); ++ m_142416_(net.minecraft.client.gui.components.Button.m_253074_(Component.m_237113_(">"), b -> tabPage = Math.min(tabPage + 1, maxPages)) ++ .m_252794_(guiLeft + f_169556_ - 20, guiTop - 50).m_253046_(20, 20).m_253136_()); + maxPages = this.f_97335_.size() / AdvancementTabType.MAX_TABS; + } } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsList.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsList.java.patch index f18b1aadd6..1f77eda1ab 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsList.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/controls/KeyBindsList.java +++ b/net/minecraft/client/gui/screens/controls/KeyBindsList.java -@@ -51,7 +_,7 @@ +@@ -50,7 +_,7 @@ } protected int m_5756_() { @@ -9,34 +9,30 @@ } public int m_5759_() { -@@ -107,7 +_,7 @@ - KeyEntry(final KeyMapping p_193916_, final Component p_193917_) { - this.f_193910_ = p_193916_; +@@ -108,10 +_,11 @@ this.f_193911_ = p_193917_; -- this.f_193912_ = new Button(0, 0, 75, 20, p_193917_, (p_193939_) -> { -+ this.f_193912_ = new Button(0, 0, 75 + 20 /* Forge: Add space */, 20, p_193917_, (p_193939_) -> { + this.f_193912_ = Button.m_253074_(p_193917_, (p_193939_) -> { KeyBindsList.this.f_193858_.f_193975_ = p_193916_; - }) { - protected MutableComponent m_5646_() { -@@ -115,6 +_,7 @@ - } - }; - this.f_193913_ = new Button(0, 0, 50, 20, Component.m_237115_("controls.reset"), (p_193935_) -> { +- }).m_252987_(0, 0, 75, 20).m_252778_((p_253311_) -> { ++ }).m_252987_(0, 0, 75 + 20 /* Forge: Add space */, 20).m_252778_((p_253311_) -> { + return p_193916_.m_90862_() ? Component.m_237110_("narrator.controls.unbound", p_193917_) : Component.m_237110_("narrator.controls.bound", p_193917_, p_253311_.get()); + }).m_253136_(); + this.f_193913_ = Button.m_253074_(Component.m_237115_("controls.reset"), (p_193935_) -> { + this.f_193910_.setToDefault(); KeyBindsList.this.f_93386_.f_91066_.m_92159_(p_193916_, p_193916_.m_90861_()); KeyMapping.m_90854_(); - }) { -@@ -128,7 +_,7 @@ + }).m_252987_(0, 0, 50, 20).m_252778_((p_253313_) -> { +@@ -123,7 +_,7 @@ boolean flag = KeyBindsList.this.f_193858_.f_193975_ == this.f_193910_; float f = (float)(p_193926_ + 90 - KeyBindsList.this.f_193859_); KeyBindsList.this.f_93386_.f_91062_.m_92889_(p_193923_, this.f_193911_, f, (float)(p_193925_ + p_193928_ / 2 - 9 / 2), 16777215); -- this.f_193913_.f_93620_ = p_193926_ + 190; -+ this.f_193913_.f_93620_ = p_193926_ + 190 + 20; - this.f_193913_.f_93621_ = p_193925_; +- this.f_193913_.m_252865_(p_193926_ + 190); ++ this.f_193913_.m_252865_(p_193926_ + 190 + 20); + this.f_193913_.m_252888_(p_193925_); this.f_193913_.f_93623_ = !this.f_193910_.m_90864_(); - this.f_193913_.m_6305_(p_193923_, p_193929_, p_193930_, p_193932_); -@@ -136,11 +_,12 @@ - this.f_193912_.f_93621_ = p_193925_; + this.f_193913_.m_86412_(p_193923_, p_193929_, p_193930_, p_193932_); +@@ -131,11 +_,12 @@ + this.f_193912_.m_252888_(p_193925_); this.f_193912_.m_93666_(this.f_193910_.m_90863_()); boolean flag1 = false; + boolean keyCodeModifierConflict = true; // gracefully handle conflicts like SHIFT vs SHIFT+G @@ -49,7 +45,7 @@ } } } -@@ -148,7 +_,7 @@ +@@ -143,7 +_,7 @@ if (flag) { this.f_193912_.m_93666_(Component.m_237113_("> ").m_7220_(this.f_193912_.m_6035_().m_6881_().m_130940_(ChatFormatting.YELLOW)).m_130946_(" <").m_130940_(ChatFormatting.YELLOW)); } else if (flag1) { @@ -57,4 +53,4 @@ + this.f_193912_.m_93666_(this.f_193912_.m_6035_().m_6881_().m_130940_(keyCodeModifierConflict ? ChatFormatting.GOLD : ChatFormatting.RED)); } - this.f_193912_.m_6305_(p_193923_, p_193929_, p_193930_, p_193932_); + this.f_193912_.m_86412_(p_193923_, p_193929_, p_193930_, p_193932_); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java.patch index 5a0a9bd0cb..a3102196d1 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java @@ -31,7 +_,7 @@ this.m_7787_(this.f_193977_); - this.f_193978_ = this.m_142416_(new Button(this.f_96543_ / 2 - 155, this.f_96544_ - 29, 150, 20, Component.m_237115_("controls.resetAll"), (p_193999_) -> { + this.f_193978_ = this.m_142416_(Button.m_253074_(Component.m_237115_("controls.resetAll"), (p_193999_) -> { for(KeyMapping keymapping : this.f_96282_.f_92059_) { - keymapping.m_90848_(keymapping.m_90861_()); + keymapping.setToDefault(); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch index ba3a8b0fdd..238674d467 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java +++ b/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java -@@ -90,6 +_,7 @@ +@@ -89,6 +_,7 @@ int i = this.f_97735_; int j = this.f_97736_; this.m_7286_(p_97795_, p_97798_, p_97796_, p_97797_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ContainerScreenEvent.Render.Background(this, p_97795_, p_97796_, p_97797_)); RenderSystem.m_69465_(); - super.m_6305_(p_97795_, p_97796_, p_97797_, p_97798_); + super.m_86412_(p_97795_, p_97796_, p_97797_, p_97798_); PoseStack posestack = RenderSystem.m_157191_(); -@@ -111,11 +_,12 @@ +@@ -110,11 +_,12 @@ this.f_97734_ = slot; int l = slot.f_40220_; int i1 = slot.f_40221_; @@ -22,7 +22,7 @@ ItemStack itemstack = this.f_97711_.m_41619_() ? this.f_97732_.m_142621_() : this.f_97711_; if (!itemstack.m_41619_()) { int l1 = 8; -@@ -155,9 +_,13 @@ +@@ -154,9 +_,13 @@ } public static void m_169606_(PoseStack p_169607_, int p_169608_, int p_169609_, int p_169610_) { @@ -37,7 +37,7 @@ RenderSystem.m_69444_(true, true, true, true); RenderSystem.m_69482_(); } -@@ -175,8 +_,10 @@ +@@ -174,8 +_,10 @@ RenderSystem.m_157182_(); this.m_93250_(200); this.f_96542_.f_115093_ = 200.0F; @@ -49,7 +49,7 @@ this.m_93250_(0); this.f_96542_.f_115093_ = 0.0F; } -@@ -286,7 +_,8 @@ +@@ -285,7 +_,8 @@ if (super.m_6375_(p_97748_, p_97749_, p_97750_)) { return true; } else { @@ -59,7 +59,7 @@ Slot slot = this.m_97744_(p_97748_, p_97749_); long i = Util.m_137550_(); this.f_97723_ = this.f_97709_ == slot && i - this.f_97721_ < 250L && this.f_97722_ == p_97750_; -@@ -297,6 +_,7 @@ +@@ -296,6 +_,7 @@ int j = this.f_97735_; int k = this.f_97736_; boolean flag1 = this.m_7467_(p_97748_, p_97749_, j, k, p_97750_); @@ -67,7 +67,7 @@ int l = -1; if (slot != null) { l = slot.f_40219_; -@@ -322,7 +_,7 @@ +@@ -321,7 +_,7 @@ } } else if (!this.f_97738_) { if (this.f_97732_.m_142621_().m_41619_()) { @@ -76,7 +76,7 @@ this.m_6597_(slot, l, p_97750_, ClickType.CLONE); } else { boolean flag2 = l != -999 && (InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 340) || InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 344)); -@@ -346,7 +_,7 @@ +@@ -345,7 +_,7 @@ this.f_97717_ = 0; } else if (p_97750_ == 1) { this.f_97717_ = 1; @@ -85,7 +85,7 @@ this.f_97717_ = 2; } } -@@ -415,10 +_,13 @@ +@@ -414,10 +_,13 @@ } public boolean m_6348_(double p_97812_, double p_97813_, int p_97814_) { @@ -99,7 +99,7 @@ int k = -1; if (slot != null) { k = slot.f_40219_; -@@ -432,7 +_,7 @@ +@@ -431,7 +_,7 @@ if (m_96638_()) { if (!this.f_97724_.m_41619_()) { for(Slot slot2 : this.f_97732_.f_38839_) { @@ -108,7 +108,7 @@ this.m_6597_(slot2, slot2.f_40219_, p_97814_, ClickType.QUICK_MOVE); } } -@@ -495,7 +_,7 @@ +@@ -494,7 +_,7 @@ this.m_6597_((Slot)null, -999, AbstractContainerMenu.m_38930_(2, this.f_97717_), ClickType.QUICK_CRAFT); } else if (!this.f_97732_.m_142621_().m_41619_()) { @@ -117,7 +117,7 @@ this.m_6597_(slot, k, p_97814_, ClickType.CLONE); } else { boolean flag1 = k != -999 && (InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 340) || InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 344)); -@@ -542,34 +_,39 @@ +@@ -541,34 +_,39 @@ } public boolean m_7933_(int p_97765_, int p_97766_, int p_97767_) { @@ -164,7 +164,7 @@ this.m_6597_(this.f_97734_, this.f_97734_.f_40219_, i, ClickType.SWAP); return true; } -@@ -604,6 +_,18 @@ +@@ -603,6 +_,18 @@ public T m_6262_() { return this.f_97732_; diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch index 45f04894d5..cd945de559 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch @@ -1,257 +1,271 @@ --- a/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java +++ b/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java -@@ -72,6 +_,8 @@ - private Slot f_98512_; - private CreativeInventoryListener f_98513_; - private boolean f_98514_; -+ private static int tabPage = 0; -+ private int maxPages = 0; +@@ -75,6 +_,8 @@ private boolean f_98515_; private final Set> f_98516_ = new HashSet<>(); + private final boolean f_256872_; ++ private final List pages = new java.util.ArrayList<>(); ++ private net.minecraftforge.client.gui.CreativeTabsScreenPage currentPage = new net.minecraftforge.client.gui.CreativeTabsScreenPage(new java.util.ArrayList<>()); -@@ -231,6 +_,12 @@ + public CreativeModeInventoryScreen(Player p_259788_, FeatureFlagSet p_260074_, boolean p_259569_) { + super(new CreativeModeInventoryScreen.ItemPickerMenu(p_259788_), p_259788_.m_150109_(), CommonComponents.f_237098_); +@@ -109,7 +_,7 @@ + private void m_257687_(Collection p_261591_) { + int i = this.f_97732_.m_257485_(this.f_98508_); + (this.f_97732_).f_98639_.clear(); +- if (f_98507_.m_257962_() == CreativeModeTab.Type.SEARCH) { ++ if (f_98507_.hasSearchBar()) { + this.m_98630_(); + } else { + (this.f_97732_).f_98639_.addAll(p_261591_); +@@ -273,6 +_,30 @@ protected void m_7856_() { if (this.f_96541_.f_91072_.m_105290_()) { super.m_7856_(); -+ int tabCount = CreativeModeTab.f_40748_.length; -+ if (tabCount > 12) { -+ m_142416_(new net.minecraft.client.gui.components.Button(f_97735_, f_97736_ - 50, 20, 20, Component.m_237113_("<"), b -> tabPage = Math.max(tabPage - 1, 0 ))); -+ m_142416_(new net.minecraft.client.gui.components.Button(f_97735_ + f_97726_ - 20, f_97736_ - 50, 20, 20, Component.m_237113_(">"), b -> tabPage = Math.min(tabPage + 1, maxPages))); -+ maxPages = (int) Math.ceil((tabCount - 12) / 10D); ++ this.pages.clear(); ++ int tabIndex = 0; ++ List currentPage = new java.util.ArrayList<>(); ++ for (CreativeModeTab sortedCreativeModeTab : net.minecraftforge.common.CreativeModeTabRegistry.getSortedCreativeModeTabs()) { ++ currentPage.add(sortedCreativeModeTab); ++ tabIndex++; ++ if (tabIndex == 10) { ++ this.pages.add(new net.minecraftforge.client.gui.CreativeTabsScreenPage(currentPage)); ++ currentPage = new java.util.ArrayList<>(); ++ tabIndex = 0; ++ } ++ } ++ if (tabIndex != 0) { ++ this.pages.add(new net.minecraftforge.client.gui.CreativeTabsScreenPage(currentPage)); ++ } ++ if (this.pages.isEmpty()) { ++ this.currentPage = new net.minecraftforge.client.gui.CreativeTabsScreenPage(new java.util.ArrayList<>()); ++ } else { ++ this.currentPage = this.pages.get(0); ++ } ++ if (this.pages.size() > 1) { ++ m_142416_(net.minecraft.client.gui.components.Button.m_253074_(Component.m_237113_("<"), b -> setCurrentPage(this.pages.get(Math.max(this.pages.indexOf(this.currentPage) - 1, 0)))).m_252794_(f_97735_, f_97736_ - 50).m_253046_(20, 20).m_253136_()); ++ m_142416_(net.minecraft.client.gui.components.Button.m_253074_(Component.m_237113_(">"), b -> setCurrentPage(this.pages.get(Math.min(this.pages.indexOf(this.currentPage) + 1, this.pages.size() - 1)))).m_252794_(f_97735_ + f_97726_ - 20, f_97736_ - 50).m_253046_(20, 20).m_253136_()); + } - this.f_96541_.f_91068_.m_90926_(true); this.f_98510_ = new EditBox(this.f_96547_, this.f_97735_ + 82, this.f_97736_ + 6, 80, 9, Component.m_237115_("itemGroup.search")); this.f_98510_.m_94199_(50); -@@ -272,7 +_,7 @@ + this.f_98510_.m_94182_(false); +@@ -318,7 +_,7 @@ public boolean m_5534_(char p_98521_, int p_98522_) { if (this.f_98514_) { return false; -- } else if (f_98507_ != CreativeModeTab.f_40754_.m_40775_()) { -+ } else if (!CreativeModeTab.f_40748_[f_98507_].hasSearchBar()) { +- } else if (f_98507_.m_257962_() != CreativeModeTab.Type.SEARCH) { ++ } else if (!f_98507_.hasSearchBar()) { return false; } else { String s = this.f_98510_.m_94155_(); -@@ -290,7 +_,7 @@ +@@ -336,7 +_,7 @@ public boolean m_7933_(int p_98547_, int p_98548_, int p_98549_) { this.f_98514_ = false; -- if (f_98507_ != CreativeModeTab.f_40754_.m_40775_()) { -+ if (!CreativeModeTab.f_40748_[f_98507_].hasSearchBar()) { +- if (f_98507_.m_257962_() != CreativeModeTab.Type.SEARCH) { ++ if (!f_98507_.hasSearchBar()) { if (this.f_96541_.f_91066_.f_92098_.m_90832_(p_98547_, p_98548_)) { this.f_98514_ = true; - this.m_98560_(CreativeModeTab.f_40754_); -@@ -327,6 +_,32 @@ + this.m_98560_(CreativeModeTabs.m_258007_()); +@@ -371,6 +_,7 @@ + } + private void m_98630_() { ++ if (!f_98507_.hasSearchBar()) return; (this.f_97732_).f_98639_.clear(); this.f_98516_.clear(); -+ -+ CreativeModeTab tab = CreativeModeTab.f_40748_[f_98507_]; -+ if (tab.hasSearchBar() && tab != CreativeModeTab.f_40754_) { -+ tab.m_6151_(f_97732_.f_98639_); -+ if (!this.f_98510_.m_94155_().isEmpty()) { -+ //TODO: Make this a SearchTree not a manual search -+ String search = this.f_98510_.m_94155_().toLowerCase(Locale.ROOT); -+ java.util.Iterator itr = f_97732_.f_98639_.iterator(); -+ while (itr.hasNext()) { -+ ItemStack stack = itr.next(); -+ boolean matches = false; -+ for (Component line : stack.m_41651_(this.f_96541_.f_91074_, this.f_96541_.f_91066_.f_92125_ ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL)) { -+ if (ChatFormatting.m_126649_(line.getString()).toLowerCase(Locale.ROOT).contains(search)) { -+ matches = true; -+ break; -+ } -+ } -+ if (!matches) -+ itr.remove(); -+ } -+ } -+ this.f_98508_ = 0.0F; -+ f_97732_.m_98642_(0.0F); -+ return; -+ } -+ String s = this.f_98510_.m_94155_(); - if (s.isEmpty()) { - for(Item item : Registry.f_122827_) { -@@ -371,9 +_,9 @@ +@@ -380,10 +_,10 @@ + SearchTree searchtree; + if (s.startsWith("#")) { + s = s.substring(1); +- searchtree = this.f_96541_.m_231372_(SearchRegistry.f_119942_); ++ searchtree = this.f_96541_.m_231372_(net.minecraftforge.client.CreativeModeTabSearchRegistry.getNameSearchKey(f_98507_)); + this.m_98619_(s); + } else { +- searchtree = this.f_96541_.m_231372_(SearchRegistry.f_119941_); ++ searchtree = this.f_96541_.m_231372_(net.minecraftforge.client.CreativeModeTabSearchRegistry.getTagSearchKey(f_98507_)); + } + (this.f_97732_).f_98639_.addAll(searchtree.m_6293_(s.toLowerCase(Locale.ROOT))); +@@ -416,7 +_,7 @@ protected void m_7027_(PoseStack p_98616_, int p_98617_, int p_98618_) { - CreativeModeTab creativemodetab = CreativeModeTab.f_40748_[f_98507_]; -- if (creativemodetab.m_40789_()) { -+ if (creativemodetab != null && creativemodetab.m_40789_()) { + if (f_98507_.m_40789_()) { RenderSystem.m_69461_(); -- this.f_96547_.m_92889_(p_98616_, creativemodetab.m_40786_(), 8.0F, 6.0F, 4210752); -+ this.f_96547_.m_92889_(p_98616_, creativemodetab.m_40786_(), 8.0F, 6.0F, creativemodetab.getLabelColor()); +- this.f_96547_.m_92889_(p_98616_, f_98507_.m_40786_(), 8.0F, 6.0F, 4210752); ++ this.f_96547_.m_92889_(p_98616_, f_98507_.m_40786_(), 8.0F, 6.0F, f_98507_.getLabelColor()); } } -@@ -384,7 +_,7 @@ +@@ -426,7 +_,7 @@ + double d0 = p_98531_ - (double)this.f_97735_; double d1 = p_98532_ - (double)this.f_97736_; - for(CreativeModeTab creativemodetab : CreativeModeTab.f_40748_) { -- if (this.m_98562_(creativemodetab, d0, d1)) { -+ if (creativemodetab != null && this.m_98562_(creativemodetab, d0, d1)) { +- for(CreativeModeTab creativemodetab : CreativeModeTabs.m_257388_()) { ++ for(CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) { + if (this.m_98562_(creativemodetab, d0, d1)) { return true; } - } -@@ -405,7 +_,7 @@ +@@ -447,7 +_,7 @@ + double d1 = p_98623_ - (double)this.f_97736_; this.f_98509_ = false; - for(CreativeModeTab creativemodetab : CreativeModeTab.f_40748_) { -- if (this.m_98562_(creativemodetab, d0, d1)) { -+ if (creativemodetab != null && this.m_98562_(creativemodetab, d0, d1)) { +- for(CreativeModeTab creativemodetab : CreativeModeTabs.m_257388_()) { ++ for(CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) { + if (this.m_98562_(creativemodetab, d0, d1)) { this.m_98560_(creativemodetab); return true; - } -@@ -416,12 +_,15 @@ - } - - private boolean m_98631_() { -+ if (CreativeModeTab.f_40748_[f_98507_] == null) return false; - return f_98507_ != CreativeModeTab.f_40761_.m_40775_() && CreativeModeTab.f_40748_[f_98507_].m_40791_() && this.f_97732_.m_98654_(); - } - +@@ -465,6 +_,7 @@ private void m_98560_(CreativeModeTab p_98561_) { -+ if (p_98561_ == null) return; - int i = f_98507_; - f_98507_ = p_98561_.m_40775_(); + CreativeModeTab creativemodetab = f_98507_; + f_98507_ = p_98561_; + slotColor = p_98561_.getSlotColor(); this.f_97737_.clear(); (this.f_97732_).f_98639_.clear(); this.m_238391_(); -@@ -499,13 +_,15 @@ +@@ -541,13 +_,15 @@ + this.f_98511_ = null; } - if (this.f_98510_ != null) { -- if (p_98561_ == CreativeModeTab.f_40754_) { -+ if (p_98561_.hasSearchBar()) { - this.f_98510_.m_94194_(true); - this.f_98510_.m_94190_(false); - this.f_98510_.m_94178_(true); - if (i != p_98561_.m_40775_()) { - this.f_98510_.m_94144_(""); - } -+ this.f_98510_.m_93674_(p_98561_.getSearchbarWidth()); -+ this.f_98510_.f_93620_ = this.f_97735_ + (82 /*default left*/ + 89 /*default width*/) - this.f_98510_.m_5711_(); +- if (f_98507_.m_257962_() == CreativeModeTab.Type.SEARCH) { ++ if (f_98507_.hasSearchBar()) { + this.f_98510_.m_94194_(true); + this.f_98510_.m_94190_(false); + this.f_98510_.m_94178_(true); + if (creativemodetab != p_98561_) { + this.f_98510_.m_94144_(""); + } ++ this.f_98510_.m_93674_(f_98507_.getSearchBarWidth()); ++ this.f_98510_.m_252865_(this.f_97735_ + (82 /*default left*/ + 89 /*default width*/) - this.f_98510_.m_5711_()); - this.m_98630_(); - } else { -@@ -565,16 +_,34 @@ + this.m_98630_(); + } else { +@@ -604,7 +_,7 @@ this.m_7333_(p_98577_); - super.m_6305_(p_98577_, p_98578_, p_98579_, p_98580_); + super.m_86412_(p_98577_, p_98578_, p_98579_, p_98580_); -- for(CreativeModeTab creativemodetab : CreativeModeTab.f_40748_) { -- if (this.m_98584_(p_98577_, creativemodetab, p_98578_, p_98579_)) { -+ int start = tabPage * 10; -+ int end = Math.min(CreativeModeTab.f_40748_.length, ((tabPage + 1) * 10) + 2); -+ if (tabPage != 0) start += 2; -+ boolean rendered = false; -+ -+ for (int x = start; x < end; x++) { -+ CreativeModeTab creativemodetab = CreativeModeTab.f_40748_[x]; -+ if (creativemodetab != null && this.m_98584_(p_98577_, creativemodetab, p_98578_, p_98579_)) { -+ rendered = true; +- for(CreativeModeTab creativemodetab : CreativeModeTabs.m_257388_()) { ++ for(CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) { + if (this.m_98584_(p_98577_, creativemodetab, p_98578_, p_98579_)) { break; } - } -+ if (!rendered && !this.m_98584_(p_98577_, CreativeModeTab.f_40754_, p_98578_, p_98579_)) -+ this.m_98584_(p_98577_, CreativeModeTab.f_40761_, p_98578_, p_98579_); - - if (this.f_98512_ != null && f_98507_ == CreativeModeTab.f_40761_.m_40775_() && this.m_6774_(this.f_98512_.f_40220_, this.f_98512_.f_40221_, 16, 16, (double)p_98578_, (double)p_98579_)) { +@@ -614,6 +_,15 @@ this.m_96602_(p_98577_, f_98506_, p_98578_, p_98579_); } -+ if (maxPages != 0) { -+ Component page = Component.m_237113_(String.format("%d / %d", tabPage + 1, maxPages + 1)); -+ this.m_93250_(300); -+ this.f_96542_.f_115093_ = 300.0F; -+ f_96547_.m_92744_(p_98577_, page.m_7532_(), f_97735_ + (f_97726_ / 2) - (f_96547_.m_92852_(page) / 2), f_97736_ - 44, -1); -+ this.m_93250_(0); -+ this.f_96542_.f_115093_ = 0.0F; ++ if (this.pages.size() != 1) { ++ Component page = Component.m_237113_(String.format("%d / %d", this.pages.indexOf(this.currentPage) + 1, this.pages.size())); ++ this.m_93250_(300); ++ this.f_96542_.f_115093_ = 300.0F; ++ f_96547_.m_92744_(p_98577_, page.m_7532_(), f_97735_ + (f_97726_ / 2f) - (f_96547_.m_92852_(page) / 2f), f_97736_ - 44, -1); ++ this.m_93250_(0); ++ this.f_96542_.f_115093_ = 0.0F; + } + RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); this.m_7025_(p_98577_, p_98578_, p_98579_); } -@@ -609,7 +_,7 @@ - list1.add(1, creativemodetab.m_40786_().m_6881_().m_130940_(ChatFormatting.BLUE)); - } +@@ -621,7 +_,7 @@ + protected void m_6057_(PoseStack p_98590_, ItemStack p_98591_, int p_98592_, int p_98593_) { + boolean flag = this.f_97734_ != null && this.f_97734_ instanceof CreativeModeInventoryScreen.CustomCreativeSlot; + boolean flag1 = f_98507_.m_257962_() == CreativeModeTab.Type.CATEGORY; +- boolean flag2 = f_98507_.m_257962_() == CreativeModeTab.Type.SEARCH; ++ boolean flag2 = f_98507_.hasSearchBar(); + TooltipFlag.Default tooltipflag$default = this.f_96541_.f_91066_.f_92125_ ? TooltipFlag.Default.f_256730_ : TooltipFlag.Default.f_256752_; + TooltipFlag tooltipflag = flag ? tooltipflag$default.m_257777_() : tooltipflag$default; + List list = p_98591_.m_41651_(this.f_96541_.f_91074_, tooltipflag); +@@ -641,8 +_,8 @@ -- this.m_169388_(p_98590_, list1, p_98591_.m_150921_(), p_98592_, p_98593_); -+ this.renderTooltip(p_98590_, list1, p_98591_.m_150921_(), p_98592_, p_98593_, p_98591_); - } else { - super.m_6057_(p_98590_, p_98591_, p_98592_, p_98593_); - } -@@ -620,16 +_,32 @@ + int i = 1; + +- for(CreativeModeTab creativemodetab : CreativeModeTabs.m_257388_()) { +- if (creativemodetab.m_257962_() != CreativeModeTab.Type.SEARCH && creativemodetab.m_257694_(p_98591_)) { ++ for(CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) { ++ if (!creativemodetab.hasSearchBar() && creativemodetab.m_257694_(p_98591_)) { + list1.add(i++, creativemodetab.m_40786_().m_6881_().m_130940_(ChatFormatting.BLUE)); + } + } +@@ -654,7 +_,7 @@ + protected void m_7286_(PoseStack p_98572_, float p_98573_, int p_98574_, int p_98575_) { RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); - CreativeModeTab creativemodetab = CreativeModeTab.f_40748_[f_98507_]; -- for(CreativeModeTab creativemodetab1 : CreativeModeTab.f_40748_) { -+ int start = tabPage * 10; -+ int end = Math.min(CreativeModeTab.f_40748_.length, ((tabPage + 1) * 10 + 2)); -+ if (tabPage != 0) start += 2; -+ -+ for (int idx = start; idx < end; idx++) { +- for(CreativeModeTab creativemodetab : CreativeModeTabs.m_257388_()) { ++ for(CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) { RenderSystem.m_157427_(GameRenderer::m_172817_); -- RenderSystem.m_157456_(0, f_98504_); -- if (creativemodetab1.m_40775_() != f_98507_) { -+ CreativeModeTab creativemodetab1 = CreativeModeTab.f_40748_[idx]; -+ if (creativemodetab1 != null && creativemodetab1.m_40775_() != f_98507_) { -+ RenderSystem.m_157456_(0, creativemodetab1.getTabsImage()); - this.m_98581_(p_98572_, creativemodetab1); - } + RenderSystem.m_157456_(0, f_98504_); + if (creativemodetab != f_98507_) { +@@ -663,7 +_,7 @@ } RenderSystem.m_157427_(GameRenderer::m_172817_); -- RenderSystem.m_157456_(0, new ResourceLocation("textures/gui/container/creative_inventory/tab_" + creativemodetab.m_40788_())); -+ if (tabPage != 0) { -+ if (creativemodetab != CreativeModeTab.f_40754_) { -+ RenderSystem.m_157456_(0, CreativeModeTab.f_40754_.getTabsImage()); -+ m_98581_(p_98572_, CreativeModeTab.f_40754_); -+ } -+ if (creativemodetab != CreativeModeTab.f_40761_) { -+ RenderSystem.m_157456_(0, CreativeModeTab.f_40761_.getTabsImage()); -+ m_98581_(p_98572_, CreativeModeTab.f_40761_); -+ } -+ } -+ -+ RenderSystem.m_157456_(0, creativemodetab.getBackgroundImage()); +- RenderSystem.m_157456_(0, new ResourceLocation("textures/gui/container/creative_inventory/tab_" + f_98507_.m_40788_())); ++ RenderSystem.m_157456_(0, f_98507_.getBackgroundLocation()); this.m_93228_(p_98572_, this.f_97735_, this.f_97736_, 0, 0, this.f_97726_, this.f_97727_); - this.f_98510_.m_6305_(p_98572_, p_98574_, p_98575_, p_98573_); + this.f_98510_.m_86412_(p_98572_, p_98574_, p_98575_, p_98573_); RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); -@@ -637,11 +_,14 @@ - int j = this.f_97736_ + 18; - int k = j + 112; +@@ -671,7 +_,7 @@ + int k = this.f_97736_ + 18; + int i = k + 112; RenderSystem.m_157427_(GameRenderer::m_172817_); - RenderSystem.m_157456_(0, f_98504_); -+ RenderSystem.m_157456_(0, creativemodetab.getTabsImage()); - if (creativemodetab.m_40791_()) { - this.m_93228_(p_98572_, i, j + (int)((float)(k - j - 17) * this.f_98508_), 232 + (this.m_98631_() ? 0 : 12), 0, 12, 15); ++ RenderSystem.m_157456_(0, f_98507_.getTabsImage()); + if (f_98507_.m_40791_()) { + this.m_93228_(p_98572_, j, k + (int)((float)(i - k - 17) * this.f_98508_), 232 + (this.m_98631_() ? 0 : 12), 0, 12, 15); } - -+ if ((creativemodetab == null || creativemodetab.getTabPage() != tabPage) && (creativemodetab != CreativeModeTab.f_40754_ && creativemodetab != CreativeModeTab.f_40761_)) -+ return; -+ - this.m_98581_(p_98572_, creativemodetab); - if (creativemodetab == CreativeModeTab.f_40761_) { - InventoryScreen.m_98850_(this.f_97735_ + 88, this.f_97736_ + 45, 20, (float)(this.f_97735_ + 88 - p_98574_), (float)(this.f_97736_ + 45 - 30 - p_98575_), this.f_96541_.f_91074_); -@@ -650,6 +_,7 @@ +@@ -684,7 +_,7 @@ } - protected boolean m_98562_(CreativeModeTab p_98563_, double p_98564_, double p_98565_) { -+ if (p_98563_.getTabPage() != tabPage && p_98563_ != CreativeModeTab.f_40754_ && p_98563_ != CreativeModeTab.f_40761_) return false; - int i = p_98563_.m_40793_(); - int j = 28 * i; + private int m_258094_(CreativeModeTab p_260136_) { +- int i = p_260136_.m_257903_(); ++ int i = currentPage.getColumn(p_260136_); + int j = 27; + int k = 27 * i; + if (p_260136_.m_6563_()) { +@@ -696,7 +_,7 @@ + + private int m_257995_(CreativeModeTab p_260181_) { + int i = 0; +- if (p_260181_.m_258064_() == CreativeModeTab.Row.TOP) { ++ if (currentPage.isTop(p_260181_)) { + i -= 32; + } else { + i += this.f_97727_; +@@ -724,8 +_,8 @@ + + protected void m_98581_(PoseStack p_98582_, CreativeModeTab p_98583_) { + boolean flag = p_98583_ == f_98507_; +- boolean flag1 = p_98583_.m_258064_() == CreativeModeTab.Row.TOP; +- int i = p_98583_.m_257903_(); ++ boolean flag1 = currentPage.isTop(p_98583_); ++ int i = currentPage.getColumn(p_98583_); + int j = i * 26; int k = 0; -@@ -718,6 +_,7 @@ + int l = this.f_97735_ + this.m_258094_(p_98583_); +@@ -742,6 +_,7 @@ i1 += this.f_97727_ - 4; } + RenderSystem.m_69478_(); //Forge: Make sure blend is enabled else tabs show a white border. - this.m_93228_(p_98582_, l, i1, j, k, 28, 32); + this.m_93228_(p_98582_, l, i1, j, k, 26, 32); this.f_96542_.f_115093_ = 100.0F; - l += 6; -@@ -909,6 +_,22 @@ + l += 5; +@@ -784,6 +_,15 @@ + + } + ++ public net.minecraftforge.client.gui.CreativeTabsScreenPage getCurrentPage() { ++ return currentPage; ++ } ++ ++ public void setCurrentPage(net.minecraftforge.client.gui.CreativeTabsScreenPage currentPage) { ++ this.currentPage = currentPage; ++ this.m_98560_(currentPage.getDefaultTab()); ++ } ++ + @OnlyIn(Dist.CLIENT) + static class CustomCreativeSlot extends Slot { + public CustomCreativeSlot(Container p_98633_, int p_98634_, int p_98635_, int p_98636_) { +@@ -947,6 +_,22 @@ public boolean m_8010_(Player p_98665_) { return this.f_98655_.m_8010_(p_98665_); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch index 499b25c72d..3fd50f982b 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch @@ -30,7 +30,7 @@ + } MobEffect mobeffect = mobeffectinstance.m_19544_(); TextureAtlasSprite textureatlassprite = mobeffecttexturemanager.m_118732_(mobeffect); - RenderSystem.m_157456_(0, textureatlassprite.m_118414_().m_118330_()); + RenderSystem.m_157456_(0, textureatlassprite.m_247685_()); @@ -108,6 +_,11 @@ int i = this.f_97736_; diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch index e79bb5c649..5b535dc91b 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java +++ b/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java -@@ -150,7 +_,7 @@ +@@ -147,7 +_,7 @@ int i2 = 86 - this.f_96547_.m_92895_(s); FormattedText formattedtext = EnchantmentNames.m_98734_().m_98737_(this.f_96547_, i2); int j2 = 6839882; @@ -9,7 +9,7 @@ this.m_93228_(p_98762_, j1, j + 14 + 19 * i1, 0, 185, 108, 19); this.m_93228_(p_98762_, j1 + 1, j + 15 + 19 * i1, 16 * i1, 239, 16, 16); this.f_96547_.m_92857_(formattedtext, k1, j + 16 + 19 * i1, i2, (j2 & 16711422) >> 1); -@@ -189,10 +_,13 @@ +@@ -186,10 +_,13 @@ Enchantment enchantment = Enchantment.m_44697_((this.f_97732_).f_39447_[j]); int l = (this.f_97732_).f_39448_[j]; int i1 = j + 1; diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/InventoryScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/InventoryScreen.java.patch index 6eb248aec6..e712f70d84 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/InventoryScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/InventoryScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/InventoryScreen.java +++ b/net/minecraft/client/gui/screens/inventory/InventoryScreen.java -@@ -100,6 +_,11 @@ +@@ -99,6 +_,11 @@ public static void m_98850_(int p_98851_, int p_98852_, int p_98853_, float p_98854_, float p_98855_, LivingEntity p_98856_) { float f = (float)Math.atan((double)(p_98854_ / 40.0F)); float f1 = (float)Math.atan((double)(p_98855_ / 40.0F)); @@ -11,4 +11,4 @@ + float f1 = angleYComponent; PoseStack posestack = RenderSystem.m_157191_(); posestack.m_85836_(); - posestack.m_85837_((double)p_98851_, (double)p_98852_, 1050.0D); + posestack.m_252880_((float)p_98851_, (float)p_98852_, 1050.0F); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch index 6971e2db4b..505948d5be 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch @@ -9,7 +9,7 @@ + PoseStack posestack = new PoseStack(); + posestack.m_85837_(0.0D, 0.0D, (f_96542_.f_115093_ + 200.0F)); + net.minecraft.client.renderer.MultiBufferSource.BufferSource bufferSource = net.minecraft.client.renderer.MultiBufferSource.m_109898_(com.mojang.blaze3d.vertex.Tesselator.m_85913_().m_85915_()); -+ f_96547_.m_92811_(String.valueOf(p_99164_.m_41613_()), (p_99166_ + 14) + 19 - 2 - f_96547_.m_92895_(String.valueOf(p_99164_.m_41613_())), p_99167_ + 6 + 3, 0xFFFFFF, true, posestack.m_85850_().m_85861_(), bufferSource, false, 0, 15728880); ++ f_96547_.m_252905_(String.valueOf(p_99164_.m_41613_()), (p_99166_ + 14) + 19 - 2 - f_96547_.m_92895_(String.valueOf(p_99164_.m_41613_())), p_99167_ + 6 + 3, 0xFFFFFF, true, posestack.m_85850_().m_252922_(), bufferSource, false, 0, 15728880); + bufferSource.m_109911_(); RenderSystem.m_157427_(GameRenderer::m_172817_); RenderSystem.m_157456_(0, f_99113_); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch index 22842acb97..fdd1788d0e 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java +++ b/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java -@@ -263,6 +_,11 @@ +@@ -259,6 +_,11 @@ } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch index ec662d3d9c..622c50a811 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java +++ b/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java -@@ -137,7 +_,7 @@ - +@@ -130,7 +_,7 @@ private void m_100013_(TransferableSelectionList p_100014_, Stream p_100015_) { p_100014_.m_6702_().clear(); + p_100014_.m_6987_((TransferableSelectionList.PackEntry)null); - p_100015_.forEach((p_170000_) -> { + p_100015_.filter(PackSelectionModel.Entry::notHidden).forEach((p_170000_) -> { p_100014_.m_6702_().add(new TransferableSelectionList.PackEntry(this.f_96541_, p_100014_, this, p_170000_)); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch index 220e6f093a..cd516dbeaa 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java +++ b/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java -@@ -106,7 +_,7 @@ +@@ -108,7 +_,7 @@ this.m_5674_(); this.f_100279_.clear(); @@ -9,7 +9,7 @@ this.f_100279_.add(new RecipeBookTabButton(recipebookcategories)); } -@@ -318,7 +_,7 @@ +@@ -305,7 +_,7 @@ } if (itemstack != null && this.f_100272_.f_91080_ != null) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch index 6629e48d34..83c681e0c0 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch @@ -1,39 +1,40 @@ --- a/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java +++ b/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java -@@ -112,7 +_,7 @@ +@@ -113,7 +_,8 @@ public static void m_232896_(Minecraft p_232897_, @Nullable Screen p_232898_) { m_232899_(p_232897_, f_232866_); - PackRepository packrepository = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource()); -- WorldLoader.InitConfig worldloader$initconfig = m_232872_(packrepository, DataPackConfig.f_45842_); -+ WorldLoader.InitConfig worldloader$initconfig = m_232872_(packrepository, new DataPackConfig(ImmutableList.of("vanilla"), ImmutableList.of())); // FORGE: Load vanilla fallback with vanilla datapacks. - CompletableFuture completablefuture = WorldLoader.m_214362_(worldloader$initconfig, (p_232935_, p_232936_) -> { - RegistryAccess.Frozen registryaccess$frozen = RegistryAccess.m_206197_().m_203557_(); - WorldGenSettings worldgensettings = WorldPresets.m_226449_(registryaccess$frozen); -@@ -122,7 +_,10 @@ - return new WorldCreationContext(p_232884_, Lifecycle.stable(), p_232883_, p_232882_); + PackRepository packrepository = new PackRepository(new ServerPacksSource()); +- WorldLoader.InitConfig worldloader$initconfig = m_245574_(packrepository, WorldDataConfiguration.f_244649_); ++ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.event.AddPackFindersEvent(net.minecraft.server.packs.PackType.SERVER_DATA, packrepository::addPackFinder)); ++ WorldLoader.InitConfig worldloader$initconfig = m_245574_(packrepository, new WorldDataConfiguration(new DataPackConfig(ImmutableList.of("vanilla"), ImmutableList.of()), FeatureFlags.f_244332_)); // FORGE: Load vanilla fallback with vanilla datapacks. + CompletableFuture completablefuture = WorldLoader.m_214362_(worldloader$initconfig, (p_247792_) -> { + return new WorldLoader.DataLoadOutput<>(new CreateWorldScreen.DataPackReloadCookie(new WorldGenSettings(WorldOptions.m_247394_(), WorldPresets.m_246552_(p_247792_.f_244104_())), p_247792_.f_244127_()), p_247792_.f_243759_()); + }, (p_247798_, p_247799_, p_247800_, p_247801_) -> { +@@ -121,7 +_,10 @@ + return new WorldCreationContext(p_247801_.f_243966_(), p_247800_, p_247799_, p_247801_.f_243979_()); }, Util.m_183991_(), p_232897_); p_232897_.m_18701_(completablefuture::isDone); -- p_232897_.m_91152_(new CreateWorldScreen(p_232898_, DataPackConfig.f_45842_, new WorldGenSettingsComponent(completablefuture.join(), Optional.of(WorldPresets.f_226437_), OptionalLong.empty()))); +- p_232897_.m_91152_(new CreateWorldScreen(p_232898_, WorldDataConfiguration.f_244649_, new WorldGenSettingsComponent(completablefuture.join(), Optional.of(WorldPresets.f_226437_), OptionalLong.empty()))); + // FORGE: Force load mods' datapacks after setting screen and ensure datapack selection reverts to vanilla if invalid. -+ CreateWorldScreen createWorldScreen = new CreateWorldScreen(p_232898_, new DataPackConfig(ImmutableList.of("vanilla"), ImmutableList.of()), new WorldGenSettingsComponent(completablefuture.join(), Optional.of(WorldPresets.f_226437_), OptionalLong.empty())); ++ CreateWorldScreen createWorldScreen = new CreateWorldScreen(p_232898_, new WorldDataConfiguration(new DataPackConfig(ImmutableList.of("vanilla"), ImmutableList.of()), FeatureFlags.f_244332_), new WorldGenSettingsComponent(completablefuture.join(), Optional.of(WorldPresets.f_226437_), OptionalLong.empty())); + p_232897_.m_91152_(createWorldScreen); + createWorldScreen.m_100878_(packrepository); } - public static CreateWorldScreen m_205426_(@Nullable Screen p_205427_, WorldStem p_205428_, @Nullable Path p_205429_) { -@@ -478,7 +_,7 @@ - if (p_232949_) { - this.m_100975_(); - } else { -- this.f_100846_ = DataPackConfig.f_45842_; -+ this.f_100846_ = new DataPackConfig(ImmutableList.of("vanilla"), ImmutableList.of()); // FORGE: Revert to *actual* vanilla data - this.f_96541_.m_91152_(this); - } + public static CreateWorldScreen m_247077_(@Nullable Screen p_249522_, LevelSettings p_249091_, WorldCreationContext p_249742_, @Nullable Path p_252076_) { +@@ -491,7 +_,7 @@ + if (p_232949_) { + this.m_100975_(); + } else { +- this.f_244371_ = WorldDataConfiguration.f_244649_; ++ this.f_244371_ = new WorldDataConfiguration(new DataPackConfig(ImmutableList.of("vanilla"), ImmutableList.of()), FeatureFlags.f_244332_); // FORGE: Revert to *actual* vanilla data + this.f_96541_.m_91152_(this); + } -@@ -653,6 +_,7 @@ - File file1 = path.toFile(); +@@ -612,6 +_,7 @@ + if (path != null) { if (this.f_100832_ == null) { - this.f_100832_ = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource(), new FolderRepositorySource(file1, PackSource.f_10527_)); + this.f_100832_ = ServerPacksSource.m_245786_(path); + net.minecraftforge.resource.ResourcePackLoader.loadResourcePacks(this.f_100832_, net.minecraftforge.server.ServerLifecycleHooks::buildPackFinder); this.f_100832_.m_10506_(); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch index 179060241f..e913d0929c 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java -@@ -132,13 +_,23 @@ +@@ -158,13 +_,23 @@ } private void m_233145_(Screen p_233146_, String p_233147_, boolean p_233148_, boolean p_233149_) { @@ -12,7 +12,7 @@ + private void doLoadLevel(Screen p_233146_, String p_233147_, boolean p_233148_, boolean p_233149_, boolean confirmExperimentalWarning) { LevelStorageSource.LevelStorageAccess levelstoragesource$levelstorageaccess = this.m_233155_(p_233147_); if (levelstoragesource$levelstorageaccess != null) { - PackRepository packrepository = m_233105_(levelstoragesource$levelstorageaccess); + PackRepository packrepository = ServerPacksSource.m_247728_(levelstoragesource$levelstorageaccess); WorldStem worldstem; try { @@ -22,20 +22,20 @@ + pld.withConfirmedWarning(true); + } } catch (Exception exception) { - f_233088_.warn("Failed to load datapacks, can't proceed with server load", (Throwable)exception); + f_233088_.warn("Failed to load level data or datapacks, can't proceed with server load", (Throwable)exception); this.f_233089_.m_91152_(new DatapackLoadFailureScreen(() -> { -@@ -151,7 +_,9 @@ +@@ -177,7 +_,9 @@ WorldData worlddata = worldstem.f_206895_(); - boolean flag = worlddata.m_5961_().m_64670_(); + boolean flag = worlddata.m_246337_().m_247070_(); boolean flag1 = worlddata.m_5754_() != Lifecycle.stable(); - if (!p_233149_ || !flag && !flag1) { + // Forge: Skip confirmation if it has been done already for this world + boolean skipConfirmation = worlddata instanceof PrimaryLevelData pld && pld.hasConfirmedExperimentalWarning(); + if (skipConfirmation || !p_233149_ || !flag && !flag1) { - this.f_233089_.m_91100_().m_235003_(levelstoragesource$levelstorageaccess).thenApply((p_233177_) -> { + this.f_233089_.m_247489_().m_247400_(levelstoragesource$levelstorageaccess).thenApply((p_233177_) -> { return true; }).exceptionallyComposeAsync((p_233183_) -> { -@@ -173,9 +_,11 @@ +@@ -199,9 +_,11 @@ return null; }); } else { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch index 7e675f87e7..25ba8f12aa 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch @@ -16,7 +16,7 @@ if (this.f_101693_.f_91066_.m_231828_().m_231551_() || p_101729_) { RenderSystem.m_157456_(0, WorldSelectionList.f_101648_); GuiComponent.m_93172_(p_101721_, p_101724_, p_101723_, p_101724_ + 32, p_101723_ + 32, -1601138544); -@@ -646,6 +_,21 @@ +@@ -560,6 +_,21 @@ public boolean m_214209_() { return !this.f_101695_.m_164916_(); @@ -24,7 +24,7 @@ + + // FORGE: Patch in experimental warning icon for worlds in the world selection screen + private void renderExperimentalWarning(PoseStack stack, int mouseX, int mouseY, int top, int left) { -+ if (this.f_101695_.isExperimental()) { ++ if (this.f_101695_.isLifecycleExperimental()) { + int leftStart = left + WorldSelectionList.this.m_5759_(); + RenderSystem.m_157456_(0, WorldSelectionList.FORGE_EXPERIMENTAL_WARNING_ICON); + GuiComponent.m_93133_(stack, leftStart - 36, top, 0.0F, 0.0F, 32, 32, 32, 32); diff --git a/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch b/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch index 2008683571..21e232dc2e 100644 --- a/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch +++ b/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/client/model/geom/LayerDefinitions.java +++ b/net/minecraft/client/model/geom/LayerDefinitions.java -@@ -293,6 +_,7 @@ - WoodType.m_61843_().forEach((p_171114_) -> { - builder.put(ModelLayers.m_171291_(p_171114_), layerdefinition20); +@@ -313,6 +_,7 @@ + WoodType.m_61843_().forEach((p_247864_) -> { + builder.put(ModelLayers.m_247439_(p_247864_), layerdefinition24); }); + net.minecraftforge.client.ForgeHooksClient.loadLayerDefinitions(builder); ImmutableMap immutablemap = builder.build(); diff --git a/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch b/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch index 0e7241950e..1f918f5773 100644 --- a/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch +++ b/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/model/geom/ModelLayers.java +++ b/net/minecraft/client/model/geom/ModelLayers.java -@@ -207,7 +_,8 @@ +@@ -217,11 +_,13 @@ } public static ModelLayerLocation m_171291_(WoodType p_171292_) { @@ -9,4 +9,10 @@ + return new ModelLayerLocation(new ResourceLocation(location.m_135827_(), "sign/" + location.m_135815_()), "main"); } + public static ModelLayerLocation m_247439_(WoodType p_252225_) { +- return m_171300_("hanging_sign/" + p_252225_.m_61846_(), "main"); ++ ResourceLocation location = new ResourceLocation(p_252225_.m_61846_()); ++ return new ModelLayerLocation(new ResourceLocation(location.m_135827_(), "hanging_sign/" + location.m_135815_()), "main"); + } + public static Stream m_171288_() { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/AccountProfileKeyPairManager.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/AccountProfileKeyPairManager.java.patch new file mode 100644 index 0000000000..f749da454b --- /dev/null +++ b/patches/minecraft/net/minecraft/client/multiplayer/AccountProfileKeyPairManager.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/multiplayer/AccountProfileKeyPairManager.java ++++ b/net/minecraft/client/multiplayer/AccountProfileKeyPairManager.java +@@ -75,6 +_,8 @@ + this.m_253216_(profilekeypair); + return Optional.of(profilekeypair); + } catch (CryptException | MinecraftClientException | IOException ioexception) { ++ // Forge: The offline user api service always returns a null profile key pair, so let's hide this useless exception if in dev ++ if (net.minecraftforge.fml.loading.FMLLoader.isProduction() || this.f_252526_ != UserApiService.OFFLINE) + f_252448_.error("Failed to retrieve profile key pair", (Throwable)ioexception); + this.m_253216_((ProfileKeyPair)null); + return p_254074_; diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch index 9daf3432a2..e972dcb7b3 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java -@@ -130,6 +_,7 @@ +@@ -127,6 +_,7 @@ this.f_104521_.accept(Component.m_237115_("connect.joining")); this.f_104523_ = p_104547_.m_134774_(); this.f_104522_.m_129498_(ConnectionProtocol.PLAY); + net.minecraftforge.network.NetworkHooks.handleClientLoginSuccess(this.f_104522_); - this.f_104522_.m_129505_(new ClientPacketListener(this.f_104519_, this.f_104520_, this.f_104522_, this.f_104523_, this.f_104519_.m_193590_())); + this.f_104522_.m_129505_(new ClientPacketListener(this.f_104519_, this.f_104520_, this.f_104522_, this.f_243717_, this.f_104523_, this.f_104519_.m_261007_().m_260825_(this.f_260722_, this.f_260612_))); } -@@ -137,7 +_,7 @@ +@@ -134,7 +_,7 @@ if (this.f_104520_ != null && this.f_104520_ instanceof RealmsScreen) { this.f_104519_.m_91152_(new DisconnectedRealmsScreen(this.f_104520_, CommonComponents.f_130661_, p_104543_)); } else { @@ -17,7 +17,7 @@ } } -@@ -158,6 +_,7 @@ +@@ -155,6 +_,7 @@ } public void m_7254_(ClientboundCustomQueryPacket p_104545_) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch index f74f73d29a..22b3b7ea3f 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientLevel.java +++ b/net/minecraft/client/multiplayer/ClientLevel.java -@@ -115,12 +_,15 @@ +@@ -117,12 +_,15 @@ p_194170_.put(BiomeColors.f_108791_, new BlockTintCache((p_194168_) -> { return this.m_104762_(p_194168_, BiomeColors.f_108791_); })); @@ -16,7 +16,7 @@ public void m_233651_(int p_233652_) { this.f_233599_.m_233856_(p_233652_, this); -@@ -174,6 +_,8 @@ +@@ -176,6 +_,8 @@ this.f_194123_ = p_205510_; this.m_46465_(); this.m_46466_(); @@ -25,15 +25,15 @@ } public void m_194171_(Runnable p_194172_) { -@@ -260,6 +_,7 @@ +@@ -262,6 +_,7 @@ this.m_46473_().m_6521_(() -> { - return Registry.f_122826_.m_7981_(p_104640_.m_6095_()).toString(); + return BuiltInRegistries.f_256780_.m_7981_(p_104640_.m_6095_()).toString(); }); + if (p_104640_.canUpdate()) p_104640_.m_8119_(); this.m_46473_().m_7238_(); -@@ -322,8 +_,10 @@ +@@ -324,8 +_,10 @@ } private void m_104739_(int p_104740_, Entity p_104741_) { @@ -44,33 +44,33 @@ } public void m_171642_(int p_171643_, Entity.RemovalReason p_171644_) { -@@ -450,6 +_,12 @@ +@@ -452,6 +_,12 @@ } - public void m_214150_(@Nullable Player p_233621_, double p_233622_, double p_233623_, double p_233624_, SoundEvent p_233625_, SoundSource p_233626_, float p_233627_, float p_233628_, long p_233629_) { -+ net.minecraftforge.event.PlayLevelSoundEvent.AtPosition event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtPosition(this, p_233622_, p_233623_, p_233624_, p_233625_, p_233626_, p_233627_, p_233628_); + public void m_262808_(@Nullable Player p_263381_, double p_263372_, double p_263404_, double p_263365_, Holder p_263335_, SoundSource p_263417_, float p_263416_, float p_263349_, long p_263408_) { ++ net.minecraftforge.event.PlayLevelSoundEvent.AtPosition event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtPosition(this, p_263372_, p_263404_, p_263365_, p_263335_, p_263417_, p_263416_, p_263349_); + if (event.isCanceled() || event.getSound() == null) return; -+ p_233625_ = event.getSound(); -+ p_233626_ = event.getSource(); -+ p_233627_ = event.getNewVolume(); -+ p_233628_ = event.getNewPitch(); - if (p_233621_ == this.f_104565_.f_91074_) { - this.m_233602_(p_233622_, p_233623_, p_233624_, p_233625_, p_233626_, p_233627_, p_233628_, false, p_233629_); ++ p_263335_ = event.getSound(); ++ p_263417_ = event.getSource(); ++ p_263416_ = event.getNewVolume(); ++ p_263349_ = event.getNewPitch(); + if (p_263381_ == this.f_104565_.f_91074_) { + this.m_233602_(p_263372_, p_263404_, p_263365_, p_263335_.m_203334_(), p_263417_, p_263416_, p_263349_, false, p_263408_); } -@@ -457,6 +_,12 @@ +@@ -459,6 +_,12 @@ } - public void m_213890_(@Nullable Player p_233631_, Entity p_233632_, SoundEvent p_233633_, SoundSource p_233634_, float p_233635_, float p_233636_, long p_233637_) { -+ net.minecraftforge.event.PlayLevelSoundEvent.AtEntity event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_233632_, p_233633_, p_233634_, p_233635_, p_233636_); + public void m_213890_(@Nullable Player p_263514_, Entity p_263536_, Holder p_263518_, SoundSource p_263487_, float p_263538_, float p_263524_, long p_263509_) { ++ net.minecraftforge.event.PlayLevelSoundEvent.AtEntity event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_263536_, p_263518_, p_263487_, p_263538_, p_263524_); + if (event.isCanceled() || event.getSound() == null) return; -+ p_233633_ = event.getSound(); -+ p_233634_ = event.getSource(); -+ p_233635_ = event.getNewVolume(); -+ p_233636_ = event.getNewPitch(); - if (p_233631_ == this.f_104565_.f_91074_) { - this.f_104565_.m_91106_().m_120367_(new EntityBoundSoundInstance(p_233633_, p_233634_, p_233635_, p_233636_, p_233632_, p_233637_)); ++ p_263518_ = event.getSound(); ++ p_263487_ = event.getSource(); ++ p_263538_ = event.getNewVolume(); ++ p_263524_ = event.getNewPitch(); + if (p_263514_ == this.f_104565_.f_91074_) { + this.f_104565_.m_91106_().m_120367_(new EntityBoundSoundInstance(p_263518_.m_203334_(), p_263487_, p_263538_, p_263524_, p_263536_, p_263509_)); } -@@ -902,6 +_,7 @@ +@@ -907,6 +_,7 @@ } public void m_104851_(Difficulty p_104852_) { @@ -78,7 +78,7 @@ this.f_104840_ = p_104852_; } -@@ -939,14 +_,46 @@ +@@ -944,14 +_,46 @@ ClientLevel.this.f_104566_.add((AbstractClientPlayer)p_171712_); } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch index bb7dc7f331..dc7c9f093a 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientPacketListener.java +++ b/net/minecraft/client/multiplayer/ClientPacketListener.java -@@ -375,6 +_,7 @@ +@@ -398,6 +_,7 @@ this.f_104888_.f_91064_.m_113434_(); this.f_104888_.f_91074_.m_172530_(); @@ -8,15 +8,15 @@ int i = p_105030_.f_132360_(); this.f_104888_.f_91074_.m_20234_(i); this.f_104889_.m_104630_(i, this.f_104888_.f_91074_); -@@ -387,6 +_,7 @@ +@@ -410,6 +_,7 @@ this.f_104888_.f_91074_.m_219749_(p_105030_.f_238174_()); this.f_104888_.f_91072_.m_171805_(p_105030_.f_132363_(), p_105030_.f_132364_()); this.f_104888_.f_91066_.m_193770_(p_105030_.f_132370_()); + net.minecraftforge.network.NetworkHooks.sendMCRegistryPackets(f_104885_, "PLAY_TO_SERVER"); this.f_104888_.f_91066_.m_92172_(); this.f_104885_.m_129512_(new ServerboundCustomPayloadPacket(ServerboundCustomPayloadPacket.f_133979_, (new FriendlyByteBuf(Unpooled.buffer())).m_130070_(ClientBrandRetriever.m_129629_()))); - this.f_104888_.m_91309_().m_90739_(); -@@ -941,8 +_,10 @@ + this.f_244346_ = new LastSeenMessagesTracker(20); +@@ -1003,8 +_,10 @@ localplayer1.m_21204_().m_22159_(localplayer.m_21204_()); } @@ -27,7 +27,7 @@ this.f_104889_.m_104630_(i, localplayer1); localplayer1.m_146922_(-180.0F); localplayer1.f_108618_ = new KeyboardInput(this.f_104888_.f_91066_); -@@ -1046,10 +_,7 @@ +@@ -1109,10 +_,7 @@ PacketUtils.m_131363_(p_104976_, this, this.f_104888_); BlockPos blockpos = p_104976_.m_131704_(); this.f_104888_.f_91073_.m_141902_(blockpos, p_104976_.m_195645_()).ifPresent((p_205557_) -> { @@ -39,18 +39,18 @@ if (p_205557_ instanceof CommandBlockEntity && this.f_104888_.f_91080_ instanceof CommandBlockEditScreen) { ((CommandBlockEditScreen)this.f_104888_.f_91080_).m_98398_(); -@@ -1194,7 +_,9 @@ +@@ -1257,7 +_,9 @@ public void m_7443_(ClientboundCommandsPacket p_104990_) { PacketUtils.m_131363_(p_104990_, this, this.f_104888_); -- this.f_104899_ = new CommandDispatcher<>(p_104990_.m_237624_(new CommandBuildContext(this.f_104903_))); -+ var context = new CommandBuildContext(this.f_104903_); +- this.f_104899_ = new CommandDispatcher<>(p_104990_.m_237624_(CommandBuildContext.m_255418_(this.f_104903_.m_247579_(), this.f_244039_))); ++ var context = CommandBuildContext.m_255418_(this.f_104903_.m_247579_(), this.f_244039_); + this.f_104899_ = new CommandDispatcher<>(p_104990_.m_237624_(context)); + this.f_104899_ = net.minecraftforge.client.ClientCommandHandler.mergeServerCommands(this.f_104899_, context); } public void m_7183_(ClientboundStopSoundPacket p_105116_) { -@@ -1213,6 +_,7 @@ +@@ -1276,6 +_,7 @@ ClientRecipeBook clientrecipebook = this.f_104888_.f_91074_.m_108631_(); clientrecipebook.m_90625_(this.f_104900_.m_44051_()); this.f_104888_.m_231374_(SearchRegistry.f_119943_, clientrecipebook.m_90639_()); @@ -58,15 +58,17 @@ } public void m_7244_(ClientboundPlayerLookAtPacket p_105054_) { -@@ -1314,6 +_,7 @@ +@@ -1368,7 +_,8 @@ + Blocks.m_50758_(); + } - this.f_104888_.m_231374_(SearchRegistry.f_119941_, nonnulllist); - this.f_104888_.m_231374_(SearchRegistry.f_119942_, nonnulllist); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent(this.f_104903_, true, f_104885_.m_129531_())); +- CreativeModeTabs.m_258007_().m_257466_(); ++ CreativeModeTabs.m_257478_().stream().filter(net.minecraft.world.item.CreativeModeTab::hasSearchBar).forEach(net.minecraft.world.item.CreativeModeTab::m_257466_); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent(this.f_104903_.m_247579_(), true, f_104885_.m_129531_())); } - private void m_205560_(ResourceKey> p_205561_, TagNetworkSerialization.NetworkPayload p_205562_) { -@@ -1666,6 +_,7 @@ + public void m_241155_(ClientboundUpdateEnabledFeaturesPacket p_251591_) { +@@ -1753,6 +_,7 @@ } public void m_7413_(ClientboundCustomPayloadPacket p_105004_) { @@ -74,7 +76,7 @@ PacketUtils.m_131363_(p_105004_, this, this.f_104888_); ResourceLocation resourcelocation = p_105004_.m_132042_(); FriendlyByteBuf friendlybytebuf = null; -@@ -1863,7 +_,7 @@ +@@ -1950,7 +_,7 @@ int j5 = friendlybytebuf.m_130242_(); this.f_104888_.f_91064_.f_173815_.m_173830_(positionsource, j5); } else { @@ -83,3 +85,20 @@ } } finally { if (friendlybytebuf != null) { +@@ -2284,6 +_,8 @@ + } + + public void m_246175_(String p_249888_) { ++ p_249888_ = net.minecraftforge.client.ForgeHooksClient.onClientSendMessage(p_249888_); ++ if (p_249888_.isEmpty()) return; + Instant instant = Instant.now(); + long i = Crypt.SaltSupplier.m_216113_(); + LastSeenMessagesTracker.Update lastseenmessagestracker$update = this.f_244346_.m_246442_(); +@@ -2292,6 +_,7 @@ + } + + public void m_246623_(String p_250092_) { ++ if (net.minecraftforge.client.ClientCommandHandler.runCommand(p_250092_)) return; + Instant instant = Instant.now(); + long i = Crypt.SaltSupplier.m_216113_(); + LastSeenMessagesTracker.Update lastseenmessagestracker$update = this.f_244346_.m_246442_(); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch index 577d96798d..66f7153dec 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch @@ -79,7 +79,7 @@ if (this.f_105193_ >= 1.0F) { this.f_105196_ = false; this.m_233729_(this.f_105189_.f_91073_, (p_233739_) -> { -@@ -263,7 +_,7 @@ +@@ -247,7 +_,7 @@ } public float m_105286_() { @@ -88,7 +88,7 @@ } public void m_105287_() { -@@ -280,7 +_,7 @@ +@@ -264,7 +_,7 @@ ItemStack itemstack = this.f_105189_.f_91074_.m_21205_(); boolean flag = this.f_105192_.m_41619_() && itemstack.m_41619_(); if (!this.f_105192_.m_41619_() && !itemstack.m_41619_()) { @@ -97,7 +97,7 @@ } return p_105282_.equals(this.f_105191_) && flag; -@@ -312,20 +_,33 @@ +@@ -296,25 +_,38 @@ private InteractionResult m_233746_(LocalPlayer p_233747_, InteractionHand p_233748_, BlockHitResult p_233749_) { BlockPos blockpos = p_233749_.m_82425_(); ItemStack itemstack = p_233747_.m_21120_(p_233748_); @@ -119,8 +119,13 @@ + boolean flag = !p_233747_.m_21205_().doesSneakBypassUse(p_233747_.m_9236_(), blockpos, p_233747_) || !p_233747_.m_21206_().doesSneakBypassUse(p_233747_.m_9236_(), blockpos, p_233747_); boolean flag1 = p_233747_.m_36341_() && flag; - if (!flag1) { + BlockState blockstate = this.f_105189_.f_91073_.m_8055_(blockpos); + if (!this.f_105190_.m_246351_(blockstate.m_60734_().m_245183_())) { + return InteractionResult.FAIL; + } + + if (event.getUseBlock() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY && !flag1)) { - InteractionResult interactionresult = this.f_105189_.f_91073_.m_8055_(blockpos).m_60664_(this.f_105189_.f_91073_, p_233747_, p_233748_, p_233749_); + InteractionResult interactionresult = blockstate.m_60664_(this.f_105189_.f_91073_, p_233747_, p_233748_, p_233749_); if (interactionresult.m_19077_()) { return interactionresult; } @@ -135,7 +140,7 @@ InteractionResult interactionresult1; if (this.f_105197_.m_46408_()) { int i = itemstack.m_41613_(); -@@ -356,10 +_,17 @@ +@@ -345,10 +_,17 @@ mutableobject.setValue(InteractionResult.PASS); return serverbounduseitempacket; } else { @@ -153,7 +158,7 @@ } mutableobject.setValue(interactionresultholder.m_19089_()); -@@ -398,6 +_,9 @@ +@@ -387,6 +_,9 @@ this.m_105297_(); Vec3 vec3 = p_105233_.m_82450_().m_82492_(p_105232_.m_20185_(), p_105232_.m_20186_(), p_105232_.m_20189_()); this.f_105190_.m_104955_(ServerboundInteractPacket.m_179612_(p_105232_, p_105231_.m_6144_(), p_105234_, vec3)); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch index 2109113cd5..7820480d4f 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/PlayerInfo.java +++ b/net/minecraft/client/multiplayer/PlayerInfo.java -@@ -82,6 +_,7 @@ +@@ -74,6 +_,7 @@ } protected void m_105317_(GameType p_105318_) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ProfileKeyPairManager.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ProfileKeyPairManager.java.patch deleted file mode 100644 index ecb09b9e26..0000000000 --- a/patches/minecraft/net/minecraft/client/multiplayer/ProfileKeyPairManager.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/multiplayer/ProfileKeyPairManager.java -+++ b/net/minecraft/client/multiplayer/ProfileKeyPairManager.java -@@ -76,6 +_,8 @@ - this.m_233776_(profilekeypair); - return Optional.of(profilekeypair); - } catch (CryptException | MinecraftClientException | IOException ioexception) { -+ // Forge: The offline user api service always returns a null profile key pair, so let's hide this useless exception if in dev -+ if (net.minecraftforge.fml.loading.FMLLoader.isProduction() || this.f_243348_ != UserApiService.OFFLINE) - f_233765_.error("Failed to retrieve profile key pair", (Throwable)ioexception); - this.m_233776_((ProfileKeyPair)null); - return p_243401_; diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch index 983b0d6d02..1b35ebfaac 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/client/multiplayer/ServerData.java +++ b/net/minecraft/client/multiplayer/ServerData.java -@@ -36,6 +_,7 @@ - private ServerData.ChatPreview f_233800_; - private boolean f_233801_ = true; +@@ -26,6 +_,7 @@ + private String f_105372_; + private boolean f_105373_; private boolean f_242950_; + public net.minecraftforge.client.ExtendedServerListData forgeData = null; diff --git a/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch index f63a7974e0..159a2402f2 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch @@ -1,32 +1,32 @@ --- a/net/minecraft/client/multiplayer/chat/ChatListener.java +++ b/net/minecraft/client/multiplayer/chat/ChatListener.java -@@ -175,12 +_,16 @@ - MessageSignature messagesignature = p_242317_.f_240893_(); - FilterMask filtermask = p_242317_.f_242992_(); +@@ -104,7 +_,9 @@ + Instant instant = Instant.now(); + this.m_246163_((MessageSignature)null, () -> { + Component component = p_251256_.m_240977_(p_250375_); +- this.f_240348_.f_91065_.m_93076_().m_93785_(component); ++ Component forgeComponent = net.minecraftforge.client.ForgeHooksClient.onClientChat(p_251256_, component, Util.f_137441_); ++ if (forgeComponent == null) return false; ++ this.f_240348_.f_91065_.m_93076_().m_93785_(forgeComponent); + this.m_241119_(p_251256_, p_250375_); + this.m_240498_(component, instant); + this.f_240659_ = Util.m_137550_(); +@@ -121,12 +_,16 @@ + MessageSignature messagesignature = p_249430_.f_244279_(); + FilterMask filtermask = p_249430_.f_242992_(); if (filtermask.m_243095_()) { -- this.f_240348_.f_91065_.m_93076_().m_240964_(p_243337_, messagesignature, guimessagetag); -+ Component forgeComponent = net.minecraftforge.client.ForgeHooksClient.onClientChat(p_242290_, p_243337_, p_242317_, p_242317_.m_241067_()); +- this.f_240348_.f_91065_.m_93076_().m_240964_(p_249231_, messagesignature, guimessagetag); ++ Component forgeComponent = net.minecraftforge.client.ForgeHooksClient.onClientPlayerChat(p_251766_, p_249231_, p_249430_, p_249430_.m_245167_()); + if (forgeComponent == null) return false; + this.f_240348_.f_91065_.m_93076_().m_240964_(forgeComponent, messagesignature, guimessagetag); - this.m_241119_(p_242290_, p_242317_.m_237220_()); + this.m_241119_(p_251766_, p_249430_.m_245692_()); } else { - Component component = filtermask.m_243081_(p_242317_.m_241775_()); + Component component = filtermask.m_246134_(p_249430_.m_245728_()); if (component != null) { -- this.f_240348_.f_91065_.m_93076_().m_240964_(p_242290_.m_240977_(component), messagesignature, guimessagetag); -+ Component forgeComponent = net.minecraftforge.client.ForgeHooksClient.onClientChat(p_242290_, p_242290_.m_240977_(component), p_242317_, p_242317_.m_241067_()); +- this.f_240348_.f_91065_.m_93076_().m_240964_(p_251766_.m_240977_(component), messagesignature, guimessagetag); ++ Component forgeComponent = net.minecraftforge.client.ForgeHooksClient.onClientPlayerChat(p_251766_, p_251766_.m_240977_(component), p_249430_, p_249430_.m_245167_()); + if (forgeComponent == null) return false; + this.f_240348_.f_91065_.m_93076_().m_240964_(forgeComponent, messagesignature, guimessagetag); - this.m_241119_(p_242290_, component); + this.m_241119_(p_251766_, component); } } -@@ -194,7 +_,9 @@ - } - - boolean m_241171_(ChatType.Bound p_241518_, PlayerChatMessage p_241542_, Component p_241510_) { -- this.f_240348_.f_91065_.m_93076_().m_93785_(p_241510_); -+ Component forgeComponent = net.minecraftforge.client.ForgeHooksClient.onClientChat(p_241518_, p_241510_, p_241542_, p_241542_.m_241067_()); -+ if (forgeComponent == null) return false; -+ this.f_240348_.f_91065_.m_93076_().m_93785_(forgeComponent); - this.m_241119_(p_241518_, p_241542_.m_237220_()); - this.m_240498_(p_241510_, p_241542_.m_241109_()); - this.f_240659_ = Util.m_137550_(); diff --git a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch index 1293f024bf..3c912fef3e 100644 --- a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/particle/ParticleEngine.java +++ b/net/minecraft/client/particle/ParticleEngine.java -@@ -63,11 +_,11 @@ +@@ -74,11 +_,11 @@ private static final int f_172264_ = 16384; private static final List f_107288_ = ImmutableList.of(ParticleRenderType.f_107429_, ParticleRenderType.f_107430_, ParticleRenderType.f_107432_, ParticleRenderType.f_107431_, ParticleRenderType.f_107433_); protected ClientLevel f_107287_; @@ -14,37 +14,37 @@ private final Queue f_107294_ = Queues.newArrayDeque(); private final Map f_107295_ = Maps.newHashMap(); private final TextureAtlas f_107296_; -@@ -177,14 +_,18 @@ +@@ -188,14 +_,18 @@ this.m_107378_(ParticleTypes.f_235901_, ShriekParticle.Provider::new); } + /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */ + @Deprecated public void m_107381_(ParticleType p_107382_, ParticleProvider p_107383_) { -- this.f_107293_.put(Registry.f_122829_.m_7447_(p_107382_), p_107383_); -+ this.f_107293_.put(Registry.f_122829_.m_7981_(p_107382_), p_107383_); +- this.f_107293_.put(BuiltInRegistries.f_257034_.m_7447_(p_107382_), p_107383_); ++ this.f_107293_.put(BuiltInRegistries.f_257034_.m_7981_(p_107382_), p_107383_); } + /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */ + @Deprecated public void m_107378_(ParticleType p_107379_, ParticleEngine.SpriteParticleRegistration p_107380_) { ParticleEngine.MutableSpriteSet particleengine$mutablespriteset = new ParticleEngine.MutableSpriteSet(); - this.f_107295_.put(Registry.f_122829_.m_7981_(p_107379_), particleengine$mutablespriteset); -- this.f_107293_.put(Registry.f_122829_.m_7447_(p_107379_), p_107380_.m_107419_(particleengine$mutablespriteset)); -+ this.f_107293_.put(Registry.f_122829_.m_7981_(p_107379_), p_107380_.m_107419_(particleengine$mutablespriteset)); + this.f_107295_.put(BuiltInRegistries.f_257034_.m_7981_(p_107379_), particleengine$mutablespriteset); +- this.f_107293_.put(BuiltInRegistries.f_257034_.m_7447_(p_107379_), p_107380_.m_107419_(particleengine$mutablespriteset)); ++ this.f_107293_.put(BuiltInRegistries.f_257034_.m_7981_(p_107379_), p_107380_.m_107419_(particleengine$mutablespriteset)); } public CompletableFuture m_5540_(PreparableReloadListener.PreparationBarrier p_107305_, ResourceManager p_107306_, ProfilerFiller p_107307_, ProfilerFiller p_107308_, Executor p_107309_, Executor p_107310_) { -@@ -288,7 +_,7 @@ +@@ -313,7 +_,7 @@ @Nullable private Particle m_107395_(T p_107396_, double p_107397_, double p_107398_, double p_107399_, double p_107400_, double p_107401_, double p_107402_) { -- ParticleProvider particleprovider = (ParticleProvider)this.f_107293_.get(Registry.f_122829_.m_7447_(p_107396_.m_6012_())); -+ ParticleProvider particleprovider = (ParticleProvider)this.f_107293_.get(Registry.f_122829_.m_7981_(p_107396_.m_6012_())); +- ParticleProvider particleprovider = (ParticleProvider)this.f_107293_.get(BuiltInRegistries.f_257034_.m_7447_(p_107396_.m_6012_())); ++ ParticleProvider particleprovider = (ParticleProvider)this.f_107293_.get(BuiltInRegistries.f_257034_.m_7981_(p_107396_.m_6012_())); return particleprovider == null ? null : particleprovider.m_6966_(p_107396_, this.f_107287_, p_107397_, p_107398_, p_107399_, p_107400_, p_107401_, p_107402_); } -@@ -369,15 +_,25 @@ +@@ -394,15 +_,25 @@ } } @@ -62,7 +62,7 @@ + RenderSystem.m_69388_(org.lwjgl.opengl.GL13.GL_TEXTURE0); PoseStack posestack = RenderSystem.m_157191_(); posestack.m_85836_(); - posestack.m_166854_(p_107337_.m_85850_().m_85861_()); + posestack.m_252931_(p_107337_.m_85850_().m_252922_()); RenderSystem.m_157182_(); - for(ParticleRenderType particlerendertype : f_107288_) { @@ -71,7 +71,7 @@ Iterable iterable = this.f_107289_.get(particlerendertype); if (iterable != null) { RenderSystem.m_157427_(GameRenderer::m_172829_); -@@ -387,6 +_,7 @@ +@@ -412,6 +_,7 @@ particlerendertype.m_6505_(bufferbuilder, this.f_107291_); for(Particle particle : iterable) { @@ -79,16 +79,16 @@ try { particle.m_5744_(bufferbuilder, p_107340_, p_107341_); } catch (Throwable throwable) { -@@ -417,7 +_,7 @@ +@@ -441,7 +_,7 @@ } public void m_107355_(BlockPos p_107356_, BlockState p_107357_) { -- if (!p_107357_.m_60795_()) { +- if (!p_107357_.m_60795_() && p_107357_.m_245147_()) { + if (!p_107357_.m_60795_() && !net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(p_107357_).addDestroyEffects(p_107357_, this.f_107287_, p_107356_, this)) { VoxelShape voxelshape = p_107357_.m_60808_(this.f_107287_, p_107356_); double d0 = 0.25D; voxelshape.m_83286_((p_172273_, p_172274_, p_172275_, p_172276_, p_172277_, p_172278_) -> { -@@ -437,7 +_,7 @@ +@@ -461,7 +_,7 @@ double d7 = d4 * d1 + p_172273_; double d8 = d5 * d2 + p_172274_; double d9 = d6 * d3 + p_172275_; @@ -97,7 +97,7 @@ } } } -@@ -481,12 +_,18 @@ +@@ -505,12 +_,18 @@ d0 = (double)i + aabb.f_82291_ + (double)0.1F; } diff --git a/patches/minecraft/net/minecraft/client/particle/VibrationSignalParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/VibrationSignalParticle.java.patch index 6d7d3e96e0..817e719650 100644 --- a/patches/minecraft/net/minecraft/client/particle/VibrationSignalParticle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/VibrationSignalParticle.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/particle/VibrationSignalParticle.java +++ b/net/minecraft/client/particle/VibrationSignalParticle.java -@@ -100,6 +_,7 @@ +@@ -105,6 +_,7 @@ this.f_107212_ = Mth.m_14139_(d0, this.f_107212_, vec3.m_7096_()); this.f_107213_ = Mth.m_14139_(d0, this.f_107213_, vec3.m_7098_()); this.f_107214_ = Mth.m_14139_(d0, this.f_107214_, vec3.m_7094_()); -+ this.m_107264_(this.f_107212_, this.f_107213_, this.f_107214_); // FORGE: update the particle's bounding box - this.f_172460_ = this.f_172462_; - this.f_172462_ = (float)Mth.m_14136_(this.f_107212_ - vec3.m_7096_(), this.f_107214_ - vec3.m_7094_()); - } ++ this.m_107264_(this.f_107212_, this.f_107213_, this.f_107214_); // FORGE: Update the particle's bounding box + double d1 = this.f_107212_ - vec3.m_7096_(); + double d2 = this.f_107213_ - vec3.m_7098_(); + double d3 = this.f_107214_ - vec3.m_7094_(); diff --git a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch index eed30bb817..9128e05de3 100644 --- a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/player/AbstractClientPlayer.java +++ b/net/minecraft/client/player/AbstractClientPlayer.java -@@ -137,6 +_,6 @@ +@@ -136,6 +_,6 @@ } } diff --git a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch index ae563b8489..62de244c50 100644 --- a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/player/LocalPlayer.java +++ b/net/minecraft/client/player/LocalPlayer.java -@@ -162,6 +_,7 @@ +@@ -150,6 +_,7 @@ } public boolean m_6469_(DamageSource p_108662_, float p_108663_) { @@ -8,31 +8,15 @@ return false; } -@@ -289,6 +_,8 @@ - } - - public void m_240287_(String p_240288_, @Nullable Component p_240289_) { -+ p_240288_ = net.minecraftforge.client.ForgeHooksClient.onClientSendMessage(p_240288_); -+ if (p_240288_.isEmpty()) return; - this.m_240966_(p_240288_, p_240289_); - } - -@@ -333,6 +_,7 @@ - } - - private void m_241110_(String p_241331_, @Nullable Component p_241563_) { -+ if (net.minecraftforge.client.ClientCommandHandler.runCommand(p_241331_)) return; - ParseResults parseresults = this.f_108617_.m_105146_().parse(p_241331_, this.f_108617_.m_105137_()); - MessageSigner messagesigner = this.m_241001_(); - LastSeenMessages.Update lastseenmessages$update = this.f_108617_.m_241918_(); -@@ -547,7 +_,13 @@ +@@ -462,7 +_,14 @@ } public void m_5496_(SoundEvent p_108651_, float p_108652_, float p_108653_) { - this.f_19853_.m_7785_(this.m_20185_(), this.m_20186_(), this.m_20189_(), p_108651_, this.m_5720_(), p_108652_, p_108653_, false); -+ net.minecraftforge.event.PlayLevelSoundEvent.AtEntity event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(this, p_108651_, this.m_5720_(), p_108652_, p_108653_); ++ net.minecraft.core.Holder holder = net.minecraft.core.registries.BuiltInRegistries.f_256894_.m_263177_(p_108651_); ++ net.minecraftforge.event.PlayLevelSoundEvent.AtEntity event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(this, holder, this.m_5720_(), p_108652_, p_108653_); + if (event.isCanceled() || event.getSound() == null) return; -+ p_108651_ = event.getSound(); ++ p_108651_ = event.getSound().get(); + SoundSource source = event.getSource(); + p_108652_ = event.getNewVolume(); + p_108653_ = event.getNewPitch(); @@ -40,7 +24,7 @@ } public void m_6330_(SoundEvent p_108655_, SoundSource p_108656_, float p_108657_, float p_108658_) { -@@ -703,6 +_,7 @@ +@@ -634,6 +_,7 @@ this.f_108601_ = !this.m_150110_().f_35935_ && !this.m_6069_() && this.m_20175_(Pose.CROUCHING) && (this.m_6144_() || !this.m_5803_() && !this.m_20175_(Pose.STANDING)); float f = Mth.m_14036_(0.3F + EnchantmentHelper.m_220302_(this), 0.0F, 1.0F); this.f_108618_.m_214106_(this.m_108635_(), f); @@ -48,16 +32,16 @@ this.f_108619_.m_91301_().m_120586_(this.f_108618_); if (this.m_6117_() && !this.m_20159_()) { this.f_108618_.f_108566_ *= 0.2F; -@@ -729,7 +_,7 @@ +@@ -660,7 +_,7 @@ } - boolean flag4 = (float)this.m_36324_().m_38702_() > 6.0F || this.m_150110_().f_35936_; -- if ((this.f_19861_ || this.m_5842_()) && !flag1 && !flag2 && this.m_108733_() && !this.m_20142_() && flag4 && !this.m_6117_() && !this.m_21023_(MobEffects.f_19610_)) { -+ if ((this.f_19861_ || this.m_5842_() || this.canStartSwimming()) && !flag1 && !flag2 && this.m_108733_() && !this.m_20142_() && flag4 && !this.m_6117_() && !this.m_21023_(MobEffects.f_19610_)) { + boolean flag4 = this.m_255269_(); +- if ((this.f_19861_ || this.m_5842_() || this.m_20159_() && this.m_20202_().m_20096_()) && !flag1 && !flag2 && this.m_108733_() && !this.m_20142_() && flag4 && !this.m_6117_() && !this.m_21023_(MobEffects.f_19610_)) { ++ if ((this.f_19861_ || this.m_5842_() || this.m_20159_() && this.m_20202_().m_20096_() || this.canStartSwimming()) && !flag1 && !flag2 && this.m_108733_() && !this.m_20142_() && flag4 && !this.m_6117_() && !this.m_21023_(MobEffects.f_19610_)) { if (this.f_108583_ <= 0 && !this.f_108619_.f_91066_.f_92091_.m_90857_()) { this.f_108583_ = 7; } else { -@@ -737,15 +_,15 @@ +@@ -668,15 +_,15 @@ } } @@ -76,7 +60,7 @@ this.m_6858_(false); } } else if (flag6) { -@@ -775,14 +_,15 @@ +@@ -706,14 +_,15 @@ if (this.f_108618_.f_108572_ && !flag7 && !flag && !this.m_150110_().f_35935_ && !this.m_20159_() && !this.m_6147_()) { ItemStack itemstack = this.m_6844_(EquipmentSlot.CHEST); @@ -95,7 +79,7 @@ } if (this.m_204029_(FluidTags.f_13131_)) { -@@ -893,6 +_,7 @@ +@@ -824,6 +_,7 @@ public void m_6083_() { super.m_6083_(); @@ -103,7 +87,7 @@ this.f_108611_ = false; if (this.m_20202_() instanceof Boat) { Boat boat = (Boat)this.m_20202_(); -@@ -1106,6 +_,18 @@ +@@ -1041,6 +_,18 @@ } else { return super.m_7398_(p_108758_); } diff --git a/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch b/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch index 0cab367728..e71c7c13a6 100644 --- a/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/player/RemotePlayer.java +++ b/net/minecraft/client/player/RemotePlayer.java -@@ -30,6 +_,7 @@ +@@ -28,6 +_,7 @@ } public boolean m_6469_(DamageSource p_108772_, float p_108773_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/EffectInstance.java.patch b/patches/minecraft/net/minecraft/client/renderer/EffectInstance.java.patch index d0136cdb01..c787408fb0 100644 --- a/patches/minecraft/net/minecraft/client/renderer/EffectInstance.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/EffectInstance.java.patch @@ -10,7 +10,7 @@ this.f_108932_ = p_108942_; Resource resource = p_108941_.m_215593_(resourcelocation); -@@ -168,7 +_,8 @@ +@@ -150,7 +_,8 @@ } else { EffectProgram effectprogram; if (program == null) { @@ -18,5 +18,5 @@ + ResourceLocation rl = ResourceLocation.m_135820_(p_172569_); + ResourceLocation resourcelocation = new ResourceLocation(rl.m_135827_(), "shaders/program/" + rl.m_135815_() + p_172568_.m_85569_()); Resource resource = p_172567_.m_215593_(resourcelocation); - InputStream inputstream = resource.m_215507_(); + try (InputStream inputstream = resource.m_215507_()) { diff --git a/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch index 4407169e19..cf344eefe1 100644 --- a/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch @@ -6,9 +6,9 @@ + Vector3f fogColor = net.minecraftforge.client.ForgeHooksClient.getFogColor(p_109019_, p_109020_, p_109021_, p_109022_, p_109023_, f_109010_, f_109011_, f_109012_); + -+ f_109010_ = fogColor.m_122239_(); -+ f_109011_ = fogColor.m_122260_(); -+ f_109012_ = fogColor.m_122269_(); ++ f_109010_ = fogColor.x(); ++ f_109011_ = fogColor.y(); ++ f_109012_ = fogColor.z(); + RenderSystem.m_69424_(f_109010_, f_109011_, f_109012_, 0.0F); } diff --git a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch index abd1f94540..c7016e0488 100644 --- a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/GameRenderer.java +++ b/net/minecraft/client/renderer/GameRenderer.java -@@ -290,6 +_,8 @@ +@@ -299,6 +_,8 @@ this.m_109128_(new ResourceLocation("shaders/post/spider.json")); } else if (p_109107_ instanceof EnderMan) { this.m_109128_(new ResourceLocation("shaders/post/invert.json")); @@ -9,15 +9,15 @@ } } -@@ -549,6 +_,7 @@ - list1.add(Pair.of(new ShaderInstance(p_172768_, "rendertype_crumbling", DefaultVertexFormat.f_85811_), (p_234230_) -> { +@@ -586,6 +_,7 @@ + list1.add(Pair.of(new ShaderInstance(p_250719_, "rendertype_crumbling", DefaultVertexFormat.f_85811_), (p_234230_) -> { f_172607_ = p_234230_; })); -+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.RegisterShadersEvent(p_172768_, list1)); ++ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.RegisterShadersEvent(p_250719_, list1)); } catch (IOException ioexception) { list1.forEach((p_172729_) -> { p_172729_.getFirst().close(); -@@ -630,19 +_,21 @@ +@@ -667,19 +_,21 @@ boolean flag = false; int i = 3; double d1 = d0; @@ -42,7 +42,7 @@ d1 = this.f_109059_.f_91077_.m_82450_().m_82557_(vec3); } -@@ -657,7 +_,7 @@ +@@ -694,7 +_,7 @@ Entity entity1 = entityhitresult.m_82443_(); Vec3 vec33 = entityhitresult.m_82450_(); double d2 = vec3.m_82557_(vec33); @@ -51,7 +51,7 @@ this.f_109059_.f_91077_ = BlockHitResult.m_82426_(vec33, Direction.m_122366_(vec31.f_82479_, vec31.f_82480_, vec31.f_82481_), new BlockPos(vec33)); } else if (d2 < d1 || this.f_109059_.f_91077_ == null) { this.f_109059_.f_91077_ = entityhitresult; -@@ -711,7 +_,7 @@ +@@ -748,7 +_,7 @@ d0 *= Mth.m_14139_(this.f_109059_.f_91066_.m_231925_().m_231551_(), 1.0D, (double)0.85714287F); } @@ -60,44 +60,43 @@ } } -@@ -848,11 +_,11 @@ +@@ -883,11 +_,11 @@ Window window = this.f_109059_.m_91268_(); RenderSystem.m_69421_(256, Minecraft.f_91002_); -- Matrix4f matrix4f = Matrix4f.m_162203_(0.0F, (float)((double)window.m_85441_() / window.m_85449_()), 0.0F, (float)((double)window.m_85442_() / window.m_85449_()), 1000.0F, 3000.0F); -+ Matrix4f matrix4f = Matrix4f.m_162203_(0.0F, (float)((double)window.m_85441_() / window.m_85449_()), 0.0F, (float)((double)window.m_85442_() / window.m_85449_()), 1000.0F, net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane()); - RenderSystem.m_157425_(matrix4f); +- Matrix4f matrix4f = (new Matrix4f()).setOrtho(0.0F, (float)((double)window.m_85441_() / window.m_85449_()), (float)((double)window.m_85442_() / window.m_85449_()), 0.0F, 1000.0F, 3000.0F); ++ Matrix4f matrix4f = (new Matrix4f()).setOrtho(0.0F, (float)((double)window.m_85441_() / window.m_85449_()), (float)((double)window.m_85442_() / window.m_85449_()), 0.0F, 1000.0F, net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane()); + RenderSystem.m_252934_(matrix4f); PoseStack posestack = RenderSystem.m_157191_(); posestack.m_166856_(); -- posestack.m_85837_(0.0D, 0.0D, -2000.0D); +- posestack.m_252880_(0.0F, 0.0F, -2000.0F); + posestack.m_85837_(0.0D, 0.0D, 1000F-net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane()); RenderSystem.m_157182_(); Lighting.m_84931_(); PoseStack posestack1 = new PoseStack(); -@@ -888,7 +_,7 @@ +@@ -923,7 +_,7 @@ } } else if (this.f_109059_.f_91080_ != null) { try { -- this.f_109059_.f_91080_.m_6305_(posestack1, i, j, this.f_109059_.m_91297_()); +- this.f_109059_.f_91080_.m_257612_(posestack1, i, j, this.f_109059_.m_91297_()); + net.minecraftforge.client.ForgeHooksClient.drawScreen(this.f_109059_.f_91080_, posestack1, i, j, this.f_109059_.m_91297_()); } catch (Throwable throwable1) { CrashReport crashreport1 = CrashReport.m_127521_(throwable1, "Rendering screen"); CrashReportCategory crashreportcategory1 = crashreport1.m_127514_("Screen render details"); -@@ -1047,6 +_,11 @@ - Matrix4f matrix4f = posestack.m_85850_().m_85861_(); - this.m_109111_(matrix4f); +@@ -1068,12 +_,19 @@ + Matrix4f matrix4f = posestack.m_85850_().m_252922_(); + this.m_252879_(matrix4f); camera.m_90575_(this.f_109059_.f_91073_, (Entity)(this.f_109059_.m_91288_() == null ? this.f_109059_.f_91074_ : this.f_109059_.m_91288_()), !this.f_109059_.f_91066_.m_92176_().m_90612_(), this.f_109059_.f_91066_.m_92176_().m_90613_(), p_109090_); + + net.minecraftforge.client.event.ViewportEvent.ComputeCameraAngles cameraSetup = net.minecraftforge.client.ForgeHooksClient.onCameraSetup(this, camera, p_109090_); + camera.setAnglesInternal(cameraSetup.getYaw(), cameraSetup.getPitch()); -+ p_109092_.m_85845_(Vector3f.f_122227_.m_122240_(cameraSetup.getRoll())); ++ p_109092_.m_252781_(Axis.f_252403_.m_252977_(cameraSetup.getRoll())); + - p_109092_.m_85845_(Vector3f.f_122223_.m_122240_(camera.m_90589_())); - p_109092_.m_85845_(Vector3f.f_122225_.m_122240_(camera.m_90590_() + 180.0F)); - Matrix3f matrix3f = p_109092_.m_85850_().m_85864_().m_8183_(); -@@ -1056,6 +_,8 @@ - - this.f_109059_.f_91060_.m_172961_(p_109092_, camera.m_90583_(), this.m_172716_(Math.max(d0, (double)this.f_109059_.f_91066_.m_231837_().m_231551_().intValue()))); + p_109092_.m_252781_(Axis.f_252529_.m_252977_(camera.m_90589_())); + p_109092_.m_252781_(Axis.f_252436_.m_252977_(camera.m_90590_() + 180.0F)); + Matrix3f matrix3f = (new Matrix3f(p_109092_.m_85850_().m_252943_())).invert(); + RenderSystem.m_253212_(matrix3f); + this.f_109059_.f_91060_.m_253210_(p_109092_, camera.m_90583_(), this.m_253088_(Math.max(d0, (double)this.f_109059_.f_91066_.m_231837_().m_231551_().intValue()))); this.f_109059_.f_91060_.m_109599_(p_109092_, p_109090_, p_109091_, flag, camera, this, this.f_109074_, matrix4f); + this.f_109059_.m_91307_().m_6182_("forge_render_last"); + net.minecraftforge.client.ForgeHooksClient.dispatchRenderLast(this.f_109059_.f_91060_, p_109092_, p_109090_, matrix4f, p_109091_); diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch index a23deb9c13..261b4f6eda 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch @@ -8,15 +8,15 @@ private static final Map f_109275_ = Util.m_137469_(Maps.newHashMap(), (p_109296_) -> { RenderType rendertype = RenderType.m_110503_(); p_109296_.put(Blocks.f_50267_, rendertype); -@@ -296,6 +_,7 @@ +@@ -298,6 +_,7 @@ + p_109296_.put(Blocks.f_50628_, rendertype3); p_109296_.put(Blocks.f_152498_, rendertype3); - p_109296_.put(Blocks.f_220862_, rendertype3); }); + @Deprecated private static final Map f_109276_ = Util.m_137469_(Maps.newHashMap(), (p_109290_) -> { RenderType rendertype = RenderType.m_110466_(); p_109290_.put(Fluids.f_76192_, rendertype); -@@ -303,6 +_,8 @@ +@@ -305,6 +_,8 @@ }); private static boolean f_109277_; @@ -25,7 +25,7 @@ public static RenderType m_109282_(BlockState p_109283_) { Block block = p_109283_.m_60734_(); if (block instanceof LeavesBlock) { -@@ -313,6 +_,8 @@ +@@ -315,6 +_,8 @@ } } @@ -34,7 +34,7 @@ public static RenderType m_109293_(BlockState p_109294_) { Block block = p_109294_.m_60734_(); if (block instanceof LeavesBlock) { -@@ -327,6 +_,8 @@ +@@ -329,6 +_,8 @@ } } @@ -43,7 +43,7 @@ public static RenderType m_109284_(BlockState p_109285_, boolean p_109286_) { RenderType rendertype = m_109282_(p_109285_); if (rendertype == RenderType.m_110466_()) { -@@ -340,6 +_,8 @@ +@@ -342,6 +_,8 @@ } } @@ -52,7 +52,7 @@ public static RenderType m_109279_(ItemStack p_109280_, boolean p_109281_) { Item item = p_109280_.m_41720_(); if (item instanceof BlockItem) { -@@ -351,8 +_,73 @@ +@@ -353,8 +_,73 @@ } public static RenderType m_109287_(FluidState p_109288_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch index fee309f024..68a385fd0b 100644 --- a/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch @@ -25,23 +25,23 @@ + FogRenderer.m_234172_(p_109604_, FogRenderer.FogMode.FOG_SKY, f, flag2, p_109601_); profilerfiller.m_6182_("sky"); RenderSystem.m_157427_(GameRenderer::m_172808_); - this.m_202423_(p_109600_, p_109607_, p_109601_, p_109604_, flag2, () -> { + this.m_202423_(p_109600_, p_254120_, p_109601_, p_109604_, flag2, () -> { FogRenderer.m_234172_(p_109604_, FogRenderer.FogMode.FOG_SKY, f, flag2, p_109601_); }); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_SKY, this, p_109600_, p_109607_, this.f_109477_, p_109604_, frustum); ++ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_SKY, this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); profilerfiller.m_6182_("fog"); FogRenderer.m_234172_(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f, 32.0F), flag2, p_109601_); profilerfiller.m_6182_("terrain_setup"); @@ -1154,7 +_,9 @@ this.m_194370_(p_109604_); profilerfiller.m_6182_("terrain"); - this.m_172993_(RenderType.m_110451_(), p_109600_, d0, d1, d2, p_109607_); + this.m_172993_(RenderType.m_110451_(), p_109600_, d0, d1, d2, p_254120_); + this.f_109461_.m_91304_().m_119428_(TextureAtlas.f_118259_).setBlurMipmap(false, this.f_109461_.f_91066_.m_232119_().m_231551_() > 0); // FORGE: fix flickering leaves when mods mess up the blurMipmap settings - this.m_172993_(RenderType.m_110457_(), p_109600_, d0, d1, d2, p_109607_); + this.m_172993_(RenderType.m_110457_(), p_109600_, d0, d1, d2, p_254120_); + this.f_109461_.m_91304_().m_119428_(TextureAtlas.f_118259_).restoreLastBlurMipmap(); - this.m_172993_(RenderType.m_110463_(), p_109600_, d0, d1, d2, p_109607_); + this.m_172993_(RenderType.m_110463_(), p_109600_, d0, d1, d2, p_254120_); if (this.f_109465_.m_104583_().m_108885_()) { - Lighting.m_84925_(p_109600_.m_85850_().m_85861_()); + Lighting.m_252995_(p_109600_.m_85850_().m_252922_()); @@ -1186,7 +_,7 @@ for(Entity entity : this.f_109465_.m_104735_()) { if (this.f_109463_.m_114397_(entity, frustum, d0, d1, d2) || entity.m_20367_(this.f_109461_.f_91074_)) { @@ -93,17 +93,17 @@ this.f_172946_.m_112267_(blockentity, p_109601_, p_109600_, multibuffersource$buffersource); p_109600_.m_85849_(); } -@@ -1290,7 +_,8 @@ +@@ -1291,7 +_,8 @@ p_109600_.m_85837_((double)blockpos2.m_123341_() - d0, (double)blockpos2.m_123342_() - d1, (double)blockpos2.m_123343_() - d2); PoseStack.Pose posestack$pose = p_109600_.m_85850_(); - VertexConsumer vertexconsumer1 = new SheetedDecalTextureGenerator(this.f_109464_.m_110108_().m_6299_(ModelBakery.f_119229_.get(k1)), posestack$pose.m_85861_(), posestack$pose.m_85864_()); + VertexConsumer vertexconsumer1 = new SheetedDecalTextureGenerator(this.f_109464_.m_110108_().m_6299_(ModelBakery.f_119229_.get(k1)), posestack$pose.m_252922_(), posestack$pose.m_252943_(), 1.0F); - this.f_109461_.m_91289_().m_110918_(this.f_109465_.m_8055_(blockpos2), blockpos2, this.f_109465_, p_109600_, vertexconsumer1); + net.minecraftforge.client.model.data.ModelData modelData = f_109465_.getModelDataManager().getAt(blockpos2); + this.f_109461_.m_91289_().renderBreakingTexture(this.f_109465_.m_8055_(blockpos2), blockpos2, this.f_109465_, p_109600_, vertexconsumer1, modelData == null ? net.minecraftforge.client.model.data.ModelData.EMPTY : modelData); p_109600_.m_85849_(); } } -@@ -1302,10 +_,13 @@ +@@ -1303,10 +_,13 @@ profilerfiller.m_6182_("outline"); BlockPos blockpos1 = ((BlockHitResult)hitresult).m_82425_(); BlockState blockstate = this.f_109465_.m_8055_(blockpos1); @@ -117,77 +117,77 @@ } PoseStack posestack = RenderSystem.m_157191_(); -@@ -1340,7 +_,8 @@ +@@ -1341,7 +_,8 @@ this.f_109415_.m_83945_(this.f_109461_.m_91385_()); RenderStateShard.f_110126_.m_110185_(); profilerfiller.m_6182_("particles"); - this.f_109461_.f_91061_.m_107336_(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_); + this.f_109461_.f_91061_.render(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_, frustum); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, p_109600_, p_109607_, this.f_109477_, p_109604_, frustum); ++ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); RenderStateShard.f_110126_.m_110188_(); } else { profilerfiller.m_6182_("translucent"); -@@ -1354,7 +_,8 @@ +@@ -1355,7 +_,8 @@ profilerfiller.m_6182_("string"); - this.m_172993_(RenderType.m_110503_(), p_109600_, d0, d1, d2, p_109607_); + this.m_172993_(RenderType.m_110503_(), p_109600_, d0, d1, d2, p_254120_); profilerfiller.m_6182_("particles"); - this.f_109461_.f_91061_.m_107336_(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_); + this.f_109461_.f_91061_.render(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_, frustum); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, p_109600_, p_109607_, this.f_109477_, p_109604_, frustum); ++ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); } posestack.m_85836_(); -@@ -1378,6 +_,7 @@ +@@ -1379,6 +_,7 @@ RenderStateShard.f_110127_.m_110185_(); profilerfiller.m_6182_("weather"); this.m_109703_(p_109606_, p_109601_, d0, d1, d2); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, p_109600_, p_109607_, this.f_109477_, p_109604_, frustum); ++ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); this.m_173012_(p_109604_); RenderStateShard.f_110127_.m_110188_(); this.f_109418_.m_110023_(p_109601_); -@@ -1386,6 +_,7 @@ +@@ -1387,6 +_,7 @@ RenderSystem.m_69458_(false); profilerfiller.m_6182_("weather"); this.m_109703_(p_109606_, p_109601_, d0, d1, d2); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, p_109600_, p_109607_, this.f_109477_, p_109604_, frustum); ++ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); this.m_173012_(p_109604_); RenderSystem.m_69458_(true); } -@@ -1520,6 +_,7 @@ +@@ -1521,6 +_,7 @@ shaderinstance.m_173362_(); VertexBuffer.m_85931_(); this.f_109461_.m_91307_().m_7238_(); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(p_172994_, this, p_172995_, p_172999_, this.f_109477_, this.f_109461_.f_91063_.m_109153_(), this.f_109442_ != null ? this.f_109442_ : this.f_172938_); ++ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(p_172994_, this, p_172995_, p_254039_, this.f_109477_, this.f_109461_.f_91063_.m_109153_(), this.f_109442_ != null ? this.f_109442_ : this.f_172938_); p_172994_.m_110188_(); } -@@ -1781,6 +_,8 @@ +@@ -1782,6 +_,8 @@ } - public void m_202423_(PoseStack p_202424_, Matrix4f p_202425_, float p_202426_, Camera p_202427_, boolean p_202428_, Runnable p_202429_) { -+ if (f_109465_.m_104583_().renderSky(f_109465_, f_109477_, p_202426_, p_202424_, p_202427_, p_202425_, p_202428_, p_202429_)) + public void m_202423_(PoseStack p_202424_, Matrix4f p_254034_, float p_202426_, Camera p_202427_, boolean p_202428_, Runnable p_202429_) { ++ if (f_109465_.m_104583_().renderSky(f_109465_, f_109477_, p_202426_, p_202424_, p_202427_, p_254034_, p_202428_, p_202429_)) + return; p_202429_.run(); if (!p_202428_) { FogType fogtype = p_202427_.m_167685_(); -@@ -1913,6 +_,8 @@ +@@ -1914,6 +_,8 @@ } - public void m_172954_(PoseStack p_172955_, Matrix4f p_172956_, float p_172957_, double p_172958_, double p_172959_, double p_172960_) { -+ if (f_109465_.m_104583_().renderClouds(f_109465_, f_109477_, p_172957_, p_172955_, p_172958_, p_172959_, p_172960_, p_172956_)) + public void m_253054_(PoseStack p_254145_, Matrix4f p_254537_, float p_254364_, double p_253843_, double p_253663_, double p_253795_) { ++ if (f_109465_.m_104583_().renderClouds(f_109465_, f_109477_, p_254364_, p_254145_, p_253843_, p_253663_, p_253795_, p_254537_)) + return; float f = this.f_109465_.m_104583_().m_108871_(); if (!Float.isNaN(f)) { RenderSystem.m_69464_(); -@@ -2103,7 +_,7 @@ - } - } else { +@@ -2100,7 +_,7 @@ + boolean flag = false; + if (this.f_109461_.f_91066_.m_232080_().m_231551_() == PrioritizeChunkUpdates.NEARBY) { BlockPos blockpos1 = chunkrenderdispatcher$renderchunk.m_112839_().m_7918_(8, 8, 8); - flag = blockpos1.m_123331_(blockpos) < 768.0D || chunkrenderdispatcher$renderchunk.m_112842_(); + flag = !net.minecraftforge.common.ForgeConfig.CLIENT.alwaysSetupTerrainOffThread.get() && (blockpos1.m_123331_(blockpos) < 768.0D || chunkrenderdispatcher$renderchunk.m_112842_()); // the target is the else block below, so invert the forge addition to get there early + } else if (this.f_109461_.f_91066_.m_232080_().m_231551_() == PrioritizeChunkUpdates.PLAYER_AFFECTED) { + flag = chunkrenderdispatcher$renderchunk.m_112842_(); } - - if (flag) { @@ -2400,7 +_,12 @@ this.f_109469_.m_110859_(p_109502_, p_109503_, p_109504_, p_109505_); } @@ -210,7 +210,7 @@ if (recorditem != null) { this.f_109461_.f_91065_.m_93055_(recorditem.m_43050_()); } -@@ -2560,7 +_,7 @@ +@@ -2548,7 +_,7 @@ break; case 1010: if (Item.m_41445_(p_234307_) instanceof RecordItem) { @@ -219,16 +219,16 @@ } else { this.m_109514_((SoundEvent)null, p_234306_); } -@@ -2730,7 +_,7 @@ +@@ -2700,7 +_,7 @@ case 2001: BlockState blockstate = Block.m_49803_(p_234307_); if (!blockstate.m_60795_()) { - SoundType soundtype = blockstate.m_60827_(); + SoundType soundtype = blockstate.getSoundType(this.f_109465_, p_234306_, null); - this.f_109465_.m_104677_(p_234306_, soundtype.m_56775_(), SoundSource.BLOCKS, (soundtype.m_56773_() + 1.0F) / 2.0F, soundtype.m_56774_() * 0.8F, false); + this.f_109465_.m_245747_(p_234306_, soundtype.m_56775_(), SoundSource.BLOCKS, (soundtype.m_56773_() + 1.0F) / 2.0F, soundtype.m_56774_() * 0.8F, false); } -@@ -2945,7 +_,7 @@ +@@ -2915,7 +_,7 @@ } else { int i = p_109538_.m_45517_(LightLayer.SKY, p_109540_); int j = p_109538_.m_45517_(LightLayer.BLOCK, p_109540_); diff --git a/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch b/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch index f5022aff27..7ff7a7dfa1 100644 --- a/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/client/renderer/LightTexture.java +++ b/net/minecraft/client/renderer/LightTexture.java -@@ -138,6 +_,8 @@ +@@ -136,6 +_,8 @@ } } + clientlevel.m_104583_().adjustLightmapColors(clientlevel, p_109882_, f, f7, f8, j, i, vector3f1); + if (f5 > 0.0F) { - float f13 = Math.max(vector3f1.m_122239_(), Math.max(vector3f1.m_122260_(), vector3f1.m_122269_())); + float f13 = Math.max(vector3f1.x(), Math.max(vector3f1.y(), vector3f1.z())); if (f13 < 1.0F) { @@ -193,7 +_,7 @@ } diff --git a/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch b/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch index f4a714495d..db8fa4adba 100644 --- a/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/PostChain.java +++ b/net/minecraft/client/renderer/PostChain.java -@@ -173,7 +_,8 @@ +@@ -157,7 +_,8 @@ throw new ChainedJsonException("Render target '" + s4 + "' can't be used as depth buffer"); } @@ -10,7 +10,7 @@ this.f_110007_.m_213713_(resourcelocation).orElseThrow(() -> { return new ChainedJsonException("Render target or texture '" + s4 + "' does not exist"); }); -@@ -276,6 +_,7 @@ +@@ -260,6 +_,7 @@ public void m_110038_(String p_110039_, int p_110040_, int p_110041_) { RenderTarget rendertarget = new TextureTarget(p_110040_, p_110041_, true, Minecraft.f_91002_); rendertarget.m_83931_(0.0F, 0.0F, 0.0F, 0.0F); diff --git a/patches/minecraft/net/minecraft/client/renderer/ShaderInstance.java.patch b/patches/minecraft/net/minecraft/client/renderer/ShaderInstance.java.patch index 3f8e870f25..4be487649c 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ShaderInstance.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ShaderInstance.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/ShaderInstance.java +++ b/net/minecraft/client/renderer/ShaderInstance.java -@@ -95,10 +_,14 @@ +@@ -96,10 +_,14 @@ @Nullable public final Uniform f_173320_; @@ -15,9 +15,9 @@ - ResourceLocation resourcelocation = new ResourceLocation("shaders/core/" + p_173337_ + ".json"); + ResourceLocation resourcelocation = new ResourceLocation(shaderLocation.m_135827_(), "shaders/core/" + shaderLocation.m_135815_() + ".json"); - try { - Reader reader = p_173336_.m_215597_(resourcelocation); -@@ -222,8 +_,10 @@ + try (Reader reader = p_173336_.m_215597_(resourcelocation)) { + JsonObject jsonobject = GsonHelper.m_13859_(reader); +@@ -205,8 +_,10 @@ Program program1 = p_173342_.m_85570_().get(p_173343_); Program program; if (program1 == null) { @@ -27,10 +27,10 @@ + String s = "shaders/core/" + loc.m_135815_() + p_173342_.m_85569_(); + ResourceLocation resourcelocation = new ResourceLocation(loc.m_135827_(), s); + Resource resource = p_173341_.m_215593_(resourcelocation); - InputStream inputstream = resource.m_215507_(); - try { -@@ -232,11 +_,11 @@ + try (InputStream inputstream = resource.m_215507_()) { + final String s1 = FileUtil.m_179922_(s); +@@ -214,11 +_,11 @@ private final Set f_173369_ = Sets.newHashSet(); public String m_142138_(boolean p_173374_, String p_173375_) { @@ -44,8 +44,8 @@ - ResourceLocation resourcelocation = new ResourceLocation(p_173375_); try { - Reader reader = p_173341_.m_215597_(resourcelocation); -@@ -262,7 +_,8 @@ + String s2; +@@ -228,7 +_,8 @@ return s2; } catch (IOException ioexception) { diff --git a/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch b/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch index e286658a17..f5981adf61 100644 --- a/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/Sheets.java +++ b/net/minecraft/client/renderer/Sheets.java -@@ -129,7 +_,8 @@ +@@ -135,11 +_,13 @@ } private static Material m_173385_(WoodType p_173386_) { @@ -9,8 +9,14 @@ + return new Material(f_110739_, new ResourceLocation(location.m_135827_(), "entity/signs/" + location.m_135815_())); } + private static Material m_245275_(WoodType p_251735_) { +- return new Material(f_110739_, new ResourceLocation("entity/signs/hanging/" + p_251735_.m_61846_())); ++ ResourceLocation location = new ResourceLocation(p_251735_.m_61846_()); ++ return new Material(f_110739_, new ResourceLocation(location.m_135827_(), "entity/signs/hanging/" + location.m_135815_())); + } + public static Material m_173381_(WoodType p_173382_) { -@@ -176,5 +_,12 @@ +@@ -190,5 +_,12 @@ default: return p_110773_; } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/BlockModelShaper.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/BlockModelShaper.java.patch index 4a3f2e2da9..eaf386db5e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/BlockModelShaper.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/BlockModelShaper.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/block/BlockModelShaper.java +++ b/net/minecraft/client/renderer/block/BlockModelShaper.java -@@ -23,8 +_,15 @@ +@@ -21,8 +_,15 @@ this.f_110878_ = p_110880_; } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch index 14419b0ec6..fb3b29a908 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch @@ -12,48 +12,46 @@ float f = (float)(i >> 16 & 255) / 255.0F; float f1 = (float)(i >> 8 & 255) / 255.0F; float f2 = (float)(i & 255) / 255.0F; -@@ -180,15 +_,16 @@ - float f30 = f4 * f; - float f31 = f4 * f1; - float f32 = f4 * f2; -- this.m_110984_(p_234372_, d1 + 0.0D, d2 + (double)f8, d0 + 0.0D, f30, f31, f32, f18, f22, j); -- this.m_110984_(p_234372_, d1 + 0.0D, d2 + (double)f10, d0 + 1.0D, f30, f31, f32, f19, f23, j); -- this.m_110984_(p_234372_, d1 + 1.0D, d2 + (double)f9, d0 + 1.0D, f30, f31, f32, f20, f24, j); -- this.m_110984_(p_234372_, d1 + 1.0D, d2 + (double)f7, d0 + 0.0D, f30, f31, f32, f21, f25, j); -+ -+ this.vertex(p_234372_, d1 + 0.0D, d2 + (double)f8, d0 + 0.0D, f30, f31, f32, alpha, f18, f22, j); -+ this.vertex(p_234372_, d1 + 0.0D, d2 + (double)f10, d0 + 1.0D, f30, f31, f32, alpha, f19, f23, j); -+ this.vertex(p_234372_, d1 + 1.0D, d2 + (double)f9, d0 + 1.0D, f30, f31, f32, alpha, f20, f24, j); -+ this.vertex(p_234372_, d1 + 1.0D, d2 + (double)f7, d0 + 0.0D, f30, f31, f32, alpha, f21, f25, j); +@@ -178,15 +_,15 @@ + float f52 = f4 * f; + float f30 = f4 * f1; + float f31 = f4 * f2; +- this.m_110984_(p_234372_, d1 + 0.0D, d2 + (double)f8, d0 + 0.0D, f52, f30, f31, f18, f22, l); +- this.m_110984_(p_234372_, d1 + 0.0D, d2 + (double)f10, d0 + 1.0D, f52, f30, f31, f19, f23, l); +- this.m_110984_(p_234372_, d1 + 1.0D, d2 + (double)f9, d0 + 1.0D, f52, f30, f31, f20, f24, l); +- this.m_110984_(p_234372_, d1 + 1.0D, d2 + (double)f7, d0 + 0.0D, f52, f30, f31, f21, f25, l); ++ this.vertex(p_234372_, d1 + 0.0D, d2 + (double)f8, d0 + 0.0D, f52, f30, f31, alpha, f18, f22, l); ++ this.vertex(p_234372_, d1 + 0.0D, d2 + (double)f10, d0 + 1.0D, f52, f30, f31, alpha, f19, f23, l); ++ this.vertex(p_234372_, d1 + 1.0D, d2 + (double)f9, d0 + 1.0D, f52, f30, f31, alpha, f20, f24, l); ++ this.vertex(p_234372_, d1 + 1.0D, d2 + (double)f7, d0 + 0.0D, f52, f30, f31, alpha, f21, f25, l); if (p_234374_.m_76171_(p_234370_, p_234371_.m_7494_())) { -- this.m_110984_(p_234372_, d1 + 0.0D, d2 + (double)f8, d0 + 0.0D, f30, f31, f32, f18, f22, j); -- this.m_110984_(p_234372_, d1 + 1.0D, d2 + (double)f7, d0 + 0.0D, f30, f31, f32, f21, f25, j); -- this.m_110984_(p_234372_, d1 + 1.0D, d2 + (double)f9, d0 + 1.0D, f30, f31, f32, f20, f24, j); -- this.m_110984_(p_234372_, d1 + 0.0D, d2 + (double)f10, d0 + 1.0D, f30, f31, f32, f19, f23, j); -+ this.vertex(p_234372_, d1 + 0.0D, d2 + (double)f8, d0 + 0.0D, f30, f31, f32, alpha, f18, f22, j); -+ this.vertex(p_234372_, d1 + 1.0D, d2 + (double)f7, d0 + 0.0D, f30, f31, f32, alpha, f21, f25, j); -+ this.vertex(p_234372_, d1 + 1.0D, d2 + (double)f9, d0 + 1.0D, f30, f31, f32, alpha, f20, f24, j); -+ this.vertex(p_234372_, d1 + 0.0D, d2 + (double)f10, d0 + 1.0D, f30, f31, f32, alpha, f19, f23, j); +- this.m_110984_(p_234372_, d1 + 0.0D, d2 + (double)f8, d0 + 0.0D, f52, f30, f31, f18, f22, l); +- this.m_110984_(p_234372_, d1 + 1.0D, d2 + (double)f7, d0 + 0.0D, f52, f30, f31, f21, f25, l); +- this.m_110984_(p_234372_, d1 + 1.0D, d2 + (double)f9, d0 + 1.0D, f52, f30, f31, f20, f24, l); +- this.m_110984_(p_234372_, d1 + 0.0D, d2 + (double)f10, d0 + 1.0D, f52, f30, f31, f19, f23, l); ++ this.vertex(p_234372_, d1 + 0.0D, d2 + (double)f8, d0 + 0.0D, f52, f30, f31, alpha, f18, f22, l); ++ this.vertex(p_234372_, d1 + 1.0D, d2 + (double)f7, d0 + 0.0D, f52, f30, f31, alpha, f21, f25, l); ++ this.vertex(p_234372_, d1 + 1.0D, d2 + (double)f9, d0 + 1.0D, f52, f30, f31, alpha, f20, f24, l); ++ this.vertex(p_234372_, d1 + 0.0D, d2 + (double)f10, d0 + 1.0D, f52, f30, f31, alpha, f19, f23, l); } } -@@ -201,10 +_,11 @@ +@@ -199,10 +_,10 @@ float f46 = f3 * f; float f47 = f3 * f1; float f48 = f3 * f2; -- this.m_110984_(p_234372_, d1, d2 + (double)f17, d0 + 1.0D, f46, f47, f48, f40, f43, l); -- this.m_110984_(p_234372_, d1, d2 + (double)f17, d0, f46, f47, f48, f40, f42, l); -- this.m_110984_(p_234372_, d1 + 1.0D, d2 + (double)f17, d0, f46, f47, f48, f41, f42, l); -- this.m_110984_(p_234372_, d1 + 1.0D, d2 + (double)f17, d0 + 1.0D, f46, f47, f48, f41, f43, l); -+ -+ this.vertex(p_234372_, d1, d2 + (double)f17, d0 + 1.0D, f46, f47, f48, alpha, f40, f43, l); -+ this.vertex(p_234372_, d1, d2 + (double)f17, d0, f46, f47, f48, alpha, f40, f42, l); -+ this.vertex(p_234372_, d1 + 1.0D, d2 + (double)f17, d0, f46, f47, f48, alpha, f41, f42, l); -+ this.vertex(p_234372_, d1 + 1.0D, d2 + (double)f17, d0 + 1.0D, f46, f47, f48, alpha, f41, f43, l); +- this.m_110984_(p_234372_, d1, d2 + (double)f17, d0 + 1.0D, f46, f47, f48, f40, f43, k); +- this.m_110984_(p_234372_, d1, d2 + (double)f17, d0, f46, f47, f48, f40, f42, k); +- this.m_110984_(p_234372_, d1 + 1.0D, d2 + (double)f17, d0, f46, f47, f48, f41, f42, k); +- this.m_110984_(p_234372_, d1 + 1.0D, d2 + (double)f17, d0 + 1.0D, f46, f47, f48, f41, f43, k); ++ this.vertex(p_234372_, d1, d2 + (double)f17, d0 + 1.0D, f46, f47, f48, alpha, f40, f43, k); ++ this.vertex(p_234372_, d1, d2 + (double)f17, d0, f46, f47, f48, alpha, f40, f42, k); ++ this.vertex(p_234372_, d1 + 1.0D, d2 + (double)f17, d0, f46, f47, f48, alpha, f41, f42, k); ++ this.vertex(p_234372_, d1 + 1.0D, d2 + (double)f17, d0 + 1.0D, f46, f47, f48, alpha, f41, f43, k); } - int k = this.m_110945_(p_234370_, p_234371_); -@@ -258,10 +_,9 @@ + int j = this.m_110945_(p_234370_, p_234371_); +@@ -256,10 +_,9 @@ if (flag7 && !m_203179_(p_234370_, p_234371_, direction, Math.max(f44, f45), p_234370_.m_8055_(p_234371_.m_121945_(direction)))) { BlockPos blockpos = p_234371_.m_121945_(direction); TextureAtlasSprite textureatlassprite2 = atextureatlassprite[1]; @@ -67,39 +65,38 @@ } } -@@ -274,15 +_,16 @@ +@@ -272,15 +_,15 @@ float f37 = f4 * f36 * f; float f38 = f4 * f36 * f1; float f39 = f4 * f36 * f2; -- this.m_110984_(p_234372_, d3, d2 + (double)f44, d4, f37, f38, f39, f54, f33, k); -- this.m_110984_(p_234372_, d5, d2 + (double)f45, d6, f37, f38, f39, f55, f34, k); -- this.m_110984_(p_234372_, d5, d2 + (double)f17, d6, f37, f38, f39, f55, f35, k); -- this.m_110984_(p_234372_, d3, d2 + (double)f17, d4, f37, f38, f39, f54, f35, k); -+ -+ this.vertex(p_234372_, d3, d2 + (double)f44, d4, f37, f38, f39, alpha, f54, f33, k); -+ this.vertex(p_234372_, d5, d2 + (double)f45, d6, f37, f38, f39, alpha, f55, f34, k); -+ this.vertex(p_234372_, d5, d2 + (double)f17, d6, f37, f38, f39, alpha, f55, f35, k); -+ this.vertex(p_234372_, d3, d2 + (double)f17, d4, f37, f38, f39, alpha, f54, f35, k); +- this.m_110984_(p_234372_, d3, d2 + (double)f44, d4, f37, f38, f39, f53, f33, j); +- this.m_110984_(p_234372_, d5, d2 + (double)f45, d6, f37, f38, f39, f32, f34, j); +- this.m_110984_(p_234372_, d5, d2 + (double)f17, d6, f37, f38, f39, f32, f35, j); +- this.m_110984_(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.f_110942_) { -- this.m_110984_(p_234372_, d3, d2 + (double)f17, d4, f37, f38, f39, f54, f35, k); -- this.m_110984_(p_234372_, d5, d2 + (double)f17, d6, f37, f38, f39, f55, f35, k); -- this.m_110984_(p_234372_, d5, d2 + (double)f45, d6, f37, f38, f39, f55, f34, k); -- this.m_110984_(p_234372_, d3, d2 + (double)f44, d4, f37, f38, f39, f54, f33, k); -+ this.vertex(p_234372_, d3, d2 + (double)f17, d4, f37, f38, f39, alpha, f54, f35, k); -+ this.vertex(p_234372_, d5, d2 + (double)f17, d6, f37, f38, f39, alpha, f55, f35, k); -+ this.vertex(p_234372_, d5, d2 + (double)f45, d6, f37, f38, f39, alpha, f55, f34, k); -+ this.vertex(p_234372_, d3, d2 + (double)f44, d4, f37, f38, f39, alpha, f54, f33, k); +- this.m_110984_(p_234372_, d3, d2 + (double)f17, d4, f37, f38, f39, f53, f35, j); +- this.m_110984_(p_234372_, d5, d2 + (double)f17, d6, f37, f38, f39, f32, f35, j); +- this.m_110984_(p_234372_, d5, d2 + (double)f45, d6, f37, f38, f39, f32, f34, j); +- this.m_110984_(p_234372_, d3, d2 + (double)f44, d4, f37, f38, f39, f53, f33, j); ++ 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); ++ this.vertex(p_234372_, d3, d2 + (double)f44, d4, f37, f38, f39, alpha, f53, f33, j); } } } -@@ -336,8 +_,8 @@ +@@ -334,8 +_,8 @@ } } - private void m_110984_(VertexConsumer p_110985_, double p_110986_, double p_110987_, double p_110988_, float p_110989_, float p_110990_, float p_110991_, float p_110992_, float p_110993_, int p_110994_) { - p_110985_.m_5483_(p_110986_, p_110987_, p_110988_).m_85950_(p_110989_, p_110990_, p_110991_, 1.0F).m_7421_(p_110992_, p_110993_).m_85969_(p_110994_).m_5601_(0.0F, 1.0F, 0.0F).m_5752_(); + private void vertex(VertexConsumer p_110985_, double p_110986_, double p_110987_, double p_110988_, float p_110989_, float p_110990_, float p_110991_, float alpha, float p_110992_, float p_110993_, int p_110994_) { -+ p_110985_.m_5483_(p_110986_, p_110987_, p_110988_).m_85950_(p_110989_, p_110990_, p_110991_, alpha).m_7421_(p_110992_, p_110993_).m_85969_(p_110994_).m_5601_(0.0F, 1.0F, 0.0F).m_5752_(); ++ p_110985_.m_5483_(p_110986_, p_110987_, p_110988_).m_85950_(p_110989_, p_110990_, p_110991_, alpha).m_7421_(p_110992_, p_110993_).m_85969_(p_110994_).m_5601_(0.0F, 1.0F, 0.0F).m_5752_(); } private int m_110945_(BlockAndTintGetter p_110946_, BlockPos p_110947_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModel.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModel.java.patch index a6a89c93f4..b9ea8ddd50 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModel.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModel.java.patch @@ -29,46 +29,42 @@ return this.f_111418_ != null ? this.f_111418_.m_111476_() : this.f_111424_; } @@ -112,6 +_,10 @@ - return this.f_111426_.isEmpty() ? ItemOverrides.f_111734_ : new ItemOverrides(p_111447_, p_111448_, p_111447_::m_119341_, this.f_111426_); + return this.f_111426_.isEmpty() ? ItemOverrides.f_111734_ : new ItemOverrides(p_250138_, p_251800_, this.f_111426_); } -+ public ItemOverrides getOverrides(ModelBakery p_111447_, BlockModel p_111448_, Function textureGetter) { -+ return this.f_111426_.isEmpty() ? ItemOverrides.f_111734_ : new ItemOverrides(p_111447_, p_111448_, p_111447_::m_119341_, textureGetter, this.f_111426_); ++ public ItemOverrides getOverrides(ModelBaker p_250138_, BlockModel p_251800_, Function spriteGetter) { ++ return this.f_111426_.isEmpty() ? ItemOverrides.f_111734_ : new ItemOverrides(p_250138_, p_251800_, this.f_111426_, spriteGetter); + } + public Collection m_7970_() { Set set = Sets.newHashSet(); -@@ -155,6 +_,9 @@ - - Set set1 = Sets.newHashSet(this.m_111480_("particle")); - -+ if (customData.hasCustomGeometry()) -+ set1.addAll(customData.getTextureDependencies(p_111469_, p_111470_)); -+ else - for(BlockElement blockelement : this.m_111436_()) { - for(BlockElementFace blockelementface : blockelement.f_111310_.values()) { - Material material = this.m_111480_(blockelementface.f_111356_); -@@ -181,11 +_,18 @@ - return set1; +@@ -161,11 +_,24 @@ + }); } -+ @Deprecated //Forge: Use Boolean variant - public BakedModel m_7611_(ModelBakery p_111457_, Function p_111458_, ModelState p_111459_, ResourceLocation p_111460_) { - return this.m_111449_(p_111457_, this, p_111458_, p_111459_, p_111460_, true); ++ /** ++ * @deprecated Forge: Use {@link #bake(ModelBaker, BlockModel, Function, ModelState, ResourceLocation, boolean)}. ++ */ ++ @Deprecated + public BakedModel m_7611_(ModelBaker p_252120_, Function p_250023_, ModelState p_251130_, ResourceLocation p_252208_) { + return this.m_111449_(p_252120_, this, p_250023_, p_251130_, p_252208_, true); } - public BakedModel m_111449_(ModelBakery p_111450_, BlockModel p_111451_, Function p_111452_, ModelState p_111453_, ResourceLocation p_111454_, boolean p_111455_) { -+ return net.minecraftforge.client.model.geometry.UnbakedGeometryHelper.bake(this, p_111450_, p_111451_, p_111452_, p_111453_, p_111454_, p_111455_); + public BakedModel m_111449_(ModelBaker p_249720_, BlockModel p_111451_, Function p_111452_, ModelState p_111453_, ResourceLocation p_111454_, boolean p_111455_) { ++ return net.minecraftforge.client.model.geometry.UnbakedGeometryHelper.bake(this, p_249720_, p_111451_, p_111452_, p_111453_, p_111454_, p_111455_); + } + ++ /** ++ * @deprecated Forge: For internal use only. Use {@link #bake(ModelBaker, BlockModel, Function, ModelState, ResourceLocation, boolean)}. ++ */ + @Deprecated(forRemoval = true, since = "1.19.2") // TODO: We cannot remove it since it's vanilla code, but make it private in 1.20 -+ public BakedModel bakeVanilla(ModelBakery p_111450_, BlockModel p_111451_, Function p_111452_, ModelState p_111453_, ResourceLocation p_111454_, boolean p_111455_, net.minecraftforge.client.RenderTypeGroup renderTypes) { -+ if (true) return net.minecraftforge.client.model.geometry.UnbakedGeometryHelper.bakeVanilla(this, p_111450_, p_111451_, p_111452_, p_111453_, p_111454_); // Redirected, in case anyone actually uses this ++ public BakedModel bakeVanilla(ModelBaker p_249720_, BlockModel p_111451_, Function p_111452_, ModelState p_111453_, ResourceLocation p_111454_, boolean p_111455_, net.minecraftforge.client.RenderTypeGroup renderTypes) { ++ if (true) return net.minecraftforge.client.model.geometry.UnbakedGeometryHelper.bakeVanilla(this, p_249720_, p_111451_, p_111452_, p_111453_, p_111454_); // Redirected, in case anyone actually uses this TextureAtlasSprite textureatlassprite = p_111452_.apply(this.m_111480_("particle")); if (this.m_111490_() == ModelBakery.f_119233_) { - return new BuiltInModel(this.m_111491_(), this.m_111446_(p_111450_, p_111451_), textureatlassprite, this.m_111479_().m_111526_()); -@@ -268,7 +_,18 @@ + return new BuiltInModel(this.m_111491_(), this.m_246736_(p_249720_, p_111451_), textureatlassprite, this.m_111479_().m_111526_()); +@@ -248,7 +_,18 @@ ItemTransform itemtransform5 = this.m_111444_(ItemTransforms.TransformType.GUI); ItemTransform itemtransform6 = this.m_111444_(ItemTransforms.TransformType.GROUND); ItemTransform itemtransform7 = this.m_111444_(ItemTransforms.TransformType.FIXED); @@ -88,7 +84,7 @@ } private ItemTransform m_111444_(ItemTransforms.TransformType p_111445_) { -@@ -387,6 +_,8 @@ +@@ -367,6 +_,8 @@ public boolean m_111526_() { return this == SIDE; } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch index 68967343cd..3978056747 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/block/model/FaceBakery.java +++ b/net/minecraft/client/renderer/block/model/FaceBakery.java -@@ -49,7 +_,10 @@ +@@ -50,7 +_,10 @@ this.m_111630_(aint, direction); } @@ -12,9 +12,9 @@ } public static BlockFaceUV m_111581_(BlockFaceUV p_111582_, Direction p_111583_, Transformation p_111584_, ResourceLocation p_111585_) { -@@ -131,8 +_,8 @@ - p_111615_[i + 1] = Float.floatToRawIntBits(p_111617_.m_122260_()); - p_111615_[i + 2] = Float.floatToRawIntBits(p_111617_.m_122269_()); +@@ -129,8 +_,8 @@ + p_111615_[i + 1] = Float.floatToRawIntBits(p_254291_.y()); + p_111615_[i + 2] = Float.floatToRawIntBits(p_254291_.z()); p_111615_[i + 3] = -1; - p_111615_[i + 4] = Float.floatToRawIntBits(p_111618_.m_118367_((double)p_111619_.m_111392_(p_111616_))); - p_111615_[i + 4 + 1] = Float.floatToRawIntBits(p_111618_.m_118393_((double)p_111619_.m_111396_(p_111616_))); @@ -22,4 +22,4 @@ + p_111615_[i + 4 + 1] = Float.floatToRawIntBits(p_111618_.m_118393_((double)p_111619_.m_111396_(p_111616_) * .999 + p_111619_.m_111396_((p_111616_ + 2) % 4) * .001)); } - private void m_111586_(Vector3f p_111587_, @Nullable BlockElementRotation p_111588_) { + private void m_252985_(Vector3f p_254412_, @Nullable BlockElementRotation p_254150_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemModelGenerator.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemModelGenerator.java.patch index 5ef8da470d..e56fc4210c 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemModelGenerator.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemModelGenerator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/block/model/ItemModelGenerator.java +++ b/net/minecraft/client/renderer/block/model/ItemModelGenerator.java -@@ -39,6 +_,7 @@ +@@ -40,6 +_,7 @@ map.put("particle", p_111672_.m_111477_("particle") ? Either.left(p_111672_.m_111480_("particle")) : map.get("layer0")); BlockModel blockmodel = new BlockModel((ResourceLocation)null, list, map, false, p_111672_.m_111479_(), p_111672_.m_111491_(), p_111672_.m_111484_()); blockmodel.f_111416_ = p_111672_.f_111416_; diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch index b0628e5912..cc710ac3f7 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch @@ -1,39 +1,43 @@ --- a/net/minecraft/client/renderer/block/model/ItemOverrides.java +++ b/net/minecraft/client/renderer/block/model/ItemOverrides.java -@@ -32,7 +_,11 @@ +@@ -31,7 +_,15 @@ this.f_173461_ = new ResourceLocation[0]; } -+ @Deprecated //Forge: Use IUnbakedModel, add texture getter - public ItemOverrides(ModelBakery p_111740_, BlockModel p_111741_, Function p_111742_, List p_111743_) { -+ this(p_111740_, p_111741_, p_111742_, p_111740_.getAtlasSet()::m_117971_, p_111743_); ++ /** ++ * @deprecated Forge: Use {@link #ItemOverrides(ModelBaker, UnbakedModel, List, java.util.function.Function)} ++ */ ++ @Deprecated + public ItemOverrides(ModelBaker p_251211_, BlockModel p_111741_, List p_111743_) { ++ this(p_251211_, p_111741_, p_111743_, p_251211_.getModelTextureGetter()); + } -+ public ItemOverrides(ModelBakery p_111740_, UnbakedModel p_111741_, Function p_111742_, Function textureGetter, List p_111743_) { ++ ++ public ItemOverrides(ModelBaker p_251211_, UnbakedModel p_111741_, List p_111743_, java.util.function.Function spriteGetter) { this.f_173461_ = p_111743_.stream().flatMap(ItemOverride::m_173449_).map(ItemOverride.Predicate::m_173459_).distinct().toArray((p_173479_) -> { return new ResourceLocation[p_173479_]; }); -@@ -46,7 +_,7 @@ +@@ -45,7 +_,7 @@ for(int j = p_111743_.size() - 1; j >= 0; --j) { ItemOverride itemoverride = p_111743_.get(j); -- BakedModel bakedmodel = this.m_173470_(p_111740_, p_111741_, p_111742_, itemoverride); -+ BakedModel bakedmodel = this.bakeModel(p_111740_, p_111741_, p_111742_, textureGetter, itemoverride); +- BakedModel bakedmodel = this.m_246989_(p_251211_, p_111741_, itemoverride); ++ BakedModel bakedmodel = this.bakeModel(p_251211_, p_111741_, itemoverride, spriteGetter); ItemOverrides.PropertyMatcher[] aitemoverrides$propertymatcher = itemoverride.m_173449_().map((p_173477_) -> { int k = object2intmap.getInt(p_173477_.m_173459_()); return new ItemOverrides.PropertyMatcher(k, p_173477_.m_173460_()); -@@ -60,9 +_,9 @@ +@@ -59,9 +_,9 @@ } @Nullable -- private BakedModel m_173470_(ModelBakery p_173471_, BlockModel p_173472_, Function p_173473_, ItemOverride p_173474_) { -+ private BakedModel bakeModel(ModelBakery p_173471_, UnbakedModel p_173472_, Function p_173473_, Function textureGetter, ItemOverride p_173474_) { - UnbakedModel unbakedmodel = p_173473_.apply(p_173474_.m_111718_()); -- return Objects.equals(unbakedmodel, p_173472_) ? null : p_173471_.m_119349_(p_173474_.m_111718_(), BlockModelRotation.X0_Y0); -+ return Objects.equals(unbakedmodel, p_173472_) ? null : p_173471_.bake(p_173474_.m_111718_(), BlockModelRotation.X0_Y0, textureGetter); +- private BakedModel m_246989_(ModelBaker p_249483_, BlockModel p_251965_, ItemOverride p_250816_) { ++ private BakedModel bakeModel(ModelBaker p_249483_, UnbakedModel p_251965_, ItemOverride p_250816_, java.util.function.Function spriteGetter) { + UnbakedModel unbakedmodel = p_249483_.m_245361_(p_250816_.m_111718_()); +- return Objects.equals(unbakedmodel, p_251965_) ? null : p_249483_.m_245240_(p_250816_.m_111718_(), BlockModelRotation.X0_Y0); ++ return Objects.equals(unbakedmodel, p_251965_) ? null : p_249483_.bake(p_250816_.m_111718_(), BlockModelRotation.X0_Y0, spriteGetter); } @Nullable -@@ -95,6 +_,10 @@ +@@ -94,6 +_,10 @@ } return p_173465_; diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransform.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransform.java.patch index cdfc8f9f00..9ddf4d9286 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransform.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransform.java.patch @@ -1,38 +1,38 @@ --- a/net/minecraft/client/renderer/block/model/ItemTransform.java +++ b/net/minecraft/client/renderer/block/model/ItemTransform.java -@@ -20,11 +_,17 @@ +@@ -22,11 +_,17 @@ public final Vector3f f_111755_; public final Vector3f f_111756_; public final Vector3f f_111757_; + public final Vector3f rightRotation; - public ItemTransform(Vector3f p_111760_, Vector3f p_111761_, Vector3f p_111762_) { -+ this(p_111760_, p_111761_, p_111762_, Vector3f.f_176763_); + public ItemTransform(Vector3f p_254427_, Vector3f p_254496_, Vector3f p_254022_) { ++ this(p_254427_, p_254496_, p_254022_, new Vector3f()); + } + -+ public ItemTransform(Vector3f p_111760_, Vector3f p_111761_, Vector3f p_111762_, Vector3f rightRotation) { - this.f_111755_ = p_111760_.m_122281_(); - this.f_111756_ = p_111761_.m_122281_(); - this.f_111757_ = p_111762_.m_122281_(); -+ this.rightRotation = rightRotation.m_122281_(); ++ public ItemTransform(Vector3f p_254427_, Vector3f p_254496_, Vector3f p_254022_, Vector3f rightRotation) { + this.f_111755_ = new Vector3f((Vector3fc)p_254427_); + this.f_111756_ = new Vector3f((Vector3fc)p_254496_); + this.f_111757_ = new Vector3f((Vector3fc)p_254022_); ++ this.rightRotation = new Vector3f(rightRotation); } public void m_111763_(boolean p_111764_, PoseStack p_111765_) { -@@ -41,6 +_,7 @@ - p_111765_.m_85837_((double)((float)i * this.f_111756_.m_122239_()), (double)this.f_111756_.m_122260_(), (double)this.f_111756_.m_122269_()); - p_111765_.m_85845_(new Quaternion(f, f1, f2, true)); - p_111765_.m_85841_(this.f_111757_.m_122239_(), this.f_111757_.m_122260_(), this.f_111757_.m_122269_()); -+ p_111765_.m_85845_(new Quaternion(rightRotation.m_122239_(), rightRotation.m_122260_() * (p_111764_ ? -1 : 1), rightRotation.m_122269_() * (p_111764_ ? -1 : 1), true)); +@@ -43,6 +_,7 @@ + p_111765_.m_252880_((float)i * this.f_111756_.x(), this.f_111756_.y(), this.f_111756_.z()); + p_111765_.m_252781_((new Quaternionf()).rotationXYZ(f * ((float)Math.PI / 180F), f1 * ((float)Math.PI / 180F), f2 * ((float)Math.PI / 180F))); + p_111765_.m_85841_(this.f_111757_.x(), this.f_111757_.y(), this.f_111757_.z()); ++ p_111765_.m_252781_(net.minecraftforge.common.util.TransformationHelper.quatFromXYZ(rightRotation.x(), rightRotation.y() * (p_111764_ ? -1 : 1), rightRotation.z() * (p_111764_ ? -1 : 1), true)); } } -@@ -77,7 +_,8 @@ - vector3f1.m_122242_(-5.0F, 5.0F); +@@ -79,7 +_,8 @@ + vector3f1.set(Mth.m_14036_(vector3f1.x, -5.0F, 5.0F), Mth.m_14036_(vector3f1.y, -5.0F, 5.0F), Mth.m_14036_(vector3f1.z, -5.0F, 5.0F)); Vector3f vector3f2 = this.m_111778_(jsonobject, "scale", f_111771_); - vector3f2.m_122242_(-4.0F, 4.0F); + vector3f2.set(Mth.m_14036_(vector3f2.x, -4.0F, 4.0F), Mth.m_14036_(vector3f2.y, -4.0F, 4.0F), Mth.m_14036_(vector3f2.z, -4.0F, 4.0F)); - return new ItemTransform(vector3f, vector3f1, vector3f2); + Vector3f rightRotation = this.m_111778_(jsonobject, "right_rotation", f_111769_); + return new ItemTransform(vector3f, vector3f1, vector3f2, rightRotation); } - private Vector3f m_111778_(JsonObject p_111779_, String p_111780_, Vector3f p_111781_) { + private Vector3f m_111778_(JsonObject p_111779_, String p_111780_, Vector3f p_253777_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/MultiVariant.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/MultiVariant.java.patch index 34d453bf29..aa3add577e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/MultiVariant.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/MultiVariant.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/renderer/block/model/MultiVariant.java +++ b/net/minecraft/client/renderer/block/model/MultiVariant.java -@@ -70,7 +_,7 @@ +@@ -68,7 +_,7 @@ WeightedBakedModel.Builder weightedbakedmodel$builder = new WeightedBakedModel.Builder(); for(Variant variant : this.m_111848_()) { -- BakedModel bakedmodel = p_111850_.m_119349_(variant.m_111883_(), variant); -+ BakedModel bakedmodel = p_111850_.bake(variant.m_111883_(), variant, p_111851_); +- BakedModel bakedmodel = p_249016_.m_245240_(variant.m_111883_(), variant); ++ BakedModel bakedmodel = p_249016_.bake(variant.m_111883_(), variant, p_111851_); weightedbakedmodel$builder.m_119559_(bakedmodel, variant.m_111886_()); } diff --git a/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch index 64c3a580c1..e077aecf77 100644 --- a/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/client/renderer/blockentity/ChestRenderer.java +++ b/net/minecraft/client/renderer/blockentity/ChestRenderer.java -@@ -119,7 +_,7 @@ +@@ -117,7 +_,7 @@ f1 = 1.0F - f1; f1 = 1.0F - f1 * f1 * f1; - int i = neighborcombineresult.m_5649_(new BrightnessCombiner<>()).applyAsInt(p_112367_); + int i = neighborcombineresult.m_5649_(new BrightnessCombiner<>()).applyAsInt(p_112367_); - Material material = Sheets.m_110767_(p_112363_, chesttype, this.f_112359_); + Material material = this.getMaterial(p_112363_, chesttype); VertexConsumer vertexconsumer = material.m_119194_(p_112366_, RenderType::m_110452_); if (flag1) { if (chesttype == ChestType.LEFT) { -@@ -141,5 +_,9 @@ +@@ -139,5 +_,9 @@ p_112372_.m_104301_(p_112370_, p_112371_, p_112376_, p_112377_); p_112373_.m_104301_(p_112370_, p_112371_, p_112376_, p_112377_); p_112374_.m_104301_(p_112370_, p_112371_, p_112376_, p_112377_); diff --git a/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch index b1a5d4d509..a0db1ed525 100644 --- a/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java +++ b/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java -@@ -51,6 +_,7 @@ - builder.put(SkullBlock.Types.ZOMBIE, new SkullModel(p_173662_.m_171103_(ModelLayers.f_171224_))); +@@ -55,6 +_,7 @@ builder.put(SkullBlock.Types.CREEPER, new SkullModel(p_173662_.m_171103_(ModelLayers.f_171130_))); builder.put(SkullBlock.Types.DRAGON, new DragonHeadModel(p_173662_.m_171103_(ModelLayers.f_171135_))); + builder.put(SkullBlock.Types.PIGLIN, new PiglinHeadModel(p_173662_.m_171103_(ModelLayers.f_260668_))); + net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.EntityRenderersEvent.CreateSkullModels(builder, p_173662_)); return builder.build(); } diff --git a/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch index 0ce30d417d..93ac9069c8 100644 --- a/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch @@ -97,7 +97,7 @@ @@ -612,8 +_,9 @@ posestack.m_85836_(); - posestack.m_85837_((double)(blockpos2.m_123341_() & 15), (double)(blockpos2.m_123342_() & 15), (double)(blockpos2.m_123343_() & 15)); + posestack.m_252880_((float)(blockpos2.m_123341_() & 15), (float)(blockpos2.m_123342_() & 15), (float)(blockpos2.m_123343_() & 15)); - blockrenderdispatcher.m_234355_(blockstate, blockpos2, renderchunkregion, posestack, bufferbuilder2, true, randomsource); + blockrenderdispatcher.renderBatched(blockstate, blockpos2, renderchunkregion, posestack, bufferbuilder2, true, randomsource, modelData, rendertype2, false); posestack.m_85849_(); diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/BoatRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/BoatRenderer.java.patch index 527f677576..2c4300d088 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/BoatRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/BoatRenderer.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/client/renderer/entity/BoatRenderer.java +++ b/net/minecraft/client/renderer/entity/BoatRenderer.java -@@ -62,7 +_,7 @@ - p_113932_.m_85845_(new Quaternion(new Vector3f(1.0F, 0.0F, 1.0F), p_113929_.m_38352_(p_113931_), true)); +@@ -73,7 +_,7 @@ + p_113932_.m_252781_((new Quaternionf()).setAngleAxis(p_113929_.m_38352_(p_113931_) * ((float)Math.PI / 180F), 1.0F, 0.0F, 1.0F)); } -- Pair pair = this.f_173934_.get(p_113929_.m_38387_()); -+ Pair pair = getModelWithLocation(p_113929_); +- Pair> pair = this.f_173934_.get(p_113929_.m_262365_()); ++ Pair> pair = getModelWithLocation(p_113929_); ResourceLocation resourcelocation = pair.getFirst(); - BoatModel boatmodel = pair.getSecond(); + ListModel listmodel = pair.getSecond(); p_113932_.m_85841_(-1.0F, -1.0F, 1.0F); -@@ -79,7 +_,10 @@ +@@ -93,7 +_,10 @@ super.m_7392_(p_113929_, p_113930_, p_113931_, p_113932_, p_113933_, p_113934_); } + @Deprecated // forge: override getModelWithLocation to change the texture / model public ResourceLocation m_5478_(Boat p_113927_) { -- return this.f_173934_.get(p_113927_.m_38387_()).getFirst(); +- return this.f_173934_.get(p_113927_.m_262365_()).getFirst(); + return getModelWithLocation(p_113927_).getFirst(); } + -+ public Pair getModelWithLocation(Boat boat) { return this.f_173934_.get(boat.m_38387_()); } ++ public Pair> getModelWithLocation(Boat boat) { return this.f_173934_.get(boat.m_262365_()); } } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch index 38f3501578..4e5afb3e5e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch @@ -6,13 +6,13 @@ float f = 0.25F; - float f1 = Mth.m_14031_(((float)p_115036_.m_32059_() + p_115038_) / 10.0F + p_115036_.f_31983_) * 0.1F + 0.1F; + float f1 = shouldBob() ? Mth.m_14031_(((float)p_115036_.m_32059_() + p_115038_) / 10.0F + p_115036_.f_31983_) * 0.1F + 0.1F : 0; - float f2 = bakedmodel.m_7442_().m_111808_(ItemTransforms.TransformType.GROUND).f_111757_.m_122260_(); - p_115039_.m_85837_(0.0D, (double)(f1 + 0.25F * f2), 0.0D); + float f2 = bakedmodel.m_7442_().m_111808_(ItemTransforms.TransformType.GROUND).f_111757_.y(); + p_115039_.m_252880_(0.0F, f1 + 0.25F * f2, 0.0F); float f3 = p_115036_.m_32008_(p_115038_); - p_115039_.m_85845_(Vector3f.f_122225_.m_122270_(f3)); -- float f4 = bakedmodel.m_7442_().f_111793_.f_111757_.m_122239_(); -- float f5 = bakedmodel.m_7442_().f_111793_.f_111757_.m_122260_(); -- float f6 = bakedmodel.m_7442_().f_111793_.f_111757_.m_122269_(); + p_115039_.m_252781_(Axis.f_252436_.m_252961_(f3)); +- float f4 = bakedmodel.m_7442_().f_111793_.f_111757_.x(); +- float f5 = bakedmodel.m_7442_().f_111793_.f_111757_.y(); +- float f6 = bakedmodel.m_7442_().f_111793_.f_111757_.z(); if (!flag) { - float f7 = -0.0F * (float)(j - 1) * 0.5F * f4; - float f8 = -0.0F * (float)(j - 1) * 0.5F * f5; @@ -20,19 +20,19 @@ + float f7 = -0.0F * (float)(j - 1) * 0.5F; + float f8 = -0.0F * (float)(j - 1) * 0.5F; + float f9 = -0.09375F * (float)(j - 1) * 0.5F; - p_115039_.m_85837_((double)f7, (double)f8, (double)f9); + p_115039_.m_252880_(f7, f8, f9); } @@ -83,18 +_,18 @@ float f11 = (this.f_115020_.m_188501_() * 2.0F - 1.0F) * 0.15F; float f13 = (this.f_115020_.m_188501_() * 2.0F - 1.0F) * 0.15F; float f10 = (this.f_115020_.m_188501_() * 2.0F - 1.0F) * 0.15F; -- p_115039_.m_85837_((double)f11, (double)f13, (double)f10); -+ p_115039_.m_85837_(shouldSpreadItems() ? f11 : 0, shouldSpreadItems() ? f13 : 0, shouldSpreadItems() ? f10 : 0); +- p_115039_.m_252880_(f11, f13, f10); ++ p_115039_.m_252880_(shouldSpreadItems() ? f11 : 0, shouldSpreadItems() ? f13 : 0, shouldSpreadItems() ? f10 : 0); } else { float f12 = (this.f_115020_.m_188501_() * 2.0F - 1.0F) * 0.15F * 0.5F; float f14 = (this.f_115020_.m_188501_() * 2.0F - 1.0F) * 0.15F * 0.5F; -- p_115039_.m_85837_((double)f12, (double)f14, 0.0D); +- p_115039_.m_252880_(f12, f14, 0.0F); + p_115039_.m_85837_(shouldSpreadItems() ? f12 : 0, shouldSpreadItems() ? f14 : 0, 0.0D); } } @@ -40,7 +40,7 @@ this.f_115019_.m_115143_(itemstack, ItemTransforms.TransformType.GROUND, false, p_115039_, p_115040_, p_115041_, OverlayTexture.f_118083_, bakedmodel); p_115039_.m_85849_(); if (!flag) { -- p_115039_.m_85837_((double)(0.0F * f4), (double)(0.0F * f5), (double)(0.09375F * f6)); +- p_115039_.m_252880_(0.0F * f4, 0.0F * f5, 0.09375F * f6); + p_115039_.m_85837_(0.0, 0.0, 0.09375F); } } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch index 76794cc909..134bbd7baa 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch @@ -7,7 +7,7 @@ - ModelResourceLocation modelresourcelocation = this.m_174212_(p_115076_, itemstack); + ModelResourceLocation modelresourcelocation = p_115076_.m_31822_().m_41720_() instanceof MapItem ? f_115045_ : f_115044_; p_115079_.m_85836_(); - p_115079_.m_85837_(-0.5D, -0.5D, -0.5D); + p_115079_.m_252880_(-0.5F, -0.5F, -0.5F); this.f_234645_.m_110937_().m_111067_(p_115079_.m_85850_(), p_115080_.m_6299_(Sheets.m_110789_()), (BlockState)null, modelmanager.m_119422_(modelresourcelocation), 1.0F, 1.0F, 1.0F, p_115081_, OverlayTexture.f_118083_); @@ -70,30 +_,31 @@ } @@ -16,23 +16,23 @@ - OptionalInt optionalint = p_115076_.m_218868_(); + MapItemSavedData mapitemsaveddata = MapItem.m_42853_(itemstack, p_115076_.f_19853_); if (flag) { - p_115079_.m_85837_(0.0D, 0.0D, 0.5D); + p_115079_.m_252880_(0.0F, 0.0F, 0.5F); } else { - p_115079_.m_85837_(0.0D, 0.0D, 0.4375D); + p_115079_.m_252880_(0.0F, 0.0F, 0.4375F); } - int j = optionalint.isPresent() ? p_115076_.m_31823_() % 4 * 2 : p_115076_.m_31823_(); + int j = mapitemsaveddata != null ? p_115076_.m_31823_() % 4 * 2 : p_115076_.m_31823_(); - p_115079_.m_85845_(Vector3f.f_122227_.m_122240_((float)j * 360.0F / 8.0F)); + p_115079_.m_252781_(Axis.f_252403_.m_252977_((float)j * 360.0F / 8.0F)); - if (optionalint.isPresent()) { + if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderItemInFrameEvent(p_115076_, this, p_115079_, p_115080_, p_115081_))) { + if (mapitemsaveddata != null) { - p_115079_.m_85845_(Vector3f.f_122227_.m_122240_(180.0F)); + p_115079_.m_252781_(Axis.f_252403_.m_252977_(180.0F)); float f = 0.0078125F; p_115079_.m_85841_(0.0078125F, 0.0078125F, 0.0078125F); - p_115079_.m_85837_(-64.0D, -64.0D, 0.0D); + p_115079_.m_252880_(-64.0F, -64.0F, 0.0F); - MapItemSavedData mapitemsaveddata = MapItem.m_151128_(optionalint.getAsInt(), p_115076_.f_19853_); - p_115079_.m_85837_(0.0D, 0.0D, -1.0D); + p_115079_.m_252880_(0.0F, 0.0F, -1.0F); if (mapitemsaveddata != null) { int i = this.m_174208_(p_115076_, 15728850, p_115081_); - Minecraft.m_91087_().f_91063_.m_109151_().m_168771_(p_115079_, p_115080_, optionalint.getAsInt(), mapitemsaveddata, true, i); diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch index ad44e9fc08..cd44be1c4f 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/ItemRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemRenderer.java -@@ -77,7 +_,7 @@ +@@ -83,7 +_,7 @@ public ItemRenderer(TextureManager p_174225_, ModelManager p_174226_, ItemColors p_174227_, BlockEntityWithoutLevelRenderer p_174228_) { this.f_115096_ = p_174225_; @@ -8,17 +8,17 @@ + this.f_115095_ = new net.minecraftforge.client.model.ForgeItemModelShaper(p_174226_); this.f_174223_ = p_174228_; - for(Item item : Registry.f_122827_) { -@@ -118,7 +_,7 @@ + for(Item item : BuiltInRegistries.f_257033_) { +@@ -124,7 +_,7 @@ } } - p_115151_.m_7442_().m_111808_(p_115145_).m_111763_(p_115146_, p_115147_); + p_115151_ = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(p_115147_, p_115151_, p_115145_, p_115146_); - p_115147_.m_85837_(-0.5D, -0.5D, -0.5D); + p_115147_.m_252880_(-0.5F, -0.5F, -0.5F); if (!p_115151_.m_7521_() && (!p_115144_.m_150930_(Items.f_42713_) || flag)) { boolean flag1; -@@ -128,8 +_,8 @@ +@@ -134,8 +_,8 @@ } else { flag1 = true; } @@ -29,7 +29,7 @@ VertexConsumer vertexconsumer; if (p_115144_.m_204117_(ItemTags.f_215866_) && p_115144_.m_41790_()) { p_115147_.m_85836_(); -@@ -153,9 +_,11 @@ +@@ -159,9 +_,11 @@ vertexconsumer = m_115211_(p_115148_, rendertype, true, p_115144_.m_41790_()); } @@ -43,7 +43,7 @@ } p_115147_.m_85849_(); -@@ -199,7 +_,7 @@ +@@ -205,7 +_,7 @@ float f = (float)(i >> 16 & 255) / 255.0F; float f1 = (float)(i >> 8 & 255) / 255.0F; float f2 = (float)(i & 255) / 255.0F; @@ -52,7 +52,7 @@ } } -@@ -302,6 +_,7 @@ +@@ -308,6 +_,7 @@ crashreportcategory.m_128165_("Item Type", () -> { return String.valueOf((Object)p_174237_.m_41720_()); }); @@ -60,7 +60,7 @@ crashreportcategory.m_128165_("Item Damage", () -> { return String.valueOf(p_174237_.m_41773_()); }); -@@ -362,6 +_,7 @@ +@@ -368,6 +_,7 @@ RenderSystem.m_69482_(); } @@ -68,7 +68,7 @@ } } -@@ -377,5 +_,9 @@ +@@ -383,5 +_,9 @@ public void m_6213_(ResourceManager p_115105_) { this.f_115095_.m_109403_(); diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch index e4acb6ae63..bb5f913fc5 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch @@ -21,7 +21,7 @@ f = Mth.m_14189_(p_115310_, livingentity.f_20884_, livingentity.f_20883_); f2 = f1 - f; @@ -98,7 +_,7 @@ - p_115311_.m_85837_(0.0D, (double)-1.501F, 0.0D); + p_115311_.m_252880_(0.0F, -1.501F, 0.0F); float f8 = 0.0F; float f5 = 0.0F; - if (!p_115308_.m_20159_() && p_115308_.m_6084_()) { diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch index ffb7b6fd8e..24fe6fe938 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch @@ -45,5 +45,5 @@ - float f3 = p_117802_.m_20069_() ? -90.0F - p_117802_.m_146909_() : -90.0F; + float f3 = p_117802_.m_20069_() || p_117802_.isInFluidType((fluidType, height) -> p_117802_.canSwimInFluidType(fluidType)) ? -90.0F - p_117802_.m_146909_() : -90.0F; float f4 = Mth.m_14179_(f, 0.0F, f3); - p_117803_.m_85845_(Vector3f.f_122223_.m_122240_(f4)); + p_117803_.m_252781_(Axis.f_252529_.m_252977_(f4)); if (p_117802_.m_6067_()) { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch index 2d162dfde4..cd2116f2d5 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch @@ -1,24 +1,27 @@ --- a/net/minecraft/client/renderer/texture/MipmapGenerator.java +++ b/net/minecraft/client/renderer/texture/MipmapGenerator.java -@@ -34,9 +_,12 @@ - } - } +@@ -26,12 +_,15 @@ + anativeimage[0] = p_251300_[0]; + boolean flag = m_246464_(anativeimage[0]); -+ int maxMipmapLevel = net.minecraftforge.client.ForgeHooksClient.getMaxMipmapLevel(p_118055_.m_84982_(), p_118055_.m_85084_()); - for(int k1 = 1; k1 <= p_118056_; ++k1) { - NativeImage nativeimage1 = anativeimage[k1 - 1]; -- NativeImage nativeimage = new NativeImage(nativeimage1.m_84982_() >> 1, nativeimage1.m_85084_() >> 1, false); -+ // Forge: guard against invalid texture size, because we allow generating mipmaps regardless of texture sizes -+ NativeImage nativeimage = new NativeImage(Math.max(1, nativeimage1.m_84982_() >> 1), Math.max(1, nativeimage1.m_85084_() >> 1), false); -+ if (k1 <= maxMipmapLevel) { - int k = nativeimage.m_84982_(); - int l = nativeimage.m_85084_(); ++ int maxMipmapLevel = net.minecraftforge.client.ForgeHooksClient.getMaxMipmapLevel(anativeimage[0].m_84982_(), anativeimage[0].m_85084_()); + for(int i = 1; i <= p_252326_; ++i) { + if (i < p_251300_.length) { + anativeimage[i] = p_251300_[i]; + } else { + NativeImage nativeimage = anativeimage[i - 1]; +- NativeImage nativeimage1 = new NativeImage(nativeimage.m_84982_() >> 1, nativeimage.m_85084_() >> 1, false); ++ // Forge: Guard against invalid texture size, because we allow generating mipmaps regardless of texture sizes ++ NativeImage nativeimage1 = new NativeImage(Math.max(1, nativeimage.m_84982_() >> 1), Math.max(1, nativeimage.m_85084_() >> 1), false); ++ if (i <= maxMipmapLevel) { + int j = nativeimage1.m_84982_(); + int k = nativeimage1.m_85084_(); -@@ -44,6 +_,7 @@ - for(int j1 = 0; j1 < l; ++j1) { - nativeimage.m_84988_(i1, j1, m_118048_(nativeimage1.m_84985_(i1 * 2 + 0, j1 * 2 + 0), nativeimage1.m_84985_(i1 * 2 + 1, j1 * 2 + 0), nativeimage1.m_84985_(i1 * 2 + 0, j1 * 2 + 1), nativeimage1.m_84985_(i1 * 2 + 1, j1 * 2 + 1), flag)); +@@ -39,6 +_,7 @@ + for(int i1 = 0; i1 < k; ++i1) { + nativeimage1.m_84988_(l, i1, m_118048_(nativeimage.m_84985_(l * 2 + 0, i1 * 2 + 0), nativeimage.m_84985_(l * 2 + 1, i1 * 2 + 0), nativeimage.m_84985_(l * 2 + 0, i1 * 2 + 1), nativeimage.m_84985_(l * 2 + 1, i1 * 2 + 1), flag)); + } ++ } } -+ } - } - anativeimage[k1] = nativeimage; + anativeimage[i] = nativeimage1; diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch new file mode 100644 index 0000000000..f7b0baa542 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch @@ -0,0 +1,71 @@ +--- a/net/minecraft/client/renderer/texture/SpriteContents.java ++++ b/net/minecraft/client/renderer/texture/SpriteContents.java +@@ -32,14 +_,29 @@ + public NativeImage[] f_243731_; + @Nullable + final SpriteContents.AnimatedTexture f_244575_; ++ @Nullable ++ public final net.minecraftforge.client.textures.ForgeTextureMetadata forgeMeta; + ++ /** ++ * @deprecated Forge: Use the {@linkplain SpriteContents#SpriteContents(ResourceLocation, FrameSize, NativeImage, AnimationMetadataSection, net.minecraftforge.client.textures.ForgeTextureMetadata) overload with Forge metadata parameter} to properly forward custom loaders. ++ */ ++ @Deprecated + public SpriteContents(ResourceLocation p_249787_, FrameSize p_251031_, NativeImage p_252131_, AnimationMetadataSection p_250432_) { ++ this(p_249787_, p_251031_, p_252131_, p_250432_, null); ++ } ++ ++ public SpriteContents(ResourceLocation p_249787_, FrameSize p_251031_, NativeImage p_252131_, AnimationMetadataSection p_250432_, @org.jetbrains.annotations.Nullable net.minecraftforge.client.textures.ForgeTextureMetadata forgeMeta) { + this.f_243877_ = p_249787_; + this.f_244302_ = p_251031_.f_244129_(); + this.f_244600_ = p_251031_.f_244503_(); + this.f_244575_ = this.m_247391_(p_251031_, p_252131_.m_84982_(), p_252131_.m_85084_(), p_250432_); + this.f_243904_ = p_252131_; + this.f_243731_ = new NativeImage[]{this.f_243904_}; ++ this.forgeMeta = forgeMeta; ++ } ++ ++ public NativeImage getOriginalImage() { ++ return this.f_243904_; + } + + public void m_246368_(int p_248864_) { +@@ -70,7 +_,7 @@ + } + } + +- int m_245088_() { ++ private int m_245088_() { + return this.f_244575_ != null ? this.f_244575_.f_243714_.size() : 1; + } + +@@ -124,6 +_,9 @@ + + void m_247381_(int p_248895_, int p_250245_, int p_250458_, int p_251337_, NativeImage[] p_248825_) { + for(int i = 0; i < this.f_243731_.length; ++i) { ++ // Forge: Skip uploading if the texture would be made invalid by mip level ++ if ((this.f_244302_ >> i) <= 0 || (this.f_244600_ >> i) <= 0) ++ break; + p_248825_[i].m_85003_(i, p_248895_ >> i, p_250245_ >> i, p_250458_ >> i, p_251337_ >> i, this.f_244302_ >> i, this.f_244600_ >> i, this.f_243731_.length > 1, false); + } + +@@ -241,7 +_,8 @@ + for(int i = 0; i < this.f_244527_.length; ++i) { + int j = SpriteContents.this.f_244302_ >> i; + int k = SpriteContents.this.f_244600_ >> i; +- this.f_244527_[i] = new NativeImage(j, k, false); ++ // Forge: Guard against invalid texture size, because we allow generating mipmaps regardless of texture sizes ++ this.f_244527_[i] = new NativeImage(Math.max(1, j), Math.max(1, k), false); + } + + } +@@ -257,6 +_,9 @@ + for(int k = 0; k < this.f_244527_.length; ++k) { + int l = SpriteContents.this.f_244302_ >> k; + int i1 = SpriteContents.this.f_244600_ >> k; ++ // Forge: Guard against invalid texture size, because we allow generating mipmaps regardless of texture sizes ++ if (l < 1 || i1 < 1) ++ continue; + + for(int j1 = 0; j1 < i1; ++j1) { + for(int k1 = 0; k1 < l; ++k1) { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch new file mode 100644 index 0000000000..87423ce24f --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/client/renderer/texture/SpriteLoader.java ++++ b/net/minecraft/client/renderer/texture/SpriteLoader.java +@@ -64,7 +_,7 @@ + int i1 = Math.min(j, k); + int j1 = Mth.m_14173_(i1); + int k1; +- if (j1 < p_261919_) { ++ if (false) { // Forge: Do not lower the mipmap level + f_244357_.warn("{}: dropping miplevel from {} to {}, because of minimum power of two: {}", this.f_244500_, p_261919_, j1, i1); + k1 = j1; + } else { +@@ -138,6 +_,9 @@ + + FrameSize framesize = animationmetadatasection.m_245821_(nativeimage.m_84982_(), nativeimage.m_85084_()); + if (Mth.m_246985_(nativeimage.m_84982_(), framesize.f_244129_()) && Mth.m_246985_(nativeimage.m_85084_(), framesize.f_244503_())) { ++ SpriteContents contents = net.minecraftforge.client.ForgeHooksClient.loadSpriteContents(p_251630_, p_250558_, framesize, nativeimage, animationmetadatasection); ++ if (contents != null) ++ return contents; + return new SpriteContents(p_251630_, framesize, nativeimage, animationmetadatasection); + } else { + f_244357_.error("Image {} size {},{} is not multiple of frame size {},{}", p_251630_, nativeimage.m_84982_(), nativeimage.m_85084_(), framesize.f_244129_(), framesize.f_244503_()); +@@ -151,6 +_,11 @@ + int i = p_249904_.m_118174_(); + int j = p_249904_.m_118187_(); + p_249904_.m_118180_((p_251421_, p_250533_, p_251913_) -> { ++ TextureAtlasSprite sprite = net.minecraftforge.client.ForgeHooksClient.loadTextureAtlasSprite(this.f_244500_, p_251421_, i, j, p_250533_, p_251913_, p_251421_.f_243731_.length - 1); ++ if (sprite != null) { ++ map.put(p_251421_.m_246162_(), sprite); ++ return; ++ } + map.put(p_251421_.m_246162_(), new TextureAtlasSprite(this.f_244500_, p_251421_, i, j, p_250533_, p_251913_)); + }); + return map; diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch index 6dd93225bb..f78eaf6a5b 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch @@ -1,30 +1,30 @@ --- a/net/minecraft/client/renderer/texture/Stitcher.java +++ b/net/minecraft/client/renderer/texture/Stitcher.java -@@ -13,6 +_,8 @@ +@@ -12,6 +_,8 @@ @OnlyIn(Dist.CLIENT) - public class Stitcher { -+ private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger(); + public class Stitcher { ++ private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); + - private static final Comparator f_118161_ = Comparator.comparing((p_118201_) -> { + private static final Comparator> f_118161_ = Comparator., Integer>comparing((p_118201_) -> { return -p_118201_.f_118204_; }).thenComparing((p_118199_) -> { -@@ -53,6 +_,14 @@ +@@ -52,6 +_,14 @@ - for(Stitcher.Holder stitcher$holder : list) { - if (!this.m_118178_(stitcher$holder)) { + for(Stitcher.Holder holder : list) { + if (!this.m_118178_(holder)) { + if (LOGGER.isInfoEnabled()) { + StringBuilder sb = new StringBuilder(); -+ sb.append("Unable to fit: ").append(stitcher$holder.f_118202_.m_118431_()); -+ sb.append(" - size: ").append(stitcher$holder.f_118202_.m_118434_()).append("x").append(stitcher$holder.f_118202_.m_118437_()); ++ sb.append("Unable to fit: ").append(holder.f_244486_().m_246162_()); ++ sb.append(" - size: ").append(holder.f_244486_.m_246492_()).append("x").append(holder.f_244486_.m_245330_()); + sb.append(" - Maybe try a lower resolution resourcepack?\n"); + list.forEach(h -> sb.append("\t").append(h).append("\n")); + LOGGER.info(sb.toString()); + } - throw new StitcherException(stitcher$holder.f_118202_, list.stream().map((p_118195_) -> { - return p_118195_.f_118202_; + throw new StitcherException(holder.f_244486_, list.stream().map((p_247946_) -> { + return p_247946_.f_244486_; }).collect(ImmutableList.toImmutableList())); -@@ -102,7 +_,7 @@ +@@ -97,7 +_,7 @@ boolean flag4 = flag2 && j != l; boolean flag; if (flag3 ^ flag4) { @@ -33,12 +33,3 @@ } else { flag = flag1 && i <= j; } -@@ -139,7 +_,7 @@ - } - - public String toString() { -- return "Holder{width=" + this.f_118203_ + ", height=" + this.f_118204_ + "}"; -+ return "Holder{width=" + this.f_118203_ + ", height=" + this.f_118204_ + ", name=" + this.f_118202_.m_118431_() + '}'; - } - } - diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch index 9be8a7b20a..ad0c429765 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch @@ -1,44 +1,11 @@ --- a/net/minecraft/client/renderer/texture/TextureAtlas.java +++ b/net/minecraft/client/renderer/texture/TextureAtlas.java -@@ -88,6 +_,7 @@ - } - } +@@ -74,6 +_,8 @@ + this.f_118263_ = List.copyOf(list); + this.f_118262_ = List.copyOf(list1); ++ + net.minecraftforge.client.ForgeHooksClient.onTextureStitchedPost(this); } - public TextureAtlas.Preparations m_118307_(ResourceManager p_118308_, Stream p_118309_, ProfilerFiller p_118310_, int p_118311_) { -@@ -102,6 +_,7 @@ - int j = Integer.MAX_VALUE; - int k = 1 << p_118311_; - p_118310_.m_6182_("extracting_frames"); -+ net.minecraftforge.client.ForgeHooksClient.onTextureStitchedPre(this, set); - - for(TextureAtlasSprite.Info textureatlassprite$info : this.m_118304_(p_118308_, set)) { - j = Math.min(j, Math.min(textureatlassprite$info.m_118434_(), textureatlassprite$info.m_118437_())); -@@ -116,7 +_,8 @@ - - int i1 = Math.min(j, k); - int j1 = Mth.m_14173_(i1); -- int k1; -+ int k1 = p_118311_; -+ if (false) // FORGE: do not lower the mipmap level - if (j1 < p_118311_) { - f_118261_.warn("{}: dropping miplevel from {} to {}, because of minimum power of two: {}", this.f_118265_, p_118311_, j1, i1); - k1 = j1; -@@ -233,11 +_,14 @@ - ResourceLocation resourcelocation = this.m_118324_(p_118289_.m_118431_()); - - try { -- InputStream inputstream = p_118288_.m_215595_(resourcelocation); -+ Resource resource = p_118288_.m_215593_(resourcelocation); -+ InputStream inputstream = resource.m_215507_(); - - TextureAtlasSprite textureatlassprite; - try { - NativeImage nativeimage = NativeImage.m_85058_(inputstream); -+ textureatlassprite = net.minecraftforge.client.ForgeHooksClient.loadTextureAtlasSprite(this, p_118288_, p_118289_, resource, p_118290_, p_118291_, p_118293_, p_118294_, p_118292_, nativeimage); -+ if (textureatlassprite == null) - textureatlassprite = new TextureAtlasSprite(this, p_118289_, p_118292_, p_118290_, p_118291_, p_118293_, p_118294_, nativeimage); - } catch (Throwable throwable1) { - if (inputstream != null) { + private void m_246472_(int p_252243_, int p_251110_, int p_249203_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch index a4d048c5bf..db49b419d5 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch @@ -1,45 +1,17 @@ --- a/net/minecraft/client/renderer/texture/TextureAtlasSprite.java +++ b/net/minecraft/client/renderer/texture/TextureAtlasSprite.java -@@ -145,6 +_,7 @@ +@@ -123,4 +_,14 @@ - void m_118375_(int p_118376_, int p_118377_, NativeImage[] p_118378_) { - for(int i = 0; i < this.f_118342_.length; ++i) { -+ if ((this.f_174723_ >> i <= 0) || (this.f_174724_ >> i <= 0)) break; - p_118378_[i].m_85003_(i, this.f_118349_ >> i, this.f_118350_ >> i, p_118376_ >> i, p_118377_ >> i, this.f_174723_ >> i, this.f_174724_ >> i, this.f_118342_.length > 1, false); - } - -@@ -389,7 +_,8 @@ - int j = p_118446_.f_118423_ >> i; - int k = p_118446_.f_118424_ >> i; - if (this.f_118443_[i] == null) { -- this.f_118443_[i] = new NativeImage(j, k, false); -+ // Forge: guard against invalid texture size, because we allow generating mipmaps regardless of texture sizes -+ this.f_118443_[i] = new NativeImage(Math.max(1, j), Math.max(1, k), false); - } - } - -@@ -404,6 +_,8 @@ - for(int k = 0; k < this.f_118443_.length; ++k) { - int l = TextureAtlasSprite.this.f_174723_ >> k; - int i1 = TextureAtlasSprite.this.f_174724_ >> k; -+ // Forge: guard against invalid texture size, because we allow generating mipmaps regardless of texture sizes -+ if (l == 0 || i1 == 0) continue; - - for(int j1 = 0; j1 < i1; ++j1) { - for(int k1 = 0; k1 < l; ++k1) { -@@ -438,5 +_,15 @@ - } - - } -+ } + void close(); + } + + // Forge Start + public int getPixelRGBA(int frameIndex, int x, int y) { -+ if (this.f_174725_ != null) { -+ x += this.f_174725_.m_174759_(frameIndex) * this.f_174723_; -+ y += this.f_174725_.m_174764_(frameIndex) * this.f_174724_; ++ if (this.f_244165_.f_244575_ != null) { ++ x += this.f_244165_.f_244575_.m_245080_(frameIndex) * this.f_244165_.f_244302_; ++ y += this.f_244165_.f_244575_.m_246436_(frameIndex) * this.f_244165_.f_244600_; + } + -+ return this.f_118342_[0].m_84985_(x, y); - } ++ return this.f_244165_.getOriginalImage().m_84985_(x, y); ++ } } diff --git a/patches/minecraft/net/minecraft/client/resources/language/ClientLanguage.java.patch b/patches/minecraft/net/minecraft/client/resources/language/ClientLanguage.java.patch index 09faaacf22..a934f7dcf0 100644 --- a/patches/minecraft/net/minecraft/client/resources/language/ClientLanguage.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/language/ClientLanguage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/resources/language/ClientLanguage.java +++ b/net/minecraft/client/resources/language/ClientLanguage.java -@@ -95,4 +_,9 @@ +@@ -80,4 +_,9 @@ public FormattedCharSequence m_5536_(FormattedText p_118925_) { return FormattedBidiReorder.m_118931_(p_118925_, this.f_118911_); } diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelBaker.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelBaker.java.patch new file mode 100644 index 0000000000..587418225e --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelBaker.java.patch @@ -0,0 +1,17 @@ +--- a/net/minecraft/client/resources/model/ModelBaker.java ++++ b/net/minecraft/client/resources/model/ModelBaker.java +@@ -6,9 +_,13 @@ + import net.minecraftforge.api.distmarker.OnlyIn; + + @OnlyIn(Dist.CLIENT) +-public interface ModelBaker { ++public interface ModelBaker extends net.minecraftforge.client.extensions.IForgeModelBaker { + UnbakedModel m_245361_(ResourceLocation p_252194_); + ++ /** ++ * @deprecated Forge: Use {@link #bake(ResourceLocation, ModelState, java.util.function.Function)} instead. ++ */ ++ @Deprecated + @Nullable + BakedModel m_245240_(ResourceLocation p_250776_, ModelState p_251280_); + } diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch index 58e5dfc4d1..d2851e0808 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch @@ -1,18 +1,9 @@ --- a/net/minecraft/client/resources/model/ModelBakery.java +++ b/net/minecraft/client/resources/model/ModelBakery.java -@@ -152,6 +_,8 @@ - public ModelBakery(ResourceManager p_119247_, BlockColors p_119248_, ProfilerFiller p_119249_, int p_119250_) { - this.f_119243_ = p_119247_; - this.f_119209_ = p_119248_; -+ -+ net.minecraftforge.client.model.geometry.GeometryLoaderManager.init(); - p_119249_.m_6180_("missing_model"); - - try { -@@ -185,12 +_,20 @@ - p_119249_.m_6182_("special"); - this.m_119306_(new ModelResourceLocation("minecraft:trident_in_hand#inventory")); - this.m_119306_(new ModelResourceLocation("minecraft:spyglass_in_hand#inventory")); +@@ -153,6 +_,13 @@ + p_252014_.m_6182_("special"); + this.m_119306_(ItemRenderer.f_244055_); + this.m_119306_(ItemRenderer.f_243706_); + Set additionalModels = Sets.newHashSet(); + net.minecraftforge.client.ForgeHooksClient.onRegisterAdditionalModels(additionalModels); + for (ResourceLocation rl : additionalModels) { @@ -20,60 +11,38 @@ + this.f_119212_.put(rl, unbakedmodel); + this.f_119214_.put(rl, unbakedmodel); + } - p_119249_.m_6182_("textures"); - Set> set = Sets.newLinkedHashSet(); - Set set1 = this.f_119214_.values().stream().flatMap((p_119340_) -> { - return p_119340_.m_5500_(this::m_119341_, set).stream(); - }).collect(Collectors.toSet()); - set1.addAll(f_119234_); -+ net.minecraftforge.client.ForgeHooksClient.gatherFluidTextures(set1); - set.stream().filter((p_119357_) -> { - return !p_119357_.getSecond().equals(f_119236_); - }).forEach((p_119292_) -> { -@@ -229,6 +_,7 @@ - try { - bakedmodel = this.m_119349_(p_119369_, BlockModelRotation.X0_Y0); - } catch (Exception exception) { -+ exception.printStackTrace(); - f_119235_.warn("Unable to bake model: '{}': {}", p_119369_, exception); - } + this.f_119214_.values().forEach((p_247954_) -> { + p_247954_.m_5500_(this::m_119341_); + }); +@@ -452,7 +_,17 @@ + return ModelBakery.this.m_119341_(p_248568_); + } -@@ -473,7 +_,13 @@ - } - - @Nullable -+ @Deprecated - public BakedModel m_119349_(ResourceLocation p_119350_, ModelState p_119351_) { -+ return bake(p_119350_, p_119351_, this.f_119244_::m_117971_); -+ } ++ @Override ++ public Function getModelTextureGetter() { ++ return this.f_243920_; ++ } + -+ @Nullable -+ public BakedModel bake(ResourceLocation p_119350_, ModelState p_119351_, java.util.function.Function sprites) { - Triple triple = Triple.of(p_119350_, p_119351_.m_6189_(), p_119351_.m_7538_()); - if (this.f_119213_.containsKey(triple)) { - return this.f_119213_.get(triple); -@@ -484,11 +_,11 @@ - if (unbakedmodel instanceof BlockModel) { - BlockModel blockmodel = (BlockModel)unbakedmodel; - if (blockmodel.m_111490_() == f_119232_) { -- return f_119241_.m_111670_(this.f_119244_::m_117971_, blockmodel).m_111449_(this, blockmodel, this.f_119244_::m_117971_, p_119351_, p_119350_, false); -+ return f_119241_.m_111670_(sprites, blockmodel).m_111449_(this, blockmodel, this.f_119244_::m_117971_, p_119351_, p_119350_, false); + public BakedModel m_245240_(ResourceLocation p_252176_, ModelState p_249765_) { ++ return bake(p_252176_, p_249765_, this.f_243920_); ++ } ++ ++ @Override ++ public BakedModel bake(ResourceLocation p_252176_, ModelState p_249765_, Function sprites) { + ModelBakery.BakedCacheKey modelbakery$bakedcachekey = new ModelBakery.BakedCacheKey(p_252176_, p_249765_.m_6189_(), p_249765_.m_7538_()); + BakedModel bakedmodel = ModelBakery.this.f_119213_.get(modelbakery$bakedcachekey); + if (bakedmodel != null) { +@@ -462,11 +_,11 @@ + if (unbakedmodel instanceof BlockModel) { + BlockModel blockmodel = (BlockModel)unbakedmodel; + if (blockmodel.m_111490_() == ModelBakery.f_119232_) { +- return ModelBakery.f_119241_.m_111670_(this.f_243920_, blockmodel).m_111449_(this, blockmodel, this.f_243920_, p_249765_, p_252176_, false); ++ return ModelBakery.f_119241_.m_111670_(sprites, blockmodel).m_111449_(this, blockmodel, sprites, p_249765_, p_252176_, false); + } } + +- BakedModel bakedmodel1 = unbakedmodel.m_7611_(this, this.f_243920_, p_249765_, p_252176_); ++ BakedModel bakedmodel1 = unbakedmodel.m_7611_(this, sprites, p_249765_, p_252176_); + ModelBakery.this.f_119213_.put(modelbakery$bakedcachekey, bakedmodel1); + return bakedmodel1; } - -- BakedModel bakedmodel = unbakedmodel.m_7611_(this, this.f_119244_::m_117971_, p_119351_, p_119350_); -+ BakedModel bakedmodel = unbakedmodel.m_7611_(this, sprites, p_119351_, p_119350_); - this.f_119213_.put(triple, bakedmodel); - return bakedmodel; - } -@@ -543,6 +_,10 @@ - public BlockStateDefinitionException(String p_119373_) { - super(p_119373_); - } -+ } -+ -+ public AtlasSet getAtlasSet() { -+ return this.f_119244_; - } - - @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch index 464b916b65..519a7633db 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch @@ -1,24 +1,23 @@ --- a/net/minecraft/client/resources/model/ModelManager.java +++ b/net/minecraft/client/resources/model/ModelManager.java -@@ -19,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class ModelManager extends SimplePreparableReloadListener implements AutoCloseable { +@@ -42,13 +_,14 @@ + public class ModelManager implements PreparableReloadListener, AutoCloseable { + private static final Logger f_243848_ = LogUtils.getLogger(); + private static final Map f_244614_ = Map.of(Sheets.f_110737_, new ResourceLocation("banner_patterns"), Sheets.f_110736_, new ResourceLocation("beds"), Sheets.f_110740_, new ResourceLocation("chests"), Sheets.f_110738_, new ResourceLocation("shield_patterns"), Sheets.f_110739_, new ResourceLocation("signs"), Sheets.f_110735_, new ResourceLocation("shulker_boxes"), TextureAtlas.f_118259_, new ResourceLocation("blocks")); - private Map f_119397_; + private Map f_119397_ = new java.util.HashMap<>(); - @Nullable - private AtlasSet f_119398_; + private final AtlasSet f_119398_; private final BlockModelShaper f_119399_; -@@ -28,6 +_,7 @@ + private final BlockColors f_119401_; private int f_119402_; private BakedModel f_119403_; private Object2IntMap f_119404_; + private ModelBakery modelBakery; public ModelManager(TextureManager p_119406_, BlockColors p_119407_, int p_119408_) { - this.f_119400_ = p_119406_; -@@ -36,6 +_,10 @@ - this.f_119399_ = new BlockModelShaper(this); + this.f_119401_ = p_119407_; +@@ -57,6 +_,10 @@ + this.f_119398_ = new AtlasSet(f_244614_, p_119406_); } + public BakedModel getModel(ResourceLocation modelLocation) { @@ -28,24 +27,32 @@ public BakedModel m_119422_(ModelResourceLocation p_119423_) { return this.f_119397_.getOrDefault(p_119423_, this.f_119403_); } -@@ -66,6 +_,8 @@ - this.f_119397_ = p_119419_.m_119251_(); - this.f_119404_ = p_119419_.m_119355_(); - this.f_119403_ = this.f_119397_.get(ModelBakery.f_119230_); -+ this.modelBakery = p_119419_; -+ net.minecraftforge.client.ForgeHooksClient.onModelBake(this, this.f_119397_, p_119419_); - p_119421_.m_6182_("cache"); - this.f_119399_.m_110892_(); - p_119421_.m_7238_(); -@@ -91,6 +_,7 @@ +@@ -71,6 +_,7 @@ + + public final CompletableFuture m_5540_(PreparableReloadListener.PreparationBarrier p_249079_, ResourceManager p_251134_, ProfilerFiller p_250336_, ProfilerFiller p_252324_, Executor p_250550_, Executor p_249221_) { + p_250336_.m_7242_(); ++ net.minecraftforge.client.model.geometry.GeometryLoaderManager.init(); + CompletableFuture> completablefuture = m_246704_(p_251134_, p_250550_); + CompletableFuture>> completablefuture1 = m_246899_(p_251134_, p_250550_); + CompletableFuture completablefuture2 = completablefuture.thenCombineAsync(completablefuture1, (p_251201_, p_251281_) -> { +@@ -201,6 +_,8 @@ + this.f_119397_ = modelbakery.m_119251_(); + this.f_119404_ = modelbakery.m_119355_(); + this.f_119403_ = p_248996_.f_244619_; ++ this.modelBakery = modelbakery; ++ net.minecraftforge.client.ForgeHooksClient.onModelBake(this, this.f_119397_, modelbakery); + p_251960_.m_6182_("cache"); + this.f_119399_.m_245515_(p_248996_.f_244561_); + p_251960_.m_7238_(); +@@ -226,6 +_,7 @@ } public TextureAtlas m_119428_(ResourceLocation p_119429_) { + if (this.f_119398_ == null) throw new RuntimeException("getAtlasTexture called too early!"); - return this.f_119398_.m_117973_(p_119429_); + return this.f_119398_.m_245433_(p_119429_); } -@@ -103,5 +_,9 @@ +@@ -235,6 +_,10 @@ public void m_119410_(int p_119411_) { this.f_119402_ = p_119411_; @@ -54,4 +61,5 @@ + public ModelBakery getModelBakery() { + return com.google.common.base.Preconditions.checkNotNull(modelBakery, "Attempted to query model bakery before it has been initialized."); } - } + + @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch b/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch index 7efbdfa11a..bd8e7a777f 100644 --- a/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch +++ b/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/server/IntegratedServer.java +++ b/net/minecraft/client/server/IntegratedServer.java -@@ -58,11 +_,12 @@ +@@ -59,11 +_,12 @@ this.m_129997_(true); this.m_129999_(true); this.m_129793_(); @@ -14,7 +14,7 @@ } public void m_5705_(BooleanSupplier p_120049_) { -@@ -178,6 +_,7 @@ +@@ -188,6 +_,7 @@ } public void m_7570_(boolean p_120053_) { diff --git a/patches/minecraft/net/minecraft/client/server/LanServerDetection.java.patch b/patches/minecraft/net/minecraft/client/server/LanServerDetection.java.patch index 6d07e0ad48..acd0a1e060 100644 --- a/patches/minecraft/net/minecraft/client/server/LanServerDetection.java.patch +++ b/patches/minecraft/net/minecraft/client/server/LanServerDetection.java.patch @@ -9,7 +9,7 @@ this.f_120088_.setSoTimeout(5000); this.f_120088_.joinGroup(this.f_120087_); } -@@ -88,7 +_,19 @@ +@@ -87,7 +_,19 @@ String s = LanServerPinger.m_120111_(p_120097_); String s1 = LanServerPinger.m_120116_(p_120097_); if (s1 != null) { diff --git a/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch b/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch index 80c709b5d2..d8f4657754 100644 --- a/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch +++ b/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch @@ -3,7 +3,7 @@ @@ -75,6 +_,7 @@ this.f_120217_ = p_120236_; this.f_120218_ = p_120237_; - this.f_120222_ = new SoundBufferLibrary(p_120238_); + this.f_120222_ = new SoundBufferLibrary(p_249332_); + net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.sound.SoundEngineLoadEvent(this)); } diff --git a/patches/minecraft/net/minecraft/commands/CommandSourceStack.java.patch b/patches/minecraft/net/minecraft/commands/CommandSourceStack.java.patch index 72ff47b2de..be270944b5 100644 --- a/patches/minecraft/net/minecraft/commands/CommandSourceStack.java.patch +++ b/patches/minecraft/net/minecraft/commands/CommandSourceStack.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/CommandSourceStack.java +++ b/net/minecraft/commands/CommandSourceStack.java -@@ -36,7 +_,7 @@ +@@ -38,7 +_,7 @@ import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; diff --git a/patches/minecraft/net/minecraft/commands/Commands.java.patch b/patches/minecraft/net/minecraft/commands/Commands.java.patch index fb861c557e..69e8966321 100644 --- a/patches/minecraft/net/minecraft/commands/Commands.java.patch +++ b/patches/minecraft/net/minecraft/commands/Commands.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -178,7 +_,7 @@ +@@ -186,7 +_,7 @@ JfrCommand.m_183645_(this.f_82090_); } @@ -9,7 +9,7 @@ TestCommand.m_127946_(this.f_82090_); } -@@ -202,6 +_,7 @@ +@@ -210,6 +_,7 @@ if (p_230943_.f_82144_) { PublishCommand.m_138184_(this.f_82090_); } @@ -17,7 +17,7 @@ this.f_82090_.setConsumer((p_230954_, p_230955_, p_230956_) -> { p_230954_.getSource().m_81342_(p_230954_, p_230955_, p_230956_); -@@ -227,7 +_,16 @@ +@@ -235,7 +_,16 @@ try { try { @@ -35,7 +35,7 @@ } catch (CommandRuntimeException commandruntimeexception) { commandsourcestack.m_81352_(commandruntimeexception.m_79226_()); return 0; -@@ -283,7 +_,8 @@ +@@ -291,7 +_,8 @@ Map, CommandNode> map = Maps.newHashMap(); RootCommandNode rootcommandnode = new RootCommandNode<>(); map.put(this.f_82090_.getRoot(), rootcommandnode); diff --git a/patches/minecraft/net/minecraft/commands/arguments/MessageArgument.java.patch b/patches/minecraft/net/minecraft/commands/arguments/MessageArgument.java.patch index c500e4a287..9a67c6f0db 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/MessageArgument.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/MessageArgument.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/MessageArgument.java +++ b/net/minecraft/commands/arguments/MessageArgument.java -@@ -134,7 +_,7 @@ +@@ -100,7 +_,7 @@ } Component m_232196_(CommandSourceStack p_232197_) throws CommandSyntaxException { diff --git a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch index 60fb7cad0b..0c384d3b7d 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java -@@ -87,7 +_,7 @@ +@@ -89,7 +_,7 @@ } private void m_121168_(CommandSourceStack p_121169_) throws CommandSyntaxException { diff --git a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch index 4f5c4fbd4a..2fedfb6f89 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelectorParser.java +++ b/net/minecraft/commands/arguments/selector/EntitySelectorParser.java -@@ -461,6 +_,9 @@ +@@ -459,6 +_,9 @@ } this.f_121201_.skip(); @@ -10,7 +10,7 @@ this.m_121281_(); } else { this.m_121304_(); -@@ -476,6 +_,7 @@ +@@ -474,6 +_,7 @@ p_121248_.suggest("@r", Component.m_237115_("argument.entity.selector.randomPlayer")); p_121248_.suggest("@s", Component.m_237115_("argument.entity.selector.self")); p_121248_.suggest("@e", Component.m_237115_("argument.entity.selector.allEntities")); diff --git a/patches/minecraft/net/minecraft/commands/synchronization/ArgumentTypeInfos.java.patch b/patches/minecraft/net/minecraft/commands/synchronization/ArgumentTypeInfos.java.patch index 719b65377c..40dc4e3e61 100644 --- a/patches/minecraft/net/minecraft/commands/synchronization/ArgumentTypeInfos.java.patch +++ b/patches/minecraft/net/minecraft/commands/synchronization/ArgumentTypeInfos.java.patch @@ -22,7 +22,7 @@ f_235379_.put(p_235389_, p_235390_); return Registry.m_122961_(p_235387_, p_235388_, p_235390_); @@ -117,12 +_,14 @@ - m_235386_(p_235385_, "resource", m_235395_(ResourceKeyArgument.class), new ResourceKeyArgument.Info()); + m_235386_(p_235385_, "resource_key", m_235395_(ResourceKeyArgument.class), new ResourceKeyArgument.Info()); m_235386_(p_235385_, "template_mirror", TemplateMirrorArgument.class, SingletonArgumentInfo.m_235451_(TemplateMirrorArgument::m_234343_)); m_235386_(p_235385_, "template_rotation", TemplateRotationArgument.class, SingletonArgumentInfo.m_235451_(TemplateRotationArgument::m_234414_)); - if (SharedConstants.f_136183_) { diff --git a/patches/minecraft/net/minecraft/core/Holder.java.patch b/patches/minecraft/net/minecraft/core/Holder.java.patch index 2c9c9f8f06..76c518e6fd 100644 --- a/patches/minecraft/net/minecraft/core/Holder.java.patch +++ b/patches/minecraft/net/minecraft/core/Holder.java.patch @@ -24,7 +24,7 @@ T m_203334_(); boolean m_203633_(); -@@ -192,6 +_,10 @@ +@@ -193,6 +_,10 @@ public Stream> m_203616_() { return this.f_205749_.stream(); diff --git a/patches/minecraft/net/minecraft/core/HolderSet.java.patch b/patches/minecraft/net/minecraft/core/HolderSet.java.patch index 44daa4c382..67e5ab6fff 100644 --- a/patches/minecraft/net/minecraft/core/HolderSet.java.patch +++ b/patches/minecraft/net/minecraft/core/HolderSet.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/core/HolderSet.java +++ b/net/minecraft/core/HolderSet.java @@ -14,7 +_,7 @@ - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; + import org.jetbrains.annotations.VisibleForTesting; -public interface HolderSet extends Iterable> { +public interface HolderSet extends Iterable>, net.minecraftforge.common.extensions.IForgeHolderSet { Stream> m_203614_(); int m_203632_(); -@@ -120,6 +_,9 @@ +@@ -133,6 +_,9 @@ public void m_205835_(List> p_205836_) { this.f_205830_ = List.copyOf(p_205836_); @@ -19,10 +19,10 @@ } public TagKey m_205839_() { -@@ -144,6 +_,11 @@ +@@ -161,6 +_,11 @@ - public boolean m_207277_(Registry p_211049_) { - return this.f_211044_ == p_211049_; + public boolean m_207277_(HolderOwner p_256542_) { + return this.f_254711_.m_254921_(p_256542_); + } + // FORGE: Keep a list of invalidation callbacks so they can be run when tags rebind + private List invalidationCallbacks = new java.util.ArrayList<>(); diff --git a/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch b/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch index 438b38b4a8..1bd6309e94 100644 --- a/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch +++ b/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java -@@ -83,14 +_,24 @@ - return this.m_205857_(p_205853_, p_205854_, p_205855_, p_205856_, true); +@@ -121,7 +_,16 @@ + } } + private static final Set KNOWN = new java.util.LinkedHashSet<>(); @@ -12,32 +12,31 @@ + KNOWN.add(m_123023_().m_135782_()); + } + - private Holder m_205857_(int p_205858_, ResourceKey p_205859_, T p_205860_, Lifecycle p_205861_, boolean p_205862_) { + public Holder.Reference m_203704_(int p_256563_, ResourceKey p_256594_, T p_256374_, Lifecycle p_256469_) { + markKnown(); - this.m_205921_(p_205859_); - Validate.notNull(p_205859_); - Validate.notNull(p_205860_); - this.f_122672_.size(Math.max(this.f_122672_.size(), p_205858_ + 1)); - this.f_122673_.put(p_205860_, p_205858_); - this.f_211051_ = null; -- if (p_205862_ && this.f_205842_.containsKey(p_205859_)) { -+ // Forge: Fix bug where a key is considered a duplicate if getOrCreateHolder was called before the entry was registered -+ if (p_205862_ && this.f_205842_.containsKey(p_205859_) && this.f_205842_.get(p_205859_).m_203633_()) { - Util.m_143785_("Adding duplicate key '" + p_205859_ + "' to registry"); - } - -@@ -299,6 +_,14 @@ - - public boolean m_142003_(ResourceKey p_175392_) { + this.m_205921_(p_256594_); + Validate.notNull(p_256594_); + Validate.notNull(p_256374_); +@@ -300,6 +_,12 @@ return this.f_205842_.containsKey(p_175392_); -+ } -+ + } + + /** @deprecated Forge: For internal use only. Use the Register events when registering values. */ + @Deprecated + public void unfreeze() { + this.f_205845_ = false; -+ if (this.f_205846_ != null && this.f_205847_ == null) -+ this.f_205847_ = new IdentityHashMap<>(); - } - ++ } ++ public Registry m_203521_() { + if (this.f_205845_) { + return this; +@@ -321,7 +_,8 @@ + throw new IllegalStateException("Some intrusive holders were not registered: " + this.f_244282_.values()); + } + +- this.f_244282_ = null; ++ // Forge: We freeze/unfreeze vanilla registries more than once, so we need to keep the unregistered intrusive holders map around. ++ // this.unregisteredIntrusiveHolders = null; + } + + return this; diff --git a/patches/minecraft/net/minecraft/core/Registry.java.patch b/patches/minecraft/net/minecraft/core/Registry.java.patch deleted file mode 100644 index 53248adcb4..0000000000 --- a/patches/minecraft/net/minecraft/core/Registry.java.patch +++ /dev/null @@ -1,206 +0,0 @@ ---- a/net/minecraft/core/Registry.java -+++ b/net/minecraft/core/Registry.java -@@ -131,6 +_,10 @@ - import org.apache.commons.lang3.Validate; - import org.slf4j.Logger; - -+/* -+ * Attention Modders: This SHOULD NOT be used, you should use ForgeRegistries instead. As it has a cleaner modder facing API. -+ * We will be wrapping all of these in our API as necessary for syncing and management. -+ */ - public abstract class Registry implements Keyable, IdMap { - private static final Logger f_122894_ = LogUtils.getLogger(); - private static final Map> f_122834_ = Maps.newLinkedHashMap(); -@@ -179,41 +_,41 @@ - public static final DefaultedRegistry f_175412_ = m_206031_(f_175423_, "step", GameEvent::m_204530_, (p_206044_) -> { - return GameEvent.f_157785_; - }); -- public static final Registry f_122821_ = m_206008_(f_122898_, (p_206042_) -> { -+ @Deprecated public static final Registry f_122821_ = forge(f_122898_, (registry) -> { - return SoundEvents.f_12019_; - }); -- public static final DefaultedRegistry f_122822_ = m_206031_(f_122899_, "empty", Fluid::m_205069_, (p_206040_) -> { -+ @Deprecated public static final DefaultedRegistry f_122822_ = forge(f_122899_, "empty", (registry) -> { - return Fluids.f_76191_; - }); -- public static final Registry f_122823_ = m_206008_(f_122900_, (p_205982_) -> { -+ @Deprecated public static final Registry f_122823_ = forge(f_122900_, (registry) -> { - return MobEffects.f_19621_; - }); -- public static final DefaultedRegistry f_122824_ = m_206031_(f_122901_, "air", Block::m_204297_, (p_205980_) -> { -+ @Deprecated public static final DefaultedRegistry f_122824_ = forge(f_122901_, "air", (registry) -> { - return Blocks.f_50016_; - }); -- public static final Registry f_122825_ = m_206008_(f_122902_, (p_205978_) -> { -+ @Deprecated public static final Registry f_122825_ = forge(f_122902_, (registry) -> { - return Enchantments.f_44987_; - }); -- public static final DefaultedRegistry> f_122826_ = m_206031_(f_122903_, "pig", EntityType::m_204041_, (p_205976_) -> { -+ @Deprecated public static final DefaultedRegistry> f_122826_ = forge(f_122903_, "pig", (registry) -> { - return EntityType.f_20510_; - }); -- public static final DefaultedRegistry f_122827_ = m_206031_(f_122904_, "air", Item::m_204114_, (p_205974_) -> { -+ @Deprecated public static final DefaultedRegistry f_122827_ = forge(f_122904_, "air", (registry) -> { - return Items.f_41852_; - }); -- public static final DefaultedRegistry f_122828_ = m_206027_(f_122905_, "empty", (p_205972_) -> { -+ @Deprecated public static final DefaultedRegistry f_122828_ = forge(f_122905_, "empty", (registry) -> { - return Potions.f_43598_; - }); -- public static final Registry> f_122829_ = m_206008_(f_122906_, (p_205970_) -> { -+ @Deprecated public static final Registry> f_122829_ = forge(f_122906_, (registry) -> { - return ParticleTypes.f_123794_; - }); -- public static final Registry> f_122830_ = m_206008_(f_122907_, (p_205968_) -> { -+ @Deprecated public static final Registry> f_122830_ = forge(f_122907_, (registry) -> { - return BlockEntityType.f_58917_; - }); -- public static final DefaultedRegistry f_235728_ = m_206027_(f_235743_, "kebab", PaintingVariants::m_218942_); -+ @Deprecated public static final DefaultedRegistry f_235728_ = forge(f_235743_, "kebab", PaintingVariants::m_218942_); - public static final Registry f_122832_ = m_206008_(f_122909_, (p_235777_) -> { - return Stats.f_12926_; - }); -- public static final DefaultedRegistry f_122833_ = m_206027_(f_122910_, "empty", (p_235775_) -> { -+ @Deprecated public static final DefaultedRegistry f_122833_ = forge(f_122910_, "empty", (registry) -> { - return ChunkStatus.f_62314_; - }); - public static final Registry> f_122861_ = m_206008_(f_122911_, (p_235773_) -> { -@@ -222,42 +_,42 @@ - public static final Registry> f_122862_ = m_206008_(f_122912_, (p_235771_) -> { - return PosRuleTestType.f_74205_; - }); -- public static final Registry> f_122863_ = m_206008_(f_122913_, (p_235769_) -> { -+ @Deprecated public static final Registry> f_122863_ = forge(f_122913_, (registry) -> { - return MenuType.f_39964_; - }); -- public static final Registry> f_122864_ = m_206008_(f_122914_, (p_235767_) -> { -+ @Deprecated public static final Registry> f_122864_ = forge(f_122914_, (p_235767_) -> { - return RecipeType.f_44107_; - }); -- public static final Registry> f_122865_ = m_206008_(f_122915_, (p_235765_) -> { -+ @Deprecated public static final Registry> f_122865_ = forge(f_122915_, (registry) -> { - return RecipeSerializer.f_44077_; - }); -- public static final Registry f_122866_ = m_206008_(f_122916_, (p_235763_) -> { -+ @Deprecated public static final Registry f_122866_ = forge(f_122916_, (registry) -> { - return Attributes.f_22286_; - }); - public static final Registry> f_175420_ = m_206008_(f_175408_, (p_235761_) -> { - return PositionSourceType.f_157871_; - }); -- public static final Registry> f_235729_ = m_206008_(f_235724_, (RegistryBootstrap)ArgumentTypeInfos::m_235384_); -- public static final Registry> f_122867_ = m_206008_(f_122917_, (p_235759_) -> { -+ @Deprecated public static final Registry> f_235729_ = forge(f_235724_, (RegistryBootstrap)ArgumentTypeInfos::m_235384_); -+ @Deprecated public static final Registry> f_122867_ = forge(f_122917_, (registry) -> { - return Stats.f_12982_; - }); - public static final DefaultedRegistry f_122868_ = m_206027_(f_122808_, "plains", (p_235757_) -> { - return VillagerType.f_35821_; - }); -- public static final DefaultedRegistry f_122869_ = m_206027_(f_122809_, "none", (p_235755_) -> { -+ @Deprecated public static final DefaultedRegistry f_122869_ = forge(f_122809_, "none", (registry) -> { - return VillagerProfession.f_35585_; - }); -- public static final Registry f_122870_ = m_206008_(f_122810_, PoiTypes::m_218082_); -- public static final DefaultedRegistry> f_122871_ = m_206027_(f_122811_, "dummy", (p_235753_) -> { -+ @Deprecated public static final Registry f_122870_ = forge(f_122810_, PoiTypes::m_218082_); -+ @Deprecated public static final DefaultedRegistry> f_122871_ = forge(f_122811_, "dummy", (registry) -> { - return MemoryModuleType.f_26349_; - }); -- public static final DefaultedRegistry> f_122872_ = m_206027_(f_122812_, "dummy", (p_235751_) -> { -+ @Deprecated public static final DefaultedRegistry> f_122872_ = forge(f_122812_, "dummy", (registry) -> { - return SensorType.f_26809_; - }); -- public static final Registry f_122873_ = m_206008_(f_122813_, (p_235749_) -> { -+ @Deprecated public static final Registry f_122873_ = forge(f_122813_, (registry) -> { - return Schedule.f_38012_; - }); -- public static final Registry f_122874_ = m_206008_(f_122814_, (p_235747_) -> { -+ @Deprecated public static final Registry f_122874_ = forge(f_122814_, (registry) -> { - return Activity.f_37979_; - }); - public static final Registry f_122875_ = m_206008_(f_122815_, (p_235745_) -> { -@@ -308,16 +_,16 @@ - public static final ResourceKey> f_235726_ = m_122978_("worldgen/world_preset"); - public static final ResourceKey> f_235727_ = m_122978_("worldgen/flat_level_generator_preset"); - public static final ResourceKey>> f_122836_ = m_122978_("worldgen/carver"); -- public static final Registry> f_122837_ = m_206008_(f_122836_, (p_235842_) -> { -+ @Deprecated public static final Registry> f_122837_ = forge(f_122836_, (registry) -> { - return WorldCarver.f_64974_; - }); - public static final ResourceKey>> f_122838_ = m_122978_("worldgen/feature"); -- public static final Registry> f_122839_ = m_206008_(f_122838_, (p_235840_) -> { -+ @Deprecated public static final Registry> f_122839_ = forge(f_122838_, (registry) -> { - return Feature.f_65731_; - }); - public static final ResourceKey>> f_205929_ = m_122978_("worldgen/structure_placement"); - public static final Registry> f_205930_ = m_206008_(f_205929_, (p_235838_) -> { -- return StructurePlacementType.f_205041_; -+ return StructurePlacementType.f_205041_; - }); - public static final ResourceKey> f_122842_ = m_122978_("worldgen/structure_piece"); - public static final Registry f_122843_ = m_206008_(f_122842_, (p_235836_) -> { -@@ -344,10 +_,10 @@ - public static final ResourceKey>> f_211075_ = m_122978_("worldgen/density_function_type"); - public static final ResourceKey>> f_122854_ = m_122978_("worldgen/structure_processor"); - public static final ResourceKey>> f_122855_ = m_122978_("worldgen/structure_pool_element"); -- public static final Registry> f_122856_ = m_206008_(f_122846_, (p_235830_) -> { -+ @Deprecated public static final Registry> f_122856_ = forge(f_122846_, (registry) -> { - return BlockStateProviderType.f_68752_; - }); -- public static final Registry> f_122858_ = m_206008_(f_122848_, (p_235828_) -> { -+ @Deprecated public static final Registry> f_122858_ = forge(f_122848_, (registry) -> { - return FoliagePlacerType.f_68591_; - }); - public static final Registry> f_122859_ = m_206008_(f_122849_, (p_235822_) -> { -@@ -356,7 +_,7 @@ - public static final Registry> f_235742_ = m_206008_(f_235741_, (p_235818_) -> { - return RootPlacerType.f_225898_; - }); -- public static final Registry> f_122860_ = m_206008_(f_122850_, (p_235814_) -> { -+ @Deprecated public static final Registry> f_122860_ = forge(f_122850_, (registry) -> { - return TreeDecoratorType.f_70043_; - }); - public static final Registry> f_122888_ = m_206008_(f_122851_, (p_235808_) -> { -@@ -401,7 +_,7 @@ - - if (p_235790_ instanceof DefaultedRegistry) { - ResourceLocation resourcelocation = ((DefaultedRegistry)p_235790_).m_122315_(); -- Validate.notNull(p_235790_.m_7745_(resourcelocation), "Missing default of DefaultedMappedRegistry: " + resourcelocation); -+ Validate.notNull(p_235790_.m_7745_(resourcelocation), "Missing default of DefaultedMappedRegistry: " + p_205993_.f_122887_ + ", Entry: " + resourcelocation); - } - - }); -@@ -411,16 +_,32 @@ - return m_205999_(p_206009_, Lifecycle.experimental(), p_206010_); - } - -+ private static Registry forge(ResourceKey> key, Registry.RegistryBootstrap def) { -+ return forge(key, Lifecycle.experimental(), def); -+ } -+ - private static DefaultedRegistry m_206027_(ResourceKey> p_206028_, String p_206029_, Registry.RegistryBootstrap p_206030_) { - return m_206016_(p_206028_, p_206029_, Lifecycle.experimental(), p_206030_); - } - -+ private static DefaultedRegistry forge(ResourceKey> key, String defKey, Registry.RegistryBootstrap def) { -+ return forge(key, defKey, Lifecycle.experimental(), def); -+ } -+ - private static DefaultedRegistry m_206031_(ResourceKey> p_206032_, String p_206033_, Function> p_206034_, Registry.RegistryBootstrap p_206035_) { - return m_206021_(p_206032_, p_206033_, Lifecycle.experimental(), p_206034_, p_206035_); - } - -+ private static Registry forge(ResourceKey> key, Lifecycle cycle, Registry.RegistryBootstrap def) { -+ return m_206011_(key, net.minecraftforge.registries.GameData.getWrapper(key, cycle), def, cycle); -+ } -+ - private static Registry m_205999_(ResourceKey> p_206000_, Lifecycle p_206001_, Registry.RegistryBootstrap p_206002_) { - return m_206011_(p_206000_, new MappedRegistry<>(p_206000_, p_206001_, (Function>)null), p_206002_, p_206001_); -+ } -+ -+ private static DefaultedRegistry forge(ResourceKey> key, String defKey, Lifecycle cycle, Registry.RegistryBootstrap def) { -+ return m_206011_(key, net.minecraftforge.registries.GameData.getWrapper(key, cycle, defKey), def, cycle); - } - - private static Registry m_206003_(ResourceKey> p_206004_, Lifecycle p_206005_, Function> p_206006_, Registry.RegistryBootstrap p_206007_) { diff --git a/patches/minecraft/net/minecraft/core/RegistryAccess.java.patch b/patches/minecraft/net/minecraft/core/RegistryAccess.java.patch deleted file mode 100644 index 8d694ab1f2..0000000000 --- a/patches/minecraft/net/minecraft/core/RegistryAccess.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/core/RegistryAccess.java -+++ b/net/minecraft/core/RegistryAccess.java -@@ -62,7 +_,7 @@ - m_123057_(builder, Registry.f_235730_, ChatType.f_237005_, ChatType.f_237005_); - m_123053_(builder, Registry.f_235726_, WorldPreset.f_226414_); - m_123053_(builder, Registry.f_235727_, FlatLevelGeneratorPreset.f_226243_); -- return builder.build(); -+ return net.minecraftforge.registries.DataPackRegistriesHooks.grabBuiltinRegistries(builder); // FORGE: Keep the map so custom registries can be added later - }); - Codec f_206151_ = m_206205_(); - Supplier f_123049_ = Suppliers.memoize(() -> { diff --git a/patches/minecraft/net/minecraft/core/RegistryCodecs.java.patch b/patches/minecraft/net/minecraft/core/RegistryCodecs.java.patch index 44f391caa3..13a4199c5f 100644 --- a/patches/minecraft/net/minecraft/core/RegistryCodecs.java.patch +++ b/patches/minecraft/net/minecraft/core/RegistryCodecs.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/core/RegistryCodecs.java +++ b/net/minecraft/core/RegistryCodecs.java -@@ -92,7 +_,8 @@ +@@ -40,7 +_,8 @@ } - private static Codec, T>> m_206315_(ResourceKey> p_206316_, Codec p_206317_) { -- return Codec.unboundedMap(ResourceKey.m_195966_(p_206316_), p_206317_); + public static Codec> m_246213_(ResourceKey> p_248884_, Lifecycle p_251810_, Codec p_250169_) { +- Codec, E>> codec = Codec.unboundedMap(ResourceKey.m_195966_(p_248884_), p_250169_); + // FORGE: Fix MC-197860 -+ return new net.minecraftforge.common.LenientUnboundedMapCodec<>(ResourceKey.m_195966_(p_206316_), p_206317_); - } - - public static Codec> m_206279_(ResourceKey> p_206280_, Codec p_206281_) { ++ Codec, E>> codec = new net.minecraftforge.common.LenientUnboundedMapCodec<>(ResourceKey.m_195966_(p_248884_), p_250169_); + return codec.xmap((p_258184_) -> { + WritableRegistry writableregistry = new MappedRegistry<>(p_248884_, p_251810_); + p_258184_.forEach((p_258191_, p_258192_) -> { diff --git a/patches/minecraft/net/minecraft/core/RegistrySetBuilder.java.patch b/patches/minecraft/net/minecraft/core/RegistrySetBuilder.java.patch new file mode 100644 index 0000000000..d55edb7c85 --- /dev/null +++ b/patches/minecraft/net/minecraft/core/RegistrySetBuilder.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/core/RegistrySetBuilder.java ++++ b/net/minecraft/core/RegistrySetBuilder.java +@@ -37,6 +_,10 @@ + return this.m_255162_(p_256261_, Lifecycle.stable(), p_256010_); + } + ++ public List>> getEntryKeys() { ++ return this.f_254732_.stream().map(RegistrySetBuilder.RegistryStub::f_254738_).toList(); ++ } ++ + private RegistrySetBuilder.BuildState m_254900_(RegistryAccess p_256400_) { + RegistrySetBuilder.BuildState registrysetbuilder$buildstate = RegistrySetBuilder.BuildState.m_255369_(p_256400_, this.f_254732_.stream().map(RegistrySetBuilder.RegistryStub::f_254738_)); + this.f_254732_.forEach((p_255629_) -> { diff --git a/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch index 824ed41f3c..f972f649a3 100644 --- a/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch +++ b/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch @@ -5,7 +5,7 @@ double d2 = p_123375_.m_7094_() + (double)((float)direction.m_122431_() * 1.125F); BlockPos blockpos = p_123375_.m_7961_().m_121945_(direction); + Boat boat = (Boat)(this.f_235889_ ? new ChestBoat(level, d0, d1, d2) : new Boat(level, d0, d1, d2)); -+ boat.m_38332_(this.f_123369_); ++ boat.m_262362_(this.f_123369_); + boat.m_146922_(direction.m_122435_()); double d3; - if (level.m_6425_(blockpos).m_205070_(FluidTags.f_13131_)) { @@ -21,7 +21,7 @@ } - Boat boat = (Boat)(this.f_235889_ ? new ChestBoat(level, d0, d1 + d3, d2) : new Boat(level, d0, d1 + d3, d2)); -- boat.m_38332_(this.f_123369_); +- boat.m_262362_(this.f_123369_); - boat.m_146922_(direction.m_122435_()); + boat.m_6034_(d0, d1 + d3, d2); level.m_7967_(boat); diff --git a/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index 063a9f9c3d..3ceecf31bc 100644 --- a/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch +++ b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -402,9 +_,10 @@ +@@ -405,9 +_,10 @@ level.m_46597_(blockpos, BaseFireBlock.m_49245_(level, blockpos)); level.m_142346_((Entity)null, GameEvent.f_157797_, blockpos); } else if (!CampfireBlock.m_51321_(blockstate) && !CandleBlock.m_152845_(blockstate) && !CandleCakeBlock.m_152910_(blockstate)) { diff --git a/patches/minecraft/net/minecraft/core/particles/ItemParticleOption.java.patch b/patches/minecraft/net/minecraft/core/particles/ItemParticleOption.java.patch index d8fe2e1c20..18398e3f78 100644 --- a/patches/minecraft/net/minecraft/core/particles/ItemParticleOption.java.patch +++ b/patches/minecraft/net/minecraft/core/particles/ItemParticleOption.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/particles/ItemParticleOption.java +++ b/net/minecraft/core/particles/ItemParticleOption.java -@@ -36,7 +_,7 @@ +@@ -35,7 +_,7 @@ public ItemParticleOption(ParticleType p_123705_, ItemStack p_123706_) { this.f_123701_ = p_123705_; diff --git a/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch b/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch new file mode 100644 index 0000000000..72e9008201 --- /dev/null +++ b/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch @@ -0,0 +1,310 @@ +--- a/net/minecraft/core/registries/BuiltInRegistries.java ++++ b/net/minecraft/core/registries/BuiltInRegistries.java +@@ -110,41 +_,89 @@ + public static final DefaultedRegistry f_256726_ = m_257834_(Registries.f_256827_, "step", (p_260052_) -> { + return GameEvent.f_157785_; + }); +- public static final Registry f_256894_ = m_258002_(Registries.f_256840_, (p_260167_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#SOUND_EVENTS} instead. ++ */ ++ @Deprecated ++ public static final Registry f_256894_ = forge(Registries.f_256840_, (p_260167_) -> { + return SoundEvents.f_12019_; + }); +- public static final DefaultedRegistry f_257020_ = m_257834_(Registries.f_256808_, "empty", (p_259453_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#FLUIDS} instead. ++ */ ++ @Deprecated ++ public static final DefaultedRegistry f_257020_ = forge(Registries.f_256808_, "empty", (p_259453_) -> { + return Fluids.f_76191_; + }); +- public static final Registry f_256974_ = m_258002_(Registries.f_256929_, (p_259689_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#MOB_EFFECTS} instead. ++ */ ++ @Deprecated ++ public static final Registry f_256974_ = forge(Registries.f_256929_, (p_259689_) -> { + return MobEffects.f_19621_; + }); +- public static final DefaultedRegistry f_256975_ = m_257834_(Registries.f_256747_, "air", (p_259909_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#BLOCKS} instead. ++ */ ++ @Deprecated ++ public static final DefaultedRegistry f_256975_ = forge(Registries.f_256747_, "air", (p_259909_) -> { + return Blocks.f_50016_; + }); +- public static final Registry f_256876_ = m_258002_(Registries.f_256762_, (p_259104_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#ENCHANTMENTS} instead. ++ */ ++ @Deprecated ++ public static final Registry f_256876_ = forge(Registries.f_256762_, (p_259104_) -> { + return Enchantments.f_44987_; + }); +- public static final DefaultedRegistry> f_256780_ = m_257834_(Registries.f_256939_, "pig", (p_259175_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#ENTITY_TYPES} instead. ++ */ ++ @Deprecated ++ public static final DefaultedRegistry> f_256780_ = forge(Registries.f_256939_, "pig", (p_259175_) -> { + return EntityType.f_20510_; + }); +- public static final DefaultedRegistry f_257033_ = m_257834_(Registries.f_256913_, "air", (p_260227_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#ITEMS} instead. ++ */ ++ @Deprecated ++ public static final DefaultedRegistry f_257033_ = forge(Registries.f_256913_, "air", (p_260227_) -> { + return Items.f_41852_; + }); +- public static final DefaultedRegistry f_256980_ = m_257988_(Registries.f_256973_, "empty", (p_259869_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#POTIONS} instead. ++ */ ++ @Deprecated ++ public static final DefaultedRegistry f_256980_ = forge(Registries.f_256973_, "empty", (p_259869_) -> { + return Potions.f_43598_; + }); +- public static final Registry> f_257034_ = m_258002_(Registries.f_256890_, (p_260266_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#PARTICLE_TYPES} instead. ++ */ ++ @Deprecated ++ public static final Registry> f_257034_ = forge(Registries.f_256890_, (p_260266_) -> { + return ParticleTypes.f_123794_; + }); +- public static final Registry> f_257049_ = m_258002_(Registries.f_256922_, (p_259434_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#BLOCK_ENTITY_TYPES} instead. ++ */ ++ @Deprecated ++ public static final Registry> f_257049_ = forge(Registries.f_256922_, (p_259434_) -> { + return BlockEntityType.f_58917_; + }); +- public static final DefaultedRegistry f_257051_ = m_257988_(Registries.f_256836_, "kebab", PaintingVariants::m_218942_); ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#PAINTING_VARIANTS} instead. ++ */ ++ @Deprecated ++ public static final DefaultedRegistry f_257051_ = forge(Registries.f_256836_, "kebab", PaintingVariants::m_218942_); + public static final Registry f_256771_ = m_258002_(Registries.f_256887_, (p_259833_) -> { + return Stats.f_12926_; + }); +- public static final DefaultedRegistry f_256940_ = m_257988_(Registries.f_256755_, "empty", (p_259971_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#CHUNK_STATUS} instead. ++ */ ++ @Deprecated ++ public static final DefaultedRegistry f_256940_ = forge(Registries.f_256755_, "empty", (p_259971_) -> { + return ChunkStatus.f_62314_; + }); + public static final Registry> f_256978_ = m_258002_(Registries.f_256947_, (p_259641_) -> { +@@ -153,42 +_,90 @@ + public static final Registry> f_256957_ = m_258002_(Registries.f_257009_, (p_259262_) -> { + return PosRuleTestType.f_74205_; + }); +- public static final Registry> f_256818_ = m_258002_(Registries.f_256798_, (p_259341_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#MENU_TYPES} instead. ++ */ ++ @Deprecated ++ public static final Registry> f_256818_ = forge(Registries.f_256798_, (p_259341_) -> { + return MenuType.f_39964_; + }); +- public static final Registry> f_256990_ = m_258002_(Registries.f_256954_, (p_259086_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#RECIPE_TYPES} instead. ++ */ ++ @Deprecated ++ public static final Registry> f_256990_ = forge(Registries.f_256954_, (p_259086_) -> { + return RecipeType.f_44107_; + }); +- public static final Registry> f_256769_ = m_258002_(Registries.f_256764_, (p_260230_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#RECIPE_SERIALIZERS} instead. ++ */ ++ @Deprecated ++ public static final Registry> f_256769_ = forge(Registries.f_256764_, (p_260230_) -> { + return RecipeSerializer.f_44077_; + }); +- public static final Registry f_256951_ = m_258002_(Registries.f_256728_, (p_260300_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#ATTRIBUTES} instead. ++ */ ++ @Deprecated ++ public static final Registry f_256951_ = forge(Registries.f_256728_, (p_260300_) -> { + return Attributes.f_22286_; + }); + public static final Registry> f_256972_ = m_258002_(Registries.f_256792_, (p_259113_) -> { + return PositionSourceType.f_157871_; + }); +- public static final Registry> f_256979_ = m_258002_(Registries.f_256982_, (RegistryBootstrap)ArgumentTypeInfos::m_235384_); +- public static final Registry> f_256899_ = m_258002_(Registries.f_256849_, (p_259967_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#COMMAND_ARGUMENT_TYPES} instead. ++ */ ++ @Deprecated ++ public static final Registry> f_256979_ = forge(Registries.f_256982_, (RegistryBootstrap)ArgumentTypeInfos::m_235384_); ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#STAT_TYPES} instead. ++ */ ++ @Deprecated ++ public static final Registry> f_256899_ = forge(Registries.f_256849_, (p_259967_) -> { + return Stats.f_12982_; + }); + public static final DefaultedRegistry f_256934_ = m_257988_(Registries.f_257019_, "plains", (p_259473_) -> { + return VillagerType.f_35821_; + }); +- public static final DefaultedRegistry f_256735_ = m_257988_(Registries.f_256749_, "none", (p_259037_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#VILLAGER_PROFESSIONS} instead. ++ */ ++ @Deprecated ++ public static final DefaultedRegistry f_256735_ = forge(Registries.f_256749_, "none", (p_259037_) -> { + return VillagerProfession.f_35585_; + }); +- public static final Registry f_256941_ = m_258002_(Registries.f_256805_, PoiTypes::m_218082_); +- public static final DefaultedRegistry> f_256784_ = m_257988_(Registries.f_257023_, "dummy", (p_259248_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#POI_TYPES} instead. ++ */ ++ @Deprecated ++ public static final Registry f_256941_ = forge(Registries.f_256805_, PoiTypes::m_218082_); ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#MEMORY_MODULE_TYPES} instead. ++ */ ++ @Deprecated ++ public static final DefaultedRegistry> f_256784_ = forge(Registries.f_257023_, "dummy", (p_259248_) -> { + return MemoryModuleType.f_26349_; + }); +- public static final DefaultedRegistry> f_256733_ = m_257988_(Registries.f_256937_, "dummy", (p_259757_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#SENSOR_TYPES} instead. ++ */ ++ @Deprecated ++ public static final DefaultedRegistry> f_256733_ = forge(Registries.f_256937_, "dummy", (p_259757_) -> { + return SensorType.f_26809_; + }); +- public static final Registry f_256962_ = m_258002_(Registries.f_256723_, (p_259540_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#SCHEDULES} instead. ++ */ ++ @Deprecated ++ public static final Registry f_256962_ = forge(Registries.f_256723_, (p_259540_) -> { + return Schedule.f_38012_; + }); +- public static final Registry f_256785_ = m_258002_(Registries.f_257025_, (p_260197_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#ACTIVITIES} instead. ++ */ ++ @Deprecated ++ public static final Registry f_256785_ = forge(Registries.f_257025_, (p_260197_) -> { + return Activity.f_37979_; + }); + public static final Registry f_257035_ = m_258002_(Registries.f_257032_, (p_260042_) -> { +@@ -221,10 +_,18 @@ + public static final Registry> f_256906_ = m_258002_(Registries.f_256774_, (p_260006_) -> { + return BlockPredicateType.f_190444_; + }); +- public static final Registry> f_257001_ = m_258002_(Registries.f_256812_, (p_260200_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#WORLD_CARVERS} instead. ++ */ ++ @Deprecated ++ public static final Registry> f_257001_ = forge(Registries.f_256812_, (p_260200_) -> { + return WorldCarver.f_64974_; + }); +- public static final Registry> f_256810_ = m_258002_(Registries.f_256833_, (p_259143_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#FEATURES} instead. ++ */ ++ @Deprecated ++ public static final Registry> f_256810_ = forge(Registries.f_256833_, (p_259143_) -> { + return Feature.f_65731_; + }); + public static final Registry> f_256950_ = m_258002_(Registries.f_256888_, (p_259179_) -> { +@@ -239,10 +_,18 @@ + public static final Registry> f_256986_ = m_258002_(Registries.f_256843_, (p_260335_) -> { + return PlacementModifierType.f_191853_; + }); +- public static final Registry> f_256760_ = m_258002_(Registries.f_256891_, (p_259345_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#BLOCK_STATE_PROVIDER_TYPES} instead. ++ */ ++ @Deprecated ++ public static final Registry> f_256760_ = forge(Registries.f_256891_, (p_259345_) -> { + return BlockStateProviderType.f_68752_; + }); +- public static final Registry> f_256861_ = m_258002_(Registries.f_256905_, (p_260329_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#FOLIAGE_PLACER_TYPES} instead. ++ */ ++ @Deprecated ++ public static final Registry> f_256861_ = forge(Registries.f_256905_, (p_260329_) -> { + return FoliagePlacerType.f_68591_; + }); + public static final Registry> f_256920_ = m_258002_(Registries.f_256963_, (p_259690_) -> { +@@ -251,7 +_,11 @@ + public static final Registry> f_256742_ = m_258002_(Registries.f_256768_, (p_259493_) -> { + return RootPlacerType.f_225898_; + }); +- public static final Registry> f_256987_ = m_258002_(Registries.f_256845_, (p_259122_) -> { ++ /** ++ * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#TREE_DECORATOR_TYPES} instead. ++ */ ++ @Deprecated ++ public static final Registry> f_256987_ = forge(Registries.f_256845_, (p_259122_) -> { + return TreeDecoratorType.f_70043_; + }); + public static final Registry> f_256958_ = m_258002_(Registries.f_256720_, (p_259370_) -> { +@@ -280,10 +_,18 @@ + return m_258073_(p_260095_, Lifecycle.stable(), p_259057_); + } + ++ private static Registry forge(ResourceKey> key, BuiltInRegistries.RegistryBootstrap def) { ++ return forge(key, Lifecycle.experimental(), def); ++ } ++ + private static DefaultedRegistry m_257988_(ResourceKey> p_259887_, String p_259325_, BuiltInRegistries.RegistryBootstrap p_259759_) { + return m_257600_(p_259887_, p_259325_, Lifecycle.stable(), p_259759_); + } + ++ private static DefaultedRegistry forge(ResourceKey> key, String defKey, BuiltInRegistries.RegistryBootstrap def) { ++ return forge(key, defKey, Lifecycle.experimental(), def); ++ } ++ + private static DefaultedRegistry m_257834_(ResourceKey> p_259296_, String p_259101_, BuiltInRegistries.RegistryBootstrap p_259485_) { + return m_257762_(p_259296_, p_259101_, Lifecycle.stable(), p_259485_); + } +@@ -292,10 +_,19 @@ + return m_257895_(p_259121_, new MappedRegistry<>(p_259121_, p_259977_, false), p_259874_, p_259977_); + } + ++ private static Registry forge(ResourceKey> key, Lifecycle cycle, BuiltInRegistries.RegistryBootstrap def) { ++ return m_257895_(key, net.minecraftforge.registries.GameData.getWrapper(key, cycle), def, cycle); ++ } ++ + private static DefaultedRegistry m_257600_(ResourceKey> p_259400_, String p_259678_, Lifecycle p_259157_, BuiltInRegistries.RegistryBootstrap p_259806_) { + return m_257895_(p_259400_, new DefaultedMappedRegistry<>(p_259678_, p_259400_, p_259157_, false), p_259806_, p_259157_); + } + ++ @SuppressWarnings("unchecked") ++ private static DefaultedRegistry forge(ResourceKey> key, String defKey, Lifecycle cycle, BuiltInRegistries.RegistryBootstrap def) { ++ return (DefaultedRegistry) m_257895_(key, net.minecraftforge.registries.GameData.getWrapper(key, cycle, defKey), def, cycle); ++ } ++ + private static DefaultedRegistry m_257762_(ResourceKey> p_260010_, String p_260220_, Lifecycle p_260139_, BuiltInRegistries.RegistryBootstrap p_260185_) { + return m_257895_(p_260010_, new DefaultedMappedRegistry<>(p_260220_, p_260010_, p_260139_, true), p_260185_, p_260139_); + } +@@ -341,7 +_,7 @@ + + if (p_259410_ instanceof DefaultedRegistry) { + ResourceLocation resourcelocation = ((DefaultedRegistry)p_259410_).m_122315_(); +- Validate.notNull(p_259410_.m_7745_(resourcelocation), "Missing default of DefaultedMappedRegistry: " + resourcelocation); ++ Validate.notNull(p_259410_.m_7745_(resourcelocation), "Missing default of DefaultedMappedRegistry: " + p_260209_.m_123023_() + ", Entry: " + resourcelocation); + } + + }); diff --git a/patches/minecraft/net/minecraft/data/BuiltinRegistries.java.patch b/patches/minecraft/net/minecraft/data/BuiltinRegistries.java.patch deleted file mode 100644 index 01124ccb88..0000000000 --- a/patches/minecraft/net/minecraft/data/BuiltinRegistries.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/data/BuiltinRegistries.java -+++ b/net/minecraft/data/BuiltinRegistries.java -@@ -60,7 +_,7 @@ - return ProcessorLists.f_127199_; - }); - public static final Registry f_123864_ = m_236001_(Registry.f_122884_, Pools::m_236491_); -- public static final Registry f_123865_ = m_236001_(Registry.f_122885_, Biomes::m_236652_); -+ @Deprecated public static final Registry f_123865_ = forge(Registry.f_122885_, Biomes::m_236652_); - public static final Registry f_194654_ = m_236001_(Registry.f_194568_, NoiseData::m_236475_); - public static final Registry f_211085_ = m_236001_(Registry.f_211074_, NoiseRouterData::m_224458_); - public static final Registry f_123866_ = m_236001_(Registry.f_122878_, NoiseGeneratorSettings::m_224383_); -@@ -71,6 +_,10 @@ - - private static Registry m_236001_(ResourceKey> p_236002_, BuiltinRegistries.RegistryBootstrap p_236003_) { - return m_235992_(p_236002_, Lifecycle.stable(), p_236003_); -+ } -+ -+ private static Registry forge(ResourceKey> key, BuiltinRegistries.RegistryBootstrap bootstrap) { -+ return m_235996_(key, net.minecraftforge.registries.GameData.getWrapper(key, Lifecycle.stable()), bootstrap, Lifecycle.stable()); - } - - private static Registry m_235992_(ResourceKey> p_235993_, Lifecycle p_235994_, BuiltinRegistries.RegistryBootstrap p_235995_) { diff --git a/patches/minecraft/net/minecraft/data/DataGenerator.java.patch b/patches/minecraft/net/minecraft/data/DataGenerator.java.patch index c1987e8697..1d0f14ba52 100644 --- a/patches/minecraft/net/minecraft/data/DataGenerator.java.patch +++ b/patches/minecraft/net/minecraft/data/DataGenerator.java.patch @@ -1,40 +1,49 @@ --- a/net/minecraft/data/DataGenerator.java +++ b/net/minecraft/data/DataGenerator.java -@@ -21,12 +_,13 @@ - private final List f_236026_ = Lists.newArrayList(); +@@ -21,6 +_,7 @@ + final Map f_236026_ = new LinkedHashMap<>(); private final WorldVersion f_236027_; private final boolean f_236028_; -+ private final List providerView = java.util.Collections.unmodifiableList(f_236025_); ++ private final Map providersView = java.util.Collections.unmodifiableMap(this.f_236026_); - public DataGenerator(Path p_236030_, Collection p_236031_, WorldVersion p_236032_, boolean p_236033_) { - this.f_123907_ = p_236030_; -- this.f_123906_ = p_236031_; - this.f_236027_ = p_236032_; - this.f_236028_ = p_236033_; -+ this.f_123906_ = Lists.newArrayList(p_236031_); - } - - public Collection m_123913_() { -@@ -51,6 +_,7 @@ - f_123905_.debug("Generator {} already run for version {}", dataprovider.m_6055_(), this.f_236027_.getName()); + public DataGenerator(Path p_251724_, WorldVersion p_250554_, boolean p_251323_) { + this.f_243753_ = p_251724_; +@@ -38,6 +_,7 @@ + f_123905_.debug("Generator {} already run for version {}", p_254418_, this.f_236027_.getName()); } else { - f_123905_.info("Starting provider: {}", (Object)dataprovider.m_6055_()); -+ net.minecraftforge.fml.StartupMessageManager.addModMessage("Generating: " + dataprovider.m_6055_()); + f_123905_.info("Starting provider: {}", (Object)p_254418_); ++ net.minecraftforge.fml.StartupMessageManager.addModMessage("Generating: " + p_254418_); stopwatch1.start(); - dataprovider.m_213708_(hashcache.m_236107_(dataprovider)); + hashcache.m_253116_(hashcache.m_253234_(p_254418_, p_253750_::m_213708_).join()); stopwatch1.stop(); -@@ -73,6 +_,14 @@ - - public DataGenerator.PathProvider m_236036_(DataGenerator.Target p_236037_, String p_236038_) { - return new DataGenerator.PathProvider(this, p_236037_, p_236038_); +@@ -56,6 +_,30 @@ + public DataGenerator.PackGenerator m_253030_(boolean p_253826_, String p_254134_) { + Path path = this.f_244116_.m_247566_(PackOutput.Target.DATA_PACK).resolve("minecraft").resolve("datapacks").resolve(p_254134_); + return new DataGenerator.PackGenerator(p_253826_, p_254134_, new PackOutput(path)); + } + -+ public List getProviders() { -+ return this.providerView; ++ public Map getProvidersView() { ++ return this.providersView; + } + -+ public void addInput(Path value) { -+ this.f_123906_.add(value); ++ public PackOutput getPackOutput() { ++ return this.f_244116_; ++ } ++ ++ public T addProvider(boolean run, DataProvider.Factory factory) { ++ return addProvider(run, factory.m_253034_(this.f_244116_)); ++ } ++ ++ public T addProvider(boolean run, T provider) { ++ String id = provider.m_6055_(); ++ ++ if (!DataGenerator.this.f_252429_.add(id)) ++ throw new IllegalStateException("Duplicate provider: " + id); ++ ++ if (run) ++ DataGenerator.this.f_236026_.put(id, provider); ++ ++ return provider; } static { diff --git a/patches/minecraft/net/minecraft/data/HashCache.java.patch b/patches/minecraft/net/minecraft/data/HashCache.java.patch index 00ba44c6f7..6f8c55f829 100644 --- a/patches/minecraft/net/minecraft/data/HashCache.java.patch +++ b/patches/minecraft/net/minecraft/data/HashCache.java.patch @@ -1,23 +1,41 @@ --- a/net/minecraft/data/HashCache.java +++ b/net/minecraft/data/HashCache.java -@@ -92,6 +_,7 @@ - MutableInt mutableint = new MutableInt(); - this.f_236083_.forEach((p_236100_, p_236101_) -> { - Path path = this.m_236109_(p_236100_); -+ if (!p_236101_.f_236114_.equals(p_236101_.f_236113_) || !Files.exists(path))//Forge: Only rewrite the cache file if it changed or is missing - p_236101_.f_236114_.m_236142_(this.f_236079_, path, DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(LocalDateTime.now()) + "\t" + p_236100_.m_6055_()); - mutableint.add(p_236101_.f_236115_); - }); -@@ -231,10 +_,10 @@ - bufferedwriter.write(p_236145_); - bufferedwriter.newLine(); +@@ -35,6 +_,7 @@ + private final Path f_236080_; + private final String f_236081_; + private final Map f_252445_; ++ private final Map originalCaches; + private final Set f_236083_ = new HashSet<>(); + private final Set f_236084_ = new HashSet<>(); + private final int f_236085_; +@@ -61,6 +_,7 @@ + } -- for(Map.Entry entry : this.f_236127_.entrySet()) { -+ for(Map.Entry entry : this.f_236127_.entrySet().stream().sorted(Map.Entry.comparingByKey()).toList()) { - bufferedwriter.write(entry.getValue().toString()); - bufferedwriter.write(32); -- bufferedwriter.write(p_236143_.relativize(entry.getKey()).toString()); -+ bufferedwriter.write(p_236143_.relativize(entry.getKey()).toString().replace("\\", "/")); // Forge: Standardize file paths. - bufferedwriter.newLine(); - } - } catch (Throwable throwable1) { + this.f_252445_ = map; ++ this.originalCaches = Map.copyOf(this.f_252445_); + this.f_236085_ = i; + } + +@@ -104,6 +_,8 @@ + this.f_252445_.forEach((p_253378_, p_253379_) -> { + if (this.f_236083_.contains(p_253378_)) { + Path path = this.m_252859_(p_253378_); ++ // Forge: Only rewrite the cache file if it changed or is missing ++ if (!p_253379_.equals(this.originalCaches.get(p_253378_)) || !Files.exists(path)) + p_253379_.m_236142_(this.f_236079_, path, DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(LocalDateTime.now()) + "\t" + p_253378_); + } + +@@ -211,10 +_,11 @@ + bufferedwriter.write(p_236145_); + bufferedwriter.newLine(); + +- for(Map.Entry entry : this.f_236127_.entrySet()) { ++ // Forge: Standardize order of entries ++ for(Map.Entry entry : this.f_236127_.entrySet().stream().sorted(Map.Entry.comparingByKey()).toList()) { + bufferedwriter.write(entry.getValue().toString()); + bufferedwriter.write(32); +- bufferedwriter.write(p_236143_.relativize(entry.getKey()).toString()); ++ bufferedwriter.write(p_236143_.relativize(entry.getKey()).toString().replace("\\", "/")); // Forge: Standardize file paths. + bufferedwriter.newLine(); + } + } catch (IOException ioexception) { diff --git a/patches/minecraft/net/minecraft/data/Main.java.patch b/patches/minecraft/net/minecraft/data/Main.java.patch index cc56fc53b5..3b850dfb92 100644 --- a/patches/minecraft/net/minecraft/data/Main.java.patch +++ b/patches/minecraft/net/minecraft/data/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/Main.java +++ b/net/minecraft/data/Main.java -@@ -52,8 +_,15 @@ +@@ -69,8 +_,15 @@ OptionSpec optionspec6 = optionparser.accepts("all", "Include all generators"); OptionSpec optionspec7 = optionparser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated"); OptionSpec optionspec8 = optionparser.accepts("input", "Input folder").withRequiredArg(); @@ -17,7 +17,7 @@ Path path = Paths.get(optionspec7.value(optionset)); boolean flag = optionset.has(optionspec6); boolean flag1 = flag || optionset.has(optionspec2); -@@ -61,10 +_,14 @@ +@@ -78,10 +_,14 @@ boolean flag3 = flag || optionset.has(optionspec3); boolean flag4 = flag || optionset.has(optionspec4); boolean flag5 = flag || optionset.has(optionspec5); diff --git a/patches/minecraft/net/minecraft/data/advancements/AdvancementProvider.java.patch b/patches/minecraft/net/minecraft/data/advancements/AdvancementProvider.java.patch index a4432a8b8e..79f2838287 100644 --- a/patches/minecraft/net/minecraft/data/advancements/AdvancementProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/advancements/AdvancementProvider.java.patch @@ -1,40 +1,53 @@ --- a/net/minecraft/data/advancements/AdvancementProvider.java +++ b/net/minecraft/data/advancements/AdvancementProvider.java -@@ -19,11 +_,18 @@ - private static final Logger f_123960_ = LogUtils.getLogger(); - private final DataGenerator.PathProvider f_236156_; - private final List>> f_123963_ = ImmutableList.of(new TheEndAdvancements(), new HusbandryAdvancements(), new AdventureAdvancements(), new NetherAdvancements(), new StoryAdvancements()); -+ protected net.minecraftforge.common.data.ExistingFileHelper fileHelper; +@@ -18,8 +_,19 @@ + private final PackOutput.PathProvider f_236156_; + private final List f_244266_; + private final CompletableFuture f_254664_; ++ @org.jetbrains.annotations.Nullable ++ protected final net.minecraftforge.common.data.ExistingFileHelper existingFileHelper; ++ /** ++ * @deprecated Forge: Use the {@linkplain #AdvancementProvider(PackOutput, CompletableFuture, List, net.minecraftforge.common.data.ExistingFileHelper) existing file helper variant} ++ */ + @Deprecated - public AdvancementProvider(DataGenerator p_123966_) { - this.f_236156_ = p_123966_.m_236036_(DataGenerator.Target.DATA_PACK, "advancements"); - } - -+ public AdvancementProvider(DataGenerator generatorIn, net.minecraftforge.common.data.ExistingFileHelper fileHelperIn) { -+ this.f_236156_ = generatorIn.m_236036_(DataGenerator.Target.DATA_PACK, "advancements"); -+ this.fileHelper = fileHelperIn; + public AdvancementProvider(PackOutput p_256529_, CompletableFuture p_255722_, List p_255883_) { ++ this(p_256529_, p_255722_, p_255883_, null); + } + - public void m_213708_(CachedOutput p_236158_) { - Set set = Sets.newHashSet(); - Consumer consumer = (p_236162_) -> { -@@ -41,6 +_,18 @@ - } - }; ++ public AdvancementProvider(PackOutput p_256529_, CompletableFuture p_255722_, List p_255883_, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ this.existingFileHelper = existingFileHelper; + this.f_236156_ = p_256529_.m_245269_(PackOutput.Target.DATA_PACK, "advancements"); + this.f_244266_ = p_255883_; + this.f_254664_ = p_255722_; +@@ -38,14 +_,27 @@ + } + }; -+ registerAdvancements(consumer, fileHelper); +- for(AdvancementSubProvider advancementsubprovider : this.f_244266_) { +- advancementsubprovider.m_245571_(p_255484_, consumer); +- } ++ // Forge: Allow mods to take control of advancement registration ++ this.registerAdvancements(p_255484_, consumer, this.existingFileHelper); + + return CompletableFuture.allOf(list.toArray((p_253393_) -> { + return new CompletableFuture[p_253393_]; + })); + }); + } + + /** -+ * This method registers all {@link Advancement advancements}. -+ * Mods can override this method to register their own custom advancements. ++ * Registers all {@linkplain Advancement advancements}. + * -+ * @param consumer a {@link Consumer} which saves any advancements provided -+ * @param fileHelper the existing file helper to check for the existence of files like parent advancements ++ * @param registries the registries available for lookup including all registries in {@link net.minecraft.core.registries.Registries} ++ * @param saver a {@link Consumer} which saves any advancements provided ++ * @param existingFileHelper the existing file helper to check for the existence of files like parent advancements + * @see Advancement.Builder#save(Consumer, ResourceLocation, net.minecraftforge.common.data.ExistingFileHelper) -+ */ -+ protected void registerAdvancements(Consumer consumer, net.minecraftforge.common.data.ExistingFileHelper fileHelper) { - for(Consumer> consumer1 : this.f_123963_) { - consumer1.accept(consumer); - } ++ */ ++ protected void registerAdvancements(HolderLookup.Provider registries, Consumer saver, net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ for (AdvancementSubProvider subProvider : this.f_244266_) { ++ subProvider.m_245571_(registries, saver); ++ } + } + + public final String m_6055_() { diff --git a/patches/minecraft/net/minecraft/data/info/WorldgenRegistryDumpReport.java.patch b/patches/minecraft/net/minecraft/data/info/WorldgenRegistryDumpReport.java.patch deleted file mode 100644 index d6a88ff9f9..0000000000 --- a/patches/minecraft/net/minecraft/data/info/WorldgenRegistryDumpReport.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/data/info/WorldgenRegistryDumpReport.java -+++ b/net/minecraft/data/info/WorldgenRegistryDumpReport.java -@@ -37,7 +_,7 @@ - private void m_236204_(CachedOutput p_236205_, RegistryAccess p_236206_, DynamicOps p_236207_, RegistryAccess.RegistryData p_236208_) { - ResourceKey> resourcekey = p_236208_.f_123101_(); - Registry registry = p_236206_.m_206191_(resourcekey); -- DataGenerator.PathProvider datagenerator$pathprovider = this.f_194676_.m_236036_(DataGenerator.Target.REPORTS, resourcekey.m_135782_().m_135815_()); -+ DataGenerator.PathProvider datagenerator$pathprovider = this.f_194676_.m_236036_(DataGenerator.Target.REPORTS, net.minecraftforge.common.ForgeHooks.prefixNamespace(resourcekey.m_135782_())); // FORGE: Custom data-pack registries are prefixed with their namespace - - for(Map.Entry, T> entry : registry.m_6579_()) { - m_236209_(datagenerator$pathprovider.m_236048_(entry.getKey().m_135782_()), p_236205_, p_236207_, p_236208_.f_123102_(), entry.getValue()); diff --git a/patches/minecraft/net/minecraft/data/loot/BlockLoot.java.patch b/patches/minecraft/net/minecraft/data/loot/BlockLoot.java.patch deleted file mode 100644 index cf18842bb2..0000000000 --- a/patches/minecraft/net/minecraft/data/loot/BlockLoot.java.patch +++ /dev/null @@ -1,37 +0,0 @@ ---- a/net/minecraft/data/loot/BlockLoot.java -+++ b/net/minecraft/data/loot/BlockLoot.java -@@ -265,7 +_,7 @@ - return LootTable.m_79147_(); - } - -- public void accept(BiConsumer p_124179_) { -+ protected void addTables() { - this.m_124288_(Blocks.f_50122_); - this.m_124288_(Blocks.f_50175_); - this.m_124288_(Blocks.f_50228_); -@@ -1312,9 +_,13 @@ - this.m_124165_(Blocks.f_152499_, m_124125_()); - this.m_124165_(Blocks.f_220862_, m_124125_()); - this.m_124165_(Blocks.f_220863_, m_124125_()); -+ } -+ -+ public void accept(BiConsumer p_124179_) { -+ this.addTables(); - Set set = Sets.newHashSet(); - -- for(Block block : Registry.f_122824_) { -+ for(Block block : getKnownBlocks()) { - ResourceLocation resourcelocation = block.m_60589_(); - if (resourcelocation != BuiltInLootTables.f_78712_ && set.add(resourcelocation)) { - LootTable.Builder loottable$builder = this.f_124070_.remove(resourcelocation); -@@ -1339,6 +_,10 @@ - - public static LootTable.Builder m_124137_(Block p_124138_) { - return m_124161_(p_124138_, DoorBlock.f_52730_, DoubleBlockHalf.LOWER); -+ } -+ -+ protected Iterable getKnownBlocks() { -+ return Registry.f_122824_; - } - - public void m_124252_(Block p_124253_) { diff --git a/patches/minecraft/net/minecraft/data/loot/BlockLootSubProvider.java.patch b/patches/minecraft/net/minecraft/data/loot/BlockLootSubProvider.java.patch new file mode 100644 index 0000000000..b06da11cbe --- /dev/null +++ b/patches/minecraft/net/minecraft/data/loot/BlockLootSubProvider.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/data/loot/BlockLootSubProvider.java ++++ b/net/minecraft/data/loot/BlockLootSubProvider.java +@@ -252,11 +_,15 @@ + + protected abstract void m_245660_(); + ++ protected Iterable getKnownBlocks() { ++ return BuiltInRegistries.f_256975_; ++ } ++ + public void m_245126_(BiConsumer p_249322_) { + this.m_245660_(); + Set set = new HashSet<>(); + +- for(Block block : BuiltInRegistries.f_256975_) { ++ for(Block block : getKnownBlocks()) { + if (block.m_245993_(this.f_243739_)) { + ResourceLocation resourcelocation = block.m_60589_(); + if (resourcelocation != BuiltInLootTables.f_78712_ && set.add(resourcelocation)) { diff --git a/patches/minecraft/net/minecraft/data/loot/EntityLoot.java.patch b/patches/minecraft/net/minecraft/data/loot/EntityLoot.java.patch deleted file mode 100644 index 7405ae5905..0000000000 --- a/patches/minecraft/net/minecraft/data/loot/EntityLoot.java.patch +++ /dev/null @@ -1,44 +0,0 @@ ---- a/net/minecraft/data/loot/EntityLoot.java -+++ b/net/minecraft/data/loot/EntityLoot.java -@@ -55,7 +_,7 @@ - return LootTable.m_79147_().m_79161_(LootPool.m_79043_().m_165133_(ConstantValue.m_165692_(1.0F)).m_79076_(LootItem.m_79579_(p_124375_))).m_79161_(LootPool.m_79043_().m_165133_(ConstantValue.m_165692_(1.0F)).m_79076_(LootTableReference.m_79776_(EntityType.f_20520_.m_20677_()))); - } - -- public void accept(BiConsumer p_124377_) { -+ protected void addTables() { - this.m_124371_(EntityType.f_217014_, LootTable.m_79147_()); - this.m_124371_(EntityType.f_20529_, LootTable.m_79147_()); - this.m_124371_(EntityType.f_147039_, LootTable.m_79147_()); -@@ -151,11 +_,15 @@ - this.m_124371_(EntityType.f_20511_, LootTable.m_79147_()); - this.m_124371_(EntityType.f_20512_, LootTable.m_79147_()); - this.m_124371_(EntityType.f_20530_, LootTable.m_79147_().m_79161_(LootPool.m_79043_().m_165133_(ConstantValue.m_165692_(1.0F)).m_79076_(LootItem.m_79579_(Items.f_42583_).m_79078_(SetItemCountFunction.m_165412_(UniformGenerator.m_165780_(0.0F, 2.0F))).m_79078_(LootingEnchantFunction.m_165229_(UniformGenerator.m_165780_(0.0F, 1.0F))))).m_79161_(LootPool.m_79043_().m_165133_(ConstantValue.m_165692_(1.0F)).m_79076_(LootItem.m_79579_(Items.f_42416_)).m_79076_(LootItem.m_79579_(Items.f_42619_)).m_79076_(LootItem.m_79579_(Items.f_42620_).m_79078_(SmeltItemFunction.m_81271_().m_79080_(LootItemEntityPropertyCondition.m_81864_(LootContext.EntityTarget.THIS, f_124366_)))).m_79080_(LootItemKilledByPlayerCondition.m_81901_()).m_79080_(LootItemRandomChanceWithLootingCondition.m_81963_(0.025F, 0.01F)))); -+ } -+ -+ public void accept(BiConsumer p_124377_) { -+ this.addTables(); - Set set = Sets.newHashSet(); - -- for(EntityType entitytype : Registry.f_122826_) { -+ for(EntityType entitytype : getKnownEntities()) { - ResourceLocation resourcelocation = entitytype.m_20677_(); -- if (!f_124367_.contains(entitytype) && entitytype.m_20674_() == MobCategory.MISC) { -+ if (isNonLiving(entitytype)) { - if (resourcelocation != BuiltInLootTables.f_78712_ && this.f_124368_.remove(resourcelocation) != null) { - throw new IllegalStateException(String.format(Locale.ROOT, "Weird loottable '%s' for '%s', not a LivingEntity so should not have loot", resourcelocation, Registry.f_122826_.m_7981_(entitytype))); - } -@@ -170,6 +_,14 @@ - } - - this.f_124368_.forEach(p_124377_); -+ } -+ -+ protected Iterable> getKnownEntities() { -+ return Registry.f_122826_; -+ } -+ -+ protected boolean isNonLiving(EntityType entitytype) { -+ return !f_124367_.contains(entitytype) && entitytype.m_20674_() == MobCategory.MISC; - } - - private LootItemCondition.Builder m_236264_() { diff --git a/patches/minecraft/net/minecraft/data/loot/EntityLootSubProvider.java.patch b/patches/minecraft/net/minecraft/data/loot/EntityLootSubProvider.java.patch new file mode 100644 index 0000000000..fc2e0bc626 --- /dev/null +++ b/patches/minecraft/net/minecraft/data/loot/EntityLootSubProvider.java.patch @@ -0,0 +1,27 @@ +--- a/net/minecraft/data/loot/EntityLootSubProvider.java ++++ b/net/minecraft/data/loot/EntityLootSubProvider.java +@@ -45,10 +_,14 @@ + + public abstract void m_246942_(); + ++ protected java.util.stream.Stream> getKnownEntityTypes() { ++ return BuiltInRegistries.f_256780_.m_123024_(); ++ } ++ + public void m_245126_(BiConsumer p_251751_) { + this.m_246942_(); + Set set = Sets.newHashSet(); +- BuiltInRegistries.f_256780_.m_203611_().forEach((p_249003_) -> { ++ this.getKnownEntityTypes().map(EntityType::m_204041_).forEach((p_249003_) -> { + EntityType entitytype = p_249003_.m_203334_(); + if (entitytype.m_245993_(this.f_244045_)) { + if (m_245552_(entitytype)) { +@@ -81,7 +_,7 @@ + } + } + +- protected static boolean m_245552_(EntityType p_249029_) { ++ protected boolean m_245552_(EntityType p_249029_) { + return f_244591_.contains(p_249029_) || p_249029_.m_20674_() != MobCategory.MISC; + } + diff --git a/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch b/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch index 1cba531e6a..305c992379 100644 --- a/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/data/loot/LootTableProvider.java +++ b/net/minecraft/data/loot/LootTableProvider.java -@@ -36,7 +_,7 @@ +@@ -35,7 +_,7 @@ - public void m_213708_(CachedOutput p_236269_) { + public CompletableFuture m_213708_(CachedOutput p_254060_) { Map map = Maps.newHashMap(); -- this.f_124434_.forEach((p_124458_) -> { -+ this.getTables().forEach((p_124458_) -> { - p_124458_.getFirst().get().accept((p_176077_, p_176078_) -> { - if (map.put(p_176077_, p_176078_.m_79165_(p_124458_.getSecond()).m_79167_()) != null) { - throw new IllegalStateException("Duplicate loot table " + p_176077_); -@@ -47,13 +_,8 @@ +- this.f_124434_.forEach((p_248012_) -> { ++ this.getTables().forEach((p_248012_) -> { + p_248012_.f_243941_().get().m_245126_((p_248006_, p_248007_) -> { + if (map.put(p_248006_, p_248007_.m_79165_(p_248012_.f_244144_).m_79167_()) != null) { + throw new IllegalStateException("Duplicate loot table " + p_248006_); +@@ -46,13 +_,8 @@ return null; }, map::get); -- for(ResourceLocation resourcelocation : Sets.difference(BuiltInLootTables.m_78766_(), map.keySet())) { +- for(ResourceLocation resourcelocation : Sets.difference(this.f_243940_, map.keySet())) { - validationcontext.m_79357_("Missing built-in table: " + resourcelocation); - } + validate(map, validationcontext); @@ -24,24 +24,24 @@ Multimap multimap = validationcontext.m_79352_(); if (!multimap.isEmpty()) { multimap.forEach((p_124446_, p_124447_) -> { -@@ -72,6 +_,20 @@ - - }); +@@ -69,6 +_,20 @@ + return new CompletableFuture[p_253403_]; + })); } + } + -+ protected List>>, LootContextParamSet>> getTables() { -+ return f_124434_; ++ public List getTables() { ++ return this.f_124434_; + } + -+ protected void validate(Map map, ValidationContext validationtracker) { -+ for(ResourceLocation resourcelocation : Sets.difference(BuiltInLootTables.m_78766_(), map.keySet())) { -+ validationtracker.m_79357_("Missing built-in table: " + resourcelocation); ++ protected void validate(Map map, ValidationContext validationcontext) { ++ for(ResourceLocation resourcelocation : Sets.difference(this.f_243940_, map.keySet())) { ++ validationcontext.m_79357_("Missing built-in table: " + resourcelocation); + } + -+ map.forEach((p_218436_2_, p_218436_3_) -> { -+ LootTables.m_79202_(validationtracker, p_218436_2_, p_218436_3_); ++ map.forEach((p_124441_, p_124442_) -> { ++ LootTables.m_79202_(validationcontext, p_124441_, p_124442_); + }); } - public String m_6055_() { + public final String m_6055_() { diff --git a/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch b/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch index fba2cfabdd..fba3579eac 100644 --- a/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch @@ -1,28 +1,38 @@ --- a/net/minecraft/data/recipes/RecipeProvider.java +++ b/net/minecraft/data/recipes/RecipeProvider.java -@@ -100,6 +_,7 @@ +@@ -88,7 +_,9 @@ + list.add(DataProvider.m_253162_(p_254020_, p_253413_.m_125966_(), this.f_236355_.m_245731_(p_253413_.m_6445_()))); + JsonObject jsonobject = p_253413_.m_5860_(); + if (jsonobject != null) { +- list.add(DataProvider.m_253162_(p_254020_, jsonobject, this.f_236356_.m_245731_(p_253413_.m_6448_()))); ++ var saveAdvancementFuture = saveAdvancement(p_254020_, p_253413_, jsonobject); ++ if (saveAdvancementFuture != null) ++ list.add(saveAdvancementFuture); + } } - }); -+ if (this.getClass() == RecipeProvider.class) //Forge: Subclasses don't need this. - m_236367_(p_236358_, Advancement.Builder.m_138353_().m_138386_("impossible", new ImpossibleTrigger.TriggerInstance()).m_138400_(), this.f_236356_.m_236048_(RecipeBuilder.f_236353_)); +@@ -98,13 +_,23 @@ + })); } -@@ -112,7 +_,7 @@ - ++ /** ++ * Called every time a recipe is saved to also save the advancement JSON if it exists. ++ * ++ * @return A completable future that saves the advancement to disk, or null to cancel saving the advancement. ++ */ ++ @org.jetbrains.annotations.Nullable ++ protected CompletableFuture saveAdvancement(CachedOutput output, FinishedRecipe finishedRecipe, JsonObject advancementJson) { ++ return DataProvider.m_253162_(output, advancementJson, this.f_236356_.m_245731_(finishedRecipe.m_6448_())); ++ } ++ + protected CompletableFuture m_253240_(CachedOutput p_253674_, ResourceLocation p_254102_, Advancement.Builder p_253712_) { + return DataProvider.m_253162_(p_253674_, p_253712_.m_138400_(), this.f_236356_.m_245731_(p_254102_)); } -- protected static void m_236367_(CachedOutput p_236368_, JsonObject p_236369_, Path p_236370_) { -+ protected void m_236367_(CachedOutput p_236368_, JsonObject p_236369_, Path p_236370_) { - try { - DataProvider.m_236072_(p_236368_, p_236369_, p_236370_); - } catch (IOException ioexception) { -@@ -121,7 +_,7 @@ + protected abstract void m_245200_(Consumer p_251297_); - } - -- protected static void m_176531_(Consumer p_176532_) { -+ protected void m_176531_(Consumer p_176532_) { - BlockFamilies.m_175934_().filter(BlockFamily::m_175956_).forEach((p_176624_) -> { - m_176580_(p_176532_, p_176624_); - }); +- protected static void m_247051_(Consumer p_249188_, FeatureFlagSet p_251836_) { ++ protected void m_247051_(Consumer p_249188_, FeatureFlagSet p_251836_) { + BlockFamilies.m_175934_().filter((p_248034_) -> { + return p_248034_.m_245288_(p_251836_); + }).forEach((p_176624_) -> { diff --git a/patches/minecraft/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch b/patches/minecraft/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch new file mode 100644 index 0000000000..cb60e38464 --- /dev/null +++ b/patches/minecraft/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/data/registries/RegistriesDatapackGenerator.java ++++ b/net/minecraft/data/registries/RegistriesDatapackGenerator.java +@@ -31,7 +_,7 @@ + public CompletableFuture m_213708_(CachedOutput p_255785_) { + return this.f_254747_.thenCompose((p_256533_) -> { + DynamicOps dynamicops = RegistryOps.m_255058_(JsonOps.INSTANCE, p_256533_); +- return CompletableFuture.allOf(RegistryDataLoader.f_243803_.stream().flatMap((p_256552_) -> { ++ return CompletableFuture.allOf(net.minecraftforge.registries.DataPackRegistriesHooks.getDataPackRegistries().stream().flatMap((p_256552_) -> { + return this.m_254918_(p_255785_, p_256533_, dynamicops, p_256552_).stream(); + }).toArray((p_255809_) -> { + return new CompletableFuture[p_255809_]; diff --git a/patches/minecraft/net/minecraft/data/registries/VanillaRegistries.java.patch b/patches/minecraft/net/minecraft/data/registries/VanillaRegistries.java.patch new file mode 100644 index 0000000000..85a6aa7e3e --- /dev/null +++ b/patches/minecraft/net/minecraft/data/registries/VanillaRegistries.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/data/registries/VanillaRegistries.java ++++ b/net/minecraft/data/registries/VanillaRegistries.java +@@ -31,6 +_,7 @@ + + public class VanillaRegistries { + private static final RegistrySetBuilder f_254635_ = (new RegistrySetBuilder()).m_254916_(Registries.f_256787_, DimensionTypes::m_236473_).m_254916_(Registries.f_257003_, (RegistrySetBuilder.RegistryBootstrap)Carvers::m_254873_).m_254916_(Registries.f_256911_, (RegistrySetBuilder.RegistryBootstrap)FeatureUtils::m_254925_).m_254916_(Registries.f_256988_, PlacementUtils::m_255199_).m_254916_(Registries.f_256944_, Structures::m_255324_).m_254916_(Registries.f_256998_, StructureSets::m_255117_).m_254916_(Registries.f_257011_, ProcessorLists::m_254888_).m_254916_(Registries.f_256948_, Pools::m_255181_).m_254916_(Registries.f_256952_, Biomes::m_254912_).m_254916_(Registries.f_256865_, NoiseData::m_236475_).m_254916_(Registries.f_257040_, NoiseRouterData::m_255288_).m_254916_(Registries.f_256932_, NoiseGeneratorSettings::m_254959_).m_254916_(Registries.f_256729_, WorldPresets::m_254897_).m_254916_(Registries.f_256724_, FlatLevelGeneratorPresets::m_254848_).m_254916_(Registries.f_256873_, ChatType::m_237021_); ++ public static final List>> DATAPACK_REGISTRY_KEYS = f_254635_.getEntryKeys(); + + private static void m_255148_(HolderLookup.Provider p_256242_) { + HolderGetter holdergetter = p_256242_.m_255025_(Registries.f_256988_); diff --git a/patches/minecraft/net/minecraft/data/tags/BannerPatternTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/BannerPatternTagsProvider.java.patch index b7ed23b1ef..1ec59cd8f1 100644 --- a/patches/minecraft/net/minecraft/data/tags/BannerPatternTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/BannerPatternTagsProvider.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/data/tags/BannerPatternTagsProvider.java +++ b/net/minecraft/data/tags/BannerPatternTagsProvider.java -@@ -7,8 +_,13 @@ +@@ -9,8 +_,13 @@ import net.minecraft.world.level.block.entity.BannerPatterns; public class BannerPatternTagsProvider extends TagsProvider { -+ /** @deprecated Forge: Use the {@link #BannerPatternTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ ++ /** @deprecated Forge: Use the {@linkplain #BannerPatternTagsProvider(PackOutput, CompletableFuture, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated - public BannerPatternTagsProvider(DataGenerator p_236411_) { - super(p_236411_, Registry.f_235736_); + public BannerPatternTagsProvider(PackOutput p_256451_, CompletableFuture p_256420_) { + super(p_256451_, Registries.f_256969_, p_256420_); + } -+ public BannerPatternTagsProvider(DataGenerator p_236411_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_236411_, Registry.f_235736_, modId, existingFileHelper); ++ public BannerPatternTagsProvider(PackOutput p_256451_, CompletableFuture p_256420_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ super(p_256451_, Registries.f_256969_, p_256420_, modId, existingFileHelper); } - protected void m_6577_() { + protected void m_6577_(HolderLookup.Provider p_255819_) { diff --git a/patches/minecraft/net/minecraft/data/tags/BiomeTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/BiomeTagsProvider.java.patch index 88e2e8d9de..7a5cd9398c 100644 --- a/patches/minecraft/net/minecraft/data/tags/BiomeTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/BiomeTagsProvider.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/data/tags/BiomeTagsProvider.java +++ b/net/minecraft/data/tags/BiomeTagsProvider.java -@@ -8,8 +_,13 @@ +@@ -11,8 +_,13 @@ import net.minecraft.world.level.biome.MultiNoiseBiomeSource; public class BiomeTagsProvider extends TagsProvider { -+ /** @deprecated Forge: Use the {@link #BiomeTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ ++ /** @deprecated Forge: Use the {@linkplain #BiomeTagsProvider(PackOutput, CompletableFuture, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated - public BiomeTagsProvider(DataGenerator p_211094_) { - super(p_211094_, BuiltinRegistries.f_123865_); + public BiomeTagsProvider(PackOutput p_255800_, CompletableFuture p_256205_) { + super(p_255800_, Registries.f_256952_, p_256205_); + } -+ public BiomeTagsProvider(DataGenerator p_211094_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_211094_, BuiltinRegistries.f_123865_, modId, existingFileHelper); ++ public BiomeTagsProvider(PackOutput p_255800_, CompletableFuture p_256205_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ super(p_255800_, Registries.f_256952_, p_256205_, modId, existingFileHelper); } - protected void m_6577_() { + protected void m_6577_(HolderLookup.Provider p_256485_) { diff --git a/patches/minecraft/net/minecraft/data/tags/BlockTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/BlockTagsProvider.java.patch deleted file mode 100644 index 39239167bd..0000000000 --- a/patches/minecraft/net/minecraft/data/tags/BlockTagsProvider.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/data/tags/BlockTagsProvider.java -+++ b/net/minecraft/data/tags/BlockTagsProvider.java -@@ -7,8 +_,13 @@ - import net.minecraft.world.level.block.Blocks; - - public class BlockTagsProvider extends TagsProvider { -+ /** @deprecated Forge: Use the {@link #BlockTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ -+ @Deprecated - public BlockTagsProvider(DataGenerator p_126511_) { - super(p_126511_, Registry.f_122824_); -+ } -+ public BlockTagsProvider(DataGenerator p_126511_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_126511_, Registry.f_122824_, modId, existingFileHelper); - } - - protected void m_6577_() { diff --git a/patches/minecraft/net/minecraft/data/tags/CatVariantTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/CatVariantTagsProvider.java.patch index ba31c956d4..01bd395e96 100644 --- a/patches/minecraft/net/minecraft/data/tags/CatVariantTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/CatVariantTagsProvider.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/data/tags/CatVariantTagsProvider.java +++ b/net/minecraft/data/tags/CatVariantTagsProvider.java -@@ -6,8 +_,13 @@ +@@ -8,8 +_,13 @@ import net.minecraft.world.entity.animal.CatVariant; public class CatVariantTagsProvider extends TagsProvider { -+ /** @deprecated Forge: Use the {@link #CatVariantTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ ++ /** @deprecated Forge: Use the {@linkplain #CatVariantTagsProvider(PackOutput, CompletableFuture, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated - public CatVariantTagsProvider(DataGenerator p_236420_) { - super(p_236420_, Registry.f_235732_); + public CatVariantTagsProvider(PackOutput p_256547_, CompletableFuture p_256090_) { + super(p_256547_, Registries.f_257006_, p_256090_); + } -+ public CatVariantTagsProvider(DataGenerator p_236420_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_236420_, Registry.f_235732_, modId, existingFileHelper); ++ public CatVariantTagsProvider(PackOutput p_256547_, CompletableFuture p_256090_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ super(p_256547_, Registries.f_257006_, p_256090_, modId, existingFileHelper); } - protected void m_6577_() { + protected void m_6577_(HolderLookup.Provider p_256078_) { diff --git a/patches/minecraft/net/minecraft/data/tags/EntityTypeTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/EntityTypeTagsProvider.java.patch index 79a9824be0..89e98efb3c 100644 --- a/patches/minecraft/net/minecraft/data/tags/EntityTypeTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/EntityTypeTagsProvider.java.patch @@ -1,16 +1,19 @@ --- a/net/minecraft/data/tags/EntityTypeTagsProvider.java +++ b/net/minecraft/data/tags/EntityTypeTagsProvider.java -@@ -6,8 +_,13 @@ +@@ -8,10 +_,15 @@ import net.minecraft.world.entity.EntityType; - public class EntityTypeTagsProvider extends TagsProvider> { -+ /** @deprecated Forge: Use the {@link #EntityTypeTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + public class EntityTypeTagsProvider extends IntrinsicHolderTagsProvider> { ++ /** @deprecated Forge: Use the {@linkplain #EntityTypeTagsProvider(PackOutput, CompletableFuture, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated - public EntityTypeTagsProvider(DataGenerator p_126517_) { - super(p_126517_, Registry.f_122826_); + public EntityTypeTagsProvider(PackOutput p_256095_, CompletableFuture p_256572_) { ++ this(p_256095_, p_256572_, "vanilla", null); + } -+ public EntityTypeTagsProvider(DataGenerator p_126517_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_126517_, Registry.f_122826_, modId, existingFileHelper); ++ public EntityTypeTagsProvider(PackOutput p_256095_, CompletableFuture p_256572_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { + super(p_256095_, Registries.f_256939_, p_256572_, (p_256665_) -> { + return p_256665_.m_204041_().m_205785_(); +- }); ++ }, modId, existingFileHelper); } - protected void m_6577_() { + protected void m_6577_(HolderLookup.Provider p_255894_) { diff --git a/patches/minecraft/net/minecraft/data/tags/FlatLevelGeneratorPresetTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/FlatLevelGeneratorPresetTagsProvider.java.patch index 87da98d5fb..78e508b444 100644 --- a/patches/minecraft/net/minecraft/data/tags/FlatLevelGeneratorPresetTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/FlatLevelGeneratorPresetTagsProvider.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/data/tags/FlatLevelGeneratorPresetTagsProvider.java +++ b/net/minecraft/data/tags/FlatLevelGeneratorPresetTagsProvider.java -@@ -7,8 +_,13 @@ +@@ -9,8 +_,13 @@ import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorPresets; public class FlatLevelGeneratorPresetTagsProvider extends TagsProvider { -+ /** @deprecated Forge: Use the {@link #FlatLevelGeneratorPresetTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ ++ /** @deprecated Forge: Use the {@linkplain #FlatLevelGeneratorPresetTagsProvider(PackOutput, CompletableFuture, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated - public FlatLevelGeneratorPresetTagsProvider(DataGenerator p_236423_) { - super(p_236423_, BuiltinRegistries.f_235990_); + public FlatLevelGeneratorPresetTagsProvider(PackOutput p_256604_, CompletableFuture p_255962_) { + super(p_256604_, Registries.f_256724_, p_255962_); + } -+ public FlatLevelGeneratorPresetTagsProvider(DataGenerator p_236423_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_236423_, BuiltinRegistries.f_235990_, modId, existingFileHelper); ++ public FlatLevelGeneratorPresetTagsProvider(PackOutput p_256604_, CompletableFuture p_255962_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ super(p_256604_, Registries.f_256724_, p_255962_, modId, existingFileHelper); } - protected void m_6577_() { + protected void m_6577_(HolderLookup.Provider p_255741_) { diff --git a/patches/minecraft/net/minecraft/data/tags/FluidTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/FluidTagsProvider.java.patch index 9e10827c9b..f187d48538 100644 --- a/patches/minecraft/net/minecraft/data/tags/FluidTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/FluidTagsProvider.java.patch @@ -1,16 +1,19 @@ --- a/net/minecraft/data/tags/FluidTagsProvider.java +++ b/net/minecraft/data/tags/FluidTagsProvider.java -@@ -7,8 +_,13 @@ +@@ -9,10 +_,15 @@ import net.minecraft.world.level.material.Fluids; - public class FluidTagsProvider extends TagsProvider { -+ /** @deprecated Forge: Use the {@link #FluidTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + public class FluidTagsProvider extends IntrinsicHolderTagsProvider { ++ /** @deprecated Forge: Use the {@linkplain #FluidTagsProvider(PackOutput, CompletableFuture, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated - public FluidTagsProvider(DataGenerator p_126523_) { - super(p_126523_, Registry.f_122822_); + public FluidTagsProvider(PackOutput p_255941_, CompletableFuture p_256600_) { ++ this(p_255941_, p_256600_, "vanilla", null); + } -+ public FluidTagsProvider(DataGenerator p_126523_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_126523_, Registry.f_122822_, modId, existingFileHelper); ++ public FluidTagsProvider(PackOutput p_255941_, CompletableFuture p_256600_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { + super(p_255941_, Registries.f_256808_, p_256600_, (p_256474_) -> { + return p_256474_.m_205069_().m_205785_(); +- }); ++ }, modId, existingFileHelper); } - protected void m_6577_() { + protected void m_6577_(HolderLookup.Provider p_256366_) { diff --git a/patches/minecraft/net/minecraft/data/tags/GameEventTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/GameEventTagsProvider.java.patch index 61fa2f5b4b..905e5d52d1 100644 --- a/patches/minecraft/net/minecraft/data/tags/GameEventTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/GameEventTagsProvider.java.patch @@ -1,16 +1,19 @@ --- a/net/minecraft/data/tags/GameEventTagsProvider.java +++ b/net/minecraft/data/tags/GameEventTagsProvider.java -@@ -10,8 +_,13 @@ +@@ -12,10 +_,15 @@ @VisibleForTesting static final GameEvent[] f_236425_ = new GameEvent[]{GameEvent.f_157791_, GameEvent.f_157792_, GameEvent.f_157793_, GameEvent.f_157794_, GameEvent.f_157795_, GameEvent.f_157796_, GameEvent.f_157797_, GameEvent.f_223702_, GameEvent.f_223703_, GameEvent.f_157802_, GameEvent.f_157803_, GameEvent.f_157804_, GameEvent.f_223704_, GameEvent.f_157806_, GameEvent.f_223705_, GameEvent.f_223706_, GameEvent.f_223707_, GameEvent.f_223708_, GameEvent.f_157810_, GameEvent.f_223709_, GameEvent.f_223710_, GameEvent.f_157811_, GameEvent.f_157812_, GameEvent.f_157816_, GameEvent.f_157769_, GameEvent.f_157770_, GameEvent.f_223696_, GameEvent.f_223697_, GameEvent.f_157772_, GameEvent.f_223699_, GameEvent.f_157774_, GameEvent.f_157775_, GameEvent.f_157776_, GameEvent.f_157777_, GameEvent.f_157778_, GameEvent.f_157781_, GameEvent.f_157784_, GameEvent.f_157785_, GameEvent.f_157786_, GameEvent.f_238175_}; -+ /** @deprecated Forge: Use the {@link #GameEventTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ ++ /** @deprecated Forge: Use the {@linkplain #GameEventTagsProvider(PackOutput, CompletableFuture, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated - public GameEventTagsProvider(DataGenerator p_176826_) { - super(p_176826_, Registry.f_175412_); + public GameEventTagsProvider(PackOutput p_256060_, CompletableFuture p_255621_) { ++ this(p_256060_, p_255621_, "vanilla", null); + } -+ public GameEventTagsProvider(DataGenerator p_176826_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_176826_, Registry.f_175412_, modId, existingFileHelper); ++ public GameEventTagsProvider(PackOutput p_256060_, CompletableFuture p_255621_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { + super(p_256060_, Registries.f_256827_, p_255621_, (p_256368_) -> { + return p_256368_.m_204530_().m_205785_(); +- }); ++ }, modId, existingFileHelper); } - protected void m_6577_() { + protected void m_6577_(HolderLookup.Provider p_255981_) { diff --git a/patches/minecraft/net/minecraft/data/tags/InstrumentTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/InstrumentTagsProvider.java.patch index 605db63436..109a86e6f0 100644 --- a/patches/minecraft/net/minecraft/data/tags/InstrumentTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/InstrumentTagsProvider.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/data/tags/InstrumentTagsProvider.java +++ b/net/minecraft/data/tags/InstrumentTagsProvider.java -@@ -7,8 +_,13 @@ +@@ -9,8 +_,13 @@ import net.minecraft.world.item.Instruments; public class InstrumentTagsProvider extends TagsProvider { -+ /** @deprecated Forge: Use the {@link #InstrumentTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ ++ /** @deprecated Forge: Use the {@linkplain #InstrumentTagsProvider(PackOutput, CompletableFuture, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated - public InstrumentTagsProvider(DataGenerator p_236428_) { - super(p_236428_, Registry.f_235738_); + public InstrumentTagsProvider(PackOutput p_256418_, CompletableFuture p_256038_) { + super(p_256418_, Registries.f_257010_, p_256038_); + } -+ public InstrumentTagsProvider(DataGenerator p_236428_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_236428_, Registry.f_235738_, modId, existingFileHelper); ++ public InstrumentTagsProvider(PackOutput p_256418_, CompletableFuture p_256038_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ super(p_256418_, Registries.f_257010_, p_256038_, modId, existingFileHelper); } - protected void m_6577_() { + protected void m_6577_(HolderLookup.Provider p_256291_) { diff --git a/patches/minecraft/net/minecraft/data/tags/IntrinsicHolderTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/IntrinsicHolderTagsProvider.java.patch new file mode 100644 index 0000000000..9e9e4c0978 --- /dev/null +++ b/patches/minecraft/net/minecraft/data/tags/IntrinsicHolderTagsProvider.java.patch @@ -0,0 +1,48 @@ +--- a/net/minecraft/data/tags/IntrinsicHolderTagsProvider.java ++++ b/net/minecraft/data/tags/IntrinsicHolderTagsProvider.java +@@ -13,21 +_,28 @@ + public abstract class IntrinsicHolderTagsProvider extends TagsProvider { + private final Function> f_254687_; + ++ /** ++ * @deprecated Forge: Use the {@linkplain #IntrinsicHolderTagsProvider(PackOutput, ResourceKey, CompletableFuture, Function, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} ++ */ ++ @Deprecated + public IntrinsicHolderTagsProvider(PackOutput p_256164_, ResourceKey> p_256155_, CompletableFuture p_256488_, Function> p_256168_) { +- super(p_256164_, p_256155_, p_256488_); ++ this(p_256164_, p_256155_, p_256488_, p_256168_, "vanilla", null); ++ } ++ public IntrinsicHolderTagsProvider(PackOutput p_256164_, ResourceKey> p_256155_, CompletableFuture p_256488_, Function> p_256168_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ super(p_256164_, p_256155_, p_256488_, modId, existingFileHelper); + this.f_254687_ = p_256168_; + } + + protected IntrinsicHolderTagsProvider.IntrinsicTagAppender m_206424_(TagKey p_255730_) { + TagBuilder tagbuilder = this.m_236451_(p_255730_); +- return new IntrinsicHolderTagsProvider.IntrinsicTagAppender<>(tagbuilder, this.f_254687_); ++ return new IntrinsicHolderTagsProvider.IntrinsicTagAppender<>(tagbuilder, this.f_254687_, this.modId); + } + +- public static class IntrinsicTagAppender extends TagsProvider.TagAppender { ++ public static class IntrinsicTagAppender extends TagsProvider.TagAppender implements net.minecraftforge.common.extensions.IForgeIntrinsicHolderTagAppender { + private final Function> f_254707_; + +- IntrinsicTagAppender(TagBuilder p_256108_, Function> p_256433_) { +- super(p_256108_); ++ IntrinsicTagAppender(TagBuilder p_256108_, Function> p_256433_, String modId) { ++ super(p_256108_, modId); + this.f_254707_ = p_256433_; + } + +@@ -45,6 +_,11 @@ + public final IntrinsicHolderTagsProvider.IntrinsicTagAppender m_255179_(T... p_255868_) { + Stream.of(p_255868_).map(this.f_254707_).forEach(this::m_255204_); + return this; ++ } ++ ++ @Override ++ public final ResourceKey getKey(T value) { ++ return this.f_254707_.apply(value); + } + } + } diff --git a/patches/minecraft/net/minecraft/data/tags/ItemTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/ItemTagsProvider.java.patch index adb78f083a..56a97742cf 100644 --- a/patches/minecraft/net/minecraft/data/tags/ItemTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/ItemTagsProvider.java.patch @@ -1,17 +1,21 @@ --- a/net/minecraft/data/tags/ItemTagsProvider.java +++ b/net/minecraft/data/tags/ItemTagsProvider.java -@@ -14,8 +_,14 @@ - public class ItemTagsProvider extends TagsProvider { +@@ -13,10 +_,17 @@ + public abstract class ItemTagsProvider extends IntrinsicHolderTagsProvider { private final Function, TagBuilder> f_126528_; -+ /** @deprecated Forge: Use the {@link #ItemTagsProvider(DataGenerator, BlockTagsProvider, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ ++ /** ++ * @deprecated Forge: Use the {@link #ItemTagsProvider(PackOutput, CompletableFuture, TagsProvider, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} ++ */ + @Deprecated - public ItemTagsProvider(DataGenerator p_126530_, BlockTagsProvider p_126531_) { - super(p_126530_, Registry.f_122827_); -+ this.f_126528_ = p_126531_::m_236451_; + public ItemTagsProvider(PackOutput p_255871_, CompletableFuture p_256035_, TagsProvider p_256467_) { ++ this(p_255871_, p_256035_, p_256467_, "vanilla", null); + } -+ public ItemTagsProvider(DataGenerator p_126530_, BlockTagsProvider p_126531_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_126530_, Registry.f_122827_, modId, existingFileHelper); - this.f_126528_ = p_126531_::m_236451_; ++ public ItemTagsProvider(PackOutput p_255871_, CompletableFuture p_256035_, TagsProvider p_256467_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { + super(p_255871_, Registries.f_256913_, p_256035_, (p_255790_) -> { + return p_255790_.m_204114_().m_205785_(); +- }); ++ }, modId, existingFileHelper); + this.f_126528_ = p_256467_::m_236451_; } diff --git a/patches/minecraft/net/minecraft/data/tags/PaintingVariantTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/PaintingVariantTagsProvider.java.patch index 8aede94387..c46db8f6c6 100644 --- a/patches/minecraft/net/minecraft/data/tags/PaintingVariantTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/PaintingVariantTagsProvider.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/data/tags/PaintingVariantTagsProvider.java +++ b/net/minecraft/data/tags/PaintingVariantTagsProvider.java -@@ -7,8 +_,13 @@ +@@ -9,8 +_,13 @@ import net.minecraft.world.entity.decoration.PaintingVariants; public class PaintingVariantTagsProvider extends TagsProvider { -+ /** @deprecated Forge: Use the {@link #PaintingVariantTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ ++ /** @deprecated Forge: Use the {@linkplain #PaintingVariantTagsProvider(PackOutput, CompletableFuture, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated - public PaintingVariantTagsProvider(DataGenerator p_236431_) { - super(p_236431_, Registry.f_235728_); + public PaintingVariantTagsProvider(PackOutput p_255750_, CompletableFuture p_256184_) { + super(p_255750_, Registries.f_256836_, p_256184_); + } -+ public PaintingVariantTagsProvider(DataGenerator p_236431_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_236431_, Registry.f_235728_, modId, existingFileHelper); ++ public PaintingVariantTagsProvider(PackOutput p_255750_, CompletableFuture p_256184_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ super(p_255750_, Registries.f_256836_, p_256184_, modId, existingFileHelper); } - protected void m_6577_() { + protected void m_6577_(HolderLookup.Provider p_256017_) { diff --git a/patches/minecraft/net/minecraft/data/tags/PoiTypeTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/PoiTypeTagsProvider.java.patch index 6a8ab10310..5567e63d66 100644 --- a/patches/minecraft/net/minecraft/data/tags/PoiTypeTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/PoiTypeTagsProvider.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/data/tags/PoiTypeTagsProvider.java +++ b/net/minecraft/data/tags/PoiTypeTagsProvider.java -@@ -7,8 +_,13 @@ +@@ -9,8 +_,13 @@ import net.minecraft.world.entity.ai.village.poi.PoiTypes; public class PoiTypeTagsProvider extends TagsProvider { -+ /** @deprecated Forge: Use the {@link #PoiTypeTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ ++ /** @deprecated Forge: Use the {@linkplain #PoiTypeTagsProvider(PackOutput, CompletableFuture, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated - public PoiTypeTagsProvider(DataGenerator p_236434_) { - super(p_236434_, Registry.f_122870_); + public PoiTypeTagsProvider(PackOutput p_256012_, CompletableFuture p_256617_) { + super(p_256012_, Registries.f_256805_, p_256617_); + } -+ public PoiTypeTagsProvider(DataGenerator p_236434_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_236434_, Registry.f_122870_, modId, existingFileHelper); ++ public PoiTypeTagsProvider(PackOutput p_256012_, CompletableFuture p_256617_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ super(p_256012_, Registries.f_256805_, p_256617_, modId, existingFileHelper); } - protected void m_6577_() { + protected void m_6577_(HolderLookup.Provider p_256206_) { diff --git a/patches/minecraft/net/minecraft/data/tags/StructureTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/StructureTagsProvider.java.patch index dff50b28d4..eb26982c29 100644 --- a/patches/minecraft/net/minecraft/data/tags/StructureTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/StructureTagsProvider.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/data/tags/StructureTagsProvider.java +++ b/net/minecraft/data/tags/StructureTagsProvider.java -@@ -7,8 +_,13 @@ +@@ -9,8 +_,13 @@ import net.minecraft.world.level.levelgen.structure.Structure; public class StructureTagsProvider extends TagsProvider { -+ /** @deprecated Forge: Use the {@link #StructureTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ ++ /** @deprecated Forge: Use the {@linkplain #StructureTagsProvider(PackOutput, CompletableFuture, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated - public StructureTagsProvider(DataGenerator p_236437_) { - super(p_236437_, BuiltinRegistries.f_235988_); + public StructureTagsProvider(PackOutput p_256522_, CompletableFuture p_256661_) { + super(p_256522_, Registries.f_256944_, p_256661_); + } -+ public StructureTagsProvider(DataGenerator p_236437_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_236437_, BuiltinRegistries.f_235988_, modId, existingFileHelper); ++ public StructureTagsProvider(PackOutput p_256522_, CompletableFuture p_256661_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ super(p_256522_, Registries.f_256944_, p_256661_, modId, existingFileHelper); } - protected void m_6577_() { + protected void m_6577_(HolderLookup.Provider p_256087_) { diff --git a/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch index 507963e6f9..3cb0af8b55 100644 --- a/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch @@ -1,55 +1,76 @@ --- a/net/minecraft/data/tags/TagsProvider.java +++ b/net/minecraft/data/tags/TagsProvider.java -@@ -30,10 +_,32 @@ - protected final DataGenerator.PathProvider f_236439_; - protected final Registry f_126540_; +@@ -32,15 +_,37 @@ + protected final CompletableFuture f_254646_; + protected final ResourceKey> f_254716_; protected final Map f_126543_ = Maps.newLinkedHashMap(); + protected final String modId; ++ @org.jetbrains.annotations.Nullable + protected final net.minecraftforge.common.data.ExistingFileHelper existingFileHelper; + private final net.minecraftforge.common.data.ExistingFileHelper.IResourceType resourceType; + private final net.minecraftforge.common.data.ExistingFileHelper.IResourceType elementResourceType; // FORGE: Resource type for validating required references to datapack registry elements. + /** -+ * @see #TagsProvider(DataGenerator, Registry, String, net.minecraftforge.common.data.ExistingFileHelper) -+ * @deprecated Forge: Use the mod id variant ++ * @deprecated Forge: Use the {@linkplain #TagsProvider(PackOutput, ResourceKey, CompletableFuture, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} + */ + @Deprecated - protected TagsProvider(DataGenerator p_126546_, Registry p_126547_) { -+ this(p_126546_, p_126547_, "vanilla", null); + protected TagsProvider(PackOutput p_256596_, ResourceKey> p_255886_, CompletableFuture p_256513_) { ++ this(p_256596_, p_255886_, p_256513_, "vanilla", null); + } -+ protected TagsProvider(DataGenerator p_126546_, Registry p_126547_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { - this.f_236439_ = p_126546_.m_236036_(DataGenerator.Target.DATA_PACK, TagManager.m_203918_(p_126547_.m_123023_())); - this.f_126540_ = p_126547_; ++ protected TagsProvider(PackOutput p_256596_, ResourceKey> p_255886_, CompletableFuture p_256513_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { + this.f_236439_ = p_256596_.m_245269_(PackOutput.Target.DATA_PACK, TagManager.m_203918_(p_255886_)); + this.f_254646_ = p_256513_; + this.f_254716_ = p_255886_; + this.modId = modId; + this.existingFileHelper = existingFileHelper; -+ this.resourceType = new net.minecraftforge.common.data.ExistingFileHelper.ResourceType(net.minecraft.server.packs.PackType.SERVER_DATA, ".json", TagManager.m_203918_(p_126547_.m_123023_())); -+ this.elementResourceType = new net.minecraftforge.common.data.ExistingFileHelper.ResourceType(net.minecraft.server.packs.PackType.SERVER_DATA, ".json", net.minecraftforge.common.ForgeHooks.prefixNamespace(p_126547_.m_123023_().m_135782_())); ++ this.resourceType = new net.minecraftforge.common.data.ExistingFileHelper.ResourceType(net.minecraft.server.packs.PackType.SERVER_DATA, ".json", TagManager.m_203918_(p_255886_)); ++ this.elementResourceType = new net.minecraftforge.common.data.ExistingFileHelper.ResourceType(net.minecraft.server.packs.PackType.SERVER_DATA, ".json", net.minecraftforge.common.ForgeHooks.prefixNamespace(p_255886_.m_135782_())); + } + + // Forge: Allow customizing the path for a given tag or returning null + @org.jetbrains.annotations.Nullable + protected Path getPath(ResourceLocation id) { -+ return this.f_236439_.m_236048_(id); ++ return this.f_236439_.m_245731_(id); } public String m_6055_() { -@@ -49,12 +_,13 @@ - List list = p_236450_.m_215904_(); - List list1 = list.stream().filter((p_236444_) -> { - return !p_236444_.m_215940_(this.f_126540_::m_7804_, this.f_126543_::containsKey); -- }).toList(); -+ }).filter(this::missing).collect(Collectors.toList()); // Forge: Add validation via existing resources - if (!list1.isEmpty()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Couldn't define tag %s as it is missing following references: %s", p_236449_, list1.stream().map(Objects::toString).collect(Collectors.joining(",")))); - } else { - JsonElement jsonelement = TagFile.f_215958_.encodeStart(JsonOps.INSTANCE, new TagFile(list, false)).getOrThrow(false, f_126541_::error); -- Path path = this.f_236439_.m_236048_(p_236449_); -+ Path path = this.getPath(p_236449_); -+ if (path == null) return; // Forge: Allow running this data provider without writing it. Recipe provider needs valid tags. +- return "Tags for " + this.f_254716_.m_135782_(); ++ return "Tags for " + this.f_254716_.m_135782_() + " mod id " + this.modId; + } - try { - DataProvider.m_236072_(p_236446_, jsonelement, path); -@@ -66,24 +_,36 @@ + protected abstract void m_6577_(HolderLookup.Provider p_256380_); +@@ -49,7 +_,13 @@ + return this.f_254646_.thenCompose((p_255494_) -> { + this.f_126543_.clear(); + this.m_6577_(p_255494_); +- HolderLookup.RegistryLookup registrylookup = p_255494_.m_255025_(this.f_254716_); ++ HolderLookup.RegistryLookup registrylookup = p_255494_.m_254861_(this.f_254716_).orElseThrow(() -> { ++ // FORGE: Throw a more descriptive error message if this is a Forge registry without tags enabled ++ if (net.minecraftforge.registries.RegistryManager.ACTIVE.getRegistry(this.f_254716_) != null) { ++ return new IllegalStateException("Forge registry " + this.f_254716_.m_135782_() + " does not have support for tags"); ++ } ++ return new IllegalStateException("Registry " + this.f_254716_.m_135782_() + " not found"); ++ }); + Predicate predicate = (p_255496_) -> { + return registrylookup.m_254902_(ResourceKey.m_135785_(this.f_254716_, p_255496_)).isPresent(); + }; +@@ -59,12 +_,13 @@ + List list = tagbuilder.m_215904_(); + List list1 = list.stream().filter((p_255492_) -> { + return !p_255492_.m_215940_(predicate, this.f_126543_::containsKey); +- }).toList(); ++ }).filter(this::missing).toList(); // Forge: Add validation via existing resources + if (!list1.isEmpty()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Couldn't define tag %s as it is missing following references: %s", resourcelocation, list1.stream().map(Objects::toString).collect(Collectors.joining(",")))); + } else { + JsonElement jsonelement = TagFile.f_215958_.encodeStart(JsonOps.INSTANCE, new TagFile(list, false)).getOrThrow(false, f_126541_::error); +- Path path = this.f_236439_.m_245731_(resourcelocation); ++ Path path = this.getPath(resourcelocation); ++ if (path == null) return CompletableFuture.completedFuture(null); // Forge: Allow running this data provider without writing it. Recipe provider needs valid tags. + return DataProvider.m_253162_(p_253684_, jsonelement, path); + } + }).toArray((p_253442_) -> { +@@ -73,22 +_,34 @@ }); } @@ -64,8 +85,8 @@ + protected TagsProvider.TagAppender m_206424_(TagKey p_206425_) { TagBuilder tagbuilder = this.m_236451_(p_206425_); -- return new TagsProvider.TagAppender<>(tagbuilder, this.f_126540_); -+ return new TagsProvider.TagAppender<>(tagbuilder, this.f_126540_, modId); +- return new TagsProvider.TagAppender<>(tagbuilder); ++ return new TagsProvider.TagAppender<>(tagbuilder, modId); } protected TagBuilder m_236451_(TagKey p_236452_) { @@ -75,23 +96,22 @@ }); } -- protected static class TagAppender { +- public static class TagAppender { + public static class TagAppender implements net.minecraftforge.common.extensions.IForgeTagAppender { private final TagBuilder f_126568_; - public final Registry f_126569_; + private final String modId; -- TagAppender(TagBuilder p_236454_, Registry p_236455_) { -+ TagAppender(TagBuilder p_236454_, Registry p_236455_, String modId) { - this.f_126568_ = p_236454_; - this.f_126569_ = p_236455_; +- protected TagAppender(TagBuilder p_256426_) { +- this.f_126568_ = p_256426_; ++ protected TagAppender(TagBuilder p_236454_, String modId) { ++ this.f_126568_ = p_236454_; + this.modId = modId; } - public TagsProvider.TagAppender m_126582_(T p_126583_) { -@@ -121,6 +_,19 @@ - this.f_126568_.m_215900_(p_126587_); - }); + public final TagsProvider.TagAppender m_255204_(ResourceKey p_256138_) { +@@ -118,6 +_,19 @@ + public TagsProvider.TagAppender m_176841_(ResourceLocation p_176842_) { + this.f_126568_.m_215909_(p_176842_); return this; + } + diff --git a/patches/minecraft/net/minecraft/data/tags/WorldPresetTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/WorldPresetTagsProvider.java.patch index 370e54ebad..30c4f0e41a 100644 --- a/patches/minecraft/net/minecraft/data/tags/WorldPresetTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/WorldPresetTagsProvider.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/data/tags/WorldPresetTagsProvider.java +++ b/net/minecraft/data/tags/WorldPresetTagsProvider.java -@@ -7,8 +_,13 @@ +@@ -9,8 +_,13 @@ import net.minecraft.world.level.levelgen.presets.WorldPresets; public class WorldPresetTagsProvider extends TagsProvider { -+ /** @deprecated Forge: Use the {@link #WorldPresetTagsProvider(DataGenerator, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ ++ /** @deprecated Forge: Use the {@linkplain #WorldPresetTagsProvider(PackOutput, CompletableFuture, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated - public WorldPresetTagsProvider(DataGenerator p_236457_) { - super(p_236457_, BuiltinRegistries.f_235989_); + public WorldPresetTagsProvider(PackOutput p_255701_, CompletableFuture p_255974_) { + super(p_255701_, Registries.f_256729_, p_255974_); + } -+ public WorldPresetTagsProvider(DataGenerator p_236457_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_236457_, BuiltinRegistries.f_235989_, modId, existingFileHelper); ++ public WorldPresetTagsProvider(PackOutput p_255701_, CompletableFuture p_255974_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { ++ super(p_255701_, Registries.f_256729_, p_255974_, modId, existingFileHelper); } - protected void m_6577_() { + protected void m_6577_(HolderLookup.Provider p_255734_) { diff --git a/patches/minecraft/net/minecraft/data/worldgen/biome/OverworldBiomes.java.patch b/patches/minecraft/net/minecraft/data/worldgen/biome/OverworldBiomes.java.patch index 64af395f46..85b7549a5e 100644 --- a/patches/minecraft/net/minecraft/data/worldgen/biome/OverworldBiomes.java.patch +++ b/patches/minecraft/net/minecraft/data/worldgen/biome/OverworldBiomes.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/data/worldgen/biome/OverworldBiomes.java +++ b/net/minecraft/data/worldgen/biome/OverworldBiomes.java -@@ -20,6 +_,8 @@ - import net.minecraft.world.level.levelgen.GenerationStep; +@@ -23,6 +_,8 @@ + import net.minecraft.world.level.levelgen.placement.PlacedFeature; public class OverworldBiomes { + // TODO: getAdditionalOverworldBiomes, likely in this class. -C diff --git a/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch b/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch index 55663bf967..97aead4c2b 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/gametest/framework/GameTestServer.java +++ b/net/minecraft/gametest/framework/GameTestServer.java -@@ -98,13 +_,14 @@ +@@ -105,13 +_,14 @@ public boolean m_7038_() { - this.m_129823_(new PlayerList(this, this.m_206579_(), this.f_129745_, 1) { + this.m_129823_(new PlayerList(this, this.m_247573_(), this.f_129745_, 1) { }); + if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; this.m_130006_(); diff --git a/patches/minecraft/net/minecraft/gametest/framework/StructureUtils.java.patch b/patches/minecraft/net/minecraft/gametest/framework/StructureUtils.java.patch index e56e9fde1b..4acfa7c4dd 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/StructureUtils.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/StructureUtils.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/StructureUtils.java +++ b/net/minecraft/gametest/framework/StructureUtils.java -@@ -238,7 +_,7 @@ +@@ -239,7 +_,7 @@ if (optional.isPresent()) { return optional.get(); } else { diff --git a/patches/minecraft/net/minecraft/locale/Language.java.patch b/patches/minecraft/net/minecraft/locale/Language.java.patch index c9bfbcf458..5aa36be141 100644 --- a/patches/minecraft/net/minecraft/locale/Language.java.patch +++ b/patches/minecraft/net/minecraft/locale/Language.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/locale/Language.java +++ b/net/minecraft/locale/Language.java -@@ -59,7 +_,8 @@ +@@ -41,7 +_,8 @@ f_128101_.error("Couldn't read strings from {}", "/assets/minecraft/lang/en_us.json", ioexception); } @@ -10,7 +10,7 @@ return new Language() { public String m_6834_(String p_128127_) { return map.getOrDefault(p_128127_, p_128127_); -@@ -80,6 +_,11 @@ +@@ -62,6 +_,11 @@ }, Style.f_131099_).isPresent(); }; } @@ -22,7 +22,7 @@ }; } -@@ -100,6 +_,9 @@ +@@ -82,6 +_,9 @@ public static void m_128114_(Language p_128115_) { f_128104_ = p_128115_; } diff --git a/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch b/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch index ce960ab5bb..a1da8d3250 100644 --- a/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch +++ b/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch @@ -3,12 +3,12 @@ @@ -39,6 +_,7 @@ while((b0 = CompoundTag.m_128420_(p_128485_, p_128487_)) != 0) { String s = CompoundTag.m_128432_(p_128485_, p_128487_); - p_128487_.m_6800_((long)(224 + 16 * s.length())); -+ p_128487_.m_6800_(32); //Forge: 4 extra bytes for the object allocation. + p_128487_.m_128926_((long)(28 + 2 * s.length())); ++ p_128487_.m_128926_(4); //Forge: 4 extra bytes for the object allocation. Tag tag = CompoundTag.m_128413_(TagTypes.m_129397_(b0), s, p_128485_, p_128486_ + 1, p_128487_); - if (map.put(s, tag) != null) { - p_128487_.m_6800_(288L); -@@ -153,6 +_,7 @@ + if (map.put(s, tag) == null) { + p_128487_.m_128926_(36L); +@@ -165,6 +_,7 @@ @Nullable public Tag m_128365_(String p_128366_, Tag p_128367_) { @@ -16,11 +16,11 @@ return this.f_128329_.put(p_128366_, p_128367_); } -@@ -445,11 +_,12 @@ +@@ -457,11 +_,12 @@ } static byte m_128420_(DataInput p_128421_, NbtAccounter p_128422_) throws IOException { -+ p_128422_.m_6800_(8); ++ p_128422_.m_128926_(2); return p_128421_.readByte(); } diff --git a/patches/minecraft/net/minecraft/nbt/NbtAccounter.java.patch b/patches/minecraft/net/minecraft/nbt/NbtAccounter.java.patch index 8f9fd462f1..3f2d145e16 100644 --- a/patches/minecraft/net/minecraft/nbt/NbtAccounter.java.patch +++ b/patches/minecraft/net/minecraft/nbt/NbtAccounter.java.patch @@ -1,10 +1,9 @@ --- a/net/minecraft/nbt/NbtAccounter.java +++ b/net/minecraft/nbt/NbtAccounter.java -@@ -18,4 +_,34 @@ - throw new RuntimeException("Tried to read NBT tag that was too big; tried to allocate: " + this.f_128919_ + "bytes where max allowed: " + this.f_128918_); +@@ -21,6 +_,36 @@ } } -+ + + /* + * UTF8 is not a simple encoding system, each character can be either + * 1, 2, or 3 bytes. Depending on where it's numerical value falls. @@ -17,7 +16,7 @@ + * This will accurately count the correct byte length to encode this string, plus the 2 bytes for it's length prefix. + */ + public String readUTF(String data) { -+ m_6800_(16); //Header length ++ m_128926_(2); //Header length + if (data == null) + return data; + @@ -30,8 +29,11 @@ + else if (c > 0x07FF) utflen += 3; + else utflen += 2; + } -+ m_6800_(8 * utflen); ++ m_128926_(utflen); + + return data; + } - } ++ + @VisibleForTesting + public long m_263225_() { + return this.f_128919_; diff --git a/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch b/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch index 9dd2128154..524b9e04dc 100644 --- a/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch +++ b/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/nbt/NbtIo.java +++ b/net/minecraft/nbt/NbtIo.java -@@ -268,10 +_,12 @@ +@@ -148,10 +_,12 @@ private static Tag m_128930_(DataInput p_128931_, int p_128932_, NbtAccounter p_128933_) throws IOException { byte b0 = p_128931_.readByte(); -+ p_128933_.m_6800_(8); // Forge: Count everything! ++ p_128933_.m_128926_(1); // Forge: Count everything! if (b0 == 0) { return EndTag.f_128534_; } else { - StringTag.m_197563_(p_128931_); + p_128933_.readUTF(p_128931_.readUTF()); //Forge: Count this string. -+ p_128933_.m_6800_(32); //Forge: 4 extra bytes for the object allocation. ++ p_128933_.m_128926_(4); //Forge: 4 extra bytes for the object allocation. try { return TagTypes.m_129397_(b0).m_7300_(p_128931_, p_128932_, p_128933_); diff --git a/patches/minecraft/net/minecraft/nbt/StringTag.java.patch b/patches/minecraft/net/minecraft/nbt/StringTag.java.patch index c09cde6752..7a76b7cbdd 100644 --- a/patches/minecraft/net/minecraft/nbt/StringTag.java.patch +++ b/patches/minecraft/net/minecraft/nbt/StringTag.java.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/nbt/StringTag.java @@ -13,7 +_,7 @@ public StringTag m_7300_(DataInput p_129315_, int p_129316_, NbtAccounter p_129317_) throws IOException { - p_129317_.m_6800_(288L); + p_129317_.m_128926_(36L); String s = p_129315_.readUTF(); -- p_129317_.m_6800_((long)(16 * s.length())); +- p_129317_.m_128926_((long)(2 * s.length())); + p_129317_.readUTF(s); return StringTag.m_129297_(s); } diff --git a/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch b/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch index bad0df39ad..f0f9b37553 100644 --- a/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch +++ b/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/FriendlyByteBuf.java +++ b/net/minecraft/network/FriendlyByteBuf.java -@@ -65,7 +_,7 @@ +@@ -71,7 +_,7 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; @@ -8,8 +8,8 @@ +public class FriendlyByteBuf extends ByteBuf implements net.minecraftforge.common.extensions.IForgeFriendlyByteBuf { private static final int f_178335_ = 5; private static final int f_178336_ = 10; - private static final int f_178337_ = 2097152; -@@ -517,6 +_,15 @@ + public static final int f_178337_ = 2097152; +@@ -578,6 +_,15 @@ } public FriendlyByteBuf m_130055_(ItemStack p_130056_) { @@ -25,8 +25,8 @@ if (p_130056_.m_41619_()) { this.writeBoolean(false); } else { -@@ -525,8 +_,8 @@ - this.m_236818_(Registry.f_122827_, item); +@@ -586,8 +_,8 @@ + this.m_236818_(BuiltInRegistries.f_257033_, item); this.writeByte(p_130056_.m_41613_()); CompoundTag compoundtag = null; - if (item.m_41465_() || item.m_41468_()) { @@ -36,8 +36,8 @@ } this.m_130079_(compoundtag); -@@ -542,7 +_,7 @@ - Item item = this.m_236816_(Registry.f_122827_); +@@ -603,7 +_,7 @@ + Item item = this.m_236816_(BuiltInRegistries.f_257033_); int i = this.readByte(); ItemStack itemstack = new ItemStack(item, i); - itemstack.m_41751_(this.m_130260_()); diff --git a/patches/minecraft/net/minecraft/network/chat/contents/TranslatableContents.java.patch b/patches/minecraft/net/minecraft/network/chat/contents/TranslatableContents.java.patch index a68df172e4..b52ad45486 100644 --- a/patches/minecraft/net/minecraft/network/chat/contents/TranslatableContents.java.patch +++ b/patches/minecraft/net/minecraft/network/chat/contents/TranslatableContents.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/contents/TranslatableContents.java +++ b/net/minecraft/network/chat/contents/TranslatableContents.java -@@ -94,6 +_,11 @@ +@@ -92,6 +_,11 @@ } } diff --git a/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch b/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch index 8f0c04cfa0..9810c89a13 100644 --- a/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/network/protocol/status/ServerStatus.java +++ b/net/minecraft/network/protocol/status/ServerStatus.java -@@ -28,6 +_,17 @@ +@@ -27,6 +_,17 @@ + @Nullable private String f_134903_; - private boolean f_238077_; private boolean f_242955_; + private transient net.minecraftforge.network.ServerStatusPing forgeData; + @@ -18,7 +18,7 @@ @Nullable public Component m_134905_() { -@@ -36,6 +_,7 @@ +@@ -35,6 +_,7 @@ public void m_134908_(Component p_134909_) { this.f_134900_ = p_134909_; @@ -26,7 +26,7 @@ } @Nullable -@@ -45,6 +_,7 @@ +@@ -44,6 +_,7 @@ public void m_134910_(ServerStatus.Players p_134911_) { this.f_134901_ = p_134911_; @@ -34,7 +34,7 @@ } @Nullable -@@ -54,10 +_,12 @@ +@@ -53,10 +_,12 @@ public void m_134912_(ServerStatus.Version p_134913_) { this.f_134902_ = p_134913_; @@ -47,15 +47,7 @@ } @Nullable -@@ -67,6 +_,7 @@ - - public void m_238078_(boolean p_238079_) { - this.f_238077_ = p_238079_; -+ invalidateJson(); - } - - public boolean m_238080_() { -@@ -75,12 +_,46 @@ +@@ -66,12 +_,46 @@ public void m_242958_(boolean p_242968_) { this.f_242955_ = p_242968_; @@ -102,7 +94,7 @@ public static class Players { private final int f_134917_; private final int f_134918_; -@@ -183,6 +_,10 @@ +@@ -170,6 +_,10 @@ serverstatus.m_242958_(GsonHelper.m_13912_(jsonobject, "enforcesSecureChat")); } @@ -113,7 +105,7 @@ return serverstatus; } -@@ -204,6 +_,10 @@ +@@ -190,6 +_,10 @@ if (p_134951_.m_134916_() != null) { jsonobject.addProperty("favicon", p_134951_.m_134916_()); diff --git a/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch b/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch index 39315237d9..8d987e4a42 100644 --- a/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch +++ b/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/network/syncher/EntityDataSerializers.java +++ b/net/minecraft/network/syncher/EntityDataSerializers.java -@@ -134,16 +_,16 @@ - public static final EntityDataSerializer> f_238116_ = EntityDataSerializer.m_238081_(Registry.f_235728_.m_206115_()); +@@ -135,16 +_,16 @@ + public static final EntityDataSerializer> f_238116_ = EntityDataSerializer.m_238081_(BuiltInRegistries.f_257051_.m_206115_()); public static void m_135050_(EntityDataSerializer p_135051_) { - f_135046_.m_13569_(p_135051_); diff --git a/patches/minecraft/net/minecraft/network/syncher/SynchedEntityData.java.patch b/patches/minecraft/net/minecraft/network/syncher/SynchedEntityData.java.patch index aeb50c2f12..bb12886083 100644 --- a/patches/minecraft/net/minecraft/network/syncher/SynchedEntityData.java.patch +++ b/patches/minecraft/net/minecraft/network/syncher/SynchedEntityData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/syncher/SynchedEntityData.java +++ b/net/minecraft/network/syncher/SynchedEntityData.java -@@ -38,11 +_,13 @@ +@@ -36,11 +_,13 @@ } public static EntityDataAccessor m_135353_(Class p_135354_, EntityDataSerializer p_135355_) { diff --git a/patches/minecraft/net/minecraft/resources/HolderSetCodec.java.patch b/patches/minecraft/net/minecraft/resources/HolderSetCodec.java.patch index 9eb0cf6812..ea3f13b0d0 100644 --- a/patches/minecraft/net/minecraft/resources/HolderSetCodec.java.patch +++ b/patches/minecraft/net/minecraft/resources/HolderSetCodec.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/resources/HolderSetCodec.java +++ b/net/minecraft/resources/HolderSetCodec.java -@@ -20,6 +_,8 @@ +@@ -22,6 +_,8 @@ private final Codec> f_206656_; private final Codec>> f_206657_; private final Codec, List>>> f_206658_; @@ -9,7 +9,7 @@ private static Codec>> m_206667_(Codec> p_206668_, boolean p_206669_) { Function>, DataResult>>> function = ExtraCodecs.m_203984_(Holder::m_203376_); -@@ -42,6 +_,10 @@ +@@ -44,6 +_,10 @@ this.f_206656_ = p_206661_; this.f_206657_ = m_206667_(p_206661_, p_206662_); this.f_206658_ = Codec.either(TagKey.m_203886_(p_206660_), this.f_206657_); @@ -20,20 +20,20 @@ } public DataResult, T>> decode(DynamicOps p_206696_, T p_206697_) { -@@ -49,9 +_,10 @@ - Optional> optional = registryops.m_206826_(this.f_206655_); +@@ -51,9 +_,10 @@ + Optional> optional = registryops.m_255006_(this.f_206655_); if (optional.isPresent()) { - Registry registry = optional.get(); + HolderGetter holdergetter = optional.get(); - return this.f_206658_.decode(p_206696_, p_206697_).map((p_206682_) -> { + // FORGE: use the wrapped codec to decode custom/tag/list instead of just tag/list + return this.combinedCodec.decode(p_206696_, p_206697_).map((p_206682_) -> { return p_206682_.mapFirst((p_206679_) -> { -- return p_206679_.map(registry::m_203561_, HolderSet::m_205800_); -+ return p_206679_.map(java.util.function.Function.identity(), tagOrList -> tagOrList.map(registry::m_203561_, HolderSet::m_205800_)); +- return p_206679_.map(holdergetter::m_254956_, HolderSet::m_205800_); ++ return p_206679_.map(java.util.function.Function.identity(), tagOrList -> tagOrList.map(holdergetter::m_254956_, HolderSet::m_205800_)); }); }); } -@@ -68,6 +_,9 @@ +@@ -70,6 +_,9 @@ return DataResult.error("HolderSet " + p_206674_ + " is not valid in current registry set"); } diff --git a/patches/minecraft/net/minecraft/resources/RegistryDataLoader.java.patch b/patches/minecraft/net/minecraft/resources/RegistryDataLoader.java.patch new file mode 100644 index 0000000000..e2295f1a2e --- /dev/null +++ b/patches/minecraft/net/minecraft/resources/RegistryDataLoader.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/resources/RegistryDataLoader.java ++++ b/net/minecraft/resources/RegistryDataLoader.java +@@ -119,7 +_,7 @@ + } + + private static String m_246502_(ResourceLocation p_252033_) { +- return p_252033_.m_135815_(); ++ return net.minecraftforge.common.ForgeHooks.prefixNamespace(p_252033_); // FORGE: add non-vanilla registry namespace to loader directory, same format as tag directory (see net.minecraft.tags.TagManager#getTagDir(ResourceKey)) + } + + static void m_255048_(RegistryOps.RegistryInfoLookup p_256369_, ResourceManager p_256349_, ResourceKey> p_255792_, WritableRegistry p_256211_, Decoder p_256232_, Map, Exception> p_255884_) { +@@ -138,6 +_,7 @@ + DataResult dataresult = p_256232_.parse(registryops, jsonelement); + E e = dataresult.getOrThrow(false, (p_248715_) -> { + }); ++ if (net.minecraftforge.common.crafting.conditions.ICondition.shouldRegisterEntry(jsonelement)) + p_256211_.m_255290_(resourcekey, e, resource.m_247137_() ? Lifecycle.stable() : dataresult.lifecycle()); + } + diff --git a/patches/minecraft/net/minecraft/resources/RegistryLoader.java.patch b/patches/minecraft/net/minecraft/resources/RegistryLoader.java.patch deleted file mode 100644 index 521f1b0cc5..0000000000 --- a/patches/minecraft/net/minecraft/resources/RegistryLoader.java.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- a/net/minecraft/resources/RegistryLoader.java -+++ b/net/minecraft/resources/RegistryLoader.java -@@ -26,7 +_,7 @@ - Map, RegistryResourceAccess.EntryThunk> map = this.f_206750_.m_214030_(p_206764_); - DataResult> dataresult = DataResult.success(p_206763_, Lifecycle.stable()); - -- for(Map.Entry, RegistryResourceAccess.EntryThunk> entry : map.entrySet()) { -+ for(Map.Entry, RegistryResourceAccess.EntryThunk> entry : net.minecraftforge.common.ForgeHooks.filterThunks(map)) { - dataresult = dataresult.flatMap((p_214227_) -> { - return this.m_214228_(p_214227_, p_206764_, p_206765_, entry.getKey(), Optional.of(entry.getValue()), p_206766_).map((p_206761_) -> { - return p_214227_; -@@ -48,7 +_,12 @@ - if (dataresult != null) { - return dataresult; - } else { -- Holder holder = p_214229_.m_214121_(p_214232_); -+ // Prevents an exception from disrupting codec decoding when calling this with prematurely frozen registries - see comment in LevelStorageSource -+ DataResult> maybeHolder = p_214229_.m_214185_(p_214232_); -+ if (maybeHolder.error().isPresent()) { -+ return maybeHolder; -+ } -+ Holder holder = maybeHolder.result().get(); - readcache.f_206803_.put(p_214232_, DataResult.success(holder)); - DataResult> dataresult1; - if (p_214233_.isEmpty()) { diff --git a/patches/minecraft/net/minecraft/resources/RegistryOps.java.patch b/patches/minecraft/net/minecraft/resources/RegistryOps.java.patch new file mode 100644 index 0000000000..5d1e7b26f5 --- /dev/null +++ b/patches/minecraft/net/minecraft/resources/RegistryOps.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/resources/RegistryOps.java ++++ b/net/minecraft/resources/RegistryOps.java +@@ -70,6 +_,20 @@ + }); + } + ++ public static com.mojang.serialization.MapCodec> retrieveRegistryLookup(ResourceKey> resourceKey) { ++ return ExtraCodecs.m_203976_(ops -> { ++ if (!(ops instanceof RegistryOps registryOps)) ++ return DataResult.error("Not a registry ops"); ++ ++ return registryOps.f_254668_.m_254838_(resourceKey).map(registryInfo -> { ++ if (!(registryInfo.f_254724_() instanceof HolderLookup.RegistryLookup registryLookup)) ++ return DataResult.>error("Found holder getter but was not a registry lookup for " + resourceKey); ++ ++ return DataResult.success(registryLookup, registryInfo.f_254751_()); ++ }).orElseGet(() -> DataResult.error("Unknown registry: " + resourceKey)); ++ }); ++ } ++ + public static RecordCodecBuilder> m_254866_(ResourceKey p_256347_) { + ResourceKey> resourcekey = ResourceKey.m_135788_(p_256347_.m_211136_()); + return ExtraCodecs.m_203976_((p_255521_) -> { diff --git a/patches/minecraft/net/minecraft/resources/RegistryResourceAccess.java.patch b/patches/minecraft/net/minecraft/resources/RegistryResourceAccess.java.patch deleted file mode 100644 index b88c6ecbf4..0000000000 --- a/patches/minecraft/net/minecraft/resources/RegistryResourceAccess.java.patch +++ /dev/null @@ -1,37 +0,0 @@ ---- a/net/minecraft/resources/RegistryResourceAccess.java -+++ b/net/minecraft/resources/RegistryResourceAccess.java -@@ -47,7 +_,7 @@ - - DataResult dataresult; - try { -- dataresult = this.m_214249_(p_214266_, p_214267_, reader); -+ dataresult = this.decodeElement(p_214266_, p_214267_, reader, p_214238_); - } catch (Throwable throwable1) { - if (reader != null) { - try { -@@ -82,7 +_,7 @@ - - DataResult dataresult; - try { -- dataresult = this.m_214249_(p_214247_, p_214248_, reader); -+ dataresult = this.decodeElement(p_214247_, p_214248_, reader, p_214260_); - } catch (Throwable throwable1) { - if (reader != null) { - try { -@@ -107,13 +_,14 @@ - }); - } - -- private DataResult> m_214249_(DynamicOps p_214250_, Decoder p_214251_, Reader p_214252_) throws IOException { -+ private DataResult> decodeElement(DynamicOps p_214250_, Decoder p_214251_, Reader p_214252_, ResourceKey key) throws IOException { - JsonElement jsonelement = JsonParser.parseReader(p_214252_); -+ if (jsonelement != null) jsonelement.getAsJsonObject().addProperty("forge:registry_name", key.m_135782_().toString()); - return p_214251_.parse(p_214250_, jsonelement).map(RegistryResourceAccess.ParsedEntry::m_195956_); - } - - private static String m_214239_(ResourceLocation p_214240_) { -- return p_214240_.m_135815_(); -+ return net.minecraftforge.common.ForgeHooks.prefixNamespace(p_214240_); // FORGE: add non-vanilla registry namespace to loader directory, same format as tag directory (see net.minecraft.tags.TagManager#getTagDir(ResourceKey)) - } - - private static ResourceLocation m_214268_(ResourceKey p_214269_) { diff --git a/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch b/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch index c3f0e5684c..47b8810fb2 100644 --- a/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch +++ b/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/resources/ResourceKey.java +++ b/net/minecraft/resources/ResourceKey.java @@ -7,7 +_,7 @@ - import java.util.Optional; import net.minecraft.core.Registry; + import net.minecraft.core.registries.BuiltInRegistries; -public class ResourceKey { +public class ResourceKey implements Comparable> { - private static final Map> f_135775_ = Collections.synchronizedMap(Maps.newIdentityHashMap()); + private static final ConcurrentMap> f_135775_ = (new MapMaker()).weakValues().makeMap(); private final ResourceLocation f_135776_; private final ResourceLocation f_135777_; -@@ -56,5 +_,18 @@ +@@ -55,6 +_,19 @@ public ResourceLocation m_211136_() { return this.f_135776_; @@ -27,4 +27,5 @@ + if (ret == 0) ret = this.m_135782_().compareTo(o.m_135782_()); + return ret; } - } + + static record InternKey(ResourceLocation f_256880_, ResourceLocation f_257046_) { diff --git a/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch b/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch index 6bf1bfd330..5d522fefbe 100644 --- a/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch +++ b/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/resources/ResourceLocation.java +++ b/net/minecraft/resources/ResourceLocation.java -@@ -125,6 +_,12 @@ +@@ -137,6 +_,12 @@ return i; } diff --git a/patches/minecraft/net/minecraft/server/Bootstrap.java.patch b/patches/minecraft/net/minecraft/server/Bootstrap.java.patch index d68e4c4f5d..35ebb0c391 100644 --- a/patches/minecraft/net/minecraft/server/Bootstrap.java.patch +++ b/patches/minecraft/net/minecraft/server/Bootstrap.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/server/Bootstrap.java +++ b/net/minecraft/server/Bootstrap.java -@@ -53,6 +_,8 @@ +@@ -47,6 +_,8 @@ DispenseItemBehavior.m_123402_(); CauldronInteraction.m_175649_(); - Registry.m_206101_(); + BuiltInRegistries.m_257498_(); + net.minecraftforge.registries.GameData.vanillaSnapshot(); + if (false) // skip redirectOutputToLog, Forge already redirects stdout and stderr output to log so that they print with more context m_135890_(); } } -@@ -126,7 +_,6 @@ - m_197757_(); +@@ -119,7 +_,6 @@ + Commands.m_82138_(); } - DefaultAttributes.m_22296_(); } - private static void m_197757_() { + private static void m_135890_() { diff --git a/patches/minecraft/net/minecraft/server/Main.java.patch b/patches/minecraft/net/minecraft/server/Main.java.patch index d80e07ae51..65aaa9c741 100644 --- a/patches/minecraft/net/minecraft/server/Main.java.patch +++ b/patches/minecraft/net/minecraft/server/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -78,6 +_,15 @@ +@@ -79,6 +_,15 @@ OptionSpec optionspec12 = optionparser.accepts("serverId").withRequiredArg(); OptionSpec optionspec13 = optionparser.accepts("jfrProfile"); OptionSpec optionspec14 = optionparser.nonOptions(); @@ -16,7 +16,7 @@ try { OptionSet optionset = optionparser.parse(p_129699_); -@@ -85,6 +_,13 @@ +@@ -86,6 +_,13 @@ optionparser.printHelpOn(System.err); return; } @@ -30,7 +30,7 @@ CrashReport.m_127529_(); if (optionset.has(optionspec13)) { -@@ -94,26 +_,25 @@ +@@ -95,26 +_,25 @@ Bootstrap.m_135870_(); Bootstrap.m_135889_(); Util.m_137584_(); @@ -63,18 +63,18 @@ LevelSummary levelsummary = levelstoragesource$levelstorageaccess.m_78308_(); if (levelsummary != null) { if (levelsummary.m_193020_()) { -@@ -158,6 +_,8 @@ - worldgensettings = optionset.has(optionspec3) ? dedicatedserverproperties.m_180927_(registryaccess$writable).m_64671_() : dedicatedserverproperties.m_180927_(registryaccess$writable); +@@ -160,6 +_,8 @@ + worlddimensions = dedicatedserverproperties.m_246483_(p_248079_.f_244104_()); } -+ // Forge: Deserialize the WorldGenSettings to ensure modded dims are loaded on first server load. Vanilla behavior only loads from the server.properties and deserializes only after the 2nd server load. -+ worldgensettings = WorldGenSettings.f_64600_.encodeStart(dynamicops, worldgensettings).flatMap(nbt -> WorldGenSettings.f_64600_.parse(dynamicops, nbt)).getOrThrow(false, errorMsg -> {}); - PrimaryLevelData primaryleveldata = new PrimaryLevelData(levelsettings, worldgensettings, Lifecycle.stable()); - return Pair.of(primaryleveldata, registryaccess$writable.m_203557_()); - } -@@ -178,22 +_,33 @@ - } ++ //Forge: Do a write-read-cycle to inject modded dimensions on first start of a dedicated server into its generated world dimensions list. ++ worlddimensions = WorldDimensions.f_243810_.encoder().encodeStart(dynamicops, worlddimensions).flatMap((writtenPayloadWithModdedDimensions) -> WorldDimensions.f_243810_.decoder().parse(dynamicops, writtenPayloadWithModdedDimensions)).resultOrPartial(f_129670_::error).orElse(worlddimensions); + WorldDimensions.Complete worlddimensions$complete = worlddimensions.m_245300_(registry); + Lifecycle lifecycle = worlddimensions$complete.m_245945_().add(p_248079_.f_244104_().m_211816_()); + return new WorldLoader.DataLoadOutput<>(new PrimaryLevelData(levelsettings, worldoptions, worlddimensions$complete.f_244634_(), lifecycle), worlddimensions$complete.m_245593_()); +@@ -180,22 +_,33 @@ + WorldData worlddata = worldstem.f_206895_(); levelstoragesource$levelstorageaccess.m_78287_(registryaccess$frozen, worlddata); - final DedicatedServer dedicatedserver = MinecraftServer.m_129872_((p_236710_) -> { - DedicatedServer dedicatedserver1 = new DedicatedServer(p_236710_, levelstoragesource$levelstorageaccess, packrepository, worldstem, dedicatedserversettings, DataFixers.m_14512_(), services, LoggerChunkProgressListener::new); diff --git a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch index c6cc897bcc..f1f997d307 100644 --- a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -240,7 +_,7 @@ +@@ -247,7 +_,7 @@ public static S m_129872_(Function p_129873_) { AtomicReference atomicreference = new AtomicReference<>(); @@ -9,15 +9,15 @@ atomicreference.get().m_130011_(); }, "Server thread"); thread.setUncaughtExceptionHandler((p_177909_, p_177910_) -> { -@@ -332,6 +_,7 @@ +@@ -340,6 +_,7 @@ this.m_129841_(dimensiondatastorage); this.f_129732_ = new CommandStorage(dimensiondatastorage); WorldBorder worldborder = serverlevel.m_6857_(); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.level.LevelEvent.Load(f_129762_.get(Level.f_46428_))); if (!serverleveldata.m_6535_()) { try { - m_177896_(serverlevel, serverleveldata, worldgensettings.m_64660_(), flag); -@@ -366,6 +_,7 @@ + m_177896_(serverlevel, serverleveldata, worldoptions.m_245100_(), flag); +@@ -374,6 +_,7 @@ ServerLevel serverlevel1 = new ServerLevel(this, this.f_129738_, this.f_129744_, derivedleveldata, resourcekey1, entry.getValue(), p_129816_, flag, j, ImmutableList.of(), false); worldborder.m_61929_(new BorderChangeListener.DelegateBorderChangeListener(serverlevel1.m_6857_())); this.f_129762_.put(resourcekey1, serverlevel1); @@ -25,7 +25,7 @@ } } -@@ -377,6 +_,7 @@ +@@ -385,6 +_,7 @@ p_177898_.m_7250_(BlockPos.f_121853_.m_6630_(80), 0.0F); } else { ServerChunkCache serverchunkcache = p_177897_.m_7726_(); @@ -33,7 +33,7 @@ ChunkPos chunkpos = new ChunkPos(serverchunkcache.m_214994_().m_224579_().m_183230_()); int i = serverchunkcache.m_8481_().m_142051_(p_177897_); if (i < p_177897_.m_141937_()) { -@@ -457,6 +_,7 @@ +@@ -468,6 +_,7 @@ ChunkPos chunkpos = new ChunkPos(i); serverlevel1.m_7726_().m_6692_(chunkpos, true); } @@ -41,7 +41,7 @@ } } -@@ -527,6 +_,8 @@ +@@ -538,6 +_,8 @@ } public void m_7041_() { @@ -50,7 +50,7 @@ if (this.f_177872_.m_142763_()) { this.m_236737_(); } -@@ -571,6 +_,7 @@ +@@ -582,6 +_,7 @@ for(ServerLevel serverlevel2 : this.m_129785_()) { if (serverlevel2 != null) { try { @@ -58,7 +58,7 @@ serverlevel2.close(); } catch (IOException ioexception1) { f_129750_.error("Exception closing the level", (Throwable)ioexception1); -@@ -619,6 +_,7 @@ +@@ -630,6 +_,7 @@ throw new IllegalStateException("Failed to initialize server"); } @@ -66,7 +66,7 @@ this.f_129726_ = Util.m_137550_(); this.f_129757_.m_134908_(Component.m_237113_(this.f_129709_)); this.f_129757_.m_134912_(new ServerStatus.Version(SharedConstants.m_183709_().getName(), SharedConstants.m_183709_().getProtocolVersion())); -@@ -653,6 +_,8 @@ +@@ -663,6 +_,8 @@ this.f_129717_ = true; JvmProfiler.f_185340_.m_183597_(this.f_129737_); } @@ -75,7 +75,7 @@ } catch (Throwable throwable1) { f_129750_.error("Encountered an unexpected exception", throwable1); CrashReport crashreport = m_206568_(throwable1); -@@ -664,6 +_,7 @@ +@@ -674,6 +_,7 @@ f_129750_.error("We were unable to save this crash report to disk."); } @@ -83,7 +83,7 @@ this.m_7268_(crashreport); } finally { try { -@@ -676,6 +_,7 @@ +@@ -686,6 +_,7 @@ this.f_236721_.f_214336_().m_196559_(); } @@ -91,7 +91,7 @@ this.m_6988_(); } -@@ -789,6 +_,7 @@ +@@ -799,6 +_,7 @@ public void m_5705_(BooleanSupplier p_129871_) { long i = Util.m_137569_(); @@ -99,7 +99,7 @@ ++this.f_129766_; this.m_5703_(p_129871_); if (i - this.f_129724_ >= 5000000000L) { -@@ -810,6 +_,7 @@ +@@ -820,6 +_,7 @@ Collections.shuffle(Arrays.asList(agameprofile)); this.f_129757_.m_134914_().m_134924_(agameprofile); } @@ -107,7 +107,7 @@ } if (this.f_129766_ % 6000 == 0) { -@@ -826,6 +_,7 @@ +@@ -836,6 +_,7 @@ long i1 = Util.m_137569_(); this.f_129735_.m_13755_(i1 - i); this.f_129754_.m_7238_(); @@ -115,7 +115,7 @@ } public void m_5703_(BooleanSupplier p_129954_) { -@@ -833,7 +_,8 @@ +@@ -843,7 +_,8 @@ this.m_129890_().m_136128_(); this.f_129754_.m_6182_("levels"); @@ -125,7 +125,7 @@ this.f_129754_.m_6521_(() -> { return serverlevel + " " + serverlevel.m_46472_().m_135782_(); }); -@@ -844,6 +_,7 @@ +@@ -854,6 +_,7 @@ } this.f_129754_.m_6180_("tick"); @@ -133,7 +133,7 @@ try { serverlevel.m_8793_(p_129954_); -@@ -852,16 +_,18 @@ +@@ -862,16 +_,18 @@ serverlevel.m_6026_(crashreport); throw new ReportedException(crashreport); } @@ -153,7 +153,7 @@ GameTestTicker.f_177648_.m_127790_(); } -@@ -929,7 +_,7 @@ +@@ -939,7 +_,7 @@ @DontObfuscate public String m_130001_() { @@ -162,16 +162,7 @@ } public SystemReport m_177935_(SystemReport p_177936_) { -@@ -1121,7 +_,7 @@ - } - - public boolean m_214000_() { -- return false; -+ return net.minecraftforge.common.ForgeMod.isServerChatPreviewEnabled(); - } - - public boolean m_129918_() { -@@ -1287,6 +_,7 @@ +@@ -1286,6 +_,7 @@ this.m_6846_().m_11315_(); this.f_129734_.m_136120_(this.f_129740_.f_206585_.m_206860_()); this.f_236720_.m_230370_(this.f_129740_.f_206584_); @@ -179,23 +170,23 @@ }, this); if (this.m_18695_()) { this.m_18701_(completablefuture::isDone); -@@ -1296,10 +_,13 @@ +@@ -1295,10 +_,13 @@ } - public static DataPackConfig m_129819_(PackRepository p_129820_, DataPackConfig p_129821_, boolean p_129822_) { -+ net.minecraftforge.resource.ResourcePackLoader.loadResourcePacks(p_129820_, net.minecraftforge.server.ServerLifecycleHooks::buildPackFinder); - p_129820_.m_10506_(); + public static WorldDataConfiguration m_246048_(PackRepository p_248681_, DataPackConfig p_248920_, boolean p_249869_, FeatureFlagSet p_251243_) { ++ net.minecraftforge.resource.ResourcePackLoader.loadResourcePacks(p_248681_, net.minecraftforge.server.ServerLifecycleHooks::buildPackFinder); + p_248681_.m_10506_(); + DataPackConfig.f_45842_.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks()); -+ p_129821_.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks()); - if (p_129822_) { -- p_129820_.m_10509_(Collections.singleton("vanilla")); -- return DataPackConfig.f_45842_; -+ p_129820_.m_10509_(net.minecraftforge.common.ForgeHooks.getModPacksWithVanilla()); -+ return new DataPackConfig(net.minecraftforge.common.ForgeHooks.getModPacksWithVanilla(), ImmutableList.of()); ++ p_248920_.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks()); + if (p_249869_) { +- p_248681_.m_10509_(Collections.singleton("vanilla")); +- return WorldDataConfiguration.f_244649_; ++ p_248681_.m_10509_(net.minecraftforge.common.ForgeHooks.getModPacksWithVanilla()); ++ return new WorldDataConfiguration(new DataPackConfig(net.minecraftforge.common.ForgeHooks.getModPacksWithVanilla(), ImmutableList.of()), FeatureFlags.f_244332_); } else { Set set = Sets.newLinkedHashSet(); -@@ -1450,6 +_,31 @@ +@@ -1464,6 +_,31 @@ public abstract boolean m_7779_(GameProfile p_129840_); @@ -227,7 +218,7 @@ public void m_142116_(Path p_177911_) throws IOException { } -@@ -1708,6 +_,10 @@ +@@ -1639,6 +_,10 @@ public WorldData m_129910_() { return this.f_129749_; diff --git a/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch b/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch index 969814890a..1c017d899b 100644 --- a/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch +++ b/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PlayerAdvancements.java +++ b/net/minecraft/server/PlayerAdvancements.java -@@ -178,6 +_,10 @@ +@@ -164,6 +_,10 @@ } this.m_136002_(p_136007_); @@ -11,7 +11,7 @@ this.m_136001_(); this.m_135994_(p_136007_); } -@@ -236,6 +_,8 @@ +@@ -197,6 +_,8 @@ } public boolean m_135988_(Advancement p_135989_, String p_135990_) { @@ -20,7 +20,7 @@ boolean flag = false; AdvancementProgress advancementprogress = this.m_135996_(p_135989_); boolean flag1 = advancementprogress.m_8193_(); -@@ -243,11 +_,14 @@ +@@ -204,11 +_,14 @@ this.m_136008_(p_135989_); this.f_135967_.add(p_135989_); flag = true; @@ -35,7 +35,7 @@ } } -@@ -265,6 +_,7 @@ +@@ -226,6 +_,7 @@ this.m_136004_(p_135999_); this.f_135967_.add(p_135999_); flag = true; diff --git a/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch b/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch index c0ffcb049c..66bee160ea 100644 --- a/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch +++ b/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/ReloadableServerResources.java +++ b/net/minecraft/server/ReloadableServerResources.java -@@ -30,12 +_,12 @@ +@@ -31,12 +_,12 @@ private static final CompletableFuture f_206846_ = CompletableFuture.completedFuture(Unit.INSTANCE); - private final CommandBuildContext f_214300_; + private final CommandBuildContext.Configurable f_214300_; private final Commands f_206847_; - private final RecipeManager f_206848_ = new RecipeManager(); + private final RecipeManager f_206848_; @@ -14,10 +14,10 @@ + private final ServerAdvancementManager f_206853_; private final ServerFunctionLibrary f_206854_; - public ReloadableServerResources(RegistryAccess.Frozen p_206857_, Commands.CommandSelection p_206858_, int p_206859_) { -@@ -44,6 +_,10 @@ + public ReloadableServerResources(RegistryAccess.Frozen p_206857_, FeatureFlagSet p_250695_, Commands.CommandSelection p_206858_, int p_206859_) { +@@ -45,6 +_,10 @@ this.f_206847_ = new Commands(p_206858_, this.f_214300_); - this.f_214300_.m_227135_(CommandBuildContext.MissingTagAccessPolicy.CREATE_NEW); + this.f_214300_.m_254905_(CommandBuildContext.MissingTagAccessPolicy.CREATE_NEW); this.f_206854_ = new ServerFunctionLibrary(p_206859_, this.f_206847_.m_82094_()); + // Forge: Create context object and pass it to the recipe manager. + this.context = new net.minecraftforge.common.crafting.conditions.ConditionContext(this.f_206849_); @@ -26,18 +26,18 @@ } public ServerFunctionLibrary m_206860_() { -@@ -80,7 +_,9 @@ +@@ -81,7 +_,9 @@ - public static CompletableFuture m_206861_(ResourceManager p_206862_, RegistryAccess.Frozen p_206863_, Commands.CommandSelection p_206864_, int p_206865_, Executor p_206866_, Executor p_206867_) { - ReloadableServerResources reloadableserverresources = new ReloadableServerResources(p_206863_, p_206864_, p_206865_); -- return SimpleReloadInstance.m_203834_(p_206862_, reloadableserverresources.m_206890_(), p_206866_, p_206867_, f_206846_, f_206845_.isDebugEnabled()).m_7237_().whenComplete((p_214309_, p_214310_) -> { + public static CompletableFuture m_247740_(ResourceManager p_248588_, RegistryAccess.Frozen p_251163_, FeatureFlagSet p_250212_, Commands.CommandSelection p_249301_, int p_251126_, Executor p_249136_, Executor p_249601_) { + ReloadableServerResources reloadableserverresources = new ReloadableServerResources(p_251163_, p_250212_, p_249301_, p_251126_); +- return SimpleReloadInstance.m_203834_(p_248588_, reloadableserverresources.m_206890_(), p_249136_, p_249601_, f_206846_, f_206845_.isDebugEnabled()).m_7237_().whenComplete((p_255534_, p_255535_) -> { + List listeners = new java.util.ArrayList<>(reloadableserverresources.m_206890_()); + listeners.addAll(net.minecraftforge.event.ForgeEventFactory.onResourceReload(reloadableserverresources)); -+ return SimpleReloadInstance.m_203834_(p_206862_, listeners, p_206866_, p_206867_, f_206846_, f_206845_.isDebugEnabled()).m_7237_().whenComplete((p_214309_, p_214310_) -> { - reloadableserverresources.f_214300_.m_227135_(CommandBuildContext.MissingTagAccessPolicy.FAIL); ++ return SimpleReloadInstance.m_203834_(p_248588_, listeners, p_249136_, p_249601_, f_206846_, f_206845_.isDebugEnabled()).m_7237_().whenComplete((p_214309_, p_214310_) -> { + reloadableserverresources.f_214300_.m_254905_(CommandBuildContext.MissingTagAccessPolicy.FAIL); }).thenApply((p_214306_) -> { return reloadableserverresources; -@@ -92,6 +_,7 @@ +@@ -93,6 +_,7 @@ m_206870_(p_206869_, p_214315_); }); Blocks.m_50758_(); @@ -45,7 +45,7 @@ } private static void m_206870_(RegistryAccess p_206871_, TagManager.LoadResult p_206872_) { -@@ -102,5 +_,16 @@ +@@ -103,5 +_,16 @@ return List.copyOf(p_214312_.getValue()); })); p_206871_.m_175515_(resourcekey).m_203652_(map); diff --git a/patches/minecraft/net/minecraft/server/WorldLoader.java.patch b/patches/minecraft/net/minecraft/server/WorldLoader.java.patch new file mode 100644 index 0000000000..2e6fc239be --- /dev/null +++ b/patches/minecraft/net/minecraft/server/WorldLoader.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/WorldLoader.java ++++ b/net/minecraft/server/WorldLoader.java +@@ -28,7 +_,7 @@ + Pair pair = p_214363_.f_214378_.m_214399_(); + CloseableResourceManager closeableresourcemanager = pair.getSecond(); + LayeredRegistryAccess layeredregistryaccess = RegistryLayer.m_245849_(); +- LayeredRegistryAccess layeredregistryaccess1 = m_245736_(closeableresourcemanager, layeredregistryaccess, RegistryLayer.WORLDGEN, RegistryDataLoader.f_243803_); ++ LayeredRegistryAccess layeredregistryaccess1 = m_245736_(closeableresourcemanager, layeredregistryaccess, RegistryLayer.WORLDGEN, net.minecraftforge.registries.DataPackRegistriesHooks.getDataPackRegistries()); + RegistryAccess.Frozen registryaccess$frozen = layeredregistryaccess1.m_246035_(RegistryLayer.DIMENSIONS); + RegistryAccess.Frozen registryaccess$frozen1 = RegistryDataLoader.m_247207_(closeableresourcemanager, registryaccess$frozen, RegistryDataLoader.f_244547_); + WorldDataConfiguration worlddataconfiguration = pair.getFirst(); diff --git a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch index 3ec7212e80..fd883412b0 100644 --- a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -82,6 +_,7 @@ +@@ -79,6 +_,7 @@ public boolean m_7038_() throws IOException { Thread thread = new Thread("Server console handler") { public void run() { @@ -8,7 +8,7 @@ BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); String s1; -@@ -159,11 +_,13 @@ +@@ -156,11 +_,13 @@ long i = Util.m_137569_(); SkullBlockEntity.m_222885_(this.f_236721_, this); GameProfileCache.m_11004_(this.m_129797_()); @@ -22,10 +22,10 @@ if (dedicatedserverproperties.f_139744_ != null) { this.m_129900_().m_46170_(GameRules.f_46153_).m_46246_(dedicatedserverproperties.f_139744_, this); } -@@ -187,12 +_,13 @@ +@@ -183,12 +_,13 @@ + thread1.start(); } - Items.f_41852_.m_6787_(CreativeModeTab.f_40754_, NonNullList.m_122779_()); + // <3 you Grum for this, saves us ~30 patch files! --^ if (dedicatedserverproperties.f_139721_) { MinecraftServerStatistics.m_18328_(this); @@ -37,12 +37,3 @@ } } -@@ -318,7 +_,7 @@ - } - - public boolean m_214000_() { -- return this.m_7913_().f_214803_; -+ return super.m_214000_() || this.m_7913_().f_214803_; - } - - public DedicatedPlayerList m_6846_() { diff --git a/patches/minecraft/net/minecraft/server/dedicated/Settings.java.patch b/patches/minecraft/net/minecraft/server/dedicated/Settings.java.patch index 49a1241a4b..3f0b381b62 100644 --- a/patches/minecraft/net/minecraft/server/dedicated/Settings.java.patch +++ b/patches/minecraft/net/minecraft/server/dedicated/Settings.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/dedicated/Settings.java +++ b/net/minecraft/server/dedicated/Settings.java -@@ -60,7 +_,7 @@ - OutputStream outputstream = Files.newOutputStream(p_139877_); +@@ -39,7 +_,7 @@ - try { -- this.f_139798_.store(outputstream, "Minecraft server properties"); -+ net.minecraftforge.common.util.SortedProperties.store(f_139798_, outputstream, "Minecraft server properties"); - } catch (Throwable throwable1) { - if (outputstream != null) { - try { + public void m_139876_(Path p_139877_) { + try (OutputStream outputstream = Files.newOutputStream(p_139877_)) { +- this.f_139798_.store(outputstream, "Minecraft server properties"); ++ net.minecraftforge.common.util.SortedProperties.store(this.f_139798_, outputstream, "Minecraft server properties"); + } catch (IOException ioexception) { + f_139797_.error("Failed to store properties to file: {}", (Object)p_139877_); + } diff --git a/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch b/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch index 8d1739b67d..601483bc80 100644 --- a/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -385,6 +_,7 @@ +@@ -395,6 +_,7 @@ this.f_140140_ = true; } @@ -8,7 +8,7 @@ return p_140179_; } } -@@ -490,6 +_,7 @@ +@@ -500,6 +_,7 @@ if (this.f_140131_.remove(p_140182_, p_140183_) && p_203002_ != null) { if (p_203002_ instanceof LevelChunk) { ((LevelChunk)p_203002_).m_62913_(false); @@ -16,7 +16,7 @@ } this.m_140258_(p_203002_); -@@ -689,8 +_,14 @@ +@@ -699,8 +_,14 @@ levelchunk.m_62952_(); if (this.f_140132_.add(chunkpos.m_45588_())) { levelchunk.m_62913_(true); @@ -31,7 +31,7 @@ } return levelchunk; -@@ -793,6 +_,7 @@ +@@ -803,6 +_,7 @@ this.f_140133_.m_46473_().m_6174_("chunkSave"); CompoundTag compoundtag = ChunkSerializer.m_63454_(this.f_140133_, p_140259_); @@ -39,7 +39,7 @@ this.m_63502_(chunkpos, compoundtag); this.m_140229_(chunkpos, chunkstatus.m_62494_()); return true; -@@ -863,6 +_,7 @@ +@@ -873,6 +_,7 @@ if (!p_183759_ && p_183758_) { p_183755_.m_9088_(p_183756_); @@ -47,7 +47,7 @@ } } -@@ -1105,7 +_,7 @@ +@@ -1115,7 +_,7 @@ } protected void m_140199_(Entity p_140200_) { @@ -56,7 +56,7 @@ EntityType entitytype = p_140200_.m_6095_(); int i = entitytype.m_20681_() * 16; if (i != 0) { -@@ -1231,6 +_,7 @@ +@@ -1262,6 +_,7 @@ } } diff --git a/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch b/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch index adb61a59e5..0fedd0bd41 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -161,6 +_,7 @@ +@@ -162,6 +_,7 @@ if (chunkholder == null) { return null; } else { @@ -8,7 +8,7 @@ Either either = chunkholder.m_140080_(ChunkStatus.f_62326_).getNow((Either)null); if (either == null) { return null; -@@ -349,7 +_,7 @@ +@@ -350,7 +_,7 @@ for(ServerChunkCache.ChunkAndHolder serverchunkcache$chunkandholder : list) { LevelChunk levelchunk1 = serverchunkcache$chunkandholder.f_184028_; ChunkPos chunkpos = levelchunk1.m_7697_(); @@ -17,7 +17,7 @@ levelchunk1.m_187632_(j); if (flag2 && (this.f_8335_ || this.f_8336_) && this.f_8329_.m_6857_().m_61927_(chunkpos)) { NaturalSpawner.m_47029_(this.f_8329_, levelchunk1, naturalspawner$spawnstate, this.f_8336_, this.f_8335_, flag1); -@@ -426,11 +_,17 @@ +@@ -431,11 +_,17 @@ } public void m_8387_(TicketType p_8388_, ChunkPos p_8389_, int p_8390_, T p_8391_) { diff --git a/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch b/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch index a2ef6f4b6b..a1e6e509b8 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -80,10 +_,9 @@ +@@ -85,10 +_,9 @@ if ($$11 instanceof ItemFrame itemframe) { if (this.f_8521_ % 10 == 0) { ItemStack itemstack = itemframe.m_31822_(); @@ -14,7 +14,7 @@ for(ServerPlayer serverplayer : this.f_8509_.m_6907_()) { mapitemsaveddata.m_77918_(serverplayer, itemstack); Packet packet = mapitemsaveddata.m_164796_(integer, serverplayer); -@@ -92,11 +_,12 @@ +@@ -97,11 +_,12 @@ } } } @@ -28,7 +28,7 @@ if (this.f_8521_ % this.f_8511_ == 0 || this.f_8510_.f_19812_ || this.f_8510_.m_20088_().m_135352_()) { if (this.f_8510_.m_20159_()) { -@@ -189,11 +_,13 @@ +@@ -194,11 +_,13 @@ public void m_8534_(ServerPlayer p_8535_) { this.f_8510_.m_6452_(p_8535_); p_8535_.f_8906_.m_9829_(new ClientboundRemoveEntitiesPacket(this.f_8510_.m_19879_())); diff --git a/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch b/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch index c8fffae38f..2c627d26f0 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -184,10 +_,11 @@ +@@ -187,10 +_,11 @@ private final List f_8558_; @Nullable private final EndDragonFight f_8559_; @@ -12,16 +12,16 @@ + private net.minecraftforge.common.util.LevelCapabilityData capabilityData; public ServerLevel(MinecraftServer p_214999_, Executor p_215000_, LevelStorageSource.LevelStorageAccess p_215001_, ServerLevelData p_215002_, ResourceKey p_215003_, LevelStem p_215004_, ChunkProgressListener p_215005_, boolean p_215006_, long p_215007_, List p_215008_, boolean p_215009_) { - super(p_215002_, p_215003_, p_215004_.m_204521_(), p_214999_::m_129905_, false, p_215006_, p_215007_, p_214999_.m_213994_()); -@@ -227,6 +_,7 @@ - } + super(p_215002_, p_215003_, p_215004_.f_63975_(), p_214999_::m_129905_, false, p_215006_, p_215007_, p_214999_.m_213994_()); +@@ -231,6 +_,7 @@ this.f_143245_ = new SleepStatus(); + this.f_243695_ = new GameEventDispatcher(this); + this.initCapabilities(); } public void m_8606_(int p_8607_, int p_8608_, boolean p_8609_, boolean p_8610_) { -@@ -255,8 +_,8 @@ +@@ -259,8 +_,8 @@ int i = this.m_46469_().m_46215_(GameRules.f_151486_); if (this.f_143245_.m_144002_(i) && this.f_143245_.m_144004_(i, this.f_8546_)) { if (this.m_46469_().m_46207_(GameRules.f_46140_)) { @@ -32,7 +32,7 @@ } this.m_8804_(); -@@ -285,7 +_,7 @@ +@@ -289,7 +_,7 @@ this.m_8807_(); this.f_8557_ = false; profilerfiller.m_7238_(); @@ -41,7 +41,7 @@ if (flag) { this.m_8886_(); } -@@ -317,7 +_,9 @@ +@@ -321,7 +_,9 @@ } profilerfiller.m_6180_("tick"); @@ -52,15 +52,15 @@ profilerfiller.m_7238_(); } } -@@ -408,6 +_,7 @@ - BlockPos blockpos2 = this.m_5452_(Heightmap.Types.MOTION_BLOCKING, this.m_46496_(i, 0, j, 15)); - BlockPos blockpos3 = blockpos2.m_7495_(); - Biome biome = this.m_204166_(blockpos2).m_203334_(); +@@ -414,6 +_,7 @@ + BlockPos blockpos1 = this.m_5452_(Heightmap.Types.MOTION_BLOCKING, this.m_46496_(i, 0, j, 15)); + BlockPos blockpos2 = blockpos1.m_7495_(); + Biome biome = this.m_204166_(blockpos1).m_203334_(); + if (this.isAreaLoaded(blockpos2, 1)) // Forge: check area to avoid loading neighbors in unloaded chunks - if (biome.m_47477_(this, blockpos3)) { - this.m_46597_(blockpos3, Blocks.f_50126_.m_49966_()); + if (biome.m_47477_(this, blockpos2)) { + this.m_46597_(blockpos2, Blocks.f_50126_.m_49966_()); } -@@ -598,15 +_,19 @@ +@@ -615,15 +_,19 @@ this.f_8548_.m_6846_().m_11270_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132161_, this.f_46440_), this.m_46472_()); } @@ -84,15 +84,15 @@ } } -@@ -665,6 +_,7 @@ - return Registry.f_122826_.m_7981_(p_8664_.m_6095_()).toString(); +@@ -682,6 +_,7 @@ + return BuiltInRegistries.f_256780_.m_7981_(p_8664_.m_6095_()).toString(); }); profilerfiller.m_6174_("tickPassenger"); + if (p_8664_.canUpdate()) p_8664_.m_6083_(); profilerfiller.m_7238_(); -@@ -701,6 +_,7 @@ +@@ -718,6 +_,7 @@ this.f_143244_.m_157554_(); } @@ -100,7 +100,7 @@ } } -@@ -774,6 +_,7 @@ +@@ -810,6 +_,7 @@ } private void m_8853_(ServerPlayer p_8854_) { @@ -108,7 +108,7 @@ Entity entity = this.m_142646_().m_142694_(p_8854_.m_20148_()); if (entity != null) { f_8566_.warn("Force-added player with duplicate UUID {}", (Object)p_8854_.m_20148_().toString()); -@@ -781,7 +_,8 @@ +@@ -817,7 +_,8 @@ this.m_143261_((ServerPlayer)entity, Entity.RemovalReason.DISCARDED); } @@ -118,7 +118,7 @@ } private boolean m_8872_(Entity p_8873_) { -@@ -789,7 +_,12 @@ +@@ -825,7 +_,12 @@ f_8566_.warn("Tried to add entity {} but it was marked as removed already", (Object)EntityType.m_20613_(p_8873_.m_6095_())); return false; } else { @@ -132,38 +132,38 @@ } } -@@ -826,10 +_,22 @@ +@@ -862,10 +_,22 @@ } - public void m_214150_(@Nullable Player p_215017_, double p_215018_, double p_215019_, double p_215020_, SoundEvent p_215021_, SoundSource p_215022_, float p_215023_, float p_215024_, long p_215025_) { -+ net.minecraftforge.event.PlayLevelSoundEvent.AtPosition event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtPosition(this, p_215018_, p_215019_, p_215020_, p_215021_, p_215022_, p_215023_, p_215024_); + public void m_262808_(@Nullable Player p_263330_, double p_263393_, double p_263369_, double p_263354_, Holder p_263412_, SoundSource p_263338_, float p_263352_, float p_263390_, long p_263403_) { ++ net.minecraftforge.event.PlayLevelSoundEvent.AtPosition event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtPosition(this, p_263393_, p_263369_, p_263354_, p_263412_, p_263338_, p_263352_, p_263390_); + if (event.isCanceled() || event.getSound() == null) return; -+ p_215021_ = event.getSound(); -+ p_215022_ = event.getSource(); -+ p_215023_ = event.getNewVolume(); -+ p_215024_ = event.getNewPitch(); - this.f_8548_.m_6846_().m_11241_(p_215017_, p_215018_, p_215019_, p_215020_, (double)p_215021_.m_215668_(p_215023_), this.m_46472_(), new ClientboundSoundPacket(p_215021_, p_215022_, p_215018_, p_215019_, p_215020_, p_215023_, p_215024_, p_215025_)); ++ p_263412_ = event.getSound(); ++ p_263338_ = event.getSource(); ++ p_263352_ = event.getNewVolume(); ++ p_263390_ = event.getNewPitch(); + this.f_8548_.m_6846_().m_11241_(p_263330_, p_263393_, p_263369_, p_263354_, (double)p_263412_.m_203334_().m_215668_(p_263352_), this.m_46472_(), new ClientboundSoundPacket(p_263412_, p_263338_, p_263393_, p_263369_, p_263354_, p_263352_, p_263390_, p_263403_)); } - public void m_213890_(@Nullable Player p_215027_, Entity p_215028_, SoundEvent p_215029_, SoundSource p_215030_, float p_215031_, float p_215032_, long p_215033_) { -+ net.minecraftforge.event.PlayLevelSoundEvent.AtEntity event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_215028_, p_215029_, p_215030_, p_215031_, p_215032_); + public void m_213890_(@Nullable Player p_263545_, Entity p_263544_, Holder p_263491_, SoundSource p_263542_, float p_263530_, float p_263520_, long p_263490_) { ++ net.minecraftforge.event.PlayLevelSoundEvent.AtEntity event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_263544_, p_263491_, p_263542_, p_263530_, p_263520_); + if (event.isCanceled() || event.getSound() == null) return; -+ p_215029_ = event.getSound(); -+ p_215030_ = event.getSource(); -+ p_215031_ = event.getNewVolume(); -+ p_215032_ = event.getNewPitch(); - this.f_8548_.m_6846_().m_11241_(p_215027_, p_215028_.m_20185_(), p_215028_.m_20186_(), p_215028_.m_20189_(), (double)p_215029_.m_215668_(p_215031_), this.m_46472_(), new ClientboundSoundEntityPacket(p_215029_, p_215030_, p_215028_, p_215031_, p_215032_, p_215033_)); ++ p_263491_ = event.getSound(); ++ p_263542_ = event.getSource(); ++ p_263530_ = event.getNewVolume(); ++ p_263520_ = event.getNewPitch(); + this.f_8548_.m_6846_().m_11241_(p_263545_, p_263544_.m_20185_(), p_263544_.m_20186_(), p_263544_.m_20189_(), (double)p_263491_.m_203334_().m_215668_(p_263530_), this.m_46472_(), new ClientboundSoundEntityPacket(p_263491_, p_263542_, p_263544_, p_263530_, p_263520_, p_263490_)); } -@@ -846,6 +_,7 @@ +@@ -887,6 +_,7 @@ } public void m_214171_(GameEvent p_215041_, Vec3 p_215042_, GameEvent.Context p_215043_) { + if (!net.minecraftforge.common.ForgeHooks.onVanillaGameEvent(this, p_215041_, p_215042_, p_215043_)) return; - int i = p_215041_.m_157827_(); - BlockPos blockpos = new BlockPos(p_215042_); - int j = SectionPos.m_123171_(blockpos.m_123341_() - i); -@@ -931,10 +_,15 @@ + this.f_243695_.m_245905_(p_215041_, p_215042_, p_215043_); + } + +@@ -923,10 +_,15 @@ } public void m_46672_(BlockPos p_215045_, Block p_215046_) { @@ -179,15 +179,7 @@ this.f_220350_.m_214152_(p_215052_, p_215053_, p_215054_); } -@@ -956,6 +_,7 @@ - - public Explosion m_7703_(@Nullable Entity p_8653_, @Nullable DamageSource p_8654_, @Nullable ExplosionDamageCalculator p_8655_, double p_8656_, double p_8657_, double p_8658_, float p_8659_, boolean p_8660_, Explosion.BlockInteraction p_8661_) { - Explosion explosion = new Explosion(this, p_8653_, p_8654_, p_8655_, p_8656_, p_8657_, p_8658_, p_8659_, p_8660_, p_8661_); -+ if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this, explosion)) return explosion; - explosion.m_46061_(); - explosion.m_46075_(false); - if (p_8661_ == Explosion.BlockInteraction.NONE) { -@@ -1462,6 +_,12 @@ +@@ -1362,6 +_,12 @@ }); } @@ -200,7 +192,7 @@ public LevelEntityGetter m_142646_() { return this.f_143244_.m_157567_(); } -@@ -1545,8 +_,8 @@ +@@ -1449,8 +_,8 @@ ServerLevel.this.f_143246_.add(mob); } @@ -211,7 +203,7 @@ ServerLevel.this.f_143247_.put(enderdragonpart.m_19879_(), enderdragonpart); } } -@@ -1570,17 +_,25 @@ +@@ -1474,17 +_,25 @@ ServerLevel.this.f_143246_.remove(mob); } diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch index 4da287afb9..3162eb8f06 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -550,6 +_,7 @@ +@@ -565,6 +_,7 @@ public void m_6667_(DamageSource p_9035_) { this.m_146850_(GameEvent.f_223707_); @@ -8,7 +8,7 @@ boolean flag = this.f_19853_.m_46469_().m_46207_(GameRules.f_46142_); if (flag) { Component component = this.m_21231_().m_19293_(); -@@ -692,11 +_,12 @@ +@@ -707,11 +_,12 @@ } @Nullable @@ -23,7 +23,7 @@ this.m_19877_(); this.m_9236_().m_143261_(this, Entity.RemovalReason.CHANGED_DIMENSION); if (!this.f_8944_) { -@@ -713,13 +_,14 @@ +@@ -728,13 +_,14 @@ PlayerList playerlist = this.f_8924_.m_6846_(); playerlist.m_11289_(this); serverlevel.m_143261_(this, Entity.RemovalReason.CHANGED_DIMENSION); @@ -41,8 +41,8 @@ this.m_9006_(p_9180_, new BlockPos(portalinfo.f_77676_)); } -@@ -731,6 +_,9 @@ - this.m_6027_(portalinfo.f_77676_.f_82479_, portalinfo.f_77676_.f_82480_, portalinfo.f_77676_.f_82481_); +@@ -746,6 +_,9 @@ + p_9180_.m_8817_(this); serverlevel.m_46473_().m_7238_(); this.m_9209_(serverlevel); + return this;//forge: this is part of the ITeleporter patch @@ -51,7 +51,7 @@ this.f_8906_.m_9829_(new ClientboundPlayerAbilitiesPacket(this.m_150110_())); playerlist.m_11229_(this, p_9180_); playerlist.m_11292_(this); -@@ -739,10 +_,12 @@ +@@ -754,10 +_,12 @@ this.f_8906_.m_9829_(new ClientboundUpdateMobEffectPacket(this.m_19879_(), mobeffectinstance)); } @@ -64,7 +64,7 @@ } return this; -@@ -806,6 +_,9 @@ +@@ -821,6 +_,9 @@ } public Either m_7720_(BlockPos p_9115_) { @@ -74,7 +74,7 @@ Direction direction = this.f_19853_.m_8055_(p_9115_).m_61143_(HorizontalDirectionalBlock.f_54117_); if (!this.m_5803_() && this.m_6084_()) { if (!this.f_19853_.m_6042_().f_63858_()) { -@@ -816,7 +_,7 @@ +@@ -831,7 +_,7 @@ return Either.left(Player.BedSleepingProblem.OBSTRUCTED); } else { this.m_9158_(this.f_19853_.m_46472_(), p_9115_, this.m_146908_(), false, true); @@ -83,7 +83,7 @@ return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW); } else { if (!this.m_7500_()) { -@@ -854,6 +_,7 @@ +@@ -869,6 +_,7 @@ } private boolean m_9116_(BlockPos p_9117_, Direction p_9118_) { @@ -91,7 +91,7 @@ return this.m_9222_(p_9117_) || this.m_9222_(p_9117_.m_121945_(p_9118_.m_122424_())); } -@@ -962,6 +_,7 @@ +@@ -977,6 +_,7 @@ this.f_8906_.m_9829_(new ClientboundOpenScreenPacket(abstractcontainermenu.f_38840_, abstractcontainermenu.m_6772_(), p_9033_.m_5446_())); this.m_143399_(abstractcontainermenu); this.f_36096_ = abstractcontainermenu; @@ -99,7 +99,7 @@ return OptionalInt.of(this.f_8940_); } } -@@ -980,6 +_,7 @@ +@@ -995,6 +_,7 @@ this.f_8906_.m_9829_(new ClientboundHorseScreenOpenPacket(this.f_8940_, p_9060_.m_6643_(), p_9059_.m_19879_())); this.f_36096_ = new HorseInventoryMenu(this.f_8940_, this.m_150109_(), p_9060_, p_9059_); this.m_143399_(this.f_36096_); @@ -107,7 +107,7 @@ } public void m_6986_(ItemStack p_9082_, InteractionHand p_9083_) { -@@ -1005,6 +_,7 @@ +@@ -1020,6 +_,7 @@ public void m_9230_() { this.f_36096_.m_6877_(this); this.f_36095_.m_150414_(this.f_36096_); @@ -115,7 +115,7 @@ this.f_36096_ = this.f_36095_; } -@@ -1131,6 +_,15 @@ +@@ -1149,6 +_,15 @@ this.m_36362_(p_9016_.m_36331_()); this.m_36364_(p_9016_.m_36332_()); this.m_219749_(p_9016_.m_219759_()); @@ -131,7 +131,7 @@ } protected void m_142540_(MobEffectInstance p_143393_, @Nullable Entity p_143394_) { -@@ -1189,6 +_,8 @@ +@@ -1211,6 +_,8 @@ } public boolean m_143403_(GameType p_143404_) { @@ -140,7 +140,7 @@ if (!this.f_8941_.m_143473_(p_143404_)) { return false; } else { -@@ -1260,6 +_,7 @@ +@@ -1275,6 +_,7 @@ this.f_184127_ = p_9157_.f_195812_(); this.m_20088_().m_135381_(f_36089_, (byte)p_9157_.f_133867_()); this.m_20088_().m_135381_(f_36090_, (byte)(p_9157_.f_133868_() == HumanoidArm.LEFT ? 0 : 1)); @@ -148,15 +148,15 @@ } public boolean m_143432_() { -@@ -1319,6 +_,7 @@ +@@ -1334,6 +_,7 @@ public void m_9213_(@Nullable Entity p_9214_) { Entity entity = this.m_8954_(); this.f_8926_ = (Entity)(p_9214_ == null ? this : p_9214_); + while (this.f_8926_ instanceof net.minecraftforge.entity.PartEntity partEntity) this.f_8926_ = partEntity.getParent(); // FORGE: fix MC-46486 if (entity != this.f_8926_) { this.f_8906_.m_9829_(new ClientboundSetCameraPacket(this.f_8926_)); - this.m_6021_(this.f_8926_.m_20185_(), this.f_8926_.m_20186_(), this.f_8926_.m_20189_()); -@@ -1348,7 +_,11 @@ + this.f_8906_.m_9774_(this.f_8926_.m_20185_(), this.f_8926_.m_20186_(), this.f_8926_.m_20189_(), this.m_146908_(), this.m_146909_()); +@@ -1364,7 +_,11 @@ @Nullable public Component m_8957_() { @@ -169,7 +169,7 @@ } public void m_6674_(InteractionHand p_9031_) { -@@ -1373,21 +_,23 @@ +@@ -1389,21 +_,23 @@ this.m_8127_(); if (p_9000_ == this.f_19853_) { this.f_8906_.m_9774_(p_9001_, p_9002_, p_9003_, p_9004_, p_9005_); @@ -177,7 +177,7 @@ + } else if (net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_9000_.m_46472_())) { ServerLevel serverlevel = this.m_9236_(); LevelData leveldata = p_9000_.m_6106_(); - this.f_8906_.m_9829_(new ClientboundRespawnPacket(p_9000_.m_220362_(), p_9000_.m_46472_(), BiomeManager.m_47877_(p_9000_.m_7328_()), this.f_8941_.m_9290_(), this.f_8941_.m_9293_(), p_9000_.m_46659_(), p_9000_.m_8584_(), true, this.m_219759_())); + this.f_8906_.m_9829_(new ClientboundRespawnPacket(p_9000_.m_220362_(), p_9000_.m_46472_(), BiomeManager.m_47877_(p_9000_.m_7328_()), this.f_8941_.m_9290_(), this.f_8941_.m_9293_(), p_9000_.m_46659_(), p_9000_.m_8584_(), (byte)3, this.m_219759_())); this.f_8906_.m_9829_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); this.f_8924_.m_6846_().m_11289_(this); serverlevel.m_143261_(this, Entity.RemovalReason.CHANGED_DIMENSION); @@ -195,7 +195,7 @@ } } -@@ -1410,6 +_,7 @@ +@@ -1426,6 +_,7 @@ } public void m_9158_(ResourceKey p_9159_, @Nullable BlockPos p_9160_, float p_9161_, boolean p_9162_, boolean p_9163_) { @@ -203,7 +203,7 @@ if (p_9160_ != null) { boolean flag = p_9160_.equals(this.f_8936_) && p_9159_.equals(this.f_8935_); if (p_9163_ && !flag) { -@@ -1461,6 +_,8 @@ +@@ -1477,6 +_,8 @@ if (itementity == null) { return null; } else { @@ -212,7 +212,7 @@ this.f_19853_.m_7967_(itementity); ItemStack itemstack = itementity.m_32055_(); if (p_9087_) { -@@ -1475,6 +_,76 @@ +@@ -1491,6 +_,76 @@ } } @@ -272,7 +272,7 @@ + this.f_8906_.m_9829_(new net.minecraft.network.protocol.game.ClientboundTabListPacket(header, footer)); + } + -+ // We need this as tablistDisplayname may be null even if the the event was fired. ++ // We need this as tablistDisplayname may be null even if the event was fired. + private boolean hasTabListName = false; + private Component tabListDisplayName = null; + /** @@ -282,14 +282,14 @@ + Component oldName = this.tabListDisplayName; + this.tabListDisplayName = net.minecraftforge.event.ForgeEventFactory.getPlayerTabListDisplayName(this); + if (!java.util.Objects.equals(oldName, this.tabListDisplayName)) { -+ this.m_20194_().m_6846_().m_11268_(new net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket(net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME, this)); ++ this.m_20194_().m_6846_().m_11268_(new net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket(net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME, this)); + } + } + public TextFilter m_8967_() { return this.f_8939_; } -@@ -1534,11 +_,13 @@ +@@ -1550,11 +_,13 @@ public boolean m_182294_(boolean p_182295_) { Inventory inventory = this.m_150109_(); diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch index c37ae3434b..534291458e 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -90,16 +90,19 @@ int i = p_9264_.m_41613_(); int j = p_9264_.m_41773_(); InteractionResultHolder interactionresultholder = p_9264_.m_41682_(p_9263_, p_9262_, p_9265_); -@@ -297,6 +_,8 @@ - public InteractionResult m_7179_(ServerPlayer p_9266_, Level p_9267_, ItemStack p_9268_, InteractionHand p_9269_, BlockHitResult p_9270_) { - BlockPos blockpos = p_9270_.m_82425_(); +@@ -299,7 +_,10 @@ BlockState blockstate = p_9267_.m_8055_(blockpos); + if (!blockstate.m_60734_().m_245993_(p_9267_.m_246046_())) { + return InteractionResult.FAIL; +- } else if (this.f_9247_ == GameType.SPECTATOR) { ++ } + net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock event = net.minecraftforge.common.ForgeHooks.onRightClickBlock(p_9266_, p_9269_, blockpos, p_9270_); + if (event.isCanceled()) return event.getCancellationResult(); - if (this.f_9247_ == GameType.SPECTATOR) { ++ if (this.f_9247_ == GameType.SPECTATOR) { MenuProvider menuprovider = blockstate.m_60750_(p_9267_, blockpos); if (menuprovider != null) { -@@ -306,10 +_,15 @@ + p_9266_.m_5893_(menuprovider); +@@ -308,10 +_,15 @@ return InteractionResult.PASS; } } else { @@ -117,7 +120,7 @@ InteractionResult interactionresult = blockstate.m_60664_(p_9267_, p_9266_, p_9269_, p_9270_); if (interactionresult.m_19077_()) { CriteriaTriggers.f_10562_.m_220040_(p_9266_, blockpos, itemstack); -@@ -317,8 +_,8 @@ +@@ -319,8 +_,8 @@ } } diff --git a/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 610401b123..742990765d 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -183,6 +_,12 @@ +@@ -182,6 +_,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, TickablePacketListener, ServerGamePacketListener { static final Logger f_9744_ = LogUtils.getLogger(); private static final int f_143608_ = 15000; @@ -12,8 +12,8 @@ + @Deprecated public static final double f_215198_ = Mth.m_144952_(6.0D); private static final int f_215199_ = -1; - private static final int f_241635_ = 4096; -@@ -432,9 +_,11 @@ + private static final int f_244471_ = 4096; +@@ -426,9 +_,11 @@ } entity.m_19890_(d3, d4, d5, f, f1); @@ -25,7 +25,7 @@ this.f_9742_.m_129512_(new ClientboundMoveVehiclePacket(entity)); return; } -@@ -451,7 +_,7 @@ +@@ -445,7 +_,7 @@ } private boolean m_9793_(Entity p_9794_) { @@ -34,49 +34,41 @@ } public void m_7376_(ServerboundAcceptTeleportationPacket p_9835_) { -@@ -1040,7 +_,7 @@ - Vec3 vec3 = blockhitresult.m_82450_(); - BlockPos blockpos = blockhitresult.m_82425_(); - Vec3 vec31 = Vec3.m_82512_(blockpos); -- if (!(this.f_9743_.m_146892_().m_82557_(vec31) > f_215198_)) { -+ if (this.f_9743_.canInteractWith(blockpos, 3)) { - Vec3 vec32 = vec3.m_82546_(vec31); - double d0 = 1.0000001D; - if (Math.abs(vec32.m_7096_()) < 1.0000001D && Math.abs(vec32.m_7098_()) < 1.0000001D && Math.abs(vec32.m_7094_()) < 1.0000001D) { -@@ -1048,7 +_,7 @@ - this.f_9743_.m_9243_(); - int i = this.f_9743_.f_19853_.m_151558_(); - if (blockpos.m_123342_() < i) { -- if (this.f_9766_ == null && this.f_9743_.m_20275_((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_() + 0.5D, (double)blockpos.m_123343_() + 0.5D) < 64.0D && serverlevel.m_7966_(this.f_9743_, blockpos)) { -+ if (this.f_9766_ == null && serverlevel.m_7966_(this.f_9743_, blockpos)) { - InteractionResult interactionresult = this.f_9743_.f_8941_.m_7179_(this.f_9743_, serverlevel, itemstack, interactionhand, blockhitresult); - if (direction == Direction.UP && !interactionresult.m_19077_() && blockpos.m_123342_() >= i - 1 && m_9790_(this.f_9743_, itemstack)) { - Component component = Component.m_237110_("build.tooHigh", i - 1).m_130940_(ChatFormatting.RED); -@@ -1184,10 +_,12 @@ - if (this.m_242598_(playerchatmessage)) { - this.f_241681_.m_241849_(() -> { - CompletableFuture completablefuture = this.m_243132_(playerchatmessage.m_241775_().f_241656_()); -- CompletableFuture completablefuture1 = this.f_9745_.m_236742_().m_243107_(this.f_9743_, playerchatmessage); -+ CompletableFuture completablefuture1 = net.minecraftforge.common.ForgeHooks.getServerChatSubmittedDecorator().m_243107_(this.f_9743_, playerchatmessage); - return CompletableFuture.allOf(completablefuture, completablefuture1).thenAcceptAsync((p_243197_) -> { - FilterMask filtermask = completablefuture.join().f_243010_(); -- PlayerChatMessage playerchatmessage1 = completablefuture1.join().m_243072_(filtermask); -+ PlayerChatMessage playerchatmessage1 = completablefuture1.join(); -+ if (playerchatmessage1 == null) return; // Forge: ServerChatEvent was canceled if this is null. -+ playerchatmessage1 = playerchatmessage1.m_243072_(filtermask); - this.m_243086_(playerchatmessage1); - }, this.f_9745_); - }); -@@ -1383,7 +_,7 @@ +@@ -1036,7 +_,7 @@ + Vec3 vec3 = blockhitresult.m_82450_(); + BlockPos blockpos = blockhitresult.m_82425_(); + Vec3 vec31 = Vec3.m_82512_(blockpos); +- if (!(this.f_9743_.m_146892_().m_82557_(vec31) > f_215198_)) { ++ if (this.f_9743_.canInteractWith(blockpos, 3)) { + Vec3 vec32 = vec3.m_82546_(vec31); + double d0 = 1.0000001D; + if (Math.abs(vec32.m_7096_()) < 1.0000001D && Math.abs(vec32.m_7098_()) < 1.0000001D && Math.abs(vec32.m_7094_()) < 1.0000001D) { +@@ -1044,7 +_,7 @@ + this.f_9743_.m_9243_(); + int i = this.f_9743_.f_19853_.m_151558_(); + if (blockpos.m_123342_() < i) { +- if (this.f_9766_ == null && this.f_9743_.m_20275_((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_() + 0.5D, (double)blockpos.m_123343_() + 0.5D) < 64.0D && serverlevel.m_7966_(this.f_9743_, blockpos)) { ++ if (this.f_9766_ == null && serverlevel.m_7966_(this.f_9743_, blockpos)) { + InteractionResult interactionresult = this.f_9743_.f_8941_.m_7179_(this.f_9743_, serverlevel, itemstack, interactionhand, blockhitresult); + if (direction == Direction.UP && !interactionresult.m_19077_() && blockpos.m_123342_() >= i - 1 && m_9790_(this.f_9743_, itemstack)) { + Component component = Component.m_237110_("build.tooHigh", i - 1).m_130940_(ChatFormatting.RED); +@@ -1188,10 +_,13 @@ + } - private CompletableFuture m_215246_(String p_215247_) { - Component component = Component.m_237113_(p_215247_); -- CompletableFuture completablefuture = this.f_9745_.m_236742_().m_236961_(this.f_9743_, component).thenApply((p_238202_) -> { -+ CompletableFuture completablefuture = net.minecraftforge.common.ForgeHooks.getServerChatPreviewDecorator().m_236961_(this.f_9743_, component).thenApply((p_238202_) -> { - return !component.equals(p_238202_) ? p_238202_ : null; - }); - completablefuture.thenAcceptAsync((p_242747_) -> { -@@ -1532,9 +_,10 @@ + CompletableFuture completablefuture = this.m_243132_(playerchatmessage.m_245728_()); +- CompletableFuture completablefuture1 = this.f_9745_.m_236742_().m_236961_(this.f_9743_, playerchatmessage.m_245692_()); ++ CompletableFuture completablefuture1 = net.minecraftforge.common.ForgeHooks.getServerChatSubmittedDecorator().m_236961_(this.f_9743_, playerchatmessage.m_245692_()); + this.f_241681_.m_241849_((p_248212_) -> { + return CompletableFuture.allOf(completablefuture, completablefuture1).thenAcceptAsync((p_248218_) -> { +- PlayerChatMessage playerchatmessage1 = playerchatmessage.m_241956_(completablefuture1.join()).m_243072_(completablefuture.join().f_243010_()); ++ Component decoratedContent = completablefuture1.join(); ++ if (decoratedContent == null) ++ return; // Forge: ServerChatEvent was canceled if this is null. ++ PlayerChatMessage playerchatmessage1 = playerchatmessage.m_241956_(decoratedContent).m_243072_(completablefuture.join().f_243010_()); + this.m_243086_(playerchatmessage1); + }, p_248212_); + }); +@@ -1434,9 +_,10 @@ return; } @@ -85,10 +77,10 @@ p_9866_.m_179617_(new ServerboundInteractPacket.Handler() { private void m_143678_(InteractionHand p_143679_, ServerGamePacketListenerImpl.EntityInteraction p_143680_) { + if(!ServerGamePacketListenerImpl.this.f_9743_.canInteractWith(entity, 1.5D)) return; //Forge: If the entity cannot be reached, do nothing. Original check was dist < 6, range is 4.5, so vanilla used padding=1.5 - ItemStack itemstack = ServerGamePacketListenerImpl.this.f_9743_.m_21120_(p_143679_).m_41777_(); - InteractionResult interactionresult = p_143680_.m_143694_(ServerGamePacketListenerImpl.this.f_9743_, entity, p_143679_); - if (interactionresult.m_19077_()) { -@@ -1552,12 +_,16 @@ + ItemStack itemstack = ServerGamePacketListenerImpl.this.f_9743_.m_21120_(p_143679_); + if (itemstack.m_246617_(serverlevel.m_246046_())) { + ItemStack itemstack1 = itemstack.m_41777_(); +@@ -1457,6 +_,8 @@ public void m_142143_(InteractionHand p_143682_, Vec3 p_143683_) { this.m_143678_(p_143682_, (p_143686_, p_143687_, p_143688_) -> { @@ -97,15 +89,16 @@ return p_143687_.m_7111_(p_143686_, p_143683_, p_143688_); }); } - - public void m_141994_() { +@@ -1465,6 +_,8 @@ if (!(entity instanceof ItemEntity) && !(entity instanceof ExperienceOrb) && !(entity instanceof AbstractArrow) && entity != ServerGamePacketListenerImpl.this.f_9743_) { + ItemStack itemstack = ServerGamePacketListenerImpl.this.f_9743_.m_21120_(InteractionHand.MAIN_HAND); + if (itemstack.m_246617_(serverlevel.m_246046_())) { + //Forge: Perform attack range check. Original check was dist < 6, range is 3, so vanilla used padding=3 + if(ServerGamePacketListenerImpl.this.f_9743_.canHit(entity, 3)) - ServerGamePacketListenerImpl.this.f_9743_.m_5706_(entity); + ServerGamePacketListenerImpl.this.f_9743_.m_5706_(entity); + } } else { - ServerGamePacketListenerImpl.this.m_9942_(Component.m_237115_("multiplayer.disconnect.invalid_entity_attacked")); -@@ -1757,6 +_,7 @@ +@@ -1669,6 +_,7 @@ } public void m_7423_(ServerboundCustomPayloadPacket p_9860_) { diff --git a/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch index 09a0a2b4e6..cba3fee14f 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -65,7 +_,13 @@ +@@ -60,7 +_,13 @@ } public void m_9933_() { @@ -15,7 +15,7 @@ this.m_10055_(); } else if (this.f_10019_ == ServerLoginPacketListenerImpl.State.DELAY_ACCEPT) { ServerPlayer serverplayer = this.f_10018_.m_6846_().m_11259_(this.f_10021_.getId()); -@@ -178,14 +_,14 @@ +@@ -147,14 +_,14 @@ GameProfile gameprofile = this.f_10018_.m_236731_(); if (gameprofile != null && p_10047_.f_238040_().equalsIgnoreCase(gameprofile.getName())) { this.f_10021_ = gameprofile; @@ -25,14 +25,14 @@ this.f_10021_ = new GameProfile((UUID)null, p_10047_.f_238040_()); if (this.f_10018_.m_129797_() && !this.f_10013_.m_129531_()) { this.f_10019_ = ServerLoginPacketListenerImpl.State.KEY; - this.f_10013_.m_129512_(new ClientboundHelloPacket("", this.f_10018_.m_129790_().getPublic().getEncoded(), this.f_10017_)); + this.f_10013_.m_129512_(new ClientboundHelloPacket("", this.f_10018_.m_129790_().getPublic().getEncoded(), this.f_252396_)); } else { - this.f_10019_ = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; + this.f_10019_ = ServerLoginPacketListenerImpl.State.NEGOTIATING; // FORGE: continue NEGOTIATING, we move to READY_TO_ACCEPT after Forge is ready } } -@@ -222,7 +_,7 @@ +@@ -186,7 +_,7 @@ throw new IllegalStateException("Protocol error", cryptexception); } @@ -41,7 +41,7 @@ public void run() { GameProfile gameprofile = ServerLoginPacketListenerImpl.this.f_10021_; -@@ -230,11 +_,11 @@ +@@ -194,11 +_,11 @@ ServerLoginPacketListenerImpl.this.f_10021_ = ServerLoginPacketListenerImpl.this.f_10018_.m_129925_().hasJoinedServer(new GameProfile((UUID)null, gameprofile.getName()), s, this.m_10064_()); if (ServerLoginPacketListenerImpl.this.f_10021_ != null) { ServerLoginPacketListenerImpl.f_10015_.info("UUID of player {} is {}", ServerLoginPacketListenerImpl.this.f_10021_.getName(), ServerLoginPacketListenerImpl.this.f_10021_.getId()); @@ -55,7 +55,7 @@ } else { ServerLoginPacketListenerImpl.this.m_10053_(Component.m_237115_("multiplayer.disconnect.unverified_username")); ServerLoginPacketListenerImpl.f_10015_.error("Username '{}' tried to join with an invalid session", (Object)gameprofile.getName()); -@@ -243,7 +_,7 @@ +@@ -207,7 +_,7 @@ if (ServerLoginPacketListenerImpl.this.f_10018_.m_129792_()) { ServerLoginPacketListenerImpl.f_10015_.warn("Authentication servers are down but will let them in anyway!"); ServerLoginPacketListenerImpl.this.f_10021_ = gameprofile; @@ -64,7 +64,7 @@ } else { ServerLoginPacketListenerImpl.this.m_10053_(Component.m_237115_("multiplayer.disconnect.authservers_down")); ServerLoginPacketListenerImpl.f_10015_.error("Couldn't verify username because servers are unavailable"); -@@ -263,6 +_,7 @@ +@@ -227,6 +_,7 @@ } public void m_7223_(ServerboundCustomQueryPacket p_10045_) { diff --git a/patches/minecraft/net/minecraft/server/packs/AbstractPackResources.java.patch b/patches/minecraft/net/minecraft/server/packs/AbstractPackResources.java.patch index 71910403b7..a90395f330 100644 --- a/patches/minecraft/net/minecraft/server/packs/AbstractPackResources.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/AbstractPackResources.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/server/packs/AbstractPackResources.java +++ b/net/minecraft/server/packs/AbstractPackResources.java -@@ -120,4 +_,10 @@ - public String m_8017_() { - return this.f_10203_.getName(); +@@ -67,4 +_,10 @@ + public boolean m_246538_() { + return this.f_254645_; } + + @Override + public String toString() + { -+ return String.format(java.util.Locale.ROOT, "%s: %s", getClass().getName(), f_10203_.getPath()); ++ return String.format(java.util.Locale.ROOT, "%s: %s", getClass().getName(), this.f_243737_); + } } diff --git a/patches/minecraft/net/minecraft/server/packs/PackResources.java.patch b/patches/minecraft/net/minecraft/server/packs/PackResources.java.patch index 16a76607d9..4a94db64ed 100644 --- a/patches/minecraft/net/minecraft/server/packs/PackResources.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/PackResources.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/packs/PackResources.java +++ b/net/minecraft/server/packs/PackResources.java @@ -9,7 +_,7 @@ - import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.metadata.MetadataSectionSerializer; + import net.minecraft.server.packs.resources.IoSupplier; -public interface PackResources extends AutoCloseable { +public interface PackResources extends AutoCloseable, net.minecraftforge.common.extensions.IForgePackResources { diff --git a/patches/minecraft/net/minecraft/server/packs/VanillaPackResources.java.patch b/patches/minecraft/net/minecraft/server/packs/VanillaPackResources.java.patch index cd64436086..2590c4a518 100644 --- a/patches/minecraft/net/minecraft/server/packs/VanillaPackResources.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/VanillaPackResources.java.patch @@ -1,70 +1,58 @@ --- a/net/minecraft/server/packs/VanillaPackResources.java +++ b/net/minecraft/server/packs/VanillaPackResources.java -@@ -148,6 +_,9 @@ - try { - Path path = f_182296_.get(p_215346_); - if (path != null) { -+ if (net.minecraftforge.resource.ResourceCacheManager.shouldUseCache() && this.cacheManager.hasCached(p_215346_, p_215347_)) { -+ set.addAll(this.cacheManager.getResources(p_215346_, p_215347_, path.getFileSystem().getPath(p_215348_), p_215349_)); -+ } else - m_215357_(set, p_215347_, path, p_215348_, p_215349_); - } else { - f_10315_.error("Can't access assets root for type: {}", (Object)p_215346_); -@@ -210,7 +_,7 @@ - - try { - URL url = VanillaPackResources.class.getResource(s); -- return m_10335_(s, url) ? url.openStream() : null; -+ return m_10335_(s, url) ? getExtraInputStream(p_10359_, s) : null; - } catch (IOException ioexception) { - return VanillaPackResources.class.getResourceAsStream(s); - } -@@ -226,7 +_,7 @@ +@@ -32,6 +_,19 @@ + this.f_10314_ = p_250468_; + this.f_244169_ = p_248798_; + this.f_244459_ = p_251106_; ++ this.cacheManager = new net.minecraftforge.resource.ResourceCacheManager(false, "indexVanillaPackCachesOnThread", ++ (packType, namespace) -> { ++ List validPaths = new java.util.ArrayList<>(); ++ ++ for (Path basePath : this.f_244459_.getOrDefault(packType, List.of())) { ++ Path path = basePath.resolve(namespace); ++ if (Files.exists(path) && PathPackResources.m_246877_(path)) { ++ validPaths.add(path); ++ } ++ } ++ ++ return validPaths; ++ }); + } @Nullable - protected InputStream m_5539_(String p_10334_) { -- return VanillaPackResources.class.getResourceAsStream("/" + p_10334_); -+ return getExtraInputStream(PackType.SERVER_DATA, "/" + p_10334_); - } - - public boolean m_7211_(PackType p_10355_, ResourceLocation p_10356_) { -@@ -301,11 +_,39 @@ - public void close() { - } - -+ //Vanilla used to just grab from the classpath, this breaks dev environments, and Forge runtime -+ //as forge ships vanilla assets in an 'extra' jar with no classes. -+ //So find that extra jar using the .mcassetsroot marker. -+ private InputStream getExtraInputStream(PackType type, String resource) { -+ try { -+ Path rootDir = f_182296_.get(type); -+ if (rootDir != null) -+ return Files.newInputStream(rootDir.resolve(resource)); -+ return VanillaPackResources.class.getResourceAsStream(resource); -+ } catch (IOException e) { -+ return VanillaPackResources.class.getResourceAsStream(resource); -+ } -+ } +@@ -66,6 +_,14 @@ + public void m_8031_(PackType p_248974_, String p_248703_, String p_250848_, PackResources.ResourceOutput p_249668_) { + FileUtil.m_245538_(p_250848_).get().ifLeft((p_248228_) -> { + List list = this.f_244459_.get(p_248974_); ++ // TODO 1.19.3: Fix resource caching to actually work and produce valid results -SS ++ // if (net.minecraftforge.resource.ResourceCacheManager.shouldUseCache() && this.cacheManager.hasCached(p_248974_, p_248703_)) { ++ // for (Path rootPath : list) { ++ // this.cacheManager.listResources(p_248974_, p_248703_, FileUtil.resolvePath(rootPath, p_248228_), this::getResource, p_249668_); ++ // } ++ // return; ++ // } + - public ResourceProvider m_215363_() { - return (p_215344_) -> { - return Optional.of(new Resource(this.m_8017_(), () -> { - return this.m_8031_(PackType.CLIENT_RESOURCES, p_215344_); - })); + int i = list.size(); + if (i == 1) { + m_246310_(p_249668_, p_248703_, list.get(0), p_248228_); +@@ -161,5 +_,20 @@ + return new Resource(this, p_248221_); + }); }; + } + -+ private final net.minecraftforge.resource.ResourceCacheManager cacheManager = new net.minecraftforge.resource.ResourceCacheManager(false, "indexVanillaPackCachesOnThread", (packType, namespace) -> f_182296_.get(packType).resolve(namespace)); ++ private final net.minecraftforge.resource.ResourceCacheManager cacheManager; + + @Override -+ public void initForNamespace(final String nameSpace) { ++ public void initForNamespace(final String namespace) { + if (net.minecraftforge.resource.ResourceCacheManager.shouldUseCache()) -+ this.cacheManager.index(nameSpace); ++ this.cacheManager.index(namespace); + } + + @Override + public void init(final PackType packType) { -+ initForNamespace("minecraft"); //Default namespaces. ++ // Forge: Init vanilla namespaces ++ initForNamespace("minecraft"); + initForNamespace("realms"); } } diff --git a/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java.patch b/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java.patch index ef0387fef8..0d2ce817fe 100644 --- a/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java +++ b/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java -@@ -6,17 +_,29 @@ - public static final PackMetadataSectionSerializer f_10366_ = new PackMetadataSectionSerializer(); +@@ -7,17 +_,29 @@ + public static final MetadataSectionType f_243696_ = new PackMetadataSectionSerializer(); private final Component f_10367_; private final int f_10368_; + private final java.util.Map packTypeVersions; diff --git a/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch b/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch index e353c41815..ea69d81655 100644 --- a/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/packs/repository/Pack.java +++ b/net/minecraft/server/packs/repository/Pack.java -@@ -26,6 +_,7 @@ +@@ -27,6 +_,7 @@ private final Pack.Position f_10406_; private final boolean f_10407_; private final boolean f_10408_; @@ -8,47 +8,25 @@ private final PackSource f_10409_; @Nullable -@@ -38,7 +_,7 @@ - try { - PackMetadataSection packmetadatasection = packresources.m_5550_(PackMetadataSection.f_10366_); - if (packmetadatasection != null) { -- pack = p_10434_.m_143873_(p_10431_, Component.m_237113_(packresources.m_8017_()), p_10432_, p_10433_, packmetadatasection, p_10435_, p_10436_); -+ pack = p_10434_.create(p_10431_, Component.m_237113_(packresources.m_8017_()), p_10432_, p_10433_, packmetadatasection, p_10435_, p_10436_, packresources.isHidden()); - break label54; - } - -@@ -73,7 +_,12 @@ - } +@@ -50,6 +_,7 @@ + this.f_10406_ = p_251298_; + this.f_10408_ = p_249753_; + this.f_10409_ = p_251608_; ++ this.hidden = p_250162_.hidden(); } -+ @Deprecated - public Pack(String p_10420_, boolean p_10421_, Supplier p_10422_, Component p_10423_, Component p_10424_, PackCompatibility p_10425_, Pack.Position p_10426_, boolean p_10427_, PackSource p_10428_) { -+ this(p_10420_, p_10421_, p_10422_, p_10423_, p_10424_, p_10425_, p_10426_, p_10427_, p_10428_, false); -+ } -+ -+ public Pack(String p_10420_, boolean p_10421_, Supplier p_10422_, Component p_10423_, Component p_10424_, PackCompatibility p_10425_, Pack.Position p_10426_, boolean p_10427_, PackSource p_10428_, boolean hidden) { - this.f_10401_ = p_10420_; - this.f_10402_ = p_10422_; - this.f_10403_ = p_10423_; -@@ -83,10 +_,16 @@ - this.f_10406_ = p_10426_; - this.f_10408_ = p_10427_; - this.f_10409_ = p_10428_; -+ this.hidden = hidden; - } + @Nullable +@@ -68,7 +_,8 @@ -+ @Deprecated - public Pack(String p_143865_, Component p_143866_, boolean p_143867_, Supplier p_143868_, PackMetadataSection p_143869_, PackType p_143870_, Pack.Position p_143871_, PackSource p_143872_) { -- this(p_143865_, p_143867_, p_143868_, p_143866_, p_143869_.m_10373_(), PackCompatibility.m_143885_(p_143869_, p_143870_), p_143871_, false, p_143872_); -+ this(p_143865_, p_143867_, p_143868_, p_143866_, p_143869_.m_10373_(), PackCompatibility.m_143885_(p_143869_, p_143870_), p_143871_, false, p_143872_, false); -+ } -+ -+ public Pack(String p_143865_, Component p_143866_, boolean p_143867_, Supplier p_143868_, PackMetadataSection p_143869_, PackType p_143870_, Pack.Position p_143871_, PackSource p_143872_, boolean hidden) { -+ this(p_143865_, p_143867_, p_143868_, p_143866_, p_143869_.m_10373_(), PackCompatibility.m_143885_(p_143869_, p_143870_), p_143871_, false, p_143872_, hidden); - } + FeatureFlagsMetadataSection featureflagsmetadatasection = packresources.m_5550_(FeatureFlagsMetadataSection.f_244642_); + FeatureFlagSet featureflagset = featureflagsmetadatasection != null ? featureflagsmetadatasection.f_244197_() : FeatureFlagSet.m_246902_(); +- pack$info = new Pack.Info(packmetadatasection.m_10373_(), packmetadatasection.m_10374_(), featureflagset); ++ // Forge: Allow separate pack formats for server data and client resources and setting isHidden ++ pack$info = new Pack.Info(packmetadatasection.m_10373_(), packmetadatasection.getPackFormat(PackType.SERVER_DATA), packmetadatasection.getPackFormat(PackType.CLIENT_RESOURCES), featureflagset, packresources.isHidden()); + } - public Component m_10429_() { -@@ -131,6 +_,8 @@ + return pack$info; +@@ -127,6 +_,8 @@ return this.f_10409_; } @@ -57,21 +35,23 @@ public boolean equals(Object p_10448_) { if (this == p_10448_) { return true; -@@ -148,8 +_,15 @@ - - @FunctionalInterface - public interface PackConstructor { -- @Nullable -- Pack m_143873_(String p_143874_, Component p_143875_, boolean p_143876_, Supplier p_143877_, PackMetadataSection p_143878_, Pack.Position p_143879_, PackSource p_143880_); -+ @Deprecated -+ @Nullable -+ default Pack m_143873_(String p_143874_, Component p_143875_, boolean p_143876_, Supplier p_143877_, PackMetadataSection p_143878_, Pack.Position p_143879_, PackSource p_143880_) -+ { -+ return create(p_143874_, p_143875_, p_143876_, p_143877_, p_143878_, p_143879_, p_143880_, false); -+ } -+ -+ @Nullable -+ Pack create(String p_143874_, Component p_143875_, boolean p_143876_, Supplier p_143877_, PackMetadataSection p_143878_, Pack.Position p_143879_, PackSource p_143880_, boolean hidden); +@@ -142,9 +_,17 @@ + return this.f_10401_.hashCode(); + } + +- public static record Info(Component f_244592_, int f_244194_, FeatureFlagSet f_244041_) { ++ public static record Info(Component f_244592_, int dataFormat, int resourceFormat, FeatureFlagSet f_244041_, boolean hidden) { ++ public Info(Component f_244592_, int f_244194_, FeatureFlagSet f_244041_) { ++ this(f_244592_, f_244194_, f_244194_, f_244041_, false); ++ } ++ ++ public int getFormat(PackType type) { ++ return type == PackType.SERVER_DATA ? this.dataFormat : this.resourceFormat; ++ } ++ + public PackCompatibility m_246438_(PackType p_249204_) { +- return PackCompatibility.m_143882_(this.f_244194_, p_249204_); ++ return PackCompatibility.m_143882_(getFormat(p_249204_), p_249204_); + } } - public static enum Position { diff --git a/patches/minecraft/net/minecraft/server/packs/repository/PackCompatibility.java.patch b/patches/minecraft/net/minecraft/server/packs/repository/PackCompatibility.java.patch deleted file mode 100644 index 87a0fd6343..0000000000 --- a/patches/minecraft/net/minecraft/server/packs/repository/PackCompatibility.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/packs/repository/PackCompatibility.java -+++ b/net/minecraft/server/packs/repository/PackCompatibility.java -@@ -33,7 +_,7 @@ - } - - public static PackCompatibility m_143885_(PackMetadataSection p_143886_, PackType p_143887_) { -- return m_143882_(p_143886_.m_10374_(), p_143887_); -+ return m_143882_(p_143886_.getPackFormat(p_143887_), p_143887_); - } - - public Component m_10492_() { diff --git a/patches/minecraft/net/minecraft/server/packs/repository/PackRepository.java.patch b/patches/minecraft/net/minecraft/server/packs/repository/PackRepository.java.patch index f2fcc8286a..6d2cf03a5e 100644 --- a/patches/minecraft/net/minecraft/server/packs/repository/PackRepository.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/repository/PackRepository.java.patch @@ -1,24 +1,15 @@ --- a/net/minecraft/server/packs/repository/PackRepository.java +++ b/net/minecraft/server/packs/repository/PackRepository.java -@@ -24,13 +_,14 @@ +@@ -22,7 +_,7 @@ + private List f_10499_ = ImmutableList.of(); - public PackRepository(Pack.PackConstructor p_10502_, RepositorySource... p_10503_) { - this.f_10500_ = p_10502_; -- this.f_10497_ = ImmutableSet.copyOf(p_10503_); -+ this.f_10497_ = new java.util.HashSet<>(java.util.Arrays.asList(p_10503_)); - } - - public PackRepository(PackType p_143890_, RepositorySource... p_143891_) { -- this((p_143894_, p_143895_, p_143896_, p_143897_, p_143898_, p_143899_, p_143900_) -> { -- return new Pack(p_143894_, p_143895_, p_143896_, p_143897_, p_143898_, p_143890_, p_143899_, p_143900_); -+ this((p_143894_, p_143895_, p_143896_, p_143897_, p_143898_, p_143899_, p_143900_, hidden) -> { -+ return new Pack(p_143894_, p_143895_, p_143896_, p_143897_, p_143898_, p_143890_, p_143899_, p_143900_, hidden); - }, p_143891_); -+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.event.AddPackFindersEvent(p_143890_, f_10497_::add)); + public PackRepository(RepositorySource... p_251886_) { +- this.f_10497_ = ImmutableSet.copyOf(p_251886_); ++ this.f_10497_ = new java.util.HashSet<>(List.of(p_251886_)); //Forge: This needs to be a mutable set, so that we can add to it later on. } public void m_10506_() { -@@ -90,6 +_,10 @@ +@@ -86,6 +_,10 @@ @Nullable public Pack m_10507_(String p_10508_) { return this.f_10498_.get(p_10508_); diff --git a/patches/minecraft/net/minecraft/server/packs/repository/ServerPacksSource.java.patch b/patches/minecraft/net/minecraft/server/packs/repository/ServerPacksSource.java.patch new file mode 100644 index 0000000000..c47942149e --- /dev/null +++ b/patches/minecraft/net/minecraft/server/packs/repository/ServerPacksSource.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/server/packs/repository/ServerPacksSource.java ++++ b/net/minecraft/server/packs/repository/ServerPacksSource.java +@@ -48,7 +_,9 @@ + } + + public static PackRepository m_245786_(Path p_251569_) { +- return new PackRepository(new ServerPacksSource(), new FolderRepositorySource(p_251569_, PackType.SERVER_DATA, PackSource.f_10529_)); ++ final PackRepository packRepository = new PackRepository(new ServerPacksSource(), new FolderRepositorySource(p_251569_, PackType.SERVER_DATA, PackSource.f_10529_)); ++ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.event.AddPackFindersEvent(PackType.SERVER_DATA, packRepository::addPackFinder)); ++ return packRepository; + } + + public static PackRepository m_247728_(LevelStorageSource.LevelStorageAccess p_250213_) { diff --git a/patches/minecraft/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch b/patches/minecraft/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch index a2ff6a4283..aceeb04c34 100644 --- a/patches/minecraft/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java +++ b/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java -@@ -71,4 +_,8 @@ +@@ -48,4 +_,8 @@ return map; } diff --git a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch index 83c53122a9..3e288bf5d6 100644 --- a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch +++ b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -125,6 +_,7 @@ +@@ -131,6 +_,7 @@ private boolean f_11209_; private static final boolean f_143988_ = false; private int f_11210_; + private final List playersView = java.util.Collections.unmodifiableList(f_11196_); - public PlayerList(MinecraftServer p_203842_, RegistryAccess.Frozen p_203843_, PlayerDataStorage p_203844_, int p_203845_) { + public PlayerList(MinecraftServer p_203842_, LayeredRegistryAccess p_251844_, PlayerDataStorage p_203844_, int p_203845_) { this.f_11195_ = p_203842_; -@@ -160,6 +_,7 @@ +@@ -167,6 +_,7 @@ LevelData leveldata = serverlevel1.m_6106_(); p_11263_.m_143427_(compoundtag); ServerGamePacketListenerImpl servergamepacketlistenerimpl = new ServerGamePacketListenerImpl(this.f_11195_, p_11262_, p_11263_); @@ -16,15 +16,15 @@ GameRules gamerules = serverlevel1.m_46469_(); boolean flag = gamerules.m_46207_(GameRules.f_46156_); boolean flag1 = gamerules.m_46207_(GameRules.f_46145_); -@@ -168,6 +_,7 @@ +@@ -176,6 +_,7 @@ servergamepacketlistenerimpl.m_9829_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); servergamepacketlistenerimpl.m_9829_(new ClientboundPlayerAbilitiesPacket(p_11263_.m_150110_())); servergamepacketlistenerimpl.m_9829_(new ClientboundSetCarriedItemPacket(p_11263_.m_150109_().f_35977_)); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.OnDatapackSyncEvent(this, p_11263_)); servergamepacketlistenerimpl.m_9829_(new ClientboundUpdateRecipesPacket(this.f_11195_.m_129894_().m_44051_())); - servergamepacketlistenerimpl.m_9829_(new ClientboundUpdateTagsPacket(TagNetworkSerialization.m_203950_(this.f_11206_))); + servergamepacketlistenerimpl.m_9829_(new ClientboundUpdateTagsPacket(TagNetworkSerialization.m_245799_(this.f_243858_))); this.m_11289_(p_11263_); -@@ -240,6 +_,7 @@ +@@ -244,6 +_,7 @@ } p_11263_.m_143429_(); @@ -32,7 +32,7 @@ } protected void m_11273_(ServerScoreboard p_11274_, ServerPlayer p_11275_) { -@@ -300,6 +_,7 @@ +@@ -304,6 +_,7 @@ compoundtag1 = compoundtag; p_11225_.m_20258_(compoundtag); f_11188_.debug("loading single player"); @@ -40,7 +40,7 @@ } else { compoundtag1 = this.f_11204_.m_78435_(p_11225_); } -@@ -308,6 +_,7 @@ +@@ -312,6 +_,7 @@ } protected void m_6765_(ServerPlayer p_11277_) { @@ -48,7 +48,7 @@ this.f_11204_.m_78433_(p_11277_); ServerStatsCounter serverstatscounter = this.f_11202_.get(p_11277_.m_20148_()); if (serverstatscounter != null) { -@@ -322,6 +_,7 @@ +@@ -326,6 +_,7 @@ } public void m_11286_(ServerPlayer p_11287_) { @@ -56,7 +56,7 @@ ServerLevel serverlevel = p_11287_.m_9236_(); p_11287_.m_36220_(Stats.f_12989_); this.m_6765_(p_11287_); -@@ -462,6 +_,7 @@ +@@ -467,6 +_,7 @@ this.f_11197_.put(serverplayer.m_20148_(), serverplayer); serverplayer.m_143429_(); serverplayer.m_21153_(serverplayer.m_21223_()); @@ -64,7 +64,7 @@ if (flag2) { serverplayer.f_8906_.m_9829_(new ClientboundSoundPacket(SoundEvents.f_12377_, SoundSource.BLOCKS, (double)blockpos.m_123341_(), (double)blockpos.m_123342_(), (double)blockpos.m_123343_(), 1.0F, 1.0F, serverlevel1.m_213780_().m_188505_())); } -@@ -546,6 +_,7 @@ +@@ -551,6 +_,7 @@ } public void m_5749_(GameProfile p_11254_) { @@ -72,7 +72,7 @@ this.f_11200_.m_11381_(new ServerOpListEntry(p_11254_, this.f_11195_.m_7022_(), this.f_11200_.m_11351_(p_11254_))); ServerPlayer serverplayer = this.m_11259_(p_11254_.getId()); if (serverplayer != null) { -@@ -555,6 +_,7 @@ +@@ -560,6 +_,7 @@ } public void m_5750_(GameProfile p_11281_) { @@ -80,7 +80,7 @@ this.f_11200_.m_11393_(p_11281_); ServerPlayer serverplayer = this.m_11259_(p_11281_.getId()); if (serverplayer != null) { -@@ -784,13 +_,6 @@ +@@ -774,13 +_,6 @@ if (serverstatscounter == null) { File file1 = this.f_11195_.m_129843_(LevelResource.f_78175_).toFile(); File file2 = new File(file1, uuid + ".json"); @@ -94,7 +94,7 @@ serverstatscounter = new ServerStatsCounter(this.f_11195_, file2); this.f_11202_.put(uuid, serverstatscounter); -@@ -809,6 +_,8 @@ +@@ -799,6 +_,8 @@ this.f_11203_.put(uuid, playeradvancements); } @@ -103,7 +103,7 @@ playeradvancements.m_135979_(p_11297_); return playeradvancements; } -@@ -838,7 +_,7 @@ +@@ -828,7 +_,7 @@ } public List m_11314_() { @@ -112,11 +112,11 @@ } @Nullable -@@ -855,6 +_,7 @@ +@@ -845,6 +_,7 @@ playeradvancements.m_135981_(this.f_11195_.m_129889_()); } + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.OnDatapackSyncEvent(this, null)); - this.m_11268_(new ClientboundUpdateTagsPacket(TagNetworkSerialization.m_203950_(this.f_11206_))); + this.m_11268_(new ClientboundUpdateTagsPacket(TagNetworkSerialization.m_245799_(this.f_243858_))); ClientboundUpdateRecipesPacket clientboundupdaterecipespacket = new ClientboundUpdateRecipesPacket(this.f_11195_.m_129894_().m_44051_()); diff --git a/patches/minecraft/net/minecraft/server/rcon/thread/RconClient.java.patch b/patches/minecraft/net/minecraft/server/rcon/thread/RconClient.java.patch index 90684bf9a7..02117a1aaa 100644 --- a/patches/minecraft/net/minecraft/server/rcon/thread/RconClient.java.patch +++ b/patches/minecraft/net/minecraft/server/rcon/thread/RconClient.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/rcon/thread/RconClient.java +++ b/net/minecraft/server/rcon/thread/RconClient.java -@@ -126,13 +_,14 @@ +@@ -123,13 +_,14 @@ } private void m_11594_(int p_11595_, String p_11596_) throws IOException { diff --git a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch index 8e0a5065a5..f4b1b08277 100644 --- a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/tags/BlockTags.java +++ b/net/minecraft/tags/BlockTags.java -@@ -164,4 +_,8 @@ +@@ -169,4 +_,8 @@ private static TagKey m_203846_(String p_203847_) { - return TagKey.m_203882_(Registry.f_122901_, new ResourceLocation(p_203847_)); + return TagKey.m_203882_(Registries.f_256747_, new ResourceLocation(p_203847_)); } + + public static TagKey create(ResourceLocation name) { -+ return TagKey.m_203882_(Registry.f_122901_, name); ++ return TagKey.m_203882_(Registries.f_256747_, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/FluidTags.java.patch b/patches/minecraft/net/minecraft/tags/FluidTags.java.patch index c6601f56da..1a1439053d 100644 --- a/patches/minecraft/net/minecraft/tags/FluidTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/FluidTags.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/tags/FluidTags.java @@ -14,4 +_,8 @@ private static TagKey m_203850_(String p_203851_) { - return TagKey.m_203882_(Registry.f_122899_, new ResourceLocation(p_203851_)); + return TagKey.m_203882_(Registries.f_256808_, new ResourceLocation(p_203851_)); } + + public static TagKey create(ResourceLocation name) { -+ return TagKey.m_203882_(Registry.f_122899_, name); ++ return TagKey.m_203882_(Registries.f_256808_, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/ItemTags.java.patch b/patches/minecraft/net/minecraft/tags/ItemTags.java.patch index 71cef07c57..e509d6e076 100644 --- a/patches/minecraft/net/minecraft/tags/ItemTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/ItemTags.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/tags/ItemTags.java +++ b/net/minecraft/tags/ItemTags.java -@@ -89,4 +_,8 @@ +@@ -93,4 +_,8 @@ private static TagKey m_203854_(String p_203855_) { - return TagKey.m_203882_(Registry.f_122904_, new ResourceLocation(p_203855_)); + return TagKey.m_203882_(Registries.f_256913_, new ResourceLocation(p_203855_)); } + + public static TagKey create(final ResourceLocation name) { -+ return TagKey.m_203882_(Registry.f_122904_, name); ++ return TagKey.m_203882_(Registries.f_256913_, name); + } } diff --git a/patches/minecraft/net/minecraft/tags/TagLoader.java.patch b/patches/minecraft/net/minecraft/tags/TagLoader.java.patch index 398f175bcc..ddb36da1ab 100644 --- a/patches/minecraft/net/minecraft/tags/TagLoader.java.patch +++ b/patches/minecraft/net/minecraft/tags/TagLoader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/TagLoader.java +++ b/net/minecraft/tags/TagLoader.java -@@ -164,7 +_,7 @@ +@@ -146,7 +_,7 @@ p_203899_.keySet().forEach((p_216008_) -> { m_144523_(p_203899_, multimap, set, p_216008_, (p_215984_, p_215985_) -> { this.m_215978_(lookup, p_215985_).ifLeft((p_215977_) -> { diff --git a/patches/minecraft/net/minecraft/tags/TagManager.java.patch b/patches/minecraft/net/minecraft/tags/TagManager.java.patch index 1cf108c357..440cf21d53 100644 --- a/patches/minecraft/net/minecraft/tags/TagManager.java.patch +++ b/patches/minecraft/net/minecraft/tags/TagManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/TagManager.java +++ b/net/minecraft/tags/TagManager.java -@@ -30,7 +_,7 @@ +@@ -31,7 +_,7 @@ public static String m_203918_(ResourceKey> p_203919_) { String s = f_203902_.get(p_203919_); diff --git a/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch b/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch index 5904935cbb..68825a6b37 100644 --- a/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch +++ b/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch @@ -9,7 +9,7 @@ private static final Logger f_19501_ = LogUtils.getLogger(); private final MobEffect f_19502_; int f_19503_; -@@ -74,6 +_,7 @@ +@@ -73,6 +_,7 @@ this.f_19506_ = p_19549_.f_19506_; this.f_19508_ = p_19549_.f_19508_; this.f_19509_ = p_19549_.f_19509_; @@ -17,7 +17,7 @@ } public boolean m_19558_(MobEffectInstance p_19559_) { -@@ -130,7 +_,7 @@ +@@ -129,7 +_,7 @@ } public MobEffect m_19544_() { @@ -26,7 +26,7 @@ } public int m_19557_() { -@@ -231,6 +_,7 @@ +@@ -230,6 +_,7 @@ public CompoundTag m_19555_(CompoundTag p_19556_) { p_19556_.m_128405_("Id", MobEffect.m_19459_(this.m_19544_())); @@ -34,7 +34,7 @@ this.m_19567_(p_19556_); return p_19556_; } -@@ -246,6 +_,7 @@ +@@ -245,6 +_,7 @@ this.f_19510_.m_19555_(compoundtag); p_19568_.m_128365_("HiddenEffect", compoundtag); } @@ -42,7 +42,7 @@ this.f_216885_.ifPresent((p_216903_) -> { MobEffectInstance.FactorData.f_216907_.encodeStart(NbtOps.f_128958_, p_216903_).resultOrPartial(f_19501_::error).ifPresent((p_216906_) -> { -@@ -256,8 +_,9 @@ +@@ -255,8 +_,9 @@ @Nullable public static MobEffectInstance m_19560_(CompoundTag p_19561_) { @@ -53,7 +53,7 @@ return mobeffect == null ? null : m_19545_(mobeffect, p_19561_); } -@@ -287,7 +_,7 @@ +@@ -286,12 +_,38 @@ optional = Optional.empty(); } @@ -61,9 +61,6 @@ + return readCurativeItems(new MobEffectInstance(p_19546_, j, Math.max(0, i), flag, flag1, flag2, mobeffectinstance, optional), p_19547_); } - public void m_19562_(boolean p_19563_) { -@@ -300,7 +_,33 @@ - public int compareTo(MobEffectInstance p_19566_) { int i = 32147; - return (this.m_19557_() <= 32147 || p_19566_.m_19557_() <= 32147) && (!this.m_19571_() || !p_19566_.m_19571_()) ? ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19557_(), p_19566_.m_19557_()).compare(this.m_19544_().m_19484_(), p_19566_.m_19544_().m_19484_()).result() : ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19544_().m_19484_(), p_19566_.m_19544_().m_19484_()).result(); diff --git a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch index b60b1df2a8..43ebf641d7 100644 --- a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch @@ -122,7 +122,7 @@ } } -@@ -728,10 +_,10 @@ +@@ -736,10 +_,10 @@ int j = Mth.m_14107_(this.f_19825_.f_82480_ - (double)p_216987_); int k = Mth.m_14107_(this.f_19825_.f_82481_); BlockPos blockpos = new BlockPos(i, j, k); @@ -135,7 +135,7 @@ return blockpos1; } } -@@ -804,10 +_,11 @@ +@@ -812,10 +_,11 @@ boolean flag1 = p_20273_.f_82480_ != vec3.f_82480_; boolean flag2 = p_20273_.f_82481_ != vec3.f_82481_; boolean flag3 = this.f_19861_ || flag1 && p_20273_.f_82480_ < 0.0D; @@ -151,16 +151,16 @@ Vec3 vec33 = m_198894_(this, new Vec3(p_20273_.f_82479_, 0.0D, p_20273_.f_82481_), aabb.m_82383_(vec32), this.f_19853_, list).m_82549_(vec32); if (vec33.m_165925_() > vec31.m_165925_()) { vec31 = vec33; -@@ -934,7 +_,7 @@ - protected void m_7355_(BlockPos p_20135_, BlockState p_20136_) { - if (!p_20136_.m_60767_().m_76332_()) { - BlockState blockstate = this.f_19853_.m_8055_(p_20135_.m_7494_()); -- SoundType soundtype = blockstate.m_204336_(BlockTags.f_144271_) ? blockstate.m_60827_() : p_20136_.m_60827_(); +@@ -943,7 +_,7 @@ + BlockState blockstate = this.f_19853_.m_8055_(p_20135_.m_7494_()); + boolean flag = blockstate.m_204336_(BlockTags.f_144271_); + if (flag || !p_20136_.m_60767_().m_76332_()) { +- SoundType soundtype = flag ? blockstate.m_60827_() : p_20136_.m_60827_(); + SoundType soundtype = blockstate.m_60713_(Blocks.f_50125_) ? blockstate.getSoundType(f_19853_, p_20135_, this) : p_20136_.getSoundType(f_19853_, p_20135_, this); this.m_5496_(soundtype.m_56776_(), soundtype.m_56773_() * 0.15F, soundtype.m_56774_()); } } -@@ -1063,19 +_,22 @@ +@@ -1068,19 +_,22 @@ public void m_5844_() { if (this.m_6069_()) { @@ -188,7 +188,7 @@ } void m_20074_() { -@@ -1098,6 +_,7 @@ +@@ -1109,6 +_,7 @@ private void m_20323_() { this.f_19800_ = this.m_204029_(FluidTags.f_13131_); this.f_19801_.clear(); @@ -196,7 +196,7 @@ double d0 = this.m_20188_() - (double)0.11111111F; Entity entity = this.m_20202_(); if (entity instanceof Boat boat) { -@@ -1110,7 +_,7 @@ +@@ -1121,7 +_,7 @@ FluidState fluidstate = this.f_19853_.m_6425_(blockpos); double d1 = (double)((float)blockpos.m_123342_() + fluidstate.m_76155_(this.f_19853_, blockpos)); if (d1 > d0) { @@ -205,7 +205,7 @@ } } -@@ -1154,7 +_,7 @@ +@@ -1165,7 +_,7 @@ } public boolean m_5843_() { @@ -214,7 +214,7 @@ } protected void m_20076_() { -@@ -1163,19 +_,23 @@ +@@ -1174,19 +_,23 @@ int k = Mth.m_14107_(this.m_20189_()); BlockPos blockpos = new BlockPos(i, j, k); BlockState blockstate = this.f_19853_.m_8055_(blockpos); @@ -240,7 +240,7 @@ } public void m_19920_(float p_19921_, Vec3 p_19922_) { -@@ -1489,6 +_,8 @@ +@@ -1500,6 +_,8 @@ p_20241_.m_128379_("HasVisualFire", this.f_146813_); } @@ -249,7 +249,7 @@ if (!this.f_19841_.isEmpty()) { ListTag listtag = new ListTag(); -@@ -1499,6 +_,10 @@ +@@ -1510,6 +_,10 @@ p_20241_.m_128365_("Tags", listtag); } @@ -260,7 +260,7 @@ this.m_7380_(p_20241_); if (this.m_20160_()) { ListTag listtag1 = new ListTag(); -@@ -1574,6 +_,9 @@ +@@ -1585,6 +_,9 @@ this.m_146915_(p_20259_.m_128471_("Glowing")); this.m_146917_(p_20259_.m_128451_("TicksFrozen")); this.f_146813_ = p_20259_.m_128471_("HasVisualFire"); @@ -270,7 +270,7 @@ if (p_20259_.m_128425_("Tags", 9)) { this.f_19841_.clear(); ListTag listtag3 = p_20259_.m_128437_("Tags", 8); -@@ -1662,6 +_,8 @@ +@@ -1673,6 +_,8 @@ } else { ItemEntity itementity = new ItemEntity(this.f_19853_, this.m_20185_(), this.m_20186_() + (double)p_19986_, this.m_20189_(), p_19985_); itementity.m_32060_(); @@ -279,7 +279,7 @@ this.f_19853_.m_7967_(itementity); return itementity; } -@@ -1698,6 +_,7 @@ +@@ -1709,6 +_,7 @@ public void m_6083_() { this.m_20256_(Vec3.f_82478_); @@ -287,7 +287,7 @@ this.m_8119_(); if (this.m_20159_()) { this.m_20202_().m_7332_(this); -@@ -1744,6 +_,7 @@ +@@ -1755,6 +_,7 @@ } } @@ -295,7 +295,7 @@ if (p_19967_ || this.m_7341_(p_19966_) && p_19966_.m_7310_(this)) { if (this.m_20159_()) { this.m_8127_(); -@@ -1782,6 +_,7 @@ +@@ -1793,6 +_,7 @@ public void m_6038_() { if (this.f_19824_ != null) { Entity entity = this.f_19824_; @@ -303,7 +303,7 @@ this.f_19824_ = null; entity.m_20351_(this); } -@@ -1957,6 +_,8 @@ +@@ -1972,6 +_,8 @@ return !this.f_19823_.isEmpty(); } @@ -312,7 +312,7 @@ public boolean m_6146_() { return true; } -@@ -2006,7 +_,7 @@ +@@ -2021,7 +_,7 @@ } public boolean m_20143_() { @@ -321,7 +321,7 @@ } public void m_20282_(boolean p_20283_) { -@@ -2112,7 +_,7 @@ +@@ -2127,7 +_,7 @@ this.m_20254_(8); } @@ -330,7 +330,7 @@ } public void m_6845_(boolean p_20313_) { -@@ -2201,7 +_,7 @@ +@@ -2223,7 +_,7 @@ } protected Component m_5677_() { @@ -339,7 +339,7 @@ } public boolean m_7306_(Entity p_20356_) { -@@ -2257,14 +_,20 @@ +@@ -2279,14 +_,20 @@ @Nullable public Entity m_5489_(ServerLevel p_20118_) { @@ -361,7 +361,7 @@ this.f_19853_.m_46473_().m_6182_("reloading"); Entity entity = this.m_6095_().m_20615_(p_20118_); if (entity != null) { -@@ -2272,17 +_,19 @@ +@@ -2294,17 +_,19 @@ entity.m_7678_(portalinfo.f_77676_.f_82479_, portalinfo.f_77676_.f_82480_, portalinfo.f_77676_.f_82481_, portalinfo.f_77678_, entity.m_146909_()); entity.m_20256_(portalinfo.f_77677_); p_20118_.m_143334_(entity); @@ -383,7 +383,7 @@ } } else { return null; -@@ -2404,6 +_,7 @@ +@@ -2426,6 +_,7 @@ return this.f_19821_; } @@ -391,7 +391,7 @@ public boolean m_6063_() { return true; } -@@ -2483,8 +_,10 @@ +@@ -2518,8 +_,10 @@ EntityDimensions entitydimensions = this.f_19815_; Pose pose = this.m_20089_(); EntityDimensions entitydimensions1 = this.m_6972_(pose); @@ -403,7 +403,7 @@ this.m_20090_(); boolean flag = (double)entitydimensions1.f_20377_ <= 4.0D && (double)entitydimensions1.f_20378_ <= 4.0D; if (!this.f_19853_.f_46443_ && !this.f_19803_ && !this.f_19794_ && flag && (entitydimensions1.f_20377_ > entitydimensions.f_20377_ || entitydimensions1.f_20378_ > entitydimensions.f_20378_) && !(this instanceof Player)) { -@@ -2492,8 +_,9 @@ +@@ -2527,8 +_,9 @@ double d0 = (double)Math.max(0.0F, entitydimensions1.f_20377_ - entitydimensions.f_20377_) + 1.0E-6D; double d1 = (double)Math.max(0.0F, entitydimensions1.f_20378_ - entitydimensions.f_20378_) + 1.0E-6D; VoxelShape voxelshape = Shapes.m_83064_(AABB.m_165882_(vec3, d0, d1, d0)); @@ -414,7 +414,7 @@ }); } -@@ -2768,9 +_,17 @@ +@@ -2807,9 +_,17 @@ this.f_19859_ = this.m_146908_(); } @@ -433,7 +433,7 @@ } else { AABB aabb = this.m_20191_().m_82406_(0.001D); int i = Mth.m_14107_(aabb.f_82288_); -@@ -2785,25 +_,28 @@ +@@ -2824,25 +_,28 @@ Vec3 vec3 = Vec3.f_82478_; int k1 = 0; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); @@ -469,7 +469,7 @@ } } } -@@ -2811,27 +_,28 @@ +@@ -2850,27 +_,28 @@ } } @@ -508,7 +508,7 @@ } } -@@ -2844,7 +_,10 @@ +@@ -2883,7 +_,10 @@ return !this.f_19853_.m_151572_(i, k, j, l); } @@ -519,7 +519,7 @@ return this.f_19799_.getDouble(p_204037_); } -@@ -2970,6 +_,7 @@ +@@ -3015,6 +_,7 @@ this.f_146801_.m_142044_(); } @@ -527,7 +527,7 @@ } -@@ -3085,6 +_,103 @@ +@@ -3130,6 +_,103 @@ public boolean m_142265_(Level p_146843_, BlockPos p_146844_) { return true; } diff --git a/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch index c70451fd28..e748486733 100644 --- a/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -292,6 +_,11 @@ - private ResourceLocation f_20546_; +@@ -300,6 +_,11 @@ private final EntityDimensions f_20547_; + private final FeatureFlagSet f_244139_; + private final java.util.function.Predicate> velocityUpdateSupplier; + private final java.util.function.ToIntFunction> trackingRangeSupplier; @@ -10,22 +10,22 @@ + private final java.util.function.BiFunction customClientFactory; + private static EntityType m_20634_(String p_20635_, EntityType.Builder p_20636_) { - return Registry.m_122961_(Registry.f_122826_, p_20635_, p_20636_.m_20712_(p_20635_)); + return Registry.m_122961_(BuiltInRegistries.f_256780_, p_20635_, p_20636_.m_20712_(p_20635_)); } -@@ -305,6 +_,9 @@ +@@ -313,6 +_,9 @@ } - public EntityType(EntityType.EntityFactory p_20574_, MobCategory p_20575_, boolean p_20576_, boolean p_20577_, boolean p_20578_, boolean p_20579_, ImmutableSet p_20580_, EntityDimensions p_20581_, int p_20582_, int p_20583_) { -+ this(p_20574_, p_20575_, p_20576_, p_20577_, p_20578_, p_20579_, p_20580_, p_20581_, p_20582_, p_20583_, EntityType::defaultVelocitySupplier, EntityType::defaultTrackingRangeSupplier, EntityType::defaultUpdateIntervalSupplier, null); + public EntityType(EntityType.EntityFactory p_251402_, MobCategory p_251431_, boolean p_251439_, boolean p_251973_, boolean p_252007_, boolean p_250908_, ImmutableSet p_250201_, EntityDimensions p_251742_, int p_250479_, int p_249249_, FeatureFlagSet p_250427_) { ++ this(p_251402_, p_251431_, p_251439_, p_251973_, p_252007_, p_250908_, p_250201_, p_251742_, p_250479_, p_249249_, p_250427_, EntityType::defaultVelocitySupplier, EntityType::defaultTrackingRangeSupplier, EntityType::defaultUpdateIntervalSupplier, null); + } -+ public EntityType(EntityType.EntityFactory p_20574_, MobCategory p_20575_, boolean p_20576_, boolean p_20577_, boolean p_20578_, boolean p_20579_, ImmutableSet p_20580_, EntityDimensions p_20581_, int p_20582_, int p_20583_, final java.util.function.Predicate> velocityUpdateSupplier, final java.util.function.ToIntFunction> trackingRangeSupplier, final java.util.function.ToIntFunction> updateIntervalSupplier, final java.util.function.BiFunction customClientFactory) { - this.f_20535_ = p_20574_; - this.f_20536_ = p_20575_; - this.f_20541_ = p_20579_; -@@ -315,6 +_,10 @@ - this.f_20547_ = p_20581_; - this.f_20542_ = p_20582_; - this.f_20543_ = p_20583_; ++ public EntityType(EntityType.EntityFactory p_251402_, MobCategory p_251431_, boolean p_251439_, boolean p_251973_, boolean p_252007_, boolean p_250908_, ImmutableSet p_250201_, EntityDimensions p_251742_, int p_250479_, int p_249249_, FeatureFlagSet p_250427_, final java.util.function.Predicate> velocityUpdateSupplier, final java.util.function.ToIntFunction> trackingRangeSupplier, final java.util.function.ToIntFunction> updateIntervalSupplier, final java.util.function.BiFunction customClientFactory) { + this.f_20535_ = p_251402_; + this.f_20536_ = p_251431_; + this.f_20541_ = p_250908_; +@@ -324,6 +_,10 @@ + this.f_20542_ = p_250479_; + this.f_20543_ = p_249249_; + this.f_244139_ = p_250427_; + this.velocityUpdateSupplier = velocityUpdateSupplier; + this.trackingRangeSupplier = trackingRangeSupplier; + this.updateIntervalSupplier = updateIntervalSupplier; @@ -33,15 +33,15 @@ } @Nullable -@@ -326,6 +_,7 @@ - public T m_20600_(ServerLevel p_20601_, @Nullable CompoundTag p_20602_, @Nullable Component p_20603_, @Nullable Player p_20604_, BlockPos p_20605_, MobSpawnType p_20606_, boolean p_20607_, boolean p_20608_) { - T t = this.m_20655_(p_20601_, p_20602_, p_20603_, p_20604_, p_20605_, p_20606_, p_20607_, p_20608_); +@@ -371,6 +_,7 @@ + public T m_262455_(ServerLevel p_262704_, @Nullable CompoundTag p_262603_, @Nullable Consumer p_262621_, BlockPos p_262672_, MobSpawnType p_262644_, boolean p_262690_, boolean p_262590_) { + T t = this.m_262451_(p_262704_, p_262603_, p_262621_, p_262672_, p_262644_, p_262690_, p_262590_); if (t != null) { -+ if (t instanceof net.minecraft.world.entity.Mob && net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn((net.minecraft.world.entity.Mob) t, p_20601_, p_20605_.m_123341_(), p_20605_.m_123342_(), p_20605_.m_123343_(), null, p_20606_)) return null; - p_20601_.m_47205_(t); ++ if (t instanceof net.minecraft.world.entity.Mob && net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn((net.minecraft.world.entity.Mob) t, p_262704_, p_262672_.m_123341_(), p_262672_.m_123342_(), p_262672_.m_123343_(), null, p_262644_)) return null; + p_262704_.m_47205_(t); } -@@ -543,14 +_,23 @@ +@@ -591,14 +_,23 @@ } public int m_20681_() { @@ -65,7 +65,7 @@ return this != f_20532_ && this != f_20467_ && this != f_20496_ && this != f_20549_ && this != f_20462_ && this != f_147033_ && this != f_20464_ && this != f_20506_ && this != f_20564_ && this != f_20569_; } -@@ -573,6 +_,12 @@ +@@ -621,6 +_,12 @@ return this.f_204038_; } @@ -78,9 +78,9 @@ public static class Builder { private final EntityType.EntityFactory f_20685_; private final MobCategory f_20686_; -@@ -585,6 +_,11 @@ - private int f_20693_ = 3; +@@ -634,6 +_,11 @@ private EntityDimensions f_20694_ = EntityDimensions.m_20395_(0.6F, 1.8F); + private FeatureFlagSet f_244453_ = FeatureFlags.f_244377_; + private java.util.function.Predicate> velocityUpdateSupplier = EntityType::defaultVelocitySupplier; + private java.util.function.ToIntFunction> trackingRangeSupplier = EntityType::defaultTrackingRangeSupplier; @@ -90,7 +90,7 @@ private Builder(EntityType.EntityFactory p_20696_, MobCategory p_20697_) { this.f_20685_ = p_20696_; this.f_20686_ = p_20697_; -@@ -641,12 +_,36 @@ +@@ -695,12 +_,36 @@ return this; } @@ -123,8 +123,8 @@ Util.m_137456_(References.f_16785_, p_20713_); } -- return new EntityType<>(this.f_20685_, this.f_20686_, this.f_20688_, this.f_20689_, this.f_20690_, this.f_20691_, this.f_20687_, this.f_20694_, this.f_20692_, this.f_20693_); -+ return new EntityType<>(this.f_20685_, this.f_20686_, this.f_20688_, this.f_20689_, this.f_20690_, this.f_20691_, this.f_20687_, this.f_20694_, this.f_20692_, this.f_20693_, velocityUpdateSupplier, trackingRangeSupplier, updateIntervalSupplier, customClientFactory); +- return new EntityType<>(this.f_20685_, this.f_20686_, this.f_20688_, this.f_20689_, this.f_20690_, this.f_20691_, this.f_20687_, this.f_20694_, this.f_20692_, this.f_20693_, this.f_244453_); ++ return new EntityType<>(this.f_20685_, this.f_20686_, this.f_20688_, this.f_20689_, this.f_20690_, this.f_20691_, this.f_20687_, this.f_20694_, this.f_20692_, this.f_20693_, this.f_244453_, velocityUpdateSupplier, trackingRangeSupplier, updateIntervalSupplier, customClientFactory); } } diff --git a/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch b/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch index 2b0bd08888..962626e1fe 100644 --- a/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ExperienceOrb.java +++ b/net/minecraft/world/entity/ExperienceOrb.java -@@ -89,7 +_,8 @@ +@@ -90,7 +_,8 @@ this.m_6478_(MoverType.SELF, this.m_20184_()); float f = 0.98F; if (this.f_19861_) { @@ -10,7 +10,7 @@ } this.m_20256_(this.m_20184_().m_82542_((double)f, 0.98D, (double)f)); -@@ -167,6 +_,7 @@ +@@ -168,6 +_,7 @@ } public boolean m_6469_(DamageSource p_20785_, float p_20786_) { @@ -18,7 +18,7 @@ if (this.m_6673_(p_20785_)) { return false; } else if (this.f_19853_.f_46443_) { -@@ -199,6 +_,7 @@ +@@ -200,6 +_,7 @@ public void m_6123_(Player p_20792_) { if (!this.f_19853_.f_46443_) { if (p_20792_.f_36101_ == 0) { @@ -26,7 +26,7 @@ p_20792_.f_36101_ = 2; p_20792_.m_7938_(this, 1); int i = this.m_147092_(p_20792_, this.f_20770_); -@@ -219,7 +_,7 @@ +@@ -220,7 +_,7 @@ Map.Entry entry = EnchantmentHelper.m_44839_(Enchantments.f_44962_, p_147093_, ItemStack::m_41768_); if (entry != null) { ItemStack itemstack = entry.getValue(); diff --git a/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch b/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch index 029df91c98..371fc67937 100644 --- a/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/LightningBolt.java +++ b/net/minecraft/world/entity/LightningBolt.java -@@ -39,6 +_,7 @@ +@@ -37,6 +_,7 @@ private ServerPlayer f_20863_; private final Set f_147134_ = Sets.newHashSet(); private int f_147135_; @@ -8,7 +8,7 @@ public LightningBolt(EntityType p_20865_, Level p_20866_) { super(p_20865_, p_20866_); -@@ -74,6 +_,14 @@ +@@ -72,6 +_,14 @@ } @@ -23,7 +23,7 @@ public void m_8119_() { super.m_8119_(); if (this.f_20860_ == 2) { -@@ -123,6 +_,7 @@ +@@ -121,6 +_,7 @@ List list1 = this.f_19853_.m_6249_(this, new AABB(this.m_20185_() - 3.0D, this.m_20186_() - 3.0D, this.m_20189_() - 3.0D, this.m_20185_() + 3.0D, this.m_20186_() + 6.0D + 3.0D, this.m_20189_() + 3.0D), Entity::m_6084_); for(Entity entity : list1) { diff --git a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch index bbbda37a66..1752fb4e1e 100644 --- a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -118,12 +_,14 @@ +@@ -119,12 +_,14 @@ import net.minecraft.world.scores.PlayerTeam; import org.slf4j.Logger; @@ -16,7 +16,7 @@ public static final int f_147166_ = 2; public static final int f_147167_ = 4; public static final int f_147168_ = 98; -@@ -274,7 +_,7 @@ +@@ -275,7 +_,7 @@ } public static AttributeSupplier.Builder m_21183_() { @@ -25,7 +25,7 @@ } protected void m_7840_(double p_20990_, boolean p_20991_, BlockState p_20992_, BlockPos p_20993_) { -@@ -292,13 +_,15 @@ +@@ -293,13 +_,15 @@ if (!p_20992_.m_60795_()) { double d0 = Math.min((double)(0.2F + f / 15.0F), 2.5D); int i = (int)(150.0D * d0); @@ -42,7 +42,7 @@ public boolean m_6040_() { return this.m_6336_() == MobType.f_21641_; } -@@ -337,8 +_,8 @@ +@@ -340,8 +_,8 @@ } } @@ -53,7 +53,7 @@ if (flag1) { this.m_20301_(this.m_7302_(this.m_20146_())); if (this.m_20146_() == -20) { -@@ -356,10 +_,11 @@ +@@ -359,10 +_,11 @@ } } @@ -67,16 +67,16 @@ this.m_20301_(this.m_7305_(this.m_20146_())); } -@@ -372,7 +_,7 @@ +@@ -375,7 +_,7 @@ } } - if (this.m_6084_() && (this.m_20071_() || this.f_146808_)) { + if (this.m_6084_() && (this.m_20071_() || this.f_146808_ || this.isInFluidType((fluidType, height) -> this.canFluidExtinguish(fluidType)))) { - if (!this.f_19853_.f_46443_ && this.f_146810_) { - this.m_146873_(); - } -@@ -740,7 +_,7 @@ + this.m_252836_(); + } + +@@ -739,7 +_,7 @@ if (!mobeffectinstance.m_19552_(this, () -> { this.m_141973_(mobeffectinstance, true, (Entity)null); })) { @@ -85,7 +85,7 @@ iterator.remove(); this.m_7285_(mobeffectinstance); } -@@ -790,8 +_,10 @@ +@@ -789,8 +_,10 @@ this.m_6842_(false); } else { Collection collection = this.f_20945_.values(); @@ -98,7 +98,7 @@ this.m_6842_(this.m_21023_(MobEffects.f_19609_)); } -@@ -827,7 +_,7 @@ +@@ -826,7 +_,7 @@ d0 *= 0.5D; } } @@ -107,7 +107,7 @@ return d0; } -@@ -870,7 +_,9 @@ +@@ -869,7 +_,9 @@ boolean flag; for(flag = false; iterator.hasNext(); flag = true) { @@ -118,7 +118,7 @@ iterator.remove(); } -@@ -904,6 +_,7 @@ +@@ -903,6 +_,7 @@ return false; } else { MobEffectInstance mobeffectinstance = this.f_20945_.get(p_147208_.m_19544_()); @@ -126,7 +126,7 @@ if (mobeffectinstance == null) { this.f_20945_.put(p_147208_.m_19544_(), p_147208_); this.m_142540_(p_147208_, p_147209_); -@@ -918,6 +_,9 @@ +@@ -917,6 +_,9 @@ } public boolean m_7301_(MobEffectInstance p_21197_) { @@ -136,7 +136,7 @@ if (this.m_6336_() == MobType.f_21641_) { MobEffect mobeffect = p_21197_.m_19544_(); if (mobeffect == MobEffects.f_19605_ || mobeffect == MobEffects.f_19614_) { -@@ -950,6 +_,7 @@ +@@ -949,6 +_,7 @@ } public boolean m_21195_(MobEffect p_21196_) { @@ -144,7 +144,7 @@ MobEffectInstance mobeffectinstance = this.m_6234_(p_21196_); if (mobeffectinstance != null) { this.m_7285_(mobeffectinstance); -@@ -986,6 +_,8 @@ +@@ -985,6 +_,8 @@ } public void m_5634_(float p_21116_) { @@ -153,7 +153,7 @@ float f = this.m_21223_(); if (f > 0.0F) { this.m_21153_(f + p_21116_); -@@ -1006,6 +_,7 @@ +@@ -1005,6 +_,7 @@ } public boolean m_6469_(DamageSource p_21016_, float p_21017_) { @@ -161,7 +161,7 @@ if (this.m_6673_(p_21016_)) { return false; } else if (this.f_19853_.f_46443_) { -@@ -1024,9 +_,11 @@ +@@ -1023,9 +_,11 @@ boolean flag = false; float f1 = 0.0F; if (p_21017_ > 0.0F && this.m_21275_(p_21016_)) { @@ -195,10 +195,10 @@ + net.minecraft.world.entity.TamableAnimal tamableEntity = (net.minecraft.world.entity.TamableAnimal)entity1; + if (tamableEntity.m_21824_()) { this.f_20889_ = 100; -- LivingEntity livingentity = wolf.m_21826_(); -+ LivingEntity livingentity = tamableEntity.m_21826_(); - if (livingentity != null && livingentity.m_6095_() == EntityType.f_20532_) { - this.f_20888_ = (Player)livingentity; +- LivingEntity livingentity1 = wolf.m_21826_(); ++ LivingEntity livingentity1 = tamableEntity.m_21826_(); + if (livingentity1 != null && livingentity1.m_6095_() == EntityType.f_20532_) { + this.f_20888_ = (Player)livingentity1; } else { @@ -1147,7 +_,7 @@ if (this instanceof ServerPlayer) { @@ -307,7 +307,7 @@ p_147241_ *= 1.0D - this.m_21133_(Attributes.f_22278_); if (!(p_147241_ <= 0.0D)) { this.f_19812_ = true; -@@ -1421,15 +_,9 @@ +@@ -1430,15 +_,9 @@ } else { BlockPos blockpos = this.m_20183_(); BlockState blockstate = this.m_146900_(); @@ -326,7 +326,7 @@ } } -@@ -1449,6 +_,11 @@ +@@ -1458,6 +_,11 @@ } public boolean m_142535_(float p_147187_, float p_147188_, DamageSource p_147189_) { @@ -338,7 +338,7 @@ boolean flag = super.m_142535_(p_147187_, p_147188_, p_147189_); int i = this.m_5639_(p_147187_, p_147188_); if (i > 0) { -@@ -1472,9 +_,10 @@ +@@ -1481,9 +_,10 @@ int i = Mth.m_14107_(this.m_20185_()); int j = Mth.m_14107_(this.m_20186_() - (double)0.2F); int k = Mth.m_14107_(this.m_20189_()); @@ -351,7 +351,7 @@ this.m_5496_(soundtype.m_56779_(), soundtype.m_56773_() * 0.5F, soundtype.m_56774_() * 0.75F); } -@@ -1522,9 +_,9 @@ +@@ -1531,9 +_,9 @@ float f2 = f1 - p_21194_; if (f2 > 0.0F && f2 < 3.4028235E37F) { if (this instanceof ServerPlayer) { @@ -363,7 +363,7 @@ } } } -@@ -1546,19 +_,22 @@ +@@ -1555,19 +_,22 @@ protected void m_6475_(DamageSource p_21240_, float p_21241_) { if (!this.m_6673_(p_21240_)) { @@ -388,7 +388,7 @@ this.m_7911_(this.m_6103_() - f2); this.m_146850_(GameEvent.f_223706_); } -@@ -1613,6 +_,8 @@ +@@ -1622,6 +_,8 @@ } public void m_21011_(InteractionHand p_21012_, boolean p_21013_) { @@ -397,7 +397,7 @@ if (!this.f_20911_ || this.f_20913_ >= this.m_21304_() / 2 || this.f_20913_ < 0) { this.f_20913_ = -1; this.f_20911_ = true; -@@ -1972,14 +_,17 @@ +@@ -1989,14 +_,17 @@ } this.f_19812_ = true; @@ -417,7 +417,7 @@ } protected float m_6108_() { -@@ -1993,14 +_,19 @@ +@@ -2010,14 +_,19 @@ public void m_7023_(Vec3 p_21280_) { if (this.m_6142_() || this.m_6109_()) { double d0 = 0.08D; @@ -439,7 +439,7 @@ double d9 = this.m_20186_(); float f4 = this.m_20142_() ? 0.9F : this.m_6108_(); float f5 = 0.02F; -@@ -2022,6 +_,7 @@ +@@ -2039,6 +_,7 @@ f4 = 0.96F; } @@ -447,7 +447,7 @@ this.m_19920_(f5, p_21280_); this.m_6478_(MoverType.SELF, this.m_20184_()); Vec3 vec36 = this.m_20184_(); -@@ -2035,6 +_,7 @@ +@@ -2052,6 +_,7 @@ if (this.f_19862_ && this.m_20229_(vec32.f_82479_, vec32.f_82480_ + (double)0.6F - this.m_20186_() + d9, vec32.f_82481_)) { this.m_20334_(vec32.f_82479_, (double)0.3F, vec32.f_82481_); } @@ -455,7 +455,7 @@ } else if (this.m_20077_() && this.m_6129_() && !this.m_203441_(fluidstate)) { double d8 = this.m_20186_(); this.m_19920_(0.02F, p_21280_); -@@ -2100,7 +_,7 @@ +@@ -2114,7 +_,7 @@ } } else { BlockPos blockpos = this.m_20099_(); @@ -464,7 +464,7 @@ float f3 = this.f_19861_ ? f2 * 0.91F : 0.91F; Vec3 vec35 = this.m_21074_(p_21280_, f2); double d2 = vec35.f_82480_; -@@ -2176,7 +_,7 @@ +@@ -2190,7 +_,7 @@ double d0 = Mth.m_14008_(p_21298_.f_82479_, (double)-0.15F, (double)0.15F); double d1 = Mth.m_14008_(p_21298_.f_82481_, (double)-0.15F, (double)0.15F); double d2 = Math.max(p_21298_.f_82480_, (double)-0.15F); @@ -473,7 +473,7 @@ d2 = 0.0D; } -@@ -2204,6 +_,7 @@ +@@ -2218,6 +_,7 @@ } public void m_8119_() { @@ -481,15 +481,15 @@ super.m_8119_(); this.m_21329_(); this.m_21333_(); -@@ -2355,6 +_,7 @@ +@@ -2369,6 +_,7 @@ ItemStack itemstack1 = this.m_6844_(equipmentslot); - if (!ItemStack.m_41728_(itemstack1, itemstack)) { + if (this.m_246525_(itemstack, itemstack1)) { + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent(this, equipmentslot, itemstack, itemstack1)); if (map == null) { map = Maps.newEnumMap(EquipmentSlot.class); } -@@ -2505,6 +_,8 @@ +@@ -2523,6 +_,8 @@ this.f_19853_.m_46473_().m_6180_("jump"); if (this.f_20899_ && this.m_6129_()) { double d7; @@ -498,7 +498,7 @@ if (this.m_20077_()) { d7 = this.m_204036_(FluidTags.f_13132_); } else { -@@ -2515,15 +_,17 @@ +@@ -2533,15 +_,17 @@ double d8 = this.m_20204_(); if (!flag1 || this.f_19861_ && !(d7 > d8)) { if (!this.m_20077_() || this.f_19861_ && !(d7 > d8)) { @@ -518,7 +518,7 @@ } } else { this.f_20954_ = 0; -@@ -2578,6 +_,8 @@ +@@ -2596,6 +_,8 @@ boolean flag = this.m_20291_(7); if (flag && !this.f_19861_ && !this.m_20159_() && !this.m_21023_(MobEffects.f_19620_)) { ItemStack itemstack = this.m_6844_(EquipmentSlot.CHEST); @@ -527,11 +527,11 @@ if (itemstack.m_150930_(Items.f_42741_) && ElytraItem.m_41140_(itemstack)) { flag = true; int i = this.f_20937_ + 1; -@@ -2809,8 +_,16 @@ +@@ -2831,8 +_,16 @@ private void m_21329_() { if (this.m_6117_()) { -- if (ItemStack.m_41758_(this.m_21120_(this.m_7655_()), this.f_20935_)) { +- if (ItemStack.m_41746_(this.m_21120_(this.m_7655_()), this.f_20935_)) { - this.f_20935_ = this.m_21120_(this.m_7655_()); + ItemStack itemStack = this.m_21120_(this.m_7655_()); + if (net.minecraftforge.common.ForgeHooks.canContinueUsing(this.f_20935_, itemStack)) this.f_20935_ = itemStack; @@ -546,7 +546,7 @@ this.m_142106_(this.f_20935_); } else { this.m_5810_(); -@@ -2833,7 +_,7 @@ +@@ -2855,7 +_,7 @@ private boolean m_21332_() { int i = this.m_21212_(); @@ -555,7 +555,7 @@ boolean flag = foodproperties != null && foodproperties.m_38748_(); flag |= i <= this.f_20935_.m_41779_() - 7; return flag && i % 4 == 0; -@@ -2863,8 +_,10 @@ +@@ -2885,8 +_,10 @@ public void m_6672_(InteractionHand p_21159_) { ItemStack itemstack = this.m_21120_(p_21159_); if (!itemstack.m_41619_() && !this.m_6117_()) { @@ -567,7 +567,7 @@ if (!this.f_19853_.f_46443_) { this.m_21155_(1, true); this.m_21155_(2, p_21159_ == InteractionHand.OFF_HAND); -@@ -2925,6 +_,9 @@ +@@ -2947,6 +_,9 @@ vec31 = vec31.m_82496_(-this.m_146909_() * ((float)Math.PI / 180F)); vec31 = vec31.m_82524_(-this.m_146908_() * ((float)Math.PI / 180F)); vec31 = vec31.m_82520_(this.m_20185_(), this.m_20188_(), this.m_20189_()); @@ -577,7 +577,7 @@ this.f_19853_.m_7106_(new ItemParticleOption(ParticleTypes.f_123752_, p_21061_), vec31.f_82479_, vec31.f_82480_, vec31.f_82481_, vec3.f_82479_, vec3.f_82480_ + 0.05D, vec3.f_82481_); } -@@ -2938,7 +_,8 @@ +@@ -2960,7 +_,8 @@ } else { if (!this.f_20935_.m_41619_() && this.m_6117_()) { this.m_21137_(this.f_20935_, 16); @@ -587,7 +587,7 @@ if (itemstack != this.f_20935_) { this.m_21008_(interactionhand, itemstack); } -@@ -2964,7 +_,11 @@ +@@ -2986,7 +_,11 @@ public void m_21253_() { if (!this.f_20935_.m_41619_()) { @@ -599,7 +599,7 @@ if (this.f_20935_.m_41781_()) { this.m_21329_(); } -@@ -2989,7 +_,7 @@ +@@ -3011,7 +_,7 @@ public boolean m_21254_() { if (this.m_6117_() && !this.f_20935_.m_41619_()) { Item item = this.f_20935_.m_41720_(); @@ -608,7 +608,7 @@ return false; } else { return item.m_8105_(this.f_20935_) - this.f_20936_ >= 5; -@@ -3115,8 +_,8 @@ +@@ -3133,8 +_,8 @@ } BlockState blockstate = this.f_19853_.m_8055_(p_21141_); @@ -619,7 +619,7 @@ } this.m_20124_(Pose.SLEEPING); -@@ -3132,15 +_,15 @@ +@@ -3150,16 +_,16 @@ private boolean m_21334_() { return this.m_21257_().map((p_147236_) -> { @@ -629,16 +629,17 @@ } public void m_5796_() { - this.m_21257_().filter(this.f_19853_::m_46805_).ifPresent((p_147228_) -> { - BlockState blockstate = this.f_19853_.m_8055_(p_147228_); + this.m_21257_().filter(this.f_19853_::m_46805_).ifPresent((p_261435_) -> { + BlockState blockstate = this.f_19853_.m_8055_(p_261435_); - if (blockstate.m_60734_() instanceof BedBlock) { -- this.f_19853_.m_7731_(p_147228_, blockstate.m_61124_(BedBlock.f_49441_, Boolean.valueOf(false)), 3); -+ if (blockstate.isBed(f_19853_, p_147228_, this)) { -+ blockstate.setBedOccupied(f_19853_, p_147228_, this, false); - Vec3 vec31 = BedBlock.m_49458_(this.m_6095_(), this.f_19853_, p_147228_, this.m_146908_()).orElseGet(() -> { - BlockPos blockpos = p_147228_.m_7494_(); ++ if (blockstate.isBed(f_19853_, p_261435_, this)) { + Direction direction = blockstate.m_61143_(BedBlock.f_54117_); +- this.f_19853_.m_7731_(p_261435_, blockstate.m_61124_(BedBlock.f_49441_, Boolean.valueOf(false)), 3); ++ blockstate.setBedOccupied(f_19853_, p_261435_, this, false); + Vec3 vec31 = BedBlock.m_260958_(this.m_6095_(), this.f_19853_, p_261435_, direction, this.m_146908_()).orElseGet(() -> { + BlockPos blockpos = p_261435_.m_7494_(); return new Vec3((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_() + 0.1D, (double)blockpos.m_123343_() + 0.5D); -@@ -3162,7 +_,9 @@ +@@ -3181,7 +_,9 @@ @Nullable public Direction m_21259_() { BlockPos blockpos = this.m_21257_().orElse((BlockPos)null); @@ -649,7 +650,7 @@ } public boolean m_5830_() { -@@ -3178,7 +_,7 @@ +@@ -3197,7 +_,7 @@ } public ItemStack m_6298_(ItemStack p_21272_) { @@ -658,7 +659,7 @@ } public ItemStack m_5584_(Level p_21067_, ItemStack p_21068_) { -@@ -3198,7 +_,7 @@ +@@ -3217,7 +_,7 @@ private void m_21063_(ItemStack p_21064_, Level p_21065_, LivingEntity p_21066_) { Item item = p_21064_.m_41720_(); if (item.m_41472_()) { @@ -667,7 +668,7 @@ if (!p_21065_.f_46443_ && pair.getFirst() != null && p_21065_.f_46441_.m_188501_() < pair.getSecond()) { p_21066_.m_7292_(new MobEffectInstance(pair.getFirst())); } -@@ -3234,6 +_,64 @@ +@@ -3253,6 +_,64 @@ this.m_21166_(p_21191_ == InteractionHand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND); } @@ -732,7 +733,7 @@ public AABB m_6921_() { if (this.m_6844_(EquipmentSlot.HEAD).m_150930_(Items.f_42683_)) { float f = 0.5F; -@@ -3244,6 +_,8 @@ +@@ -3263,6 +_,8 @@ } public static EquipmentSlot m_147233_(ItemStack p_147234_) { @@ -741,7 +742,7 @@ Item item = p_147234_.m_41720_(); if (!p_147234_.m_150930_(Items.f_42047_) && (!(item instanceof BlockItem) || !(((BlockItem)item).m_40614_() instanceof AbstractSkullBlock))) { if (item instanceof ArmorItem) { -@@ -3251,7 +_,7 @@ +@@ -3270,7 +_,7 @@ } else if (p_147234_.m_150930_(Items.f_42741_)) { return EquipmentSlot.CHEST; } else { diff --git a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch index 28da8713ac..71b47c8319 100644 --- a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch @@ -24,7 +24,7 @@ for(ItemEntity itementity : this.f_19853_.m_45976_(ItemEntity.class, this.m_20191_().m_82377_((double)vec3i.m_123341_(), (double)vec3i.m_123342_(), (double)vec3i.m_123343_()))) { if (!itementity.m_213877_() && !itementity.m_32055_().m_41619_() && !itementity.m_32063_() && this.m_7243_(itementity.m_32055_())) { this.m_7581_(itementity); -@@ -657,6 +_,14 @@ +@@ -673,6 +_,14 @@ this.m_146870_(); } else if (!this.m_21532_() && !this.m_8023_()) { Entity entity = this.f_19853_.m_45930_(this, -1.0D); @@ -39,7 +39,7 @@ if (entity != null) { double d0 = entity.m_20280_(this); int i = this.m_6095_().m_20674_().m_21611_(); -@@ -1374,13 +_,23 @@ +@@ -1398,13 +_,23 @@ return false; } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java.patch index 96b0a1224c..26c6b3ec84 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/attributes/AttributeSupplier.java.patch @@ -22,7 +22,7 @@ + } private AttributeInstance m_22274_(Attribute p_22275_) { - AttributeInstance attributeinstance = new AttributeInstance(p_22275_, (p_22273_) -> { + AttributeInstance attributeinstance = new AttributeInstance(p_22275_, (p_258260_) -> { @@ -93,6 +_,7 @@ public AttributeSupplier m_22265_() { diff --git a/patches/minecraft/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java.patch index 1f67333325..42e5039d86 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java +++ b/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java -@@ -81,11 +_,12 @@ - private static final Map, AttributeSupplier> f_22294_ = ImmutableMap., AttributeSupplier>builder().put(EntityType.f_217014_, Allay.m_218388_().m_22265_()).put(EntityType.f_20529_, LivingEntity.m_21183_().m_22265_()).put(EntityType.f_147039_, Axolotl.m_149176_().m_22265_()).put(EntityType.f_20549_, Bat.m_27455_().m_22265_()).put(EntityType.f_20550_, Bee.m_27858_().m_22265_()).put(EntityType.f_20551_, Blaze.m_32238_().m_22265_()).put(EntityType.f_20553_, Cat.m_28168_().m_22265_()).put(EntityType.f_20554_, CaveSpider.m_32267_().m_22265_()).put(EntityType.f_20555_, Chicken.m_28263_().m_22265_()).put(EntityType.f_20556_, AbstractFish.m_27495_().m_22265_()).put(EntityType.f_20557_, Cow.m_28307_().m_22265_()).put(EntityType.f_20558_, Creeper.m_32318_().m_22265_()).put(EntityType.f_20559_, Dolphin.m_28379_().m_22265_()).put(EntityType.f_20560_, AbstractChestedHorse.m_30501_().m_22265_()).put(EntityType.f_20562_, Zombie.m_34328_().m_22265_()).put(EntityType.f_20563_, ElderGuardian.m_32471_().m_22265_()).put(EntityType.f_20566_, EnderMan.m_32541_().m_22265_()).put(EntityType.f_20567_, Endermite.m_32619_().m_22265_()).put(EntityType.f_20565_, EnderDragon.m_31167_().m_22265_()).put(EntityType.f_20568_, Evoker.m_32657_().m_22265_()).put(EntityType.f_20452_, Fox.m_28553_().m_22265_()).put(EntityType.f_217012_, Frog.m_218525_().m_22265_()).put(EntityType.f_20453_, Ghast.m_32752_().m_22265_()).put(EntityType.f_20454_, Giant.m_32796_().m_22265_()).put(EntityType.f_147034_, GlowSquid.m_29988_().m_22265_()).put(EntityType.f_147035_, Goat.m_149401_().m_22265_()).put(EntityType.f_20455_, Guardian.m_32853_().m_22265_()).put(EntityType.f_20456_, Hoglin.m_34551_().m_22265_()).put(EntityType.f_20457_, AbstractHorse.m_30627_().m_22265_()).put(EntityType.f_20458_, Zombie.m_34328_().m_22265_()).put(EntityType.f_20459_, Illusioner.m_32931_().m_22265_()).put(EntityType.f_20460_, IronGolem.m_28883_().m_22265_()).put(EntityType.f_20466_, Llama.m_30824_().m_22265_()).put(EntityType.f_20468_, MagmaCube.m_33000_().m_22265_()).put(EntityType.f_20504_, Cow.m_28307_().m_22265_()).put(EntityType.f_20503_, AbstractChestedHorse.m_30501_().m_22265_()).put(EntityType.f_20505_, Ocelot.m_29036_().m_22265_()).put(EntityType.f_20507_, Panda.m_29157_().m_22265_()).put(EntityType.f_20508_, Parrot.m_29438_().m_22265_()).put(EntityType.f_20509_, Monster.m_33035_().m_22265_()).put(EntityType.f_20510_, Pig.m_29503_().m_22265_()).put(EntityType.f_20511_, Piglin.m_34770_().m_22265_()).put(EntityType.f_20512_, PiglinBrute.m_35075_().m_22265_()).put(EntityType.f_20513_, Pillager.m_33307_().m_22265_()).put(EntityType.f_20532_, Player.m_36340_().m_22265_()).put(EntityType.f_20514_, PolarBear.m_29560_().m_22265_()).put(EntityType.f_20516_, AbstractFish.m_27495_().m_22265_()).put(EntityType.f_20517_, Rabbit.m_29717_().m_22265_()).put(EntityType.f_20518_, Ravager.m_33371_().m_22265_()).put(EntityType.f_20519_, AbstractFish.m_27495_().m_22265_()).put(EntityType.f_20520_, Sheep.m_29873_().m_22265_()).put(EntityType.f_20521_, Shulker.m_33477_().m_22265_()).put(EntityType.f_20523_, Silverfish.m_33551_().m_22265_()).put(EntityType.f_20524_, AbstractSkeleton.m_32166_().m_22265_()).put(EntityType.f_20525_, SkeletonHorse.m_30918_().m_22265_()).put(EntityType.f_20526_, Monster.m_33035_().m_22265_()).put(EntityType.f_20528_, SnowGolem.m_29934_().m_22265_()).put(EntityType.f_20479_, Spider.m_33815_().m_22265_()).put(EntityType.f_20480_, Squid.m_29988_().m_22265_()).put(EntityType.f_20481_, AbstractSkeleton.m_32166_().m_22265_()).put(EntityType.f_20482_, Strider.m_33937_().m_22265_()).put(EntityType.f_217013_, Tadpole.m_218720_().m_22265_()).put(EntityType.f_20488_, Llama.m_30824_().m_22265_()).put(EntityType.f_20489_, AbstractFish.m_27495_().m_22265_()).put(EntityType.f_20490_, Turtle.m_30207_().m_22265_()).put(EntityType.f_20491_, Vex.m_34040_().m_22265_()).put(EntityType.f_20492_, Villager.m_35503_().m_22265_()).put(EntityType.f_20493_, Vindicator.m_34104_().m_22265_()).put(EntityType.f_217015_, Warden.m_219463_().m_22265_()).put(EntityType.f_20494_, Mob.m_21552_().m_22265_()).put(EntityType.f_20495_, Witch.m_34155_().m_22265_()).put(EntityType.f_20496_, WitherBoss.m_31501_().m_22265_()).put(EntityType.f_20497_, AbstractSkeleton.m_32166_().m_22265_()).put(EntityType.f_20499_, Wolf.m_30425_().m_22265_()).put(EntityType.f_20500_, Zoglin.m_34257_().m_22265_()).put(EntityType.f_20501_, Zombie.m_34328_().m_22265_()).put(EntityType.f_20502_, ZombieHorse.m_31008_().m_22265_()).put(EntityType.f_20530_, Zombie.m_34328_().m_22265_()).put(EntityType.f_20531_, ZombifiedPiglin.m_34470_().m_22265_()).build(); +@@ -82,11 +_,12 @@ + private static final Map, AttributeSupplier> f_22294_ = ImmutableMap., AttributeSupplier>builder().put(EntityType.f_217014_, Allay.m_218388_().m_22265_()).put(EntityType.f_20529_, LivingEntity.m_21183_().m_22265_()).put(EntityType.f_147039_, Axolotl.m_149176_().m_22265_()).put(EntityType.f_20549_, Bat.m_27455_().m_22265_()).put(EntityType.f_20550_, Bee.m_27858_().m_22265_()).put(EntityType.f_20551_, Blaze.m_32238_().m_22265_()).put(EntityType.f_20553_, Cat.m_28168_().m_22265_()).put(EntityType.f_243976_, Camel.m_247319_().m_22265_()).put(EntityType.f_20554_, CaveSpider.m_32267_().m_22265_()).put(EntityType.f_20555_, Chicken.m_28263_().m_22265_()).put(EntityType.f_20556_, AbstractFish.m_27495_().m_22265_()).put(EntityType.f_20557_, Cow.m_28307_().m_22265_()).put(EntityType.f_20558_, Creeper.m_32318_().m_22265_()).put(EntityType.f_20559_, Dolphin.m_28379_().m_22265_()).put(EntityType.f_20560_, AbstractChestedHorse.m_30501_().m_22265_()).put(EntityType.f_20562_, Zombie.m_34328_().m_22265_()).put(EntityType.f_20563_, ElderGuardian.m_32471_().m_22265_()).put(EntityType.f_20566_, EnderMan.m_32541_().m_22265_()).put(EntityType.f_20567_, Endermite.m_32619_().m_22265_()).put(EntityType.f_20565_, EnderDragon.m_31167_().m_22265_()).put(EntityType.f_20568_, Evoker.m_32657_().m_22265_()).put(EntityType.f_20452_, Fox.m_28553_().m_22265_()).put(EntityType.f_217012_, Frog.m_218525_().m_22265_()).put(EntityType.f_20453_, Ghast.m_32752_().m_22265_()).put(EntityType.f_20454_, Giant.m_32796_().m_22265_()).put(EntityType.f_147034_, GlowSquid.m_29988_().m_22265_()).put(EntityType.f_147035_, Goat.m_149401_().m_22265_()).put(EntityType.f_20455_, Guardian.m_32853_().m_22265_()).put(EntityType.f_20456_, Hoglin.m_34551_().m_22265_()).put(EntityType.f_20457_, AbstractHorse.m_30627_().m_22265_()).put(EntityType.f_20458_, Zombie.m_34328_().m_22265_()).put(EntityType.f_20459_, Illusioner.m_32931_().m_22265_()).put(EntityType.f_20460_, IronGolem.m_28883_().m_22265_()).put(EntityType.f_20466_, Llama.m_30824_().m_22265_()).put(EntityType.f_20468_, MagmaCube.m_33000_().m_22265_()).put(EntityType.f_20504_, Cow.m_28307_().m_22265_()).put(EntityType.f_20503_, AbstractChestedHorse.m_30501_().m_22265_()).put(EntityType.f_20505_, Ocelot.m_29036_().m_22265_()).put(EntityType.f_20507_, Panda.m_29157_().m_22265_()).put(EntityType.f_20508_, Parrot.m_29438_().m_22265_()).put(EntityType.f_20509_, Monster.m_33035_().m_22265_()).put(EntityType.f_20510_, Pig.m_29503_().m_22265_()).put(EntityType.f_20511_, Piglin.m_34770_().m_22265_()).put(EntityType.f_20512_, PiglinBrute.m_35075_().m_22265_()).put(EntityType.f_20513_, Pillager.m_33307_().m_22265_()).put(EntityType.f_20532_, Player.m_36340_().m_22265_()).put(EntityType.f_20514_, PolarBear.m_29560_().m_22265_()).put(EntityType.f_20516_, AbstractFish.m_27495_().m_22265_()).put(EntityType.f_20517_, Rabbit.m_29717_().m_22265_()).put(EntityType.f_20518_, Ravager.m_33371_().m_22265_()).put(EntityType.f_20519_, AbstractFish.m_27495_().m_22265_()).put(EntityType.f_20520_, Sheep.m_29873_().m_22265_()).put(EntityType.f_20521_, Shulker.m_33477_().m_22265_()).put(EntityType.f_20523_, Silverfish.m_33551_().m_22265_()).put(EntityType.f_20524_, AbstractSkeleton.m_32166_().m_22265_()).put(EntityType.f_20525_, SkeletonHorse.m_30918_().m_22265_()).put(EntityType.f_20526_, Monster.m_33035_().m_22265_()).put(EntityType.f_20528_, SnowGolem.m_29934_().m_22265_()).put(EntityType.f_20479_, Spider.m_33815_().m_22265_()).put(EntityType.f_20480_, Squid.m_29988_().m_22265_()).put(EntityType.f_20481_, AbstractSkeleton.m_32166_().m_22265_()).put(EntityType.f_20482_, Strider.m_33937_().m_22265_()).put(EntityType.f_217013_, Tadpole.m_218720_().m_22265_()).put(EntityType.f_20488_, Llama.m_30824_().m_22265_()).put(EntityType.f_20489_, AbstractFish.m_27495_().m_22265_()).put(EntityType.f_20490_, Turtle.m_30207_().m_22265_()).put(EntityType.f_20491_, Vex.m_34040_().m_22265_()).put(EntityType.f_20492_, Villager.m_35503_().m_22265_()).put(EntityType.f_20493_, Vindicator.m_34104_().m_22265_()).put(EntityType.f_217015_, Warden.m_219463_().m_22265_()).put(EntityType.f_20494_, Mob.m_21552_().m_22265_()).put(EntityType.f_20495_, Witch.m_34155_().m_22265_()).put(EntityType.f_20496_, WitherBoss.m_31501_().m_22265_()).put(EntityType.f_20497_, AbstractSkeleton.m_32166_().m_22265_()).put(EntityType.f_20499_, Wolf.m_30425_().m_22265_()).put(EntityType.f_20500_, Zoglin.m_34257_().m_22265_()).put(EntityType.f_20501_, Zombie.m_34328_().m_22265_()).put(EntityType.f_20502_, ZombieHorse.m_31008_().m_22265_()).put(EntityType.f_20530_, Zombie.m_34328_().m_22265_()).put(EntityType.f_20531_, ZombifiedPiglin.m_34470_().m_22265_()).build(); public static AttributeSupplier m_22297_(EntityType p_22298_) { - return f_22294_.get(p_22298_); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch index d38a1e6c6c..04fc081e99 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch @@ -1,16 +1,17 @@ --- a/net/minecraft/world/entity/ai/behavior/StartAttacking.java +++ b/net/minecraft/world/entity/ai/behavior/StartAttacking.java -@@ -46,7 +_,11 @@ - } - - public static void m_24213_(E p_24214_, LivingEntity p_24215_) { -- p_24214_.m_6274_().m_21879_(MemoryModuleType.f_26372_, p_24215_); -- p_24214_.m_6274_().m_21936_(MemoryModuleType.f_26326_); -+ net.minecraftforge.event.entity.living.LivingChangeTargetEvent changeTargetEvent = net.minecraftforge.common.ForgeHooks.onLivingChangeTarget(p_24214_, p_24215_, net.minecraftforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET); -+ if(!changeTargetEvent.isCanceled()) { -+ p_24214_.m_6274_().m_21879_(MemoryModuleType.f_26372_, changeTargetEvent.getNewTarget()); -+ p_24214_.m_6274_().m_21936_(MemoryModuleType.f_26326_); -+ net.minecraftforge.common.ForgeHooks.onLivingSetAttackTarget(p_24214_, changeTargetEvent.getNewTarget(), net.minecraftforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET); // TODO: Remove in 1.20 -+ } - } - } +@@ -30,8 +_,13 @@ + if (!p_258774_.m_6779_(livingentity)) { + return false; + } else { +- p_258778_.m_257512_(livingentity); ++ net.minecraftforge.event.entity.living.LivingChangeTargetEvent changeTargetEvent = net.minecraftforge.common.ForgeHooks.onLivingChangeTarget(p_258774_, livingentity, net.minecraftforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET); ++ if (changeTargetEvent.isCanceled()) ++ return false; ++ ++ p_258778_.m_257512_(changeTargetEvent.getNewTarget()); + p_258779_.m_257971_(); ++ net.minecraftforge.common.ForgeHooks.onLivingSetAttackTarget(p_258774_, changeTargetEvent.getNewTarget(), net.minecraftforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET); // TODO: Remove in 1.20 + return true; + } + } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch index 88d2a14113..88d95f0349 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/navigation/PathNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/PathNavigation.java -@@ -227,10 +_,10 @@ +@@ -228,10 +_,10 @@ Vec3 vec3 = this.m_7475_(); this.f_26505_ = this.f_26494_.m_20205_() > 0.75F ? this.f_26494_.m_20205_() / 2.0F : 0.75F - this.f_26494_.m_20205_() / 2.0F; Vec3i vec3i = this.f_26496_.m_77400_(); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/village/poi/PoiTypes.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/village/poi/PoiTypes.java.patch index cae00172c5..7488c9a561 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/village/poi/PoiTypes.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/village/poi/PoiTypes.java.patch @@ -1,23 +1,22 @@ --- a/net/minecraft/world/entity/ai/village/poi/PoiTypes.java +++ b/net/minecraft/world/entity/ai/village/poi/PoiTypes.java -@@ -48,8 +_,9 @@ +@@ -48,7 +_,9 @@ private static final Set f_218069_ = ImmutableList.of(Blocks.f_50256_, Blocks.f_152477_, Blocks.f_152476_, Blocks.f_152478_).stream().flatMap((p_218093_) -> { return p_218093_.m_49965_().m_61056_().stream(); }).collect(ImmutableSet.toImmutableSet()); - private static final Map> f_218070_ = Maps.newHashMap(); -- protected static final Set f_218067_ = new ObjectOpenHashSet<>(f_218070_.keySet()); + // Forge: We patch these 2 fields to support modded entries + private static final Map f_218070_ = net.minecraftforge.registries.GameData.getBlockStatePointOfInterestTypeMap(); + protected static final Set f_218067_ = f_218070_.keySet(); private static Set m_218073_(Block p_218074_) { return ImmutableSet.copyOf(p_218074_.m_49965_().m_61056_()); -@@ -67,16 +_,10 @@ +@@ -66,16 +_,10 @@ } - private static void m_218077_(Holder p_218078_) { -- p_218078_.m_203334_().f_27325_().forEach((p_218081_) -> { -- Holder holder = f_218070_.put(p_218081_, p_218078_); + private static void m_246216_(Holder p_250815_, Set p_250679_) { +- p_250679_.forEach((p_218081_) -> { +- Holder holder = f_218070_.put(p_218081_, p_250815_); - if (holder != null) { - throw (IllegalStateException)Util.m_137570_(new IllegalStateException(String.format(Locale.ROOT, "%s is defined in more than one PoI type", p_218081_))); - } @@ -29,4 +28,4 @@ + return Optional.ofNullable(f_218070_.get(p_218076_)).flatMap(net.minecraftforge.registries.ForgeRegistries.POI_TYPES::getHolder); } - public static PoiType m_218082_(Registry p_218083_) { + public static boolean m_252831_(BlockState p_254440_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch index d932f5221b..fa0b24c948 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Bee.java +++ b/net/minecraft/world/entity/animal/Bee.java -@@ -472,7 +_,7 @@ +@@ -474,7 +_,7 @@ return false; } else { BlockEntity blockentity = this.f_19853_.m_7702_(this.f_27698_); @@ -9,7 +9,7 @@ } } -@@ -614,8 +_,18 @@ +@@ -617,8 +_,18 @@ return MobType.f_21642_; } diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch index 6955ebed62..e66f2a0192 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Cat.java +++ b/net/minecraft/world/entity/animal/Cat.java -@@ -365,8 +_,8 @@ +@@ -367,8 +_,8 @@ if (this.m_21830_(p_28153_)) { if (!(item instanceof DyeItem)) { if (item.m_41472_() && this.m_6898_(itemstack) && this.m_21223_() < this.m_21233_()) { @@ -10,7 +10,7 @@ return InteractionResult.CONSUME; } -@@ -391,7 +_,7 @@ +@@ -393,7 +_,7 @@ } } else if (this.m_6898_(itemstack)) { this.m_142075_(p_28153_, p_28154_, itemstack); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch index 59518a66dd..a13c5abd75 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Fox.java +++ b/net/minecraft/world/entity/animal/Fox.java -@@ -648,13 +_,16 @@ +@@ -652,13 +_,16 @@ } protected void m_6668_(DamageSource p_28536_) { @@ -18,7 +18,7 @@ } public static boolean m_28471_(Fox p_28472_, LivingEntity p_28473_) { -@@ -804,6 +_,17 @@ +@@ -808,6 +_,17 @@ protected void m_8026_() { ServerLevel serverlevel = (ServerLevel)this.f_25114_; Fox fox = (Fox)this.f_25113_.m_142606_(serverlevel, this.f_25115_); @@ -36,7 +36,7 @@ if (fox != null) { ServerPlayer serverplayer = this.f_25113_.m_27592_(); ServerPlayer serverplayer1 = this.f_25115_.m_27592_(); -@@ -875,7 +_,7 @@ +@@ -879,7 +_,7 @@ } protected void m_28686_() { @@ -45,7 +45,7 @@ BlockState blockstate = Fox.this.f_19853_.m_8055_(this.f_25602_); if (blockstate.m_60713_(Blocks.f_50685_)) { this.m_148928_(blockstate); -@@ -930,7 +_,7 @@ +@@ -934,7 +_,7 @@ } public boolean m_8036_() { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch index fcc9497394..5f87496d5d 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/animal/MushroomCow.java +++ b/net/minecraft/world/entity/animal/MushroomCow.java -@@ -42,7 +_,7 @@ +@@ -41,7 +_,7 @@ import net.minecraft.world.level.gameevent.GameEvent; import org.apache.commons.lang3.tuple.Pair; --public class MushroomCow extends Cow implements Shearable { +-public class MushroomCow extends Cow implements Shearable, VariantHolder { +public class MushroomCow extends Cow implements Shearable, net.minecraftforge.common.IForgeShearable { private static final EntityDataAccessor f_28908_ = SynchedEntityData.m_135353_(MushroomCow.class, EntityDataSerializers.f_135030_); private static final int f_148934_ = 1024; @Nullable -@@ -104,7 +_,7 @@ +@@ -103,7 +_,7 @@ this.m_5496_(soundevent, 1.0F, 1.0F); return InteractionResult.m_19078_(this.f_19853_.f_46443_); @@ -18,7 +18,7 @@ this.m_5851_(SoundSource.PLAYERS); this.m_146852_(GameEvent.f_157781_, p_28941_); if (!this.f_19853_.f_46443_) { -@@ -145,7 +_,17 @@ +@@ -144,7 +_,17 @@ } } @@ -35,39 +35,40 @@ + private java.util.List shearInternal(SoundSource p_28924_) { this.f_19853_.m_6269_((Player)null, this, SoundEvents.f_12075_, p_28924_, 1.0F, 1.0F); if (!this.f_19853_.m_5776_()) { - ((ServerLevel)this.f_19853_).m_8767_(ParticleTypes.f_123813_, this.m_20185_(), this.m_20227_(0.5D), this.m_20189_(), 1, 0.0D, 0.0D, 0.0D, 0.0D); -@@ -166,10 +_,13 @@ - cow.m_20331_(this.m_20147_()); - this.f_19853_.m_7967_(cow); + Cow cow = EntityType.f_20557_.m_20615_(this.f_19853_); +@@ -166,11 +_,14 @@ + cow.m_20331_(this.m_20147_()); + this.f_19853_.m_7967_(cow); -+ java.util.List items = new java.util.ArrayList<>(); - for(int i = 0; i < 5; ++i) { -- this.f_19853_.m_7967_(new ItemEntity(this.f_19853_, this.m_20185_(), this.m_20227_(1.0D), this.m_20189_(), new ItemStack(this.m_28955_().f_28961_.m_60734_()))); -+ items.add(new ItemStack(this.m_28955_().f_28961_.m_60734_())); ++ java.util.List items = new java.util.ArrayList<>(); + for(int i = 0; i < 5; ++i) { +- this.f_19853_.m_7967_(new ItemEntity(this.f_19853_, this.m_20185_(), this.m_20227_(1.0D), this.m_20189_(), new ItemStack(this.m_262365_().f_28961_.m_60734_()))); ++ items.add(new ItemStack(this.m_262365_().f_28961_.m_60734_())); + } ++ return items; } -+ return items; } + return java.util.Collections.emptyList(); } -@@ -182,6 +_,7 @@ - p_28944_.m_128359_("Type", this.m_28955_().f_28960_); +@@ -183,6 +_,7 @@ + p_28944_.m_128359_("Type", this.m_262365_().m_7912_()); if (this.f_28909_ != null) { p_28944_.m_128405_("EffectId", MobEffect.m_19459_(this.f_28909_)); + net.minecraftforge.common.ForgeHooks.saveMobEffect(p_28944_, "forge:effect_id", this.f_28909_); p_28944_.m_128405_("EffectDuration", this.f_28910_); } -@@ -192,6 +_,7 @@ - this.m_28928_(MushroomCow.MushroomType.m_28976_(p_28936_.m_128461_("Type"))); +@@ -193,6 +_,7 @@ + this.m_262362_(MushroomCow.MushroomType.m_28976_(p_28936_.m_128461_("Type"))); if (p_28936_.m_128425_("EffectId", 1)) { this.f_28909_ = MobEffect.m_19453_(p_28936_.m_128451_("EffectId")); + this.f_28909_ = net.minecraftforge.common.ForgeHooks.loadMobEffect(p_28936_, "forge:effect_id", this.f_28909_); } if (p_28936_.m_128425_("EffectDuration", 3)) { -@@ -238,6 +_,11 @@ +@@ -235,6 +_,11 @@ } return mushroomcow$mushroomtype2; @@ -78,4 +79,4 @@ + return m_6220_(); } - public static enum MushroomType { + public static enum MushroomType implements StringRepresentable { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch index 7f3d64cc9d..d854203ff8 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Parrot.java +++ b/net/minecraft/world/entity/animal/Parrot.java -@@ -241,7 +_,7 @@ +@@ -245,7 +_,7 @@ } if (!this.f_19853_.f_46443_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch index db6195b185..0bee89a04d 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch @@ -7,13 +7,13 @@ - if (p_29473_.m_46791_() != Difficulty.PEACEFUL) { + if (p_29473_.m_46791_() != Difficulty.PEACEFUL && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.f_20531_, (timer) -> {})) { ZombifiedPiglin zombifiedpiglin = EntityType.f_20531_.m_20615_(p_29473_); - zombifiedpiglin.m_8061_(EquipmentSlot.MAINHAND, new ItemStack(Items.f_42430_)); - zombifiedpiglin.m_7678_(this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), this.m_146909_()); -@@ -212,6 +_,7 @@ - } + if (zombifiedpiglin != null) { + zombifiedpiglin.m_8061_(EquipmentSlot.MAINHAND, new ItemStack(Items.f_42430_)); +@@ -213,6 +_,7 @@ + } - zombifiedpiglin.m_21530_(); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zombifiedpiglin); - p_29473_.m_7967_(zombifiedpiglin); - this.m_146870_(); - } else { + zombifiedpiglin.m_21530_(); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zombifiedpiglin); + p_29473_.m_7967_(zombifiedpiglin); + this.m_146870_(); + } else { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch index c705cf9062..e0f1810709 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Rabbit.java +++ b/net/minecraft/world/entity/animal/Rabbit.java -@@ -511,7 +_,7 @@ +@@ -519,7 +_,7 @@ public boolean m_8036_() { if (this.f_25600_ <= 0) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch index b2f2b5f609..4112d73969 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch @@ -9,7 +9,7 @@ private static final int f_149039_ = 40; private static final EntityDataAccessor f_29799_ = SynchedEntityData.m_135353_(Sheep.class, EntityDataSerializers.f_135027_); private static final Map f_29800_ = Util.m_137469_(Maps.newEnumMap(DyeColor.class), (p_29841_) -> { -@@ -212,7 +_,7 @@ +@@ -232,7 +_,7 @@ public InteractionResult m_6071_(Player p_29853_, InteractionHand p_29854_) { ItemStack itemstack = p_29853_.m_21120_(p_29854_); @@ -18,7 +18,7 @@ if (!this.f_19853_.f_46443_ && this.m_6220_()) { this.m_5851_(SoundSource.PLAYERS); this.m_146852_(GameEvent.f_157781_, p_29853_); -@@ -362,5 +_,28 @@ +@@ -385,5 +_,28 @@ protected float m_6431_(Pose p_29850_, EntityDimensions p_29851_) { return 0.95F * p_29851_.f_20378_; diff --git a/patches/minecraft/net/minecraft/world/entity/animal/allay/Allay.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/allay/Allay.java.patch index 857bb9b36b..25a45a2a1b 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/allay/Allay.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/allay/Allay.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/animal/allay/Allay.java +++ b/net/minecraft/world/entity/animal/allay/Allay.java -@@ -326,7 +_,7 @@ +@@ -329,7 +_,7 @@ public boolean m_7243_(ItemStack p_218387_) { ItemStack itemstack = this.m_21120_(InteractionHand.MAIN_HAND); -- return !itemstack.m_41619_() && itemstack.m_41726_(p_218387_) && this.f_218303_.m_19183_(p_218387_) && this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_); -+ return !itemstack.m_41619_() && itemstack.m_41726_(p_218387_) && this.f_218303_.m_19183_(p_218387_) && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this); +- return !itemstack.m_41619_() && this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) && this.f_218303_.m_19183_(p_218387_) && this.m_245613_(itemstack, p_218387_); ++ return !itemstack.m_41619_() && this.f_218303_.m_19183_(p_218387_) && this.m_245613_(itemstack, p_218387_) && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this); } - protected void m_7581_(ItemEntity p_218359_) { + private boolean m_245613_(ItemStack p_252278_, ItemStack p_250405_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch index fa3acdaa51..33de9b9b0c 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java -@@ -290,6 +_,7 @@ +@@ -306,6 +_,7 @@ this.f_30520_.m_19164_(this); this.m_7493_(); @@ -8,7 +8,7 @@ } protected void m_7493_() { -@@ -348,9 +_,9 @@ +@@ -353,9 +_,9 @@ protected void m_7355_(BlockPos p_30584_, BlockState p_30585_) { if (!p_30585_.m_60767_().m_76332_()) { BlockState blockstate = this.f_19853_.m_8055_(p_30584_.m_7494_()); @@ -20,15 +20,15 @@ } if (this.m_20160_() && this.f_30523_) { -@@ -702,6 +_,7 @@ - this.m_20334_(vec3.f_82479_, d1, vec3.f_82481_); - this.m_30655_(true); - this.f_19812_ = true; +@@ -770,6 +_,7 @@ + this.m_20334_(vec3.f_82479_, d1, vec3.f_82481_); + this.m_30655_(true); + this.f_19812_ = true; + net.minecraftforge.common.ForgeHooks.onLivingJump(this); - if (f1 > 0.0F) { - float f2 = Mth.m_14031_(this.m_146908_() * ((float)Math.PI / 180F)); - float f3 = Mth.m_14089_(this.m_146908_() * ((float)Math.PI / 180F)); -@@ -1033,6 +_,25 @@ + if (p_251655_ > 0.0F) { + float f = Mth.m_14031_(this.m_146908_() * ((float)Math.PI / 180F)); + float f1 = Mth.m_14089_(this.m_146908_() * ((float)Math.PI / 180F)); +@@ -1078,6 +_,25 @@ this.m_214179_(p_30555_.m_213780_()); return super.m_6518_(p_30555_, p_30556_, p_30557_, p_30558_, p_30559_); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/horse/Horse.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/horse/Horse.java.patch index e7caff48fe..28e5f3bd41 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/horse/Horse.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/horse/Horse.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/Horse.java +++ b/net/minecraft/world/entity/animal/horse/Horse.java -@@ -140,6 +_,8 @@ +@@ -144,6 +_,8 @@ this.m_5496_(SoundEvents.f_11974_, p_30709_.m_56773_() * 0.6F, p_30709_.m_56774_()); } diff --git a/patches/minecraft/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch index b3d71bbebe..fa0cf19ae1 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java +++ b/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java -@@ -27,6 +_,10 @@ +@@ -28,6 +_,10 @@ public void m_8037_() { ServerLevel serverlevel = (ServerLevel)this.f_30925_.f_19853_; @@ -11,12 +11,11 @@ DifficultyInstance difficultyinstance = serverlevel.m_6436_(this.f_30925_.m_20183_()); this.f_30925_.m_30923_(false); this.f_30925_.m_30651_(true); -@@ -46,7 +_,7 @@ - abstracthorse.m_5997_(this.f_30925_.m_217043_().m_216328_(0.0D, 1.1485D), 0.0D, this.f_30925_.m_217043_().m_216328_(0.0D, 1.1485D)); - serverlevel.m_47205_(abstracthorse); +@@ -56,6 +_,7 @@ + + } } -- + })); } - private AbstractHorse m_30929_(DifficultyInstance p_30930_) { + @Nullable diff --git a/patches/minecraft/net/minecraft/world/entity/boss/EnderDragonPart.java.patch b/patches/minecraft/net/minecraft/world/entity/boss/EnderDragonPart.java.patch index 9906520e98..dce2131dbc 100644 --- a/patches/minecraft/net/minecraft/world/entity/boss/EnderDragonPart.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/boss/EnderDragonPart.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/boss/EnderDragonPart.java +++ b/net/minecraft/world/entity/boss/EnderDragonPart.java -@@ -8,13 +_,13 @@ - import net.minecraft.world.entity.Pose; +@@ -11,13 +_,13 @@ import net.minecraft.world.entity.boss.enderdragon.EnderDragon; + import net.minecraft.world.item.ItemStack; -public class EnderDragonPart extends Entity { +public class EnderDragonPart extends net.minecraftforge.entity.PartEntity { diff --git a/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch b/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch index ee71a56019..ae139399cf 100644 --- a/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java -@@ -219,7 +_,7 @@ - int k1 = this.m_31502_() - 1; - this.f_31430_.m_142711_(1.0F - (float)k1 / 220.0F); - if (k1 <= 0) { -- Explosion.BlockInteraction explosion$blockinteraction = this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; -+ Explosion.BlockInteraction explosion$blockinteraction = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; - this.f_19853_.m_46518_(this, this.m_20185_(), this.m_20188_(), this.m_20189_(), 7.0F, false, explosion$blockinteraction); - if (!this.m_20067_()) { - this.f_19853_.m_6798_(1023, this.m_20183_(), 0); -@@ -280,7 +_,7 @@ +@@ -278,7 +_,7 @@ if (this.f_31429_ > 0) { --this.f_31429_; @@ -18,7 +9,7 @@ int j1 = Mth.m_14107_(this.m_20186_()); int i2 = Mth.m_14107_(this.m_20185_()); int j2 = Mth.m_14107_(this.m_20189_()); -@@ -294,7 +_,7 @@ +@@ -292,7 +_,7 @@ int i1 = j2 + k2; BlockPos blockpos = new BlockPos(l2, l, i1); BlockState blockstate = this.f_19853_.m_8055_(blockpos); @@ -27,11 +18,14 @@ flag = this.f_19853_.m_46953_(blockpos, true, this) || flag; } } -@@ -315,6 +_,7 @@ +@@ -313,6 +_,10 @@ } } -+ @Deprecated //Forge: DO NOT USE use BlockState.canEntityDestroy ++ /** ++ * @deprecated Forge: Use {@link BlockState#canEntityDestroy(net.minecraft.world.level.BlockGetter, BlockPos, Entity)} instead. ++ */ ++ @Deprecated public static boolean m_31491_(BlockState p_31492_) { return !p_31492_.m_60795_() && !p_31492_.m_204336_(BlockTags.f_13070_); } diff --git a/patches/minecraft/net/minecraft/world/entity/item/FallingBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/item/FallingBlockEntity.java.patch index 4abc29c862..4ab472cf5a 100644 --- a/patches/minecraft/net/minecraft/world/entity/item/FallingBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/item/FallingBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -117,11 +_,11 @@ +@@ -119,11 +_,11 @@ if (!this.f_19853_.f_46443_) { BlockPos blockpos = this.m_20183_(); boolean flag = this.f_31946_.m_60734_() instanceof ConcretePowderBlock; diff --git a/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch index 98535e8720..d36f84786c 100644 --- a/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -43,6 +_,10 @@ +@@ -41,6 +_,10 @@ @Nullable private UUID f_31982_; public final float f_31983_; @@ -11,7 +11,7 @@ public ItemEntity(EntityType p_31991_, Level p_31992_) { super(p_31991_, p_31992_); -@@ -59,6 +_,7 @@ +@@ -57,6 +_,7 @@ this.m_6034_(p_149664_, p_149665_, p_149666_); this.m_20334_(p_149668_, p_149669_, p_149670_); this.m_32045_(p_149667_); @@ -19,7 +19,7 @@ } private ItemEntity(ItemEntity p_31994_) { -@@ -86,6 +_,7 @@ +@@ -84,6 +_,7 @@ } public void m_8119_() { @@ -27,7 +27,7 @@ if (this.m_32055_().m_41619_()) { this.m_146870_(); } else { -@@ -99,6 +_,9 @@ +@@ -97,6 +_,9 @@ this.f_19856_ = this.m_20189_(); Vec3 vec3 = this.m_20184_(); float f = this.m_20192_() - 0.11111111F; @@ -37,7 +37,7 @@ if (this.m_20069_() && this.m_204036_(FluidTags.f_13131_) > (double)f) { this.m_32067_(); } else if (this.m_20077_() && this.m_204036_(FluidTags.f_13132_) > (double)f) { -@@ -120,7 +_,7 @@ +@@ -118,7 +_,7 @@ this.m_6478_(MoverType.SELF, this.m_20184_()); float f1 = 0.98F; if (this.f_19861_) { @@ -46,7 +46,7 @@ } this.m_20256_(this.m_20184_().m_82542_((double)f1, 0.98D, (double)f1)); -@@ -150,7 +_,14 @@ +@@ -148,7 +_,14 @@ } } @@ -62,7 +62,7 @@ this.m_146870_(); } -@@ -208,6 +_,8 @@ +@@ -206,6 +_,8 @@ return false; } else if (p_32028_.m_41782_() ^ p_32027_.m_41782_()) { return false; @@ -71,7 +71,7 @@ } else { return !p_32028_.m_41782_() || p_32028_.m_41783_().equals(p_32027_.m_41783_()); } -@@ -241,6 +_,7 @@ +@@ -239,6 +_,7 @@ } public boolean m_6469_(DamageSource p_32013_, float p_32014_) { @@ -79,7 +79,7 @@ if (this.m_6673_(p_32013_)) { return false; } else if (!this.m_32055_().m_41619_() && this.m_32055_().m_150930_(Items.f_42686_) && p_32013_.m_19372_()) { -@@ -254,7 +_,7 @@ +@@ -252,7 +_,7 @@ this.f_31987_ = (int)((float)this.f_31987_ - p_32014_); this.m_146852_(GameEvent.f_223706_, p_32013_.m_7639_()); if (this.f_31987_ <= 0) { @@ -88,7 +88,7 @@ this.m_146870_(); } -@@ -266,6 +_,7 @@ +@@ -264,6 +_,7 @@ p_32050_.m_128376_("Health", (short)this.f_31987_); p_32050_.m_128376_("Age", (short)this.f_31985_); p_32050_.m_128376_("PickupDelay", (short)this.f_31986_); @@ -96,7 +96,7 @@ if (this.m_32057_() != null) { p_32050_.m_128362_("Thrower", this.m_32057_()); } -@@ -286,6 +_,7 @@ +@@ -284,6 +_,7 @@ if (p_32034_.m_128441_("PickupDelay")) { this.f_31986_ = p_32034_.m_128448_("PickupDelay"); } @@ -104,7 +104,7 @@ if (p_32034_.m_128403_("Owner")) { this.f_31982_ = p_32034_.m_128342_("Owner"); -@@ -305,10 +_,18 @@ +@@ -303,10 +_,18 @@ public void m_6123_(Player p_32040_) { if (!this.f_19853_.f_46443_) { @@ -124,7 +124,7 @@ p_32040_.m_7938_(this, i); if (itemstack.m_41619_()) { this.m_146870_(); -@@ -332,8 +_,8 @@ +@@ -330,8 +_,8 @@ } @Nullable @@ -135,7 +135,7 @@ if (!this.f_19853_.f_46443_ && entity instanceof ItemEntity) { ((ItemEntity)entity).m_32069_(); } -@@ -409,7 +_,7 @@ +@@ -407,7 +_,7 @@ public void m_32065_() { this.m_32062_(); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Creeper.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Creeper.java.patch deleted file mode 100644 index afbb15fecf..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/monster/Creeper.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/monster/Creeper.java -+++ b/net/minecraft/world/entity/monster/Creeper.java -@@ -219,7 +_,7 @@ - - private void m_32315_() { - if (!this.f_19853_.f_46443_) { -- Explosion.BlockInteraction explosion$blockinteraction = this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; -+ Explosion.BlockInteraction explosion$blockinteraction = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; - float f = this.m_7090_() ? 2.0F : 1.0F; - this.f_20890_ = true; - this.f_19853_.m_46511_(this, this.m_20185_(), this.m_20186_(), this.m_20189_(), (float)this.f_32272_ * f, explosion$blockinteraction); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch index 0459a3c290..33b919bffd 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EnderMan.java +++ b/net/minecraft/world/entity/monster/EnderMan.java -@@ -105,7 +_,6 @@ +@@ -110,7 +_,6 @@ } public void m_6710_(@Nullable LivingEntity p_32537_) { @@ -8,7 +8,7 @@ AttributeInstance attributeinstance = this.m_21051_(Attributes.f_22279_); if (p_32537_ == null) { this.f_32477_ = 0; -@@ -120,6 +_,7 @@ +@@ -125,6 +_,7 @@ } } @@ -16,7 +16,7 @@ } protected void m_8097_() { -@@ -194,7 +_,7 @@ +@@ -199,7 +_,7 @@ boolean m_32534_(Player p_32535_) { ItemStack itemstack = p_32535_.m_150109_().f_35975_.get(3); @@ -25,7 +25,7 @@ return false; } else { Vec3 vec3 = p_32535_.m_20252_(1.0F).m_82541_(); -@@ -273,8 +_,10 @@ +@@ -278,8 +_,10 @@ boolean flag = blockstate.m_60767_().m_76334_(); boolean flag1 = blockstate.m_60819_().m_205070_(FluidTags.f_13131_); if (flag && !flag1) { @@ -37,7 +37,7 @@ if (flag2) { this.f_19853_.m_214171_(GameEvent.f_238175_, vec3, GameEvent.Context.m_223717_(this)); if (!this.m_20067_()) { -@@ -411,7 +_,7 @@ +@@ -422,7 +_,7 @@ public boolean m_8036_() { if (this.f_32554_.m_32530_() == null) { return false; @@ -46,7 +46,7 @@ return false; } else { return this.f_32554_.m_217043_().m_188503_(m_186073_(2000)) == 0; -@@ -431,7 +_,7 @@ +@@ -442,7 +_,7 @@ BlockState blockstate2 = this.f_32554_.m_32530_(); if (blockstate2 != null) { blockstate2 = Block.m_49931_(blockstate2, this.f_32554_.f_19853_, blockpos); @@ -55,7 +55,7 @@ level.m_7731_(blockpos, blockstate2, 3); level.m_220407_(GameEvent.f_157797_, blockpos, GameEvent.Context.m_223719_(this.f_32554_, blockstate2)); this.f_32554_.m_32521_((BlockState)null); -@@ -441,7 +_,7 @@ +@@ -452,7 +_,7 @@ } private boolean m_32558_(Level p_32559_, BlockPos p_32560_, BlockState p_32561_, BlockState p_32562_, BlockState p_32563_, BlockPos p_32564_) { @@ -64,7 +64,7 @@ } } -@@ -531,7 +_,7 @@ +@@ -544,7 +_,7 @@ public boolean m_8036_() { if (this.f_32583_.m_32530_() != null) { return false; diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch index 632d342244..bf54090d65 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Evoker.java +++ b/net/minecraft/world/entity/monster/Evoker.java -@@ -273,7 +_,7 @@ +@@ -275,7 +_,7 @@ return false; } else if (Evoker.this.f_19797_ < this.f_33775_) { return false; diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Pillager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Pillager.java.patch index 8a0d749f07..2fb78f5d0d 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Pillager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Pillager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Pillager.java +++ b/net/minecraft/world/entity/monster/Pillager.java -@@ -119,7 +_,7 @@ +@@ -109,7 +_,7 @@ public AbstractIllager.IllagerArmPose m_6768_() { if (this.m_33309_()) { return AbstractIllager.IllagerArmPose.CROSSBOW_CHARGE; diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch index 8acc37706f..f595f3544e 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Shulker.java +++ b/net/minecraft/world/entity/monster/Shulker.java -@@ -356,6 +_,12 @@ +@@ -359,6 +_,12 @@ if (blockpos1.m_123342_() > this.f_19853_.m_141937_() && this.f_19853_.m_46859_(blockpos1) && this.f_19853_.m_6857_().m_61937_(blockpos1) && this.f_19853_.m_45756_(this, (new AABB(blockpos1)).m_82406_(1.0E-6D))) { Direction direction = this.m_149810_(blockpos1); if (direction != null) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch index 6696c2ca50..6671356d66 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch @@ -1,14 +1,15 @@ --- a/net/minecraft/world/entity/monster/Slime.java +++ b/net/minecraft/world/entity/monster/Slime.java -@@ -123,6 +_,7 @@ +@@ -124,6 +_,8 @@ if (this.f_19861_ && !this.f_33583_) { int i = this.m_33632_(); -+ if (spawnCustomParticles()) i = 0; // don't spawn particles if it's handled by the implementation itself ++ // Forge: Don't spawn particles if it's handled by the implementation itself ++ if (!spawnCustomParticles()) for(int j = 0; j < i * 8; ++j) { float f = this.f_19796_.m_188501_() * ((float)Math.PI * 2F); float f1 = this.f_19796_.m_188501_() * 0.5F + 0.5F; -@@ -316,6 +_,12 @@ +@@ -319,6 +_,12 @@ public EntityDimensions m_6972_(Pose p_33597_) { return super.m_6972_(p_33597_).m_20388_(0.255F * (float)this.m_33632_()); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch index 2741308170..8ebf03a1b4 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Zombie.java +++ b/net/minecraft/world/entity/monster/Zombie.java -@@ -191,7 +_,7 @@ +@@ -192,7 +_,7 @@ if (!this.f_19853_.f_46443_ && this.m_6084_() && !this.m_21525_()) { if (this.m_34329_()) { --this.f_34266_; @@ -9,7 +9,7 @@ this.m_7595_(); } } else if (this.m_7593_()) { -@@ -253,6 +_,7 @@ +@@ -254,6 +_,7 @@ if (zombie != null) { zombie.m_34339_(zombie.f_19853_.m_6436_(zombie.m_20183_()).m_19057_()); zombie.m_34336_(zombie.m_7586_() && this.m_34330_()); @@ -17,7 +17,7 @@ } } -@@ -273,11 +_,14 @@ +@@ -274,11 +_,14 @@ livingentity = (LivingEntity)p_34288_.m_7639_(); } @@ -34,7 +34,7 @@ for(int l = 0; l < 50; ++l) { int i1 = i + Mth.m_216271_(this.f_19796_, 7, 40) * Mth.m_216271_(this.f_19796_, -1, 1); -@@ -289,6 +_,7 @@ +@@ -290,6 +_,7 @@ if (NaturalSpawner.m_47051_(spawnplacements$type, this.f_19853_, blockpos, entitytype) && SpawnPlacements.m_217074_(entitytype, serverlevel, MobSpawnType.REINFORCEMENT, blockpos, this.f_19853_.f_46441_)) { zombie.m_6034_((double)i1, (double)j1, (double)k1); if (!this.f_19853_.m_45914_((double)i1, (double)j1, (double)k1, 7.0D) && this.f_19853_.m_45784_(zombie) && this.f_19853_.m_45786_(zombie) && !this.f_19853_.m_46855_(zombie.m_20191_())) { @@ -42,24 +42,24 @@ zombie.m_6710_(livingentity); zombie.m_6518_(serverlevel, this.f_19853_.m_6436_(zombie.m_20183_()), MobSpawnType.REINFORCEMENT, (SpawnGroupData)null, (CompoundTag)null); serverlevel.m_47205_(zombie); -@@ -374,7 +_,7 @@ +@@ -375,7 +_,7 @@ public boolean m_214076_(ServerLevel p_219160_, LivingEntity p_219161_) { boolean flag = super.m_214076_(p_219160_, p_219161_); -- if ((p_219160_.m_46791_() == Difficulty.NORMAL || p_219160_.m_46791_() == Difficulty.HARD) && p_219161_ instanceof Villager) { -+ if ((p_219160_.m_46791_() == Difficulty.NORMAL || p_219160_.m_46791_() == Difficulty.HARD) && p_219161_ instanceof Villager && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(p_219161_, EntityType.f_20530_, (timer) -> {})) { +- if ((p_219160_.m_46791_() == Difficulty.NORMAL || p_219160_.m_46791_() == Difficulty.HARD) && p_219161_ instanceof Villager villager) { ++ if ((p_219160_.m_46791_() == Difficulty.NORMAL || p_219160_.m_46791_() == Difficulty.HARD) && p_219161_ instanceof Villager villager && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(p_219161_, EntityType.f_20530_, (timer) -> {})) { if (p_219160_.m_46791_() != Difficulty.HARD && this.f_19796_.m_188499_()) { return flag; } -@@ -386,6 +_,7 @@ - zombievillager.m_34391_(villager.m_35517_().m_26179_(NbtOps.f_128958_).getValue()); - zombievillager.m_34411_(villager.m_6616_().m_45388_()); - zombievillager.m_34373_(villager.m_7809_()); +@@ -387,6 +_,7 @@ + zombievillager.m_34391_(villager.m_35517_().m_262795_(NbtOps.f_128958_)); + zombievillager.m_34411_(villager.m_6616_().m_45388_()); + zombievillager.m_34373_(villager.m_7809_()); + net.minecraftforge.event.ForgeEventFactory.onLivingConvert(p_219161_, zombievillager); - if (!this.m_20067_()) { - p_219160_.m_5898_((Player)null, 1026, this.m_20183_(), 0); - } -@@ -460,7 +_,7 @@ + if (!this.m_20067_()) { + p_219160_.m_5898_((Player)null, 1026, this.m_20183_(), 0); + } +@@ -464,7 +_,7 @@ } public static boolean m_219162_(RandomSource p_219163_) { @@ -68,7 +68,7 @@ } protected void m_34339_(float p_34340_) { -@@ -480,7 +_,7 @@ +@@ -484,7 +_,7 @@ } protected void m_7572_() { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch index e8fc4892db..f189f01e3c 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java +++ b/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java -@@ -80,9 +_,10 @@ +@@ -87,9 +_,10 @@ ++this.f_34649_; } else { this.f_34649_ = 0; @@ -12,7 +12,7 @@ this.m_7580_(); this.m_8063_((ServerLevel)this.f_19853_); } -@@ -97,6 +_,7 @@ +@@ -104,6 +_,7 @@ ZombifiedPiglin zombifiedpiglin = this.m_21406_(EntityType.f_20531_, true); if (zombifiedpiglin != null) { zombifiedpiglin.m_7292_(new MobEffectInstance(MobEffects.f_19604_, 200, 0)); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch index 159655def2..8de2645992 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/net/minecraft/world/entity/monster/piglin/Piglin.java -@@ -282,7 +_,7 @@ +@@ -297,7 +_,7 @@ } else if (this.m_34773_()) { return PiglinArmPose.CROSSBOW_CHARGE; } else { @@ -9,7 +9,7 @@ } } -@@ -324,7 +_,7 @@ +@@ -339,7 +_,7 @@ } protected void m_34785_(ItemStack p_34786_) { @@ -18,7 +18,7 @@ this.m_8061_(EquipmentSlot.OFFHAND, p_34786_); this.m_21508_(EquipmentSlot.OFFHAND); } else { -@@ -334,7 +_,7 @@ +@@ -349,7 +_,7 @@ } public boolean m_7243_(ItemStack p_34777_) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch index 00279f0a3b..564c6a40a4 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/PiglinAi.java +++ b/net/minecraft/world/entity/monster/piglin/PiglinAi.java -@@ -258,7 +_,7 @@ +@@ -268,7 +_,7 @@ ItemStack itemstack = p_34868_.m_21120_(InteractionHand.OFF_HAND); p_34868_.m_21008_(InteractionHand.OFF_HAND, ItemStack.f_41583_); if (p_34868_.m_34667_()) { @@ -9,7 +9,7 @@ if (p_34869_ && flag) { m_34860_(p_34868_, m_34996_(p_34868_)); } else if (!flag) { -@@ -346,7 +_,7 @@ +@@ -356,7 +_,7 @@ return false; } else if (m_35024_(p_34858_) && p_34858_.m_6274_().m_21874_(MemoryModuleType.f_26372_)) { return false; @@ -18,7 +18,7 @@ return m_35028_(p_34858_); } else { boolean flag = p_34858_.m_34780_(p_34859_); -@@ -445,7 +_,7 @@ +@@ -455,7 +_,7 @@ } protected static boolean m_34909_(Piglin p_34910_, ItemStack p_34911_) { @@ -27,7 +27,7 @@ } protected static void m_34837_(Piglin p_34838_, LivingEntity p_34839_) { -@@ -546,7 +_,7 @@ +@@ -550,7 +_,7 @@ public static boolean m_34808_(LivingEntity p_34809_) { for(ItemStack itemstack : p_34809_.m_6168_()) { Item item = itemstack.m_41720_(); @@ -36,7 +36,7 @@ return true; } } -@@ -704,7 +_,7 @@ +@@ -703,7 +_,7 @@ } private static boolean m_34918_(LivingEntity p_34919_) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch index f2ee3e920c..ebbe260f86 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java +++ b/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java -@@ -13,7 +_,7 @@ - } - - protected boolean m_6114_(ServerLevel p_35255_, E p_35256_) { -- return !p_35256_.m_21206_().m_41619_() && !p_35256_.m_21206_().m_150930_(Items.f_42740_); -+ return !p_35256_.m_21206_().m_41619_() && !p_35256_.m_21206_().canPerformAction(net.minecraftforge.common.ToolActions.SHIELD_BLOCK); - } - - protected void m_6735_(ServerLevel p_35258_, E p_35259_, long p_35260_) { +@@ -10,7 +_,7 @@ + return BehaviorBuilder.m_258034_((p_259197_) -> { + return p_259197_.group(p_259197_.m_258080_(MemoryModuleType.f_26336_)).apply(p_259197_, (p_259512_) -> { + return (p_259681_, p_260321_, p_259451_) -> { +- if (!p_260321_.m_21206_().m_41619_() && !p_260321_.m_21206_().m_150930_(Items.f_42740_)) { ++ if (!p_260321_.m_21206_().m_41619_() && !p_260321_.m_21206_().canPerformAction(net.minecraftforge.common.ToolActions.SHIELD_BLOCK)) { + PiglinAi.m_34867_(p_260321_, true); + return true; + } else { diff --git a/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch index f6ce93e0e8..36df415a77 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch @@ -13,13 +13,13 @@ } protected Component m_5677_() { -- return Component.m_237115_(this.m_6095_().m_20675_() + "." + Registry.f_122869_.m_7981_(this.m_7141_().m_35571_()).m_135815_()); +- return Component.m_237115_(this.m_6095_().m_20675_() + "." + BuiltInRegistries.f_256735_.m_7981_(this.m_7141_().m_35571_()).m_135815_()); + net.minecraft.resources.ResourceLocation profName = net.minecraftforge.registries.ForgeRegistries.VILLAGER_PROFESSIONS.getKey(this.m_7141_().m_35571_()); + return Component.m_237115_(this.m_6095_().m_20675_() + '.' + (!"minecraft".equals(profName.m_135827_()) ? profName.m_135827_() + '.' : "") + profName.m_135815_()); } public void m_7822_(byte p_35391_) { -@@ -709,7 +_,7 @@ +@@ -710,7 +_,7 @@ } public void m_8038_(ServerLevel p_35409_, LightningBolt p_35410_) { @@ -27,12 +27,12 @@ + if (p_35409_.m_46791_() != Difficulty.PEACEFUL && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.f_20495_, (timer) -> {})) { f_201976_.info("Villager {} was struck by lightning {}.", this, p_35410_); Witch witch = EntityType.f_20495_.m_20615_(p_35409_); - witch.m_7678_(this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), this.m_146909_()); -@@ -721,6 +_,7 @@ - } + if (witch != null) { +@@ -723,6 +_,7 @@ + } - witch.m_21530_(); + witch.m_21530_(); + net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, witch); - p_35409_.m_47205_(witch); - this.m_35524_(); - this.m_146870_(); + p_35409_.m_47205_(witch); + this.m_35524_(); + this.m_146870_(); diff --git a/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch b/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch index 7f2d87658c..e652aca966 100644 --- a/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -114,7 +_,8 @@ +@@ -112,7 +_,8 @@ import net.minecraft.world.scores.Team; import org.slf4j.Logger; @@ -10,7 +10,7 @@ private static final Logger f_219722_ = LogUtils.getLogger(); public static final int f_150082_ = 16; public static final int f_150083_ = 20; -@@ -169,6 +_,9 @@ +@@ -164,6 +_,9 @@ private Optional f_238176_ = Optional.empty(); @Nullable public FishingHook f_36083_; @@ -18,9 +18,9 @@ + private final java.util.Collection suffixes = new java.util.LinkedList<>(); + @Nullable private Pose forcedPose; - public Player(Level p_219727_, BlockPos p_219728_, float p_219729_, GameProfile p_219730_, @Nullable ProfilePublicKey p_219731_) { - super(EntityType.f_20532_, p_219727_); -@@ -195,7 +_,7 @@ + public Player(Level p_250508_, BlockPos p_250289_, float p_251702_, GameProfile p_252153_) { + super(EntityType.f_20532_, p_250508_); +@@ -189,7 +_,7 @@ } public static AttributeSupplier.Builder m_36340_() { @@ -29,7 +29,7 @@ } protected void m_8097_() { -@@ -209,6 +_,7 @@ +@@ -203,6 +_,7 @@ } public void m_8119_() { @@ -37,7 +37,7 @@ this.f_19794_ = this.m_5833_(); if (this.m_5833_()) { this.f_19861_ = false; -@@ -224,7 +_,7 @@ +@@ -218,7 +_,7 @@ this.f_36110_ = 100; } @@ -46,7 +46,7 @@ this.m_6145_(false, true); } } else if (this.f_36110_ > 0) { -@@ -280,6 +_,7 @@ +@@ -273,6 +_,7 @@ this.m_36372_(); this.f_36087_.m_41518_(); this.m_7594_(); @@ -54,7 +54,7 @@ } public boolean m_36341_() { -@@ -355,6 +_,10 @@ +@@ -348,6 +_,10 @@ } protected void m_7594_() { @@ -65,7 +65,7 @@ if (this.m_20175_(Pose.SWIMMING)) { Pose pose; if (this.m_21255_()) { -@@ -578,6 +_,7 @@ +@@ -574,6 +_,7 @@ } public void m_6667_(DamageSource p_36152_) { @@ -73,7 +73,7 @@ super.m_6667_(p_36152_); this.m_20090_(); if (!this.m_5833_()) { -@@ -635,7 +_,7 @@ +@@ -631,7 +_,7 @@ @Nullable public ItemEntity m_36176_(ItemStack p_36177_, boolean p_36178_) { @@ -82,7 +82,7 @@ } @Nullable -@@ -673,7 +_,12 @@ +@@ -669,7 +_,12 @@ } } @@ -95,7 +95,7 @@ float f = this.f_36093_.m_36020_(p_36282_); if (f > 1.0F) { int i = EnchantmentHelper.m_44926_(this); -@@ -715,11 +_,12 @@ +@@ -711,11 +_,12 @@ f /= 5.0F; } @@ -109,7 +109,7 @@ } public void m_7378_(CompoundTag p_36215_) { -@@ -814,6 +_,7 @@ +@@ -801,6 +_,7 @@ } public boolean m_6469_(DamageSource p_36154_, float p_36155_) { @@ -117,7 +117,7 @@ if (this.m_6673_(p_36154_)) { return false; } else if (this.f_36077_.f_35934_ && !p_36154_.m_19378_()) { -@@ -848,7 +_,7 @@ +@@ -835,7 +_,7 @@ protected void m_6728_(LivingEntity p_36295_) { super.m_6728_(p_36295_); @@ -126,7 +126,7 @@ this.m_36384_(true); } -@@ -877,7 +_,7 @@ +@@ -864,7 +_,7 @@ } protected void m_7909_(float p_36383_) { @@ -135,7 +135,7 @@ if (!this.f_19853_.f_46443_) { this.m_36246_(Stats.f_12982_.m_12902_(this.f_20935_.m_41720_())); } -@@ -887,6 +_,7 @@ +@@ -874,6 +_,7 @@ InteractionHand interactionhand = this.m_7655_(); this.f_20935_.m_41622_(i, this, (p_219739_) -> { p_219739_.m_21190_(interactionhand); @@ -143,7 +143,7 @@ }); if (this.f_20935_.m_41619_()) { if (interactionhand == InteractionHand.MAIN_HAND) { -@@ -905,10 +_,13 @@ +@@ -892,10 +_,13 @@ protected void m_6475_(DamageSource p_36312_, float p_36313_) { if (!this.m_6673_(p_36312_)) { @@ -157,7 +157,7 @@ float f = p_36313_ - f2; if (f > 0.0F && f < 3.4028235E37F) { this.m_36222_(Stats.f_12933_, Math.round(f * 10.0F)); -@@ -917,8 +_,8 @@ +@@ -904,8 +_,8 @@ if (f2 != 0.0F) { this.m_36399_(p_36312_.m_19377_()); float f1 = this.m_21223_(); @@ -167,7 +167,7 @@ if (f2 < 3.4028235E37F) { this.m_36222_(Stats.f_12931_, Math.round(f2 * 10.0F)); } -@@ -967,6 +_,8 @@ +@@ -958,6 +_,8 @@ return InteractionResult.PASS; } else { @@ -176,7 +176,7 @@ ItemStack itemstack = this.m_21120_(p_36159_); ItemStack itemstack1 = itemstack.m_41777_(); InteractionResult interactionresult = p_36158_.m_6096_(this, p_36159_); -@@ -975,6 +_,9 @@ +@@ -966,6 +_,9 @@ itemstack.m_41764_(itemstack1.m_41613_()); } @@ -186,7 +186,7 @@ return interactionresult; } else { if (!itemstack.m_41619_() && p_36158_ instanceof LivingEntity) { -@@ -985,6 +_,7 @@ +@@ -976,6 +_,7 @@ InteractionResult interactionresult1 = itemstack.m_41647_(this, (LivingEntity)p_36158_, p_36159_); if (interactionresult1.m_19077_()) { if (itemstack.m_41619_() && !this.f_36077_.f_35937_) { @@ -194,7 +194,7 @@ this.m_21008_(p_36159_, ItemStack.f_41583_); } -@@ -1014,6 +_,7 @@ +@@ -1005,6 +_,7 @@ return !this.f_36077_.f_35935_; } @@ -202,7 +202,7 @@ protected Vec3 m_5763_(Vec3 p_36201_, MoverType p_36202_) { if (!this.f_36077_.f_35935_ && p_36201_.f_82480_ <= 0.0D && (p_36202_ == MoverType.SELF || p_36202_ == MoverType.PLAYER) && this.m_36343_() && this.m_36386_()) { double d0 = p_36201_.f_82479_; -@@ -1065,10 +_,11 @@ +@@ -1056,10 +_,11 @@ } private boolean m_36386_() { @@ -215,7 +215,7 @@ if (p_36347_.m_6097_()) { if (!p_36347_.m_7313_(this)) { float f = (float)this.m_21133_(Attributes.f_22281_); -@@ -1082,11 +_,10 @@ +@@ -1073,11 +_,10 @@ float f2 = this.m_36403_(0.5F); f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; @@ -228,7 +228,7 @@ i += EnchantmentHelper.m_44894_(this); if (this.m_20142_() && flag) { this.f_19853_.m_6263_((Player)null, this.m_20185_(), this.m_20186_(), this.m_20189_(), SoundEvents.f_12314_, this.m_5720_(), 1.0F, 1.0F); -@@ -1096,8 +_,10 @@ +@@ -1087,8 +_,10 @@ boolean flag2 = flag && this.f_19789_ > 0.0F && !this.f_19861_ && !this.m_6147_() && !this.m_20069_() && !this.m_21023_(MobEffects.f_19610_) && !this.m_20159_() && p_36347_ instanceof LivingEntity; flag2 = flag2 && !this.m_20142_(); @@ -240,7 +240,7 @@ } f += f1; -@@ -1105,9 +_,7 @@ +@@ -1096,9 +_,7 @@ double d0 = (double)(this.f_19787_ - this.f_19867_); if (flag && !flag2 && !flag1 && this.f_19861_ && d0 < (double)this.m_6113_()) { ItemStack itemstack = this.m_21120_(InteractionHand.MAIN_HAND); @@ -251,7 +251,7 @@ } float f4 = 0.0F; -@@ -1138,8 +_,8 @@ +@@ -1129,8 +_,8 @@ if (flag3) { float f3 = 1.0F + EnchantmentHelper.m_44821_(this) * f; @@ -262,7 +262,7 @@ livingentity.m_147240_((double)0.4F, (double)Mth.m_14031_(this.m_146908_() * ((float)Math.PI / 180F)), (double)(-Mth.m_14089_(this.m_146908_() * ((float)Math.PI / 180F)))); livingentity.m_6469_(DamageSource.m_19344_(this), f3); } -@@ -1180,13 +_,15 @@ +@@ -1171,13 +_,15 @@ EnchantmentHelper.m_44896_(this, p_36347_); ItemStack itemstack1 = this.m_21205_(); Entity entity = p_36347_; @@ -280,7 +280,7 @@ this.m_21008_(InteractionHand.MAIN_HAND, ItemStack.f_41583_); } } -@@ -1212,6 +_,7 @@ +@@ -1203,6 +_,7 @@ } } } @@ -288,7 +288,7 @@ } } -@@ -1228,7 +_,7 @@ +@@ -1219,7 +_,7 @@ } if (this.f_19796_.m_188501_() < f) { @@ -297,7 +297,7 @@ this.m_5810_(); this.f_19853_.m_7605_(this, (byte)30); } -@@ -1297,6 +_,7 @@ +@@ -1283,6 +_,7 @@ } public void m_6145_(boolean p_36226_, boolean p_36227_) { @@ -305,16 +305,16 @@ super.m_5796_(); if (this.f_19853_ instanceof ServerLevel && p_36227_) { ((ServerLevel)this.f_19853_).m_8878_(); -@@ -1322,7 +_,7 @@ +@@ -1308,7 +_,7 @@ } else if (block instanceof BedBlock && BedBlock.m_49488_(p_36131_)) { - return BedBlock.m_49458_(EntityType.f_20532_, p_36131_, p_36132_, p_36133_); + return BedBlock.m_260958_(EntityType.f_20532_, p_36131_, p_36132_, blockstate.m_61143_(BedBlock.f_54117_), p_36133_); } else if (!p_36134_) { - return Optional.empty(); + return blockstate.getRespawnPosition(EntityType.f_20532_, p_36131_, p_36132_, p_36133_, null); } else { boolean flag = block.m_5568_(); boolean flag1 = p_36131_.m_8055_(p_36132_.m_7494_()).m_60734_().m_5568_(); -@@ -1502,6 +_,7 @@ +@@ -1488,6 +_,7 @@ public boolean m_142535_(float p_150093_, float p_150094_, DamageSource p_150095_) { if (this.f_36077_.f_35936_) { @@ -322,7 +322,7 @@ return false; } else { if (p_150093_ >= 2.0F) { -@@ -1519,7 +_,7 @@ +@@ -1501,7 +_,7 @@ public boolean m_36319_() { if (!this.f_19861_ && !this.m_21255_() && !this.m_20069_() && !this.m_21023_(MobEffects.f_19620_)) { ItemStack itemstack = this.m_6844_(EquipmentSlot.CHEST); @@ -331,7 +331,7 @@ this.m_36320_(); return true; } -@@ -1561,6 +_,10 @@ +@@ -1543,6 +_,10 @@ } public void m_6756_(int p_36291_) { @@ -342,7 +342,7 @@ this.m_36401_(p_36291_); this.f_36080_ += (float)p_36291_ / (float)this.m_36323_(); this.f_36079_ = Mth.m_14045_(this.f_36079_ + p_36291_, 0, Integer.MAX_VALUE); -@@ -1589,7 +_,7 @@ +@@ -1571,7 +_,7 @@ } public void m_7408_(ItemStack p_36172_, int p_36173_) { @@ -351,7 +351,7 @@ if (this.f_36078_ < 0) { this.f_36078_ = 0; this.f_36080_ = 0.0F; -@@ -1600,6 +_,10 @@ +@@ -1582,6 +_,10 @@ } public void m_6749_(int p_36276_) { @@ -362,7 +362,7 @@ this.f_36078_ += p_36276_; if (this.f_36078_ < 0) { this.f_36078_ = 0; -@@ -1791,7 +_,11 @@ +@@ -1773,7 +_,11 @@ } public Component m_5446_() { @@ -375,7 +375,7 @@ return this.m_36218_(mutablecomponent); } -@@ -1928,24 +_,24 @@ +@@ -1910,24 +_,24 @@ Predicate predicate = ((ProjectileWeaponItem)p_36349_.m_41720_()).m_6442_(); ItemStack itemstack = ProjectileWeaponItem.m_43010_(this, predicate); if (!itemstack.m_41619_()) { @@ -404,7 +404,7 @@ this.m_36246_(Stats.f_12982_.m_12902_(p_36186_.m_41720_())); p_36185_.m_6263_((Player)null, this.m_20185_(), this.m_20186_(), this.m_20189_(), SoundEvents.f_12321_, SoundSource.PLAYERS, 0.5F, p_36185_.f_46441_.m_188501_() * 0.1F + 0.9F); if (this instanceof ServerPlayer) { -@@ -2032,5 +_,63 @@ +@@ -2014,5 +_,63 @@ public Component m_36423_() { return this.f_36413_; } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch index 8ec30f2350..d678e7dc48 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/AbstractArrow.java +++ b/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -149,7 +_,7 @@ +@@ -150,7 +_,7 @@ --this.f_36706_; } @@ -9,7 +9,7 @@ this.m_20095_(); } -@@ -185,7 +_,7 @@ +@@ -186,7 +_,7 @@ } } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch index 68286cff68..3e99d16dbf 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java +++ b/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -@@ -64,7 +_,7 @@ +@@ -65,7 +_,7 @@ } HitResult hitresult = ProjectileUtil.m_37294_(this, this::m_5603_); diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch index 446e08e925..6c34b13958 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/FishingHook.java +++ b/net/minecraft/world/entity/projectile/FishingHook.java -@@ -228,8 +_,8 @@ +@@ -229,8 +_,8 @@ private boolean m_37136_(Player p_37137_) { ItemStack itemstack = p_37137_.m_21205_(); ItemStack itemstack1 = p_37137_.m_21206_(); @@ -11,7 +11,7 @@ if (!p_37137_.m_213877_() && p_37137_.m_6084_() && (flag || flag1) && !(this.m_20280_(p_37137_) > 1024.0D)) { return false; } else { -@@ -240,7 +_,7 @@ +@@ -241,7 +_,7 @@ private void m_37171_() { HitResult hitresult = ProjectileUtil.m_37294_(this, this::m_5603_); @@ -20,7 +20,7 @@ } protected boolean m_5603_(Entity p_37135_) { -@@ -295,7 +_,7 @@ +@@ -296,7 +_,7 @@ double d1 = (double)((float)Mth.m_14107_(this.m_20186_()) + 1.0F); double d2 = this.m_20189_() + (double)(f2 * (float)this.f_37091_ * 0.1F); BlockState blockstate = serverlevel.m_8055_(new BlockPos(d0, d1 - 1.0D, d2)); @@ -29,7 +29,7 @@ if (this.f_19796_.m_188501_() < 0.15F) { serverlevel.m_8767_(ParticleTypes.f_123795_, d0, d1 - (double)0.1F, d2, 1, (double)f1, 0.1D, (double)f2, 0.0D); } -@@ -331,7 +_,7 @@ +@@ -332,7 +_,7 @@ double d5 = (double)((float)Mth.m_14107_(this.m_20186_()) + 1.0F); double d6 = this.m_20189_() + (double)(Mth.m_14089_(f6) * f7) * 0.1D; BlockState blockstate1 = serverlevel.m_8055_(new BlockPos(d4, d5 - 1.0D, d6)); @@ -38,7 +38,7 @@ serverlevel.m_8767_(ParticleTypes.f_123769_, d4, d5, d6, 2 + this.f_19796_.m_188503_(2), (double)0.1F, 0.0D, (double)0.1F, 0.0D); } } -@@ -402,6 +_,7 @@ +@@ -403,6 +_,7 @@ Player player = this.m_37168_(); if (!this.f_19853_.f_46443_ && player != null && !this.m_37136_(player)) { int i = 0; @@ -46,7 +46,7 @@ if (this.f_37094_ != null) { this.m_150155_(this.f_37094_); CriteriaTriggers.f_10553_.m_40416_((ServerPlayer)player, p_37157_, this, Collections.emptyList()); -@@ -409,8 +_,15 @@ +@@ -410,8 +_,15 @@ i = this.f_37094_ instanceof ItemEntity ? 3 : 5; } else if (this.f_37089_ > 0) { LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerLevel)this.f_19853_)).m_78972_(LootContextParams.f_81460_, this.m_20182_()).m_78972_(LootContextParams.f_81463_, p_37157_).m_78972_(LootContextParams.f_81455_, this).m_230911_(this.f_19796_).m_78963_((float)this.f_37096_ + player.m_36336_()); @@ -62,7 +62,7 @@ CriteriaTriggers.f_10553_.m_40416_((ServerPlayer)player, p_37157_, this, list); for(ItemStack itemstack : list) { -@@ -435,7 +_,7 @@ +@@ -436,7 +_,7 @@ } this.m_146870_(); diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch index d8e1fbe09d..86a03b827b 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch @@ -1,11 +1,12 @@ --- a/net/minecraft/world/entity/projectile/LargeFireball.java +++ b/net/minecraft/world/entity/projectile/LargeFireball.java -@@ -26,7 +_,7 @@ +@@ -25,7 +_,8 @@ protected void m_6532_(HitResult p_37218_) { super.m_6532_(p_37218_); if (!this.f_19853_.f_46443_) { - boolean flag = this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_); ++ // TODO 1.19.3: The creation of Level.ExplosionInteraction means this code path will fire EntityMobGriefingEvent twice. Should we try and fix it? -SS + boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this.m_37282_()); - this.f_19853_.m_46518_((Entity)null, this.m_20185_(), this.m_20186_(), this.m_20189_(), (float)this.f_37197_, flag, flag ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE); + this.f_19853_.m_255391_(this, this.m_20185_(), this.m_20186_(), this.m_20189_(), (float)this.f_37197_, flag, Level.ExplosionInteraction.MOB); this.m_146870_(); } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch index 0290dfd3be..327fdc44d9 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/Projectile.java +++ b/net/minecraft/world/entity/projectile/Projectile.java -@@ -211,7 +_,7 @@ +@@ -212,7 +_,7 @@ if (entity instanceof Player) { return entity.m_142265_(p_150167_, p_150168_); } else { diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch index a39bf01fe0..f4c0de75d3 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch @@ -8,8 +8,8 @@ + if (!event.isCanceled()) { // Don't indent to lower patch size if (this.f_19796_.m_188501_() < 0.05F && this.f_19853_.m_46469_().m_46207_(GameRules.f_46134_)) { Endermite endermite = EntityType.f_20567_.m_20615_(this.f_19853_); - endermite.m_7678_(entity.m_20185_(), entity.m_20186_(), entity.m_20189_(), entity.m_146908_(), entity.m_146909_()); -@@ -59,8 +_,10 @@ + if (endermite != null) { +@@ -61,8 +_,10 @@ entity.m_6021_(this.m_20185_(), this.m_20186_(), this.m_20189_()); } @@ -21,7 +21,7 @@ } } else if (entity != null) { entity.m_6021_(this.m_20185_(), this.m_20186_(), this.m_20189_()); -@@ -83,12 +_,12 @@ +@@ -85,12 +_,12 @@ } @Nullable diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch index 3885f6a8b3..1c9d5346e0 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/WitherSkull.java +++ b/net/minecraft/world/entity/projectile/WitherSkull.java -@@ -41,7 +_,7 @@ +@@ -40,7 +_,7 @@ } public float m_7077_(Explosion p_37619_, BlockGetter p_37620_, BlockPos p_37621_, BlockState p_37622_, FluidState p_37623_, float p_37624_) { @@ -9,12 +9,3 @@ } protected void m_5790_(EntityHitResult p_37626_) { -@@ -83,7 +_,7 @@ - protected void m_6532_(HitResult p_37628_) { - super.m_6532_(p_37628_); - if (!this.f_19853_.f_46443_) { -- Explosion.BlockInteraction explosion$blockinteraction = this.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; -+ Explosion.BlockInteraction explosion$blockinteraction = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_19853_, this.m_37282_()) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; - this.f_19853_.m_46518_(this, this.m_20185_(), this.m_20186_(), this.m_20189_(), 1.0F, false, explosion$blockinteraction); - this.m_146870_(); - } diff --git a/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch b/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch index f89740f054..37882eca8a 100644 --- a/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java -@@ -813,7 +_,7 @@ +@@ -817,7 +_,7 @@ } } @@ -9,7 +9,7 @@ VINDICATOR(EntityType.f_20493_, new int[]{0, 0, 2, 0, 1, 4, 2, 5}), EVOKER(EntityType.f_20568_, new int[]{0, 0, 0, 0, 0, 1, 1, 2}), PILLAGER(EntityType.f_20513_, new int[]{0, 4, 3, 3, 4, 4, 4, 2}), -@@ -827,6 +_,20 @@ +@@ -831,6 +_,20 @@ private RaiderType(EntityType p_37821_, int[] p_37822_) { this.f_37814_ = p_37821_; this.f_37815_ = p_37822_; diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch index efffcdbe11..3929ff026f 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/AbstractMinecart.java +++ b/net/minecraft/world/entity/vehicle/AbstractMinecart.java -@@ -46,7 +_,7 @@ +@@ -45,7 +_,7 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -9,7 +9,7 @@ private static final EntityDataAccessor f_38079_ = SynchedEntityData.m_135353_(AbstractMinecart.class, EntityDataSerializers.f_135028_); private static final EntityDataAccessor f_38080_ = SynchedEntityData.m_135353_(AbstractMinecart.class, EntityDataSerializers.f_135028_); private static final EntityDataAccessor f_38081_ = SynchedEntityData.m_135353_(AbstractMinecart.class, EntityDataSerializers.f_135029_); -@@ -76,6 +_,7 @@ +@@ -75,6 +_,7 @@ p_38135_.put(RailShape.NORTH_WEST, Pair.of(vec3i2, vec3i)); p_38135_.put(RailShape.NORTH_EAST, Pair.of(vec3i2, vec3i1)); }); @@ -17,7 +17,7 @@ private int f_38070_; private double f_38071_; private double f_38072_; -@@ -85,6 +_,7 @@ +@@ -84,6 +_,7 @@ private double f_38076_; private double f_38077_; private double f_38078_; @@ -25,7 +25,7 @@ protected AbstractMinecart(EntityType p_38087_, Level p_38088_) { super(p_38087_, p_38088_); -@@ -99,6 +_,14 @@ +@@ -98,6 +_,14 @@ this.f_19856_ = p_38094_; } @@ -40,7 +40,7 @@ public static AbstractMinecart m_38119_(Level p_38120_, double p_38121_, double p_38122_, double p_38123_, AbstractMinecart.Type p_38124_) { if (p_38124_ == AbstractMinecart.Type.CHEST) { return new MinecartChest(p_38120_, p_38121_, p_38122_, p_38123_); -@@ -133,7 +_,7 @@ +@@ -132,7 +_,7 @@ } public boolean m_6094_() { @@ -49,7 +49,7 @@ } protected Vec3 m_7643_(Direction.Axis p_38132_, BlockUtil.FoundRectangle p_38133_) { -@@ -302,9 +_,9 @@ +@@ -301,9 +_,9 @@ BlockPos blockpos = new BlockPos(k, i, j); BlockState blockstate = this.f_19853_.m_8055_(blockpos); @@ -61,7 +61,7 @@ this.m_6025_(k, i, j, blockstate.m_61143_(PoweredRailBlock.f_55215_)); } } else { -@@ -329,8 +_,11 @@ +@@ -328,8 +_,11 @@ } this.m_19915_(this.m_146908_(), this.m_146909_()); @@ -75,7 +75,7 @@ if (!list.isEmpty()) { for(int l = 0; l < list.size(); ++l) { Entity entity1 = list.get(l); -@@ -342,7 +_,7 @@ +@@ -341,7 +_,7 @@ } } } else { @@ -84,7 +84,7 @@ if (!this.m_20363_(entity) && entity.m_6094_() && entity instanceof AbstractMinecart) { entity.m_7334_(this); } -@@ -367,16 +_,23 @@ +@@ -366,16 +_,23 @@ } protected void m_38163_() { @@ -110,7 +110,7 @@ } } -@@ -390,18 +_,19 @@ +@@ -389,18 +_,19 @@ d1 = (double)p_38156_.m_123342_(); boolean flag = false; boolean flag1 = false; @@ -133,7 +133,7 @@ switch (railshape) { case ASCENDING_EAST: this.m_20256_(vec31.m_82520_(-d3, 0.0D, 0.0D)); -@@ -447,7 +_,7 @@ +@@ -446,7 +_,7 @@ } } @@ -142,7 +142,7 @@ double d22 = this.m_20184_().m_165924_(); if (d22 < 0.03D) { this.m_20256_(Vec3.f_82478_); -@@ -476,10 +_,7 @@ +@@ -475,10 +_,7 @@ d0 = d23 + d4 * d14; d2 = d10 + d5 * d14; this.m_6034_(d0, d1, d2); @@ -154,7 +154,7 @@ if (vec3i.m_123342_() != 0 && Mth.m_14107_(this.m_20185_()) - p_38156_.m_123341_() == vec3i.m_123341_() && Mth.m_14107_(this.m_20189_()) - p_38156_.m_123343_() == vec3i.m_123343_()) { this.m_6034_(this.m_20185_(), this.m_20186_() + (double)vec3i.m_123342_(), this.m_20189_()); } else if (vec3i1.m_123342_() != 0 && Mth.m_14107_(this.m_20185_()) - p_38156_.m_123341_() == vec3i1.m_123341_() && Mth.m_14107_(this.m_20189_()) - p_38156_.m_123343_() == vec3i1.m_123343_()) { -@@ -507,7 +_,10 @@ +@@ -506,7 +_,10 @@ this.m_20334_(d26 * (double)(j - p_38156_.m_123341_()), vec35.f_82480_, d26 * (double)(i - p_38156_.m_123343_())); } @@ -166,7 +166,7 @@ Vec3 vec36 = this.m_20184_(); double d27 = vec36.m_165924_(); if (d27 > 0.01D) { -@@ -567,7 +_,7 @@ +@@ -566,7 +_,7 @@ BlockState blockstate = this.f_19853_.m_8055_(new BlockPos(i, j, k)); if (BaseRailBlock.m_49416_(blockstate)) { @@ -175,7 +175,7 @@ p_38098_ = (double)j; if (railshape.m_61745_()) { p_38098_ = (double)(j + 1); -@@ -606,7 +_,7 @@ +@@ -605,7 +_,7 @@ BlockState blockstate = this.f_19853_.m_8055_(new BlockPos(i, j, k)); if (BaseRailBlock.m_49416_(blockstate)) { @@ -184,7 +184,7 @@ Pair pair = m_38125_(railshape); Vec3i vec3i = pair.getFirst(); Vec3i vec3i1 = pair.getSecond(); -@@ -668,6 +_,10 @@ +@@ -667,6 +_,10 @@ } public void m_7334_(Entity p_38165_) { @@ -195,7 +195,7 @@ if (!this.f_19853_.f_46443_) { if (!p_38165_.f_19794_ && !this.f_19794_) { if (!this.m_20363_(p_38165_)) { -@@ -701,11 +_,11 @@ +@@ -700,11 +_,11 @@ Vec3 vec32 = this.m_20184_(); Vec3 vec33 = p_38165_.m_20184_(); @@ -209,9 +209,9 @@ p_38165_.m_20256_(vec33.m_82542_(0.2D, 1.0D, 0.2D)); p_38165_.m_5997_(vec32.f_82479_ + d0, 0.0D, vec32.f_82481_ + d1); this.m_20256_(vec32.m_82542_(0.95D, 1.0D, 0.95D)); -@@ -808,6 +_,42 @@ - public Packet m_5654_() { - return new ClientboundAddEntityPacket(this); +@@ -803,6 +_,42 @@ + public void m_38138_(boolean p_38139_) { + this.m_20088_().m_135381_(f_38084_, p_38139_); } + + // Forge Start diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch index e82d69c7dd..abb2347b62 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/vehicle/Boat.java +++ b/net/minecraft/world/entity/vehicle/Boat.java -@@ -48,7 +_,7 @@ +@@ -50,7 +_,7 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; --public class Boat extends Entity { +-public class Boat extends Entity implements VariantHolder { +public class Boat extends Entity implements net.minecraftforge.common.extensions.IForgeBoat { private static final EntityDataAccessor f_38282_ = SynchedEntityData.m_135353_(Boat.class, EntityDataSerializers.f_135028_); private static final EntityDataAccessor f_38283_ = SynchedEntityData.m_135353_(Boat.class, EntityDataSerializers.f_135028_); private static final EntityDataAccessor f_38284_ = SynchedEntityData.m_135353_(Boat.class, EntityDataSerializers.f_135029_); -@@ -439,7 +_,7 @@ +@@ -452,7 +_,7 @@ for(int i2 = i1; i2 < j1; ++i2) { blockpos$mutableblockpos.m_122178_(l1, k1, i2); FluidState fluidstate = this.f_19853_.m_6425_(blockpos$mutableblockpos); @@ -18,7 +18,7 @@ f = Math.max(f, fluidstate.m_76155_(this.f_19853_, blockpos$mutableblockpos)); } -@@ -480,7 +_,7 @@ +@@ -493,7 +_,7 @@ blockpos$mutableblockpos.m_122178_(l1, k2, i2); BlockState blockstate = this.f_19853_.m_8055_(blockpos$mutableblockpos); if (!(blockstate.m_60734_() instanceof WaterlilyBlock) && Shapes.m_83157_(blockstate.m_60812_(this.f_19853_, blockpos$mutableblockpos).m_83216_((double)l1, (double)k2, (double)i2), voxelshape, BooleanOp.f_82689_)) { @@ -27,7 +27,7 @@ ++k1; } } -@@ -509,7 +_,7 @@ +@@ -522,7 +_,7 @@ for(int i2 = i1; i2 < j1; ++i2) { blockpos$mutableblockpos.m_122178_(k1, l1, i2); FluidState fluidstate = this.f_19853_.m_6425_(blockpos$mutableblockpos); @@ -36,7 +36,7 @@ float f = (float)l1 + fluidstate.m_76155_(this.f_19853_, blockpos$mutableblockpos); this.f_38277_ = Math.max((double)f, this.f_38277_); flag |= aabb.f_82289_ < (double)f; -@@ -539,7 +_,7 @@ +@@ -552,7 +_,7 @@ for(int i2 = i1; i2 < j1; ++i2) { blockpos$mutableblockpos.m_122178_(k1, l1, i2); FluidState fluidstate = this.f_19853_.m_6425_(blockpos$mutableblockpos); @@ -45,7 +45,7 @@ if (!fluidstate.m_76170_()) { return Boat.Status.UNDER_FLOWING_WATER; } -@@ -753,7 +_,7 @@ +@@ -766,7 +_,7 @@ } this.m_183634_(); @@ -54,7 +54,7 @@ this.f_19789_ -= (float)p_38307_; } -@@ -809,7 +_,7 @@ +@@ -822,7 +_,7 @@ } protected boolean m_7310_(Entity p_38390_) { @@ -63,7 +63,7 @@ } protected int m_213801_() { -@@ -834,6 +_,16 @@ +@@ -843,6 +_,16 @@ public boolean m_5842_() { return this.f_38279_ == Boat.Status.UNDER_WATER || this.f_38279_ == Boat.Status.UNDER_FLOWING_WATER; diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/ChestBoat.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/ChestBoat.java.patch index a37c3e2974..c2850b0312 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/ChestBoat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/ChestBoat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/ChestBoat.java +++ b/net/minecraft/world/entity/vehicle/ChestBoat.java -@@ -187,4 +_,26 @@ +@@ -190,4 +_,26 @@ public void m_213775_() { this.f_219864_ = NonNullList.m_122780_(this.m_6643_(), ItemStack.f_41583_); } diff --git a/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch index d19cd584c8..44acdcacb8 100644 --- a/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch @@ -1,26 +1,23 @@ --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -211,9 +_,11 @@ - private void m_150407_(int p_150408_, ItemStack p_150409_, Supplier p_150410_) { - ItemStack itemstack = this.f_38841_.get(p_150408_); - if (!ItemStack.m_41728_(itemstack, p_150409_)) { -+ boolean clientStackChanged = !p_150409_.equals(itemstack, true); - ItemStack itemstack1 = p_150410_.get(); - this.f_38841_.set(p_150408_, itemstack1); - -+ if(clientStackChanged) - for(ContainerListener containerlistener : this.f_38848_) { - containerlistener.m_7934_(this, p_150408_, itemstack1); +@@ -229,6 +_,8 @@ + ItemStack itemstack1 = p_150438_.get(); + this.f_150394_.set(p_150436_, itemstack1); + if (this.f_150397_ != null) { ++ // Forge: Only synchronize a slot change if the itemstack actually changed in a way that is relevant to the client (i.e. share tag changed) ++ if (!p_150437_.equals(itemstack, true)) + this.f_150397_.m_142074_(this, p_150436_, itemstack1); + } } -@@ -400,6 +_,7 @@ +@@ -401,6 +_,7 @@ ItemStack itemstack11 = this.m_142621_(); p_150434_.m_141945_(itemstack11, slot7.m_7993_(), clickaction); - if (!itemstack11.m_150926_(slot7, clickaction, p_150434_) && !itemstack10.m_150932_(itemstack11, slot7, clickaction, p_150434_, this.m_150446_())) { + if (!this.m_246200_(p_150434_, clickaction, slot7, itemstack10, itemstack11)) { + if (!net.minecraftforge.common.ForgeHooks.onItemStackedOn(itemstack11, itemstack10, slot7, clickaction, p_150434_, m_150446_())) if (itemstack10.m_41619_()) { if (!itemstack11.m_41619_()) { int l2 = clickaction == ClickAction.PRIMARY ? itemstack11.m_41613_() : 1; -@@ -601,14 +_,15 @@ +@@ -611,14 +_,15 @@ ItemStack itemstack = slot.m_7993_(); if (!itemstack.m_41619_() && ItemStack.m_150942_(p_38904_, itemstack)) { int j = itemstack.m_41613_() + p_38904_.m_41613_(); @@ -40,7 +37,7 @@ slot.m_6654_(); flag = true; } -@@ -708,7 +_,7 @@ +@@ -718,7 +_,7 @@ p_38925_.m_41764_(1); break; case 2: diff --git a/patches/minecraft/net/minecraft/world/inventory/MenuType.java.patch b/patches/minecraft/net/minecraft/world/inventory/MenuType.java.patch index 897b6cfe3d..778090bb13 100644 --- a/patches/minecraft/net/minecraft/world/inventory/MenuType.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/MenuType.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/inventory/MenuType.java +++ b/net/minecraft/world/inventory/MenuType.java -@@ -3,7 +_,7 @@ - import net.minecraft.core.Registry; +@@ -4,7 +_,7 @@ + import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.entity.player.Inventory; -public class MenuType { @@ -9,12 +9,12 @@ public static final MenuType f_39957_ = m_39988_("generic_9x1", ChestMenu::m_39234_); public static final MenuType f_39958_ = m_39988_("generic_9x2", ChestMenu::m_39243_); public static final MenuType f_39959_ = m_39988_("generic_9x3", ChestMenu::m_39255_); -@@ -42,6 +_,14 @@ +@@ -43,6 +_,14 @@ public T m_39985_(int p_39986_, Inventory p_39987_) { return this.f_39981_.m_39994_(p_39986_, p_39987_); + } -+ ++ + @Override + public T create(int windowId, Inventory playerInv, net.minecraft.network.FriendlyByteBuf extraData) { + if (this.f_39981_ instanceof net.minecraftforge.network.IContainerFactory) { diff --git a/patches/minecraft/net/minecraft/world/item/BannerItem.java.patch b/patches/minecraft/net/minecraft/world/item/BannerItem.java.patch index 9d66f62fe8..50184b8a2d 100644 --- a/patches/minecraft/net/minecraft/world/item/BannerItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BannerItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BannerItem.java +++ b/net/minecraft/world/item/BannerItem.java -@@ -35,7 +_,8 @@ +@@ -36,7 +_,8 @@ holder.m_203543_().map((p_220002_) -> { return p_220002_.m_135782_().m_214299_(); }).ifPresent((p_220006_) -> { diff --git a/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch b/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch index c83bbe306f..12af7c0140 100644 --- a/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -80,9 +_,9 @@ +@@ -82,9 +_,9 @@ } } @@ -12,7 +12,7 @@ if (player == null || !player.m_150110_().f_35937_) { itemstack.m_41774_(1); } -@@ -93,10 +_,16 @@ +@@ -95,10 +_,16 @@ } } @@ -29,7 +29,7 @@ @Nullable public BlockPlaceContext m_7732_(BlockPlaceContext p_40609_) { return p_40609_; -@@ -200,11 +_,19 @@ +@@ -195,11 +_,19 @@ } public Block m_40614_() { diff --git a/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch b/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch index 2092d7824e..3786816660 100644 --- a/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch +++ b/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch @@ -1,129 +1,160 @@ --- a/net/minecraft/world/item/CreativeModeTab.java +++ b/net/minecraft/world/item/CreativeModeTab.java -@@ -84,18 +_,23 @@ - private final String f_40763_; - private final Component f_40764_; - private String f_40765_; -+ @Deprecated - private String f_40766_ = "items.png"; +@@ -28,14 +_,26 @@ + private Consumer> f_256965_; + private final Supplier f_256912_; + private final CreativeModeTab.DisplayItemsGenerator f_256824_; + private net.minecraft.resources.ResourceLocation backgroundLocation; - private boolean f_40767_ = true; - private boolean f_40768_ = true; - private EnchantmentCategory[] f_40769_ = new EnchantmentCategory[0]; - private ItemStack f_40770_; ++ private final boolean hasSearchBar; ++ private final int searchBarWidth; ++ private final net.minecraft.resources.ResourceLocation tabsImage; ++ private final int labelColor; ++ private final int slotColor; -+ public CreativeModeTab(String label) { -+ this(-1, label); -+ } -+ - public CreativeModeTab(int p_40773_, String p_40774_) { -- this.f_40762_ = p_40773_; - this.f_40763_ = p_40774_; - this.f_40764_ = Component.m_237115_("itemGroup." + p_40774_); - this.f_40770_ = ItemStack.f_41583_; -- f_40748_[p_40773_] = this; -+ this.f_40762_ = addGroupSafe(p_40773_, this); +- CreativeModeTab(CreativeModeTab.Row p_260217_, int p_259557_, CreativeModeTab.Type p_260176_, Component p_260100_, Supplier p_259543_, CreativeModeTab.DisplayItemsGenerator p_259085_) { ++ CreativeModeTab(CreativeModeTab.Row p_260217_, int p_259557_, CreativeModeTab.Type p_260176_, Component p_260100_, Supplier p_259543_, CreativeModeTab.DisplayItemsGenerator p_259085_, net.minecraft.resources.ResourceLocation backgroundLocation, boolean hasSearchBar, int searchBarWidth, net.minecraft.resources.ResourceLocation tabsImage, int labelColor, int slotColor) { + this.f_256931_ = p_260217_; + this.f_256967_ = p_259557_; + this.f_40764_ = p_260100_; + this.f_256912_ = p_259543_; + this.f_256824_ = p_259085_; + this.f_256819_ = p_260176_; ++ this.backgroundLocation = backgroundLocation; ++ this.hasSearchBar = hasSearchBar; ++ this.searchBarWidth = searchBarWidth; ++ this.tabsImage = tabsImage; ++ this.labelColor = labelColor; ++ this.slotColor = slotColor; } - public int m_40775_() { -@@ -120,15 +_,28 @@ - - public abstract ItemStack m_6976_(); + public static CreativeModeTab.Builder m_257815_(CreativeModeTab.Row p_259342_, int p_260312_) { +@@ -54,6 +_,10 @@ + return this.f_40770_; + } + /** -+ * @deprecated Forge use {@link #getBackgroundImage()} instead ++ * Forge: Use {@link #getBackgroundLocation()} instead. + */ + @Deprecated public String m_40788_() { return this.f_40766_; } +@@ -92,7 +_,7 @@ + + public void m_258021_(FeatureFlagSet p_260125_, boolean p_259855_) { + CreativeModeTab.ItemDisplayBuilder creativemodetab$itemdisplaybuilder = new CreativeModeTab.ItemDisplayBuilder(this, p_260125_); +- this.f_256824_.m_257865_(p_260125_, creativemodetab$itemdisplaybuilder, p_259855_); ++ net.minecraftforge.client.ForgeHooksClient.onCreativeModeTabBuildContents(this, this.f_256824_).m_257865_(p_260125_, creativemodetab$itemdisplaybuilder, p_259855_); + this.f_243839_ = creativemodetab$itemdisplaybuilder.f_244363_; + this.f_243841_ = creativemodetab$itemdisplaybuilder.f_244585_; + this.m_257466_(); +@@ -121,9 +_,34 @@ -+ /** -+ * @deprecated Forge: use {@link #setBackgroundImage(net.minecraft.resources.ResourceLocation)} instead -+ */ -+ @Deprecated - public CreativeModeTab m_40779_(String p_40780_) { - this.f_40766_ = p_40780_; - return this; } -+ public CreativeModeTab setBackgroundImage(net.minecraft.resources.ResourceLocation texture) { -+ this.backgroundLocation = texture; -+ return this; -+ } -+ - public CreativeModeTab m_40784_(String p_40785_) { - this.f_40765_ = p_40785_; - return this; -@@ -153,10 +_,12 @@ - } - - public int m_40793_() { -+ if (f_40762_ > 11) return ((f_40762_ - 12) % 10) % 5; - return this.f_40762_ % 6; - } - - public boolean m_40794_() { -+ if (f_40762_ > 11) return ((f_40762_ - 12) % 10) < 5; - return this.f_40762_ < 6; - } - -@@ -190,5 +_,58 @@ - item.m_6787_(this, p_40778_); - } - -+ } -+ -+ public int getTabPage() { -+ return f_40762_ < 12 ? 0 : ((f_40762_ - 12) / 10) + 1; ++ public net.minecraft.resources.ResourceLocation getBackgroundLocation() { ++ return backgroundLocation; + } + + public boolean hasSearchBar() { -+ return f_40762_ == f_40754_.f_40762_; ++ return this.hasSearchBar; + } + -+ /** -+ * Gets the width of the search bar of the creative tab, use this if your -+ * creative tab name overflows together with a custom texture. -+ * -+ * @return The width of the search bar, 89 by default -+ */ -+ public int getSearchbarWidth() { -+ return 89; ++ public int getSearchBarWidth() { ++ return searchBarWidth; + } + -+ public net.minecraft.resources.ResourceLocation getBackgroundImage() { -+ if (backgroundLocation != null) return backgroundLocation; //FORGE: allow custom namespace -+ return new net.minecraft.resources.ResourceLocation("textures/gui/container/creative_inventory/tab_" + this.m_40788_()); -+ } -+ -+ private static final net.minecraft.resources.ResourceLocation CREATIVE_INVENTORY_TABS = new net.minecraft.resources.ResourceLocation("textures/gui/container/creative_inventory/tabs.png"); + public net.minecraft.resources.ResourceLocation getTabsImage() { -+ return CREATIVE_INVENTORY_TABS; ++ return tabsImage; + } + + public int getLabelColor() { -+ return 4210752; ++ return labelColor; + } + + public int getSlotColor() { -+ return -2130706433; ++ return slotColor; + } + -+ public static synchronized int getGroupCountSafe() { -+ return CreativeModeTab.f_40748_.length; -+ } + public static class Builder { + private static final CreativeModeTab.DisplayItemsGenerator f_256756_ = (p_259074_, p_259433_, p_260293_) -> { + }; ++ private static final net.minecraft.resources.ResourceLocation CREATIVE_INVENTORY_TABS_IMAGE = new net.minecraft.resources.ResourceLocation("textures/gui/container/creative_inventory/tabs.png"); + private final CreativeModeTab.Row f_256796_; + private final int f_256977_; + private Component f_256856_ = Component.m_237119_(); +@@ -136,6 +_,13 @@ + private boolean f_256854_ = false; + private CreativeModeTab.Type f_256847_ = CreativeModeTab.Type.CATEGORY; + private String f_257036_ = "items.png"; ++ @org.jetbrains.annotations.Nullable ++ private net.minecraft.resources.ResourceLocation backgroundLocation; ++ private boolean hasSearchBar = false; ++ private int searchBarWidth = 89; ++ private net.minecraft.resources.ResourceLocation tabsImage = CREATIVE_INVENTORY_TABS_IMAGE; ++ private int labelColor = 4210752; ++ private int slotColor = -2130706433; + + public Builder(CreativeModeTab.Row p_259171_, int p_259661_) { + this.f_256796_ = p_259171_; +@@ -174,23 +_,57 @@ + + protected CreativeModeTab.Builder m_257623_(CreativeModeTab.Type p_259283_) { + this.f_256847_ = p_259283_; ++ if (p_259283_ == Type.SEARCH) ++ return this.withSearchBar(); + return this; + } + + public CreativeModeTab.Builder m_257609_(String p_259981_) { +- this.f_257036_ = p_259981_; +- return this; ++ return withBackgroundLocation(new net.minecraft.resources.ResourceLocation("textures/gui/container/creative_inventory/tab_" + p_259981_)); ++ } + -+ private static synchronized int addGroupSafe(int index, CreativeModeTab newGroup) { -+ if(index == -1) { -+ index = f_40748_.length; ++ public CreativeModeTab.Builder withBackgroundLocation(net.minecraft.resources.ResourceLocation background) { ++ this.backgroundLocation = background; ++ return this; + } -+ if (index >= f_40748_.length) { -+ CreativeModeTab[] tmp = new CreativeModeTab[index + 1]; -+ System.arraycopy(f_40748_, 0, tmp, 0, f_40748_.length); -+ f_40748_ = tmp; ++ ++ public CreativeModeTab.Builder withSearchBar() { ++ this.hasSearchBar = true; ++ if (this.backgroundLocation == null) ++ return this.m_257609_("item_search.png"); ++ return this; + } -+ f_40748_[index] = newGroup; -+ return index; - } - } ++ ++ public CreativeModeTab.Builder withSearchBar(int searchBarWidth) { ++ this.searchBarWidth = searchBarWidth; ++ return withSearchBar(); ++ } ++ ++ public CreativeModeTab.Builder withTabsImage(net.minecraft.resources.ResourceLocation tabsImage) { ++ this.tabsImage = tabsImage; ++ return this; ++ } ++ ++ public CreativeModeTab.Builder withLabelColor(int labelColor) { ++ this.labelColor = labelColor; ++ return this; ++ } ++ ++ public CreativeModeTab.Builder withSlotColor(int slotColor) { ++ this.slotColor = slotColor; ++ return this; + } + + public CreativeModeTab m_257652_() { + if ((this.f_256847_ == CreativeModeTab.Type.HOTBAR || this.f_256847_ == CreativeModeTab.Type.INVENTORY) && this.f_256953_ != f_256756_) { + throw new IllegalStateException("Special tabs can't have display items"); + } else { +- CreativeModeTab creativemodetab = new CreativeModeTab(this.f_256796_, this.f_256977_, this.f_256847_, this.f_256856_, this.f_256981_, this.f_256953_); ++ CreativeModeTab creativemodetab = new CreativeModeTab(this.f_256796_, this.f_256977_, this.f_256847_, this.f_256856_, this.f_256981_, this.f_256953_, this.backgroundLocation, this.hasSearchBar, this.searchBarWidth, this.tabsImage, this.labelColor, this.slotColor); + creativemodetab.f_257018_ = this.f_256854_; + creativemodetab.f_40768_ = this.f_256851_; + creativemodetab.f_40767_ = this.f_256992_; + creativemodetab.f_40766_ = this.f_257036_; ++ creativemodetab.backgroundLocation = this.backgroundLocation != null ? this.backgroundLocation : new net.minecraft.resources.ResourceLocation("textures/gui/container/creative_inventory/tab_" + this.f_257036_); + return creativemodetab; + } + } diff --git a/patches/minecraft/net/minecraft/world/item/CreativeModeTabs.java.patch b/patches/minecraft/net/minecraft/world/item/CreativeModeTabs.java.patch new file mode 100644 index 0000000000..595cf3be0a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/CreativeModeTabs.java.patch @@ -0,0 +1,93 @@ +--- a/net/minecraft/world/item/CreativeModeTabs.java ++++ b/net/minecraft/world/item/CreativeModeTabs.java +@@ -1027,7 +_,7 @@ + }).m_257501_((p_261440_, p_261441_, p_261442_) -> { + Set set = ItemStackLinkedSet.m_261170_(); + +- for(CreativeModeTab creativemodetab : CreativeModeTabs.f_243931_) { ++ for(CreativeModeTab creativemodetab : CreativeModeTabs.m_257478_()) { + if (creativemodetab.m_257962_() != CreativeModeTab.Type.SEARCH) { + set.addAll(creativemodetab.m_261235_()); + } +@@ -1450,11 +_,15 @@ + return new ItemStack(Blocks.f_50087_); + }).m_257609_("inventory.png").m_257809_().m_257826_().m_257623_(CreativeModeTab.Type.INVENTORY).m_257794_().m_257652_(); + private static final List f_243931_ = m_257615_(f_256788_, f_256725_, f_256776_, f_256791_, f_257028_, f_256917_, f_256750_, f_256869_, f_256797_, f_256839_, f_256968_, f_256731_, f_256837_, f_257039_); ++ private static final List DEFAULT_TABS = com.google.common.collect.ImmutableList.of(f_256917_, f_256750_, f_256837_, f_257039_); + @Nullable + public static FeatureFlagSet f_256842_; + public static boolean f_256844_ = false; ++ private static final List FORGE_TABS_VIEW = net.minecraftforge.common.util.ConcatenatedListView.of(net.minecraftforge.common.CreativeModeTabRegistry.getSortedCreativeModeTabs(), DEFAULT_TABS); + + private static List m_257615_(CreativeModeTab... p_259856_) { ++ if (true) ++ return List.of(p_259856_); // Forge: We do not validate vanilla tabs here, we have our own mechanism for that. This should only be invoked when the field TABS is initialized, whose use-cases are patched out. + Map, String> map = new HashMap<>(); + + for(CreativeModeTab creativemodetab : p_259856_) { +@@ -1469,7 +_,7 @@ + } + + public static CreativeModeTab m_257543_() { +- return f_256788_; ++ return net.minecraftforge.common.CreativeModeTabRegistry.getSortedCreativeModeTabs().stream().filter(CreativeModeTab::m_257497_).findFirst().orElse(f_256788_); + } + + private static void m_247461_(CreativeModeTab.Output p_249919_, Item p_249272_, CreativeModeTab.TabVisibility p_251809_) { +@@ -1483,7 +_,7 @@ + + private static void m_247563_(CreativeModeTab.Output p_249134_, Set p_251824_, CreativeModeTab.TabVisibility p_250904_) { + for(Enchantment enchantment : BuiltInRegistries.f_256876_) { +- if (p_251824_.contains(enchantment.f_44672_)) { ++ if (enchantment.allowedInCreativeTab(Items.f_42690_, p_251824_)) { + p_249134_.m_246267_(EnchantedBookItem.m_41161_(new EnchantmentInstance(enchantment, enchantment.m_6586_())), p_250904_); + } + } +@@ -1492,7 +_,7 @@ + + private static void m_245641_(CreativeModeTab.Output p_249319_, Set p_249855_, CreativeModeTab.TabVisibility p_251772_) { + for(Enchantment enchantment : BuiltInRegistries.f_256876_) { +- if (p_249855_.contains(enchantment.f_44672_)) { ++ if (enchantment.allowedInCreativeTab(Items.f_42690_, p_249855_)) { + for(int i = enchantment.m_44702_(); i <= enchantment.m_6586_(); ++i) { + p_249319_.m_246267_(EnchantedBookItem.m_41161_(new EnchantmentInstance(enchantment, i)), p_251772_); + } +@@ -1531,11 +_,11 @@ + } + + public static List m_257388_() { +- return f_243931_.stream().filter(CreativeModeTab::m_257497_).toList(); ++ return FORGE_TABS_VIEW.stream().filter(CreativeModeTab::m_257497_).toList(); + } + + public static List m_257478_() { +- return f_243931_; ++ return FORGE_TABS_VIEW; + } + + public static CreativeModeTab m_258007_() { +@@ -1543,12 +_,12 @@ + } + + private static void m_257534_(FeatureFlagSet p_259307_, boolean p_260177_) { +- f_243931_.stream().filter((p_259647_) -> { ++ m_257478_().stream().filter((p_259647_) -> { + return p_259647_.m_257962_() == CreativeModeTab.Type.CATEGORY; + }).forEach((p_259425_) -> { + p_259425_.m_258021_(p_259307_, p_260177_); + }); +- f_243931_.stream().filter((p_260124_) -> { ++ m_257478_().stream().filter((p_260124_) -> { + return p_260124_.m_257962_() != CreativeModeTab.Type.CATEGORY; + }).forEach((p_259952_) -> { + p_259952_.m_258021_(p_259307_, p_260177_); +@@ -1568,5 +_,9 @@ + m_257534_(f_256842_, f_256844_); + return true; + } ++ } ++ ++ public static List defaultTabs() { ++ return DEFAULT_TABS; + } + } diff --git a/patches/minecraft/net/minecraft/world/item/CrossbowItem.java.patch b/patches/minecraft/net/minecraft/world/item/CrossbowItem.java.patch index f659deca02..0ecf23d3c4 100644 --- a/patches/minecraft/net/minecraft/world/item/CrossbowItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/CrossbowItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/CrossbowItem.java +++ b/net/minecraft/world/item/CrossbowItem.java -@@ -241,6 +_,7 @@ +@@ -240,6 +_,7 @@ } public static void m_40887_(Level p_40888_, LivingEntity p_40889_, InteractionHand p_40890_, ItemStack p_40891_, float p_40892_, float p_40893_) { diff --git a/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch b/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch index 72b33c42e0..5a26be0c10 100644 --- a/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch +++ b/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch @@ -16,7 +16,7 @@ this.f_41039_ = new float[]{(float)i / 255.0F, (float)j / 255.0F, (float)k / 255.0F}; this.f_41040_ = p_41050_; } -@@ -109,5 +_,22 @@ +@@ -100,5 +_,23 @@ public String m_7912_() { return this.f_41035_; @@ -31,7 +31,8 @@ + if (stack.m_41720_() instanceof DyeItem) + return ((DyeItem)stack.m_41720_()).m_41089_(); + -+ for (DyeColor color : f_41032_) { ++ for (int x = 0; x < BLACK.m_41060_(); x++) { ++ DyeColor color = m_41053_(x); + if (stack.m_204117_(color.getTag())) + return color; + } diff --git a/patches/minecraft/net/minecraft/world/item/EnchantedBookItem.java.patch b/patches/minecraft/net/minecraft/world/item/EnchantedBookItem.java.patch deleted file mode 100644 index 3b1d33c534..0000000000 --- a/patches/minecraft/net/minecraft/world/item/EnchantedBookItem.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/world/item/EnchantedBookItem.java -+++ b/net/minecraft/world/item/EnchantedBookItem.java -@@ -72,7 +_,7 @@ - public void m_6787_(CreativeModeTab p_41151_, NonNullList p_41152_) { - if (p_41151_ == CreativeModeTab.f_40754_) { - for(Enchantment enchantment : Registry.f_122825_) { -- if (enchantment.f_44672_ != null) { -+ if (enchantment.allowedInCreativeTab(this, p_41151_)) { - for(int i = enchantment.m_44702_(); i <= enchantment.m_6586_(); ++i) { - p_41152_.add(m_41161_(new EnchantmentInstance(enchantment, i))); - } -@@ -80,7 +_,7 @@ - } - } else if (p_41151_.m_40795_().length != 0) { - for(Enchantment enchantment1 : Registry.f_122825_) { -- if (p_41151_.m_40776_(enchantment1.f_44672_)) { -+ if (enchantment1.allowedInCreativeTab(this, p_41151_)) { - p_41152_.add(m_41161_(new EnchantmentInstance(enchantment1, enchantment1.m_6586_()))); - } - } diff --git a/patches/minecraft/net/minecraft/world/item/Item.java.patch b/patches/minecraft/net/minecraft/world/item/Item.java.patch index c10c61557b..2bf5870184 100644 --- a/patches/minecraft/net/minecraft/world/item/Item.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Item.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/item/Item.java +++ b/net/minecraft/world/item/Item.java -@@ -46,9 +_,9 @@ +@@ -49,9 +_,9 @@ import net.minecraft.world.phys.Vec3; import org.slf4j.Logger; --public class Item implements ItemLike { -+public class Item implements ItemLike, net.minecraftforge.common.extensions.IForgeItem { +-public class Item implements FeatureElement, ItemLike { ++public class Item implements FeatureElement, ItemLike, net.minecraftforge.common.extensions.IForgeItem { private static final Logger f_150883_ = LogUtils.getLogger(); - public static final Map f_41373_ = Maps.newHashMap(); + public static final Map f_41373_ = net.minecraftforge.registries.GameData.getBlockItemMap(); protected static final UUID f_41374_ = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); protected static final UUID f_41375_ = UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3"); public static final int f_150884_ = 64; -@@ -96,7 +_,8 @@ +@@ -98,7 +_,8 @@ f_150883_.error("Item classes should end with Item and {} doesn't.", (Object)s); } } @@ -22,7 +22,7 @@ } /** @deprecated */ -@@ -105,6 +_,8 @@ +@@ -107,6 +_,8 @@ return this.f_204113_; } @@ -31,7 +31,7 @@ public void m_5929_(Level p_41428_, LivingEntity p_41429_, ItemStack p_41430_, int p_41431_) { } -@@ -131,9 +_,9 @@ +@@ -133,9 +_,9 @@ } public InteractionResultHolder m_7203_(Level p_41432_, Player p_41433_, InteractionHand p_41434_) { @@ -44,7 +44,7 @@ p_41433_.m_6672_(p_41434_); return InteractionResultHolder.m_19096_(itemstack); } else { -@@ -148,10 +_,12 @@ +@@ -150,10 +_,12 @@ return this.m_41472_() ? p_41411_.m_5584_(p_41410_, p_41409_) : p_41409_; } @@ -57,7 +57,7 @@ public final int m_41462_() { return this.f_41371_; } -@@ -165,11 +_,12 @@ +@@ -167,11 +_,12 @@ } public int m_142158_(ItemStack p_150900_) { @@ -72,7 +72,7 @@ return Mth.m_14169_(f / 3.0F, 1.0F, 1.0F); } -@@ -226,10 +_,12 @@ +@@ -228,10 +_,12 @@ } @Nullable @@ -85,7 +85,7 @@ public boolean m_41470_() { return this.f_41378_ != null; } -@@ -250,7 +_,7 @@ +@@ -252,7 +_,7 @@ public int m_8105_(ItemStack p_41454_) { if (p_41454_.m_41720_().m_41472_()) { @@ -94,7 +94,7 @@ } else { return 0; } -@@ -292,7 +_,7 @@ +@@ -294,7 +_,7 @@ } public boolean m_8120_(ItemStack p_41456_) { @@ -103,7 +103,7 @@ } protected static BlockHitResult m_41435_(Level p_41436_, Player p_41437_, ClipContext.Fluid p_41438_) { -@@ -305,11 +_,13 @@ +@@ -307,11 +_,13 @@ float f5 = Mth.m_14031_(-f * ((float)Math.PI / 180F)); float f6 = f3 * f4; float f7 = f2 * f4; @@ -119,15 +119,7 @@ public int m_6473_() { return 0; } -@@ -322,6 +_,7 @@ - } - - protected boolean m_220152_(CreativeModeTab p_220153_) { -+ if (getCreativeTabs().stream().anyMatch(tab -> tab == p_220153_)) return true; - CreativeModeTab creativemodetab = this.m_41471_(); - return creativemodetab != null && (p_220153_ == CreativeModeTab.f_40754_ || p_220153_ == creativemodetab); - } -@@ -335,12 +_,20 @@ +@@ -320,12 +_,20 @@ return false; } @@ -149,7 +141,7 @@ } public ItemStack m_7968_() { -@@ -351,6 +_,8 @@ +@@ -336,6 +_,8 @@ return this.f_41380_ != null; } @@ -158,8 +150,8 @@ @Nullable public FoodProperties m_41473_() { return this.f_41380_; -@@ -381,6 +_,32 @@ - return true; +@@ -370,6 +_,32 @@ + return this.f_243811_; } + // FORGE START @@ -191,15 +183,15 @@ public static class Properties { int f_41478_ = 64; int f_41479_; -@@ -392,6 +_,7 @@ - @Nullable +@@ -380,6 +_,7 @@ FoodProperties f_41483_; boolean f_41484_; + FeatureFlagSet f_244559_ = FeatureFlags.f_244377_; + private boolean canRepair = true; public Item.Properties m_41489_(FoodProperties p_41490_) { this.f_41483_ = p_41490_; -@@ -434,6 +_,11 @@ +@@ -417,6 +_,11 @@ public Item.Properties m_41486_() { this.f_41484_ = true; @@ -210,4 +202,4 @@ + canRepair = false; return this; } - } + diff --git a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch index 51a673ae01..d440aedccf 100644 --- a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -70,7 +_,7 @@ +@@ -73,7 +_,7 @@ import net.minecraft.world.level.block.state.pattern.BlockInWorld; import org.slf4j.Logger; -public final class ItemStack { +public final class ItemStack extends net.minecraftforge.common.capabilities.CapabilityProvider implements net.minecraftforge.common.extensions.IForgeItemStack { - public static final Codec f_41582_ = RecordCodecBuilder.create((p_41697_) -> { - return p_41697_.group(Registry.f_122827_.m_194605_().fieldOf("id").forGetter((p_150946_) -> { + public static final Codec f_41582_ = RecordCodecBuilder.create((p_258963_) -> { + return p_258963_.group(BuiltInRegistries.f_257033_.m_194605_().fieldOf("id").forGetter((p_150946_) -> { return p_150946_.f_41589_; -@@ -80,6 +_,9 @@ +@@ -83,6 +_,9 @@ return Optional.ofNullable(p_150939_.f_41590_); - })).apply(p_41697_, ItemStack::new); + })).apply(p_258963_, ItemStack::new); }); + private final net.minecraft.core.Holder.Reference delegate; + private CompoundTag capNBT; @@ -19,7 +19,7 @@ private static final Logger f_41585_ = LogUtils.getLogger(); public static final ItemStack f_41583_ = new ItemStack((Item)null); public static final DecimalFormat f_41584_ = Util.m_137469_(new DecimalFormat("#.##"), (p_41704_) -> { -@@ -134,10 +_,15 @@ +@@ -138,10 +_,15 @@ this(p_220155_.m_203334_(), p_220156_); } @@ -39,14 +39,14 @@ this.m_41721_(this.m_41773_()); } -@@ -150,14 +_,19 @@ +@@ -154,14 +_,19 @@ } private ItemStack(CompoundTag p_41608_) { + super(ItemStack.class, true); + this.capNBT = p_41608_.m_128441_("ForgeCaps") ? p_41608_.m_128469_("ForgeCaps") : null; + Item rawItem = - this.f_41589_ = Registry.f_122827_.m_7745_(new ResourceLocation(p_41608_.m_128461_("id"))); + this.f_41589_ = BuiltInRegistries.f_257033_.m_7745_(new ResourceLocation(p_41608_.m_128461_("id"))); + this.delegate = net.minecraftforge.registries.ForgeRegistries.ITEMS.getDelegateOrThrow(rawItem); this.f_41587_ = p_41608_.m_128445_("Count"); if (p_41608_.m_128425_("tag", 10)) { @@ -60,7 +60,7 @@ this.m_41721_(this.m_41773_()); } -@@ -192,7 +_,7 @@ +@@ -200,7 +_,7 @@ } public Item m_41720_() { @@ -69,7 +69,7 @@ } public Holder m_220173_() { -@@ -220,6 +_,15 @@ +@@ -228,6 +_,15 @@ } public InteractionResult m_41661_(UseOnContext p_41662_) { @@ -85,7 +85,7 @@ Player player = p_41662_.m_43723_(); BlockPos blockpos = p_41662_.m_8083_(); BlockInWorld blockinworld = new BlockInWorld(p_41662_.m_43725_(), blockpos, false); -@@ -227,7 +_,7 @@ +@@ -235,7 +_,7 @@ return InteractionResult.PASS; } else { Item item = this.m_41720_(); @@ -94,7 +94,7 @@ if (player != null && interactionresult.m_146666_()) { player.m_36246_(Stats.f_12982_.m_12902_(item)); } -@@ -256,11 +_,15 @@ +@@ -264,11 +_,15 @@ p_41740_.m_128365_("tag", this.f_41590_.m_6426_()); } @@ -111,7 +111,7 @@ } public boolean m_41753_() { -@@ -268,7 +_,7 @@ +@@ -276,7 +_,7 @@ } public boolean m_41763_() { @@ -120,7 +120,7 @@ CompoundTag compoundtag = this.m_41783_(); return compoundtag == null || !compoundtag.m_128471_("Unbreakable"); } else { -@@ -277,19 +_,19 @@ +@@ -285,19 +_,19 @@ } public boolean m_41768_() { @@ -144,7 +144,7 @@ } public boolean m_220157_(int p_220158_, RandomSource p_220159_, @Nullable ServerPlayer p_220160_) { -@@ -325,6 +_,7 @@ +@@ -333,6 +_,7 @@ public void m_41622_(int p_41623_, T p_41624_, Consumer p_41625_) { if (!p_41624_.f_19853_.f_46443_ && (!(p_41624_ instanceof Player) || !((Player)p_41624_).m_150110_().f_35937_)) { if (this.m_41763_()) { @@ -152,7 +152,7 @@ if (this.m_220157_(p_41623_, p_41624_.m_217043_(), p_41624_ instanceof ServerPlayer ? (ServerPlayer)p_41624_ : null)) { p_41625_.accept(p_41624_); Item item = this.m_41720_(); -@@ -377,7 +_,7 @@ +@@ -385,7 +_,7 @@ } public boolean m_41735_(BlockState p_41736_) { @@ -161,7 +161,7 @@ } public InteractionResult m_41647_(Player p_41648_, LivingEntity p_41649_, InteractionHand p_41650_) { -@@ -388,7 +_,7 @@ +@@ -396,7 +_,7 @@ if (this.m_41619_()) { return f_41583_; } else { @@ -170,7 +170,7 @@ itemstack.m_41754_(this.m_41612_()); if (this.f_41590_ != null) { itemstack.f_41590_ = this.f_41590_.m_6426_(); -@@ -405,7 +_,7 @@ +@@ -419,7 +_,7 @@ if (p_41659_.f_41590_ == null && p_41660_.f_41590_ != null) { return false; } else { @@ -179,7 +179,7 @@ } } else { return false; -@@ -428,7 +_,7 @@ +@@ -442,7 +_,7 @@ } else if (this.f_41590_ == null && p_41745_.f_41590_ != null) { return false; } else { @@ -188,7 +188,7 @@ } } -@@ -552,7 +_,7 @@ +@@ -550,7 +_,7 @@ public void m_41751_(@Nullable CompoundTag p_41752_) { this.f_41590_ = p_41752_; @@ -197,7 +197,7 @@ this.m_41721_(this.m_41773_()); } -@@ -613,7 +_,7 @@ +@@ -611,7 +_,7 @@ public List m_41651_(@Nullable Player p_41652_, TooltipFlag p_41653_) { List list = Lists.newArrayList(); @@ -206,15 +206,15 @@ if (this.m_41788_()) { mutablecomponent.m_130940_(ChatFormatting.ITALIC); } -@@ -752,6 +_,7 @@ - } +@@ -754,6 +_,7 @@ + list.add(f_243862_); } + net.minecraftforge.event.ForgeEventFactory.onItemTooltip(this, p_41652_, list, p_41653_); return list; } -@@ -760,7 +_,7 @@ +@@ -762,7 +_,7 @@ } private int m_41618_() { @@ -223,7 +223,7 @@ } public void m_41654_(ItemStack.TooltipPart p_41655_) { -@@ -875,9 +_,10 @@ +@@ -877,9 +_,10 @@ } } } else { @@ -235,7 +235,7 @@ return multimap; } -@@ -905,7 +_,7 @@ +@@ -907,7 +_,7 @@ MutableComponent mutablecomponent1 = ComponentUtils.m_130748_(mutablecomponent); if (!this.f_41591_) { @@ -244,7 +244,7 @@ return p_220170_.m_131144_(new HoverEvent(HoverEvent.Action.f_130832_, new HoverEvent.ItemStackInfo(this))); }); } -@@ -958,12 +_,31 @@ +@@ -960,12 +_,31 @@ this.m_41720_().m_5929_(p_41732_, p_41733_, this, p_41734_); } diff --git a/patches/minecraft/net/minecraft/world/item/Items.java.patch b/patches/minecraft/net/minecraft/world/item/Items.java.patch index 2bf95c7582..c502b84431 100644 --- a/patches/minecraft/net/minecraft/world/item/Items.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Items.java.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/world/item/Items.java +++ b/net/minecraft/world/item/Items.java -@@ -1190,11 +_,23 @@ +@@ -1210,11 +_,23 @@ } - private static Item m_151089_(Block p_151090_, CreativeModeTab p_151091_, Block... p_151092_) { -- BlockItem blockitem = new BlockItem(p_151090_, (new Item.Properties()).m_41491_(p_151091_)); -+ BlockItem blockitem = new BlockItem(p_151090_, (new Item.Properties()).m_41491_(p_151091_)) { + private static Item m_245048_(Block p_252092_, Block... p_248886_) { +- BlockItem blockitem = new BlockItem(p_252092_, new Item.Properties()); ++ BlockItem blockitem = new BlockItem(p_252092_, new Item.Properties()) { + @Override + public void m_6192_(java.util.Map map, Item self) { + super.m_6192_(map, self); -+ for (Block b : p_151092_) { ++ for (Block b : p_248886_) { + map.put(b, self); + } + } -- for(Block block : p_151092_) { +- for(Block block : p_248886_) { - Item.f_41373_.put(block, blockitem); - } + @Override + public void removeFromBlockToItemMap(java.util.Map map, Item self) { + super.removeFromBlockToItemMap(map, self); -+ for (Block b : p_151092_) { ++ for (Block b : p_248886_) { + map.remove(b); + } + } diff --git a/patches/minecraft/net/minecraft/world/item/MapItem.java.patch b/patches/minecraft/net/minecraft/world/item/MapItem.java.patch index 5703d9dfe4..368212ac6d 100644 --- a/patches/minecraft/net/minecraft/world/item/MapItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/MapItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/MapItem.java +++ b/net/minecraft/world/item/MapItem.java -@@ -56,8 +_,18 @@ +@@ -58,8 +_,18 @@ @Nullable public static MapItemSavedData m_42853_(ItemStack p_42854_, Level p_42855_) { diff --git a/patches/minecraft/net/minecraft/world/item/PotionItem.java.patch b/patches/minecraft/net/minecraft/world/item/PotionItem.java.patch index 4793da9538..10e55f9670 100644 --- a/patches/minecraft/net/minecraft/world/item/PotionItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/PotionItem.java.patch @@ -1,18 +1,10 @@ --- a/net/minecraft/world/item/PotionItem.java +++ b/net/minecraft/world/item/PotionItem.java -@@ -127,12 +_,12 @@ +@@ -124,6 +_,6 @@ } public boolean m_5812_(ItemStack p_42999_) { - return super.m_5812_(p_42999_) || !PotionUtils.m_43547_(p_42999_).isEmpty(); + return super.m_5812_(p_42999_) || PotionUtils.m_43579_(p_42999_).isFoil(p_42999_); } - - public void m_6787_(CreativeModeTab p_42981_, NonNullList p_42982_) { -- if (this.m_220152_(p_42981_)) { -- for(Potion potion : Registry.f_122828_) { -+ for(Potion potion : Registry.f_122828_) { -+ if (potion.allowedInCreativeTab(this, p_42981_, this.m_220152_(p_42981_))) { - if (potion != Potions.f_43598_) { - p_42982_.add(PotionUtils.m_43549_(new ItemStack(this), potion)); - } + } diff --git a/patches/minecraft/net/minecraft/world/item/SpawnEggItem.java.patch b/patches/minecraft/net/minecraft/world/item/SpawnEggItem.java.patch index 25352c2d1f..d65d126dc7 100644 --- a/patches/minecraft/net/minecraft/world/item/SpawnEggItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/SpawnEggItem.java.patch @@ -24,3 +24,32 @@ @Nullable public static SpawnEggItem m_43213_(@Nullable EntityType p_43214_) { return f_43201_.get(p_43214_); +@@ -141,15 +_,15 @@ + if (p_43229_ != null && p_43229_.m_128425_("EntityTag", 10)) { + CompoundTag compoundtag = p_43229_.m_128469_("EntityTag"); + if (compoundtag.m_128425_("id", 8)) { +- return EntityType.m_20632_(compoundtag.m_128461_("id")).orElse(this.f_43204_); ++ return EntityType.m_20632_(compoundtag.m_128461_("id")).orElse(this.getDefaultType()); + } + } + +- return this.f_43204_; ++ return this.getDefaultType(); + } + + public FeatureFlagSet m_245183_() { +- return this.f_43204_.m_245183_(); ++ return this.getDefaultType().m_245183_(); + } + + public Optional m_43215_(Player p_43216_, Mob p_43217_, EntityType p_43218_, ServerLevel p_43219_, Vec3 p_43220_, ItemStack p_43221_) { +@@ -184,5 +_,9 @@ + } + } + } ++ } ++ ++ protected EntityType getDefaultType() { ++ return f_43204_; + } + } diff --git a/patches/minecraft/net/minecraft/world/item/StandingAndWallBlockItem.java.patch b/patches/minecraft/net/minecraft/world/item/StandingAndWallBlockItem.java.patch index b2f8cd3020..7656465d46 100644 --- a/patches/minecraft/net/minecraft/world/item/StandingAndWallBlockItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/StandingAndWallBlockItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/StandingAndWallBlockItem.java +++ b/net/minecraft/world/item/StandingAndWallBlockItem.java -@@ -42,4 +_,9 @@ +@@ -48,4 +_,9 @@ super.m_6192_(p_43252_, p_43253_); p_43252_.put(this.f_43246_, p_43253_); } diff --git a/patches/minecraft/net/minecraft/world/item/SuspiciousStewItem.java.patch b/patches/minecraft/net/minecraft/world/item/SuspiciousStewItem.java.patch index 4befe5bb3c..fb04d49fbc 100644 --- a/patches/minecraft/net/minecraft/world/item/SuspiciousStewItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/SuspiciousStewItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/SuspiciousStewItem.java +++ b/net/minecraft/world/item/SuspiciousStewItem.java -@@ -22,6 +_,7 @@ +@@ -29,6 +_,7 @@ ListTag listtag = compoundtag.m_128437_("Effects", 9); CompoundTag compoundtag1 = new CompoundTag(); compoundtag1.m_128405_("EffectId", MobEffect.m_19459_(p_43260_)); @@ -8,11 +8,11 @@ compoundtag1.m_128405_("EffectDuration", p_43261_); listtag.add(compoundtag1); compoundtag.m_128365_("Effects", listtag); -@@ -41,6 +_,7 @@ +@@ -49,6 +_,7 @@ } MobEffect mobeffect = MobEffect.m_19453_(compoundtag1.m_128451_("EffectId")); + mobeffect = net.minecraftforge.common.ForgeHooks.loadMobEffect(compoundtag1, "forge:effect_id", mobeffect); if (mobeffect != null) { - p_43265_.m_7292_(new MobEffectInstance(mobeffect, j)); + p_259500_.accept(new MobEffectInstance(mobeffect, j)); } diff --git a/patches/minecraft/net/minecraft/world/item/TippedArrowItem.java.patch b/patches/minecraft/net/minecraft/world/item/TippedArrowItem.java.patch deleted file mode 100644 index 7f789fa142..0000000000 --- a/patches/minecraft/net/minecraft/world/item/TippedArrowItem.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/world/item/TippedArrowItem.java -+++ b/net/minecraft/world/item/TippedArrowItem.java -@@ -20,8 +_,8 @@ - } - - public void m_6787_(CreativeModeTab p_43356_, NonNullList p_43357_) { -- if (this.m_220152_(p_43356_)) { -- for(Potion potion : Registry.f_122828_) { -+ for (Potion potion : Registry.f_122828_) { -+ if (potion.allowedInCreativeTab(this, p_43356_, this.m_220152_(p_43356_))) { - if (!potion.m_43488_().isEmpty()) { - p_43357_.add(PotionUtils.m_43549_(new ItemStack(this), potion)); - } diff --git a/patches/minecraft/net/minecraft/world/item/alchemy/PotionBrewing.java.patch b/patches/minecraft/net/minecraft/world/item/alchemy/PotionBrewing.java.patch index 00e1b1f9e0..4eabfa660d 100644 --- a/patches/minecraft/net/minecraft/world/item/alchemy/PotionBrewing.java.patch +++ b/patches/minecraft/net/minecraft/world/item/alchemy/PotionBrewing.java.patch @@ -51,7 +51,7 @@ } @@ -196,7 +_,7 @@ } else if (!(p_43505_ instanceof PotionItem)) { - throw new IllegalArgumentException("Expected a potion, got: " + Registry.f_122827_.m_7981_(p_43505_)); + throw new IllegalArgumentException("Expected a potion, got: " + BuiltInRegistries.f_257033_.m_7981_(p_43505_)); } else { - f_43495_.add(new PotionBrewing.Mix<>(p_43503_, Ingredient.m_43929_(p_43504_), p_43505_)); + f_43495_.add(new PotionBrewing.Mix<>(net.minecraftforge.registries.ForgeRegistries.ITEMS, p_43503_, Ingredient.m_43929_(p_43504_), p_43505_)); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch index f45f36b507..50cff6945c 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/Ingredient.java +++ b/net/minecraft/world/item/crafting/Ingredient.java -@@ -29,12 +_,19 @@ +@@ -30,12 +_,19 @@ import net.minecraft.world.level.ItemLike; public class Ingredient implements Predicate { @@ -20,29 +20,29 @@ protected Ingredient(Stream p_43907_) { this.f_43902_ = p_43907_.toArray((p_43933_) -> { -@@ -78,7 +_,8 @@ +@@ -72,7 +_,8 @@ } public IntList m_43931_() { - if (this.f_43904_ == null) { + if (this.f_43904_ == null || checkInvalidation()) { + this.markValid(); - this.m_43948_(); - this.f_43904_ = new IntArrayList(this.f_43903_.length); + ItemStack[] aitemstack = this.m_43908_(); + this.f_43904_ = new IntArrayList(aitemstack.length); -@@ -94,6 +_,10 @@ +@@ -87,6 +_,10 @@ + } public final void m_43923_(FriendlyByteBuf p_43924_) { - this.m_43948_(); + if (!this.isVanilla()) { + net.minecraftforge.common.crafting.CraftingHelper.write(p_43924_, this); + return; + } - p_43924_.m_236828_(Arrays.asList(this.f_43903_), FriendlyByteBuf::m_130055_); + p_43924_.m_236828_(Arrays.asList(this.m_43908_()), FriendlyByteBuf::m_130055_); } -@@ -115,6 +_,38 @@ - return this.f_43902_.length == 0 && (this.f_43903_ == null || this.f_43903_.length == 0) && (this.f_43904_ == null || this.f_43904_.isEmpty()); +@@ -108,6 +_,38 @@ + return this.f_43902_.length == 0; } + public final boolean checkInvalidation() { @@ -79,8 +79,8 @@ + public static Ingredient m_43938_(Stream p_43939_) { Ingredient ingredient = new Ingredient(p_43939_); - return ingredient.f_43902_.length == 0 ? f_43901_ : ingredient; -@@ -143,11 +_,15 @@ + return ingredient.m_43947_() ? f_43901_ : ingredient; +@@ -136,11 +_,15 @@ } public static Ingredient m_43940_(FriendlyByteBuf p_43941_) { @@ -97,7 +97,7 @@ if (p_43918_.isJsonObject()) { return m_43938_(Stream.of(m_43919_(p_43918_.getAsJsonObject()))); } else if (p_43918_.isJsonArray()) { -@@ -182,6 +_,12 @@ +@@ -175,6 +_,12 @@ } } @@ -110,7 +110,7 @@ public static class ItemValue implements Ingredient.Value { private final ItemStack f_43951_; -@@ -214,6 +_,9 @@ +@@ -207,6 +_,9 @@ list.add(new ItemStack(holder)); } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch index 37b3713b3f..a913f23d81 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch @@ -50,7 +50,7 @@ + + public static Recipe fromJson(ResourceLocation p_44046_, JsonObject p_44047_, net.minecraftforge.common.crafting.conditions.ICondition.IContext context) { String s = GsonHelper.m_13906_(p_44047_, "type"); - return Registry.f_122865_.m_6612_(new ResourceLocation(s)).orElseThrow(() -> { + return BuiltInRegistries.f_256769_.m_6612_(new ResourceLocation(s)).orElseThrow(() -> { return new JsonSyntaxException("Invalid or unsupported recipe type '" + s + "'"); - }).m_6729_(p_44046_, p_44047_); + }).fromJson(p_44046_, p_44047_, context); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/RecipeSerializer.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/RecipeSerializer.java.patch index dc4a038678..1fbeaa9c79 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/RecipeSerializer.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/RecipeSerializer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/RecipeSerializer.java +++ b/net/minecraft/world/item/crafting/RecipeSerializer.java -@@ -5,7 +_,7 @@ +@@ -6,7 +_,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; @@ -8,8 +8,8 @@ +public interface RecipeSerializer> extends net.minecraftforge.common.extensions.IForgeRecipeSerializer { RecipeSerializer f_44076_ = m_44098_("crafting_shaped", new ShapedRecipe.Serializer()); RecipeSerializer f_44077_ = m_44098_("crafting_shapeless", new ShapelessRecipe.Serializer()); - SimpleRecipeSerializer f_44078_ = m_44098_("crafting_special_armordye", new SimpleRecipeSerializer<>(ArmorDyeRecipe::new)); -@@ -28,8 +_,10 @@ + RecipeSerializer f_44078_ = m_44098_("crafting_special_armordye", new SimpleCraftingRecipeSerializer<>(ArmorDyeRecipe::new)); +@@ -29,8 +_,10 @@ RecipeSerializer f_44095_ = m_44098_("stonecutting", new SingleItemRecipe.Serializer<>(StonecutterRecipe::new)); RecipeSerializer f_44096_ = m_44098_("smithing", new UpgradeRecipe.Serializer()); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/RecipeType.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/RecipeType.java.patch index 4f958eb612..6838525233 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/RecipeType.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/RecipeType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/RecipeType.java +++ b/net/minecraft/world/item/crafting/RecipeType.java -@@ -19,4 +_,14 @@ +@@ -20,4 +_,14 @@ } }); } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch index 93aea7b9b5..48b578ef8c 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch @@ -22,7 +22,7 @@ final int f_44146_; final int f_44147_; final NonNullList f_44148_; -@@ -109,10 +_,20 @@ +@@ -115,10 +_,20 @@ return this.f_44146_; } @@ -43,7 +43,7 @@ static NonNullList m_44202_(String[] p_44203_, Map p_44204_, int p_44205_, int p_44206_) { NonNullList nonnulllist = NonNullList.m_122780_(p_44205_ * p_44206_, Ingredient.f_43901_); Set set = Sets.newHashSet(p_44204_.keySet()); -@@ -179,7 +_,7 @@ +@@ -185,7 +_,7 @@ return nonnulllist.isEmpty() || nonnulllist.stream().filter((p_151277_) -> { return !p_151277_.m_43947_(); }).anyMatch((p_151273_) -> { @@ -52,7 +52,7 @@ }); } -@@ -201,15 +_,15 @@ +@@ -207,15 +_,15 @@ static String[] m_44196_(JsonArray p_44197_) { String[] astring = new String[p_44197_.size()]; @@ -72,7 +72,7 @@ } if (i > 0 && astring[0].length() != s.length()) { -@@ -243,17 +_,7 @@ +@@ -249,17 +_,7 @@ } public static ItemStack m_151274_(JsonObject p_151275_) { @@ -91,11 +91,11 @@ } public static Item m_151278_(JsonObject p_151279_) { -@@ -269,6 +_,7 @@ +@@ -275,6 +_,7 @@ } public static class Serializer implements RecipeSerializer { + private static final ResourceLocation NAME = new ResourceLocation("minecraft", "crafting_shaped"); public ShapedRecipe m_6729_(ResourceLocation p_44236_, JsonObject p_44237_) { String s = GsonHelper.m_13851_(p_44237_, "group", ""); - Map map = ShapedRecipe.m_44210_(GsonHelper.m_13930_(p_44237_, "key")); + CraftingBookCategory craftingbookcategory = CraftingBookCategory.f_244644_.m_262792_(GsonHelper.m_13851_(p_44237_, "category", (String)null), CraftingBookCategory.MISC); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch index 32a998ada1..e63685313b 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch @@ -1,21 +1,22 @@ --- a/net/minecraft/world/item/crafting/ShapelessRecipe.java +++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java -@@ -18,12 +_,14 @@ - final String f_44242_; +@@ -19,6 +_,7 @@ + final CraftingBookCategory f_244076_; final ItemStack f_44243_; final NonNullList f_44244_; + private final boolean isSimple; - public ShapelessRecipe(ResourceLocation p_44246_, String p_44247_, ItemStack p_44248_, NonNullList p_44249_) { - this.f_44241_ = p_44246_; - this.f_44242_ = p_44247_; - this.f_44243_ = p_44248_; - this.f_44244_ = p_44249_; -+ this.isSimple = p_44249_.stream().allMatch(Ingredient::isSimple); + public ShapelessRecipe(ResourceLocation p_251840_, String p_249640_, CraftingBookCategory p_249390_, ItemStack p_252071_, NonNullList p_250689_) { + this.f_44241_ = p_251840_; +@@ -26,6 +_,7 @@ + this.f_244076_ = p_249390_; + this.f_44243_ = p_252071_; + this.f_44244_ = p_250689_; ++ this.isSimple = p_250689_.stream().allMatch(Ingredient::isSimple); } public ResourceLocation m_6423_() { -@@ -48,17 +_,20 @@ +@@ -54,17 +_,20 @@ public boolean m_5818_(CraftingContainer p_44262_, Level p_44263_) { StackedContents stackedcontents = new StackedContents(); @@ -37,13 +38,14 @@ } public ItemStack m_5874_(CraftingContainer p_44260_) { -@@ -70,13 +_,14 @@ +@@ -76,14 +_,15 @@ } public static class Serializer implements RecipeSerializer { + private static final ResourceLocation NAME = new ResourceLocation("minecraft", "crafting_shapeless"); public ShapelessRecipe m_6729_(ResourceLocation p_44290_, JsonObject p_44291_) { String s = GsonHelper.m_13851_(p_44291_, "group", ""); + CraftingBookCategory craftingbookcategory = CraftingBookCategory.f_244644_.m_262792_(GsonHelper.m_13851_(p_44291_, "category", (String)null), CraftingBookCategory.MISC); NonNullList nonnulllist = m_44275_(GsonHelper.m_13933_(p_44291_, "ingredients")); if (nonnulllist.isEmpty()) { throw new JsonParseException("No ingredients for shapeless recipe"); @@ -53,8 +55,8 @@ + throw new JsonParseException("Too many ingredients for shapeless recipe. The maximum is " + (ShapedRecipe.MAX_WIDTH * ShapedRecipe.MAX_HEIGHT)); } else { ItemStack itemstack = ShapedRecipe.m_151274_(GsonHelper.m_13930_(p_44291_, "result")); - return new ShapelessRecipe(p_44290_, s, itemstack, nonnulllist); -@@ -88,7 +_,7 @@ + return new ShapelessRecipe(p_44290_, s, craftingbookcategory, itemstack, nonnulllist); +@@ -95,7 +_,7 @@ for(int i = 0; i < p_44276_.size(); ++i) { Ingredient ingredient = Ingredient.m_43917_(p_44276_.get(i)); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch index ab74c3b598..39a41ee075 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/crafting/SimpleCookingSerializer.java +++ b/net/minecraft/world/item/crafting/SimpleCookingSerializer.java -@@ -21,11 +_,17 @@ - String s = GsonHelper.m_13851_(p_44348_, "group", ""); +@@ -22,11 +_,17 @@ + CookingBookCategory cookingbookcategory = CookingBookCategory.f_244271_.m_262792_(GsonHelper.m_13851_(p_44348_, "category", (String)null), CookingBookCategory.MISC); JsonElement jsonelement = (JsonElement)(GsonHelper.m_13885_(p_44348_, "ingredient") ? GsonHelper.m_13933_(p_44348_, "ingredient") : GsonHelper.m_13930_(p_44348_, "ingredient")); Ingredient ingredient = Ingredient.m_43917_(jsonelement); + //Forge: Check if primitive string to keep vanilla or a object which can contain a count field. @@ -11,11 +11,11 @@ + else { String s1 = GsonHelper.m_13906_(p_44348_, "result"); ResourceLocation resourcelocation = new ResourceLocation(s1); -- ItemStack itemstack = new ItemStack(Registry.f_122827_.m_6612_(resourcelocation).orElseThrow(() -> { -+ itemstack = new ItemStack(Registry.f_122827_.m_6612_(resourcelocation).orElseThrow(() -> { +- ItemStack itemstack = new ItemStack(BuiltInRegistries.f_257033_.m_6612_(resourcelocation).orElseThrow(() -> { ++ itemstack = new ItemStack(BuiltInRegistries.f_257033_.m_6612_(resourcelocation).orElseThrow(() -> { return new IllegalStateException("Item: " + s1 + " does not exist"); })); + } float f = GsonHelper.m_13820_(p_44348_, "experience", 0.0F); int i = GsonHelper.m_13824_(p_44348_, "cookingtime", this.f_44327_); - return this.f_44328_.m_44352_(p_44347_, s, ingredient, itemstack, f, i); + return this.f_44328_.m_44352_(p_44347_, s, cookingbookcategory, ingredient, itemstack, f, i); diff --git a/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch b/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch index 7804f1863d..ec7f06a013 100644 --- a/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch +++ b/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/enchantment/EnchantmentHelper.java +++ b/net/minecraft/world/item/enchantment/EnchantmentHelper.java @@ -59,7 +_,14 @@ - return Registry.f_122825_.m_7981_(p_182433_); + return BuiltInRegistries.f_256876_.m_7981_(p_182433_); } + /** @deprecated forge: use {@link #getTagEnchantmentLevel(Enchantment, ItemStack)} or {@link ItemStack#getEnchantmentLevel(Enchantment)} */ @@ -75,7 +75,7 @@ @@ -396,7 +_,7 @@ boolean flag = p_44819_.m_150930_(Items.f_42517_); - for(Enchantment enchantment : Registry.f_122825_) { + for(Enchantment enchantment : BuiltInRegistries.f_256876_) { - if ((!enchantment.m_6591_() || p_44820_) && enchantment.m_6592_() && (enchantment.f_44672_.m_7454_(item) || flag)) { + if ((!enchantment.m_6591_() || p_44820_) && enchantment.m_6592_() && (enchantment.canApplyAtEnchantingTable(p_44819_) || (flag && enchantment.isAllowedOnBooks()))) { for(int i = enchantment.m_6586_(); i > enchantment.m_44702_() - 1; --i) { diff --git a/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch index ea4968c6fa..cc6570f14d 100644 --- a/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/world/level/BaseSpawner.java +++ b/net/minecraft/world/level/BaseSpawner.java -@@ -127,11 +_,15 @@ +@@ -131,11 +_,15 @@ entity.m_7678_(entity.m_20185_(), entity.m_20186_(), entity.m_20189_(), randomsource.m_188501_() * 360.0F, 0.0F); if (entity instanceof Mob) { Mob mob = (Mob)entity; + net.minecraftforge.eventbus.api.Event.Result res = net.minecraftforge.event.ForgeEventFactory.canEntitySpawn(mob, p_151312_, (float)entity.m_20185_(), (float)entity.m_20186_(), (float)entity.m_20189_(), this, MobSpawnType.SPAWNER); + if (res == net.minecraftforge.eventbus.api.Event.Result.DENY) continue; + if (res == net.minecraftforge.eventbus.api.Event.Result.DEFAULT) - if (this.f_45444_.m_186574_().isEmpty() && !mob.m_5545_(p_151312_, MobSpawnType.SPAWNER) || !mob.m_6914_(p_151312_)) { + if (spawndata.m_186574_().isEmpty() && !mob.m_5545_(p_151312_, MobSpawnType.SPAWNER) || !mob.m_6914_(p_151312_)) { continue; } - if (this.f_45444_.m_186567_().m_128440_() == 1 && this.f_45444_.m_186567_().m_128425_("id", 8)) { + if (spawndata.m_186567_().m_128440_() == 1 && spawndata.m_186567_().m_128425_("id", 8)) { + if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(mob, (LevelAccessor)p_151312_, (float)entity.m_20185_(), (float)entity.m_20186_(), (float)entity.m_20189_(), this, MobSpawnType.SPAWNER)) ((Mob)entity).m_6518_(p_151312_, p_151312_.m_6436_(entity.m_20183_()), MobSpawnType.SPAWNER, (SpawnGroupData)null, (CompoundTag)null); } } -@@ -275,4 +_,12 @@ +@@ -283,4 +_,12 @@ public double m_45474_() { return this.f_45446_; } diff --git a/patches/minecraft/net/minecraft/world/level/Explosion.java.patch b/patches/minecraft/net/minecraft/world/level/Explosion.java.patch index 80f822e4b2..40dfc7c398 100644 --- a/patches/minecraft/net/minecraft/world/level/Explosion.java.patch +++ b/patches/minecraft/net/minecraft/world/level/Explosion.java.patch @@ -6,9 +6,9 @@ private final Map f_46021_ = Maps.newHashMap(); + private final Vec3 position; - public Explosion(Level p_151471_, @Nullable Entity p_151472_, double p_151473_, double p_151474_, double p_151475_, float p_151476_) { - this(p_151471_, p_151472_, p_151473_, p_151474_, p_151475_, p_151476_, false, Explosion.BlockInteraction.DESTROY); -@@ -85,6 +_,7 @@ + public Explosion(Level p_46024_, @Nullable Entity p_46025_, double p_46026_, double p_46027_, double p_46028_, float p_46029_, List p_46030_) { + this(p_46024_, p_46025_, p_46026_, p_46027_, p_46028_, p_46029_, false, Explosion.BlockInteraction.DESTROY_WITH_DECAY, p_46030_); +@@ -81,6 +_,7 @@ this.f_46010_ = p_46060_; this.f_46018_ = p_46053_ == null ? DamageSource.m_19358_(this) : p_46053_; this.f_46019_ = p_46054_ == null ? this.m_46062_(p_46052_) : p_46054_; @@ -16,7 +16,7 @@ } private ExplosionDamageCalculator m_46062_(@Nullable Entity p_46063_) { -@@ -180,6 +_,7 @@ +@@ -176,6 +_,7 @@ int j2 = Mth.m_14107_(this.f_46015_ - (double)f2 - 1.0D); int j1 = Mth.m_14107_(this.f_46015_ + (double)f2 + 1.0D); List list = this.f_46012_.m_45933_(this.f_46016_, new AABB((double)k1, (double)i2, (double)j2, (double)l1, (double)i1, (double)j1)); @@ -24,7 +24,7 @@ Vec3 vec3 = new Vec3(this.f_46013_, this.f_46014_, this.f_46015_); for(int k2 = 0; k2 < list.size(); ++k2) { -@@ -242,7 +_,7 @@ +@@ -238,7 +_,7 @@ if (!blockstate.m_60795_()) { BlockPos blockpos1 = blockpos.m_7949_(); this.f_46012_.m_46473_().m_6180_("explosion_blocks"); @@ -33,7 +33,7 @@ Level $$9 = this.f_46012_; if ($$9 instanceof ServerLevel) { ServerLevel serverlevel = (ServerLevel)$$9; -@@ -259,8 +_,7 @@ +@@ -255,8 +_,7 @@ } } @@ -43,7 +43,7 @@ this.f_46012_.m_46473_().m_7238_(); } } -@@ -332,6 +_,15 @@ +@@ -347,6 +_,15 @@ public List m_46081_() { return this.f_46020_; diff --git a/patches/minecraft/net/minecraft/world/level/Level.java.patch b/patches/minecraft/net/minecraft/world/level/Level.java.patch index 1e87872f2f..fde98a55bb 100644 --- a/patches/minecraft/net/minecraft/world/level/Level.java.patch +++ b/patches/minecraft/net/minecraft/world/level/Level.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -65,7 +_,7 @@ - import net.minecraft.world.phys.AABB; +@@ -68,7 +_,7 @@ + import net.minecraft.world.phys.Vec3; import net.minecraft.world.scores.Scoreboard; -public abstract class Level implements LevelAccessor, AutoCloseable { +public abstract class Level extends net.minecraftforge.common.capabilities.CapabilityProvider implements LevelAccessor, AutoCloseable, net.minecraftforge.common.extensions.IForgeLevel { - public static final Codec> f_46427_ = ResourceKey.m_195966_(Registry.f_122819_); - public static final ResourceKey f_46428_ = ResourceKey.m_135785_(Registry.f_122819_, new ResourceLocation("overworld")); - public static final ResourceKey f_46429_ = ResourceKey.m_135785_(Registry.f_122819_, new ResourceLocation("the_nether")); -@@ -104,8 +_,14 @@ + public static final Codec> f_46427_ = ResourceKey.m_195966_(Registries.f_256858_); + public static final ResourceKey f_46428_ = ResourceKey.m_135785_(Registries.f_256858_, new ResourceLocation("overworld")); + public static final ResourceKey f_46429_ = ResourceKey.m_135785_(Registries.f_256858_, new ResourceLocation("the_nether")); +@@ -107,8 +_,14 @@ private final BiomeManager f_46420_; private final ResourceKey f_46421_; private long f_186455_; @@ -24,7 +24,7 @@ this.f_46446_ = p_220355_; this.f_46442_ = p_220352_; this.f_204147_ = p_220354_; -@@ -190,17 +_,45 @@ +@@ -193,17 +_,45 @@ } else { LevelChunk levelchunk = this.m_46745_(p_46605_); Block block = p_46606_.m_60734_(); @@ -71,7 +71,7 @@ if (blockstate1 == p_46606_) { if (blockstate != blockstate1) { this.m_6550_(p_46605_, blockstate, blockstate1); -@@ -225,9 +_,8 @@ +@@ -228,9 +_,8 @@ } this.m_6559_(p_46605_, blockstate, blockstate1); @@ -82,7 +82,7 @@ } } } -@@ -277,6 +_,7 @@ +@@ -280,6 +_,7 @@ } public void m_46672_(BlockPos p_46673_, Block p_46674_) { @@ -90,7 +90,7 @@ } public void m_46590_(BlockPos p_46591_, Block p_46592_, Direction p_46593_) { -@@ -377,10 +_,26 @@ +@@ -399,10 +_,26 @@ (this.f_151504_ ? this.f_151503_ : this.f_151512_).add(p_151526_); } @@ -117,7 +117,7 @@ if (!this.f_151503_.isEmpty()) { this.f_151512_.addAll(this.f_151503_); this.f_151503_.clear(); -@@ -403,12 +_,19 @@ +@@ -425,12 +_,19 @@ public void m_46653_(Consumer p_46654_, T p_46655_) { try { @@ -137,15 +137,24 @@ } } -@@ -434,6 +_,7 @@ +@@ -472,7 +_,7 @@ + explosion$blockinteraction1 = this.m_255157_(GameRules.f_254629_); + break; + case MOB: +- explosion$blockinteraction1 = this.m_46469_().m_46207_(GameRules.f_46132_) ? this.m_255157_(GameRules.f_254692_) : Explosion.BlockInteraction.KEEP; ++ explosion$blockinteraction1 = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this, p_256233_) ? this.m_255157_(GameRules.f_254692_) : Explosion.BlockInteraction.KEEP; + break; + case TNT: + explosion$blockinteraction1 = this.m_255157_(GameRules.f_254705_); +@@ -483,6 +_,7 @@ - public Explosion m_7703_(@Nullable Entity p_46526_, @Nullable DamageSource p_46527_, @Nullable ExplosionDamageCalculator p_46528_, double p_46529_, double p_46530_, double p_46531_, float p_46532_, boolean p_46533_, Explosion.BlockInteraction p_46534_) { - Explosion explosion = new Explosion(this, p_46526_, p_46527_, p_46528_, p_46529_, p_46530_, p_46531_, p_46532_, p_46533_, p_46534_); + Explosion.BlockInteraction explosion$blockinteraction = explosion$blockinteraction1; + Explosion explosion = new Explosion(this, p_256233_, p_255861_, p_255867_, p_256447_, p_255732_, p_255717_, p_256013_, p_256228_, explosion$blockinteraction); + if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this, explosion)) return explosion; explosion.m_46061_(); - explosion.m_46075_(true); + explosion.m_46075_(p_256377_); return explosion; -@@ -461,6 +_,7 @@ +@@ -514,6 +_,7 @@ if (!this.m_151570_(p_46748_)) { this.m_46745_(p_46748_).m_8114_(p_46748_); } @@ -153,7 +162,7 @@ } public boolean m_46749_(BlockPos p_46750_) { -@@ -531,6 +_,7 @@ +@@ -584,6 +_,7 @@ list.add(p_151522_); } @@ -161,7 +170,7 @@ if (p_151522_ instanceof EnderDragon) { for(EnderDragonPart enderdragonpart : ((EnderDragon)p_151522_).m_31156_()) { if (p_151522_ != p_46536_ && p_46538_.test(enderdragonpart)) { -@@ -540,6 +_,11 @@ +@@ -593,6 +_,11 @@ } }); @@ -173,29 +182,32 @@ return list; } -@@ -551,6 +_,8 @@ - list.add(p_151539_); +@@ -616,6 +_,8 @@ + } } + + if (false) - if (p_151539_ instanceof EnderDragon enderdragon) { + if (p_261454_ instanceof EnderDragon enderdragon) { for(EnderDragonPart enderdragonpart : enderdragon.m_31156_()) { - T t = p_151528_.m_141992_(enderdragonpart); -@@ -561,6 +_,12 @@ - } + T t = p_261885_.m_141992_(enderdragonpart); +@@ -630,6 +_,15 @@ + return AbortableIterationConsumer.Continuation.CONTINUE; }); + for (net.minecraftforge.entity.PartEntity p : this.getPartEntities()) { -+ T t = p_151528_.m_141992_(p); -+ if (t != null && t.m_20191_().m_82381_(p_151529_) && p_151530_.test(t)) { -+ list.add(t); ++ T t = p_261885_.m_141992_(p); ++ if (t != null && t.m_20191_().m_82381_(p_262086_) && p_261688_.test(t)) { ++ p_262071_.add(t); ++ if (p_262071_.size() >= p_261858_) { ++ break; ++ } + } + } - return list; } -@@ -572,6 +_,7 @@ + @Nullable +@@ -640,6 +_,7 @@ this.m_46745_(p_151544_).m_8092_(true); } @@ -203,7 +215,7 @@ } public int m_5736_() { -@@ -616,7 +_,7 @@ +@@ -684,7 +_,7 @@ public int m_46681_(BlockPos p_46682_, Direction p_46683_) { BlockState blockstate = this.m_8055_(p_46682_); int i = blockstate.m_60746_(this, p_46682_, p_46683_); @@ -212,7 +224,7 @@ } public boolean m_46753_(BlockPos p_46754_) { -@@ -769,16 +_,15 @@ +@@ -837,16 +_,15 @@ public abstract Scoreboard m_6188_(); public void m_46717_(BlockPos p_46718_, Block p_46719_) { @@ -233,7 +245,7 @@ this.m_213960_(blockstate, blockpos, p_46719_, p_46718_, false); } } -@@ -863,6 +_,18 @@ +@@ -931,6 +_,18 @@ public BiomeManager m_7062_() { return this.f_46420_; diff --git a/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch b/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch index bd48d34cc8..4c8cb51440 100644 --- a/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch +++ b/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/LevelReader.java +++ b/net/minecraft/world/level/LevelReader.java -@@ -182,6 +_,10 @@ +@@ -187,6 +_,10 @@ } /** @deprecated */ diff --git a/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch b/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch index 1738c6de72..3a40054f40 100644 --- a/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch @@ -3,29 +3,29 @@ @@ -11,8 +_,12 @@ private final boolean f_46906_; private final GameRules f_46907_; - private final DataPackConfig f_46908_; + private final WorldDataConfiguration f_243681_; + private final com.mojang.serialization.Lifecycle lifecycle; - public LevelSettings(String p_46910_, GameType p_46911_, boolean p_46912_, Difficulty p_46913_, boolean p_46914_, GameRules p_46915_, DataPackConfig p_46916_) { -+ this(p_46910_, p_46911_, p_46912_, p_46913_, p_46914_, p_46915_, p_46916_, com.mojang.serialization.Lifecycle.stable()); + public LevelSettings(String p_250485_, GameType p_250207_, boolean p_251631_, Difficulty p_252122_, boolean p_248961_, GameRules p_248536_, WorldDataConfiguration p_249797_) { ++ this(p_250485_, p_250207_, p_251631_, p_252122_, p_248961_, p_248536_, p_249797_, com.mojang.serialization.Lifecycle.stable()); + } -+ public LevelSettings(String p_46910_, GameType p_46911_, boolean p_46912_, Difficulty p_46913_, boolean p_46914_, GameRules p_46915_, DataPackConfig p_46916_, com.mojang.serialization.Lifecycle lifecycle) { - this.f_46902_ = p_46910_; - this.f_46903_ = p_46911_; - this.f_46904_ = p_46912_; ++ public LevelSettings(String p_250485_, GameType p_250207_, boolean p_251631_, Difficulty p_252122_, boolean p_248961_, GameRules p_248536_, WorldDataConfiguration p_249797_, com.mojang.serialization.Lifecycle lifecycle) { + this.f_46902_ = p_250485_; + this.f_46903_ = p_250207_; + this.f_46904_ = p_251631_; @@ -20,13 +_,14 @@ - this.f_46906_ = p_46914_; - this.f_46907_ = p_46915_; - this.f_46908_ = p_46916_; + this.f_46906_ = p_248961_; + this.f_46907_ = p_248536_; + this.f_243681_ = p_249797_; + this.lifecycle = lifecycle; } - public static LevelSettings m_46924_(Dynamic p_46925_, DataPackConfig p_46926_) { + public static LevelSettings m_46924_(Dynamic p_46925_, WorldDataConfiguration p_251697_) { GameType gametype = GameType.m_46393_(p_46925_.get("GameType").asInt(0)); return new LevelSettings(p_46925_.get("LevelName").asString(""), gametype, p_46925_.get("hardcore").asBoolean(false), p_46925_.get("Difficulty").asNumber().map((p_46928_) -> { return Difficulty.m_19029_(p_46928_.byteValue()); -- }).result().orElse(Difficulty.NORMAL), p_46925_.get("allowCommands").asBoolean(gametype == GameType.CREATIVE), new GameRules(p_46925_.get("GameRules")), p_46926_); -+ }).result().orElse(Difficulty.NORMAL), p_46925_.get("allowCommands").asBoolean(gametype == GameType.CREATIVE), new GameRules(p_46925_.get("GameRules")), p_46926_, net.minecraftforge.common.ForgeHooks.parseLifecycle(p_46925_.get("forgeLifecycle").asString("stable"))); +- }).result().orElse(Difficulty.NORMAL), p_46925_.get("allowCommands").asBoolean(gametype == GameType.CREATIVE), new GameRules(p_46925_.get("GameRules")), p_251697_); ++ }).result().orElse(Difficulty.NORMAL), p_46925_.get("allowCommands").asBoolean(gametype == GameType.CREATIVE), new GameRules(p_46925_.get("GameRules")), p_251697_, net.minecraftforge.common.ForgeHooks.parseLifecycle(p_46925_.get("forgeLifecycle").asString("stable"))); } public String m_46917_() { @@ -33,27 +33,27 @@ } public LevelSettings m_46922_(GameType p_46923_) { -- return new LevelSettings(this.f_46902_, p_46923_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_, this.f_46908_); -+ return new LevelSettings(this.f_46902_, p_46923_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_, this.f_46908_, this.lifecycle); +- return new LevelSettings(this.f_46902_, p_46923_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_, this.f_243681_); ++ return new LevelSettings(this.f_46902_, p_46923_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_, this.f_243681_, this.lifecycle); } public LevelSettings m_46918_(Difficulty p_46919_) { -- return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, p_46919_, this.f_46906_, this.f_46907_, this.f_46908_); +- return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, p_46919_, this.f_46906_, this.f_46907_, this.f_243681_); + net.minecraftforge.common.ForgeHooks.onDifficultyChange(p_46919_, this.f_46905_); -+ return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, p_46919_, this.f_46906_, this.f_46907_, this.f_46908_, this.lifecycle); ++ return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, p_46919_, this.f_46906_, this.f_46907_, this.f_243681_, this.lifecycle); } - public LevelSettings m_46920_(DataPackConfig p_46921_) { -- return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_, p_46921_); -+ return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_, p_46921_, this.lifecycle); + public LevelSettings m_247275_(WorldDataConfiguration p_250867_) { +- return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_, p_250867_); ++ return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_, f_243681_, this.lifecycle); } public LevelSettings m_46935_() { -- return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_.m_46202_(), this.f_46908_); -+ return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_.m_46202_(), this.f_46908_, this.lifecycle); +- return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_.m_46202_(), this.f_243681_); ++ return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_.m_46202_(), this.f_243681_, this.lifecycle); + } + public LevelSettings withLifecycle(com.mojang.serialization.Lifecycle lifecycle) { -+ return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_, this.f_46908_, lifecycle); ++ return new LevelSettings(this.f_46902_, this.f_46903_, this.f_46904_, this.f_46905_, this.f_46906_, this.f_46907_, this.f_243681_, lifecycle); + } + public com.mojang.serialization.Lifecycle getLifecycle() { + return this.lifecycle; diff --git a/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch index 1e2750ded4..827476501c 100644 --- a/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch @@ -8,16 +8,16 @@ public final class NaturalSpawner { private static final Logger f_46977_ = LogUtils.getLogger(); private static final int f_151589_ = 24; -@@ -84,7 +_,7 @@ - mob = (Mob)entity; - } while(mob.m_21532_() || mob.m_8023_()); +@@ -74,7 +_,7 @@ + } + } - MobCategory mobcategory = entity.m_6095_().m_20674_(); + MobCategory mobcategory = entity.getClassification(true); if (mobcategory != MobCategory.MISC) { Entity entity_f = entity; BlockPos blockpos = entity.m_20183_(); -@@ -180,13 +_,15 @@ +@@ -172,13 +_,15 @@ } mob.m_7678_(d0, (double)i, d1, p_47040_.f_46441_.m_188501_() * 360.0F, 0.0F); @@ -35,17 +35,17 @@ return; } -@@ -266,7 +_,8 @@ +@@ -259,7 +_,8 @@ } private static WeightedRandomList m_220443_(ServerLevel p_220444_, StructureManager p_220445_, ChunkGenerator p_220446_, MobCategory p_220447_, BlockPos p_220448_, @Nullable Holder p_220449_) { - return m_220455_(p_220448_, p_220444_, p_220447_, p_220445_) ? NetherFortressStructure.f_228517_ : p_220446_.m_223133_(p_220449_ != null ? p_220449_ : p_220444_.m_204166_(p_220448_), p_220445_, p_220447_, p_220448_); + // Forge: Add in potential spawns, and replace hardcoded nether fortress mob list -+ return net.minecraftforge.event.ForgeEventFactory.getPotentialSpawns(p_220444_, p_220447_, p_220448_, m_220455_(p_220448_, p_220444_, p_220447_, p_220445_) ? p_220445_.m_220521_().m_175515_(Registry.f_235725_).m_123013_(BuiltinStructures.f_209859_).m_226612_().get(MobCategory.MONSTER).f_210044_() : p_220446_.m_223133_(p_220449_ != null ? p_220449_ : p_220444_.m_204166_(p_220448_), p_220445_, p_220447_, p_220448_)); ++ return net.minecraftforge.event.ForgeEventFactory.getPotentialSpawns(p_220444_, p_220447_, p_220448_, m_220455_(p_220448_, p_220444_, p_220447_, p_220445_) ? p_220445_.m_220521_().m_175515_(Registries.f_256944_).m_123013_(BuiltinStructures.f_209859_).m_226612_().get(MobCategory.MONSTER).f_210044_() : p_220446_.m_223133_(p_220449_ != null ? p_220449_ : p_220444_.m_204166_(p_220448_), p_220445_, p_220447_, p_220448_)); } public static boolean m_220455_(BlockPos p_220456_, ServerLevel p_220457_, MobCategory p_220458_, StructureManager p_220459_) { -@@ -305,6 +_,13 @@ +@@ -298,6 +_,13 @@ if (p_47052_ == SpawnPlacements.Type.NO_RESTRICTIONS) { return true; } else if (p_47055_ != null && p_47053_.m_6857_().m_61937_(p_47054_)) { @@ -59,7 +59,7 @@ BlockState blockstate = p_47053_.m_8055_(p_47054_); FluidState fluidstate = p_47053_.m_6425_(p_47054_); BlockPos blockpos = p_47054_.m_7494_(); -@@ -317,14 +_,12 @@ +@@ -310,14 +_,12 @@ case ON_GROUND: default: BlockState blockstate1 = p_47053_.m_8055_(blockpos1); @@ -75,7 +75,7 @@ } } -@@ -370,6 +_,7 @@ +@@ -367,6 +_,7 @@ entity.m_7678_(d0, (double)blockpos.m_123342_(), d1, p_220454_.m_188501_() * 360.0F, 0.0F); if (entity instanceof Mob) { Mob mob = (Mob)entity; diff --git a/patches/minecraft/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch b/patches/minecraft/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch index d92c997b1d..d9fb33ec50 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/biome/BiomeGenerationSettings.java +++ b/net/minecraft/world/level/biome/BiomeGenerationSettings.java -@@ -37,6 +_,7 @@ +@@ -39,6 +_,7 @@ })).apply(p_186655_, BiomeGenerationSettings::new); }); private final Map>> f_47780_; @@ -8,7 +8,7 @@ private final List> f_47781_; private final Supplier>> f_47783_; private final Supplier> f_186648_; -@@ -52,10 +_,15 @@ +@@ -54,10 +_,15 @@ this.f_186648_ = Suppliers.memoize(() -> { return p_186651_.stream().flatMap(HolderSet::m_203614_).map(Holder::m_203334_).collect(Collectors.toSet()); }); diff --git a/patches/minecraft/net/minecraft/world/level/biome/BiomeSource.java.patch b/patches/minecraft/net/minecraft/world/level/biome/BiomeSource.java.patch index 031a6c058f..876392a5cd 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/BiomeSource.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/BiomeSource.java.patch @@ -3,7 +3,7 @@ @@ -23,20 +_,24 @@ public abstract class BiomeSource implements BiomeResolver { - public static final Codec f_47888_ = Registry.f_122889_.m_194605_().dispatchStable(BiomeSource::m_5820_, Function.identity()); + public static final Codec f_47888_ = BuiltInRegistries.f_256737_.m_194605_().dispatchStable(BiomeSource::m_5820_, Function.identity()); - private final Set> f_47891_; + private final java.util.function.Supplier>> lazyPossibleBiomes; // FORGE: Allow custom biome sources to lazily evaluate possible biomes. diff --git a/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch b/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch index c0ab6eb0f9..8c8bc2f6cb 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/biome/BiomeSpecialEffects.java +++ b/net/minecraft/world/level/biome/BiomeSpecialEffects.java -@@ -200,7 +_,7 @@ +@@ -201,7 +_,7 @@ } } @@ -9,7 +9,7 @@ NONE("none") { public int m_6583_(double p_48081_, double p_48082_, int p_48083_) { return p_48083_; -@@ -219,14 +_,37 @@ +@@ -220,14 +_,37 @@ }; private final String f_48051_; diff --git a/patches/minecraft/net/minecraft/world/level/block/BambooBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BambooBlock.java.patch deleted file mode 100644 index 8746b3f74c..0000000000 --- a/patches/minecraft/net/minecraft/world/level/block/BambooBlock.java.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/net/minecraft/world/level/block/BambooBlock.java -+++ b/net/minecraft/world/level/block/BambooBlock.java -@@ -26,7 +_,7 @@ - import net.minecraft.world.phys.shapes.CollisionContext; - import net.minecraft.world.phys.shapes.VoxelShape; - --public class BambooBlock extends Block implements BonemealableBlock { -+public class BambooBlock extends Block implements BonemealableBlock, net.minecraftforge.common.IPlantable { - protected static final float f_152092_ = 3.0F; - protected static final float f_152093_ = 5.0F; - protected static final float f_152094_ = 1.5F; -@@ -110,10 +_,11 @@ - - public void m_213898_(BlockState p_220738_, ServerLevel p_220739_, BlockPos p_220740_, RandomSource p_220741_) { - if (p_220738_.m_61143_(f_48871_) == 0) { -- if (p_220741_.m_188503_(3) == 0 && p_220739_.m_46859_(p_220740_.m_7494_()) && p_220739_.m_45524_(p_220740_.m_7494_(), 0) >= 9) { -+ if (p_220739_.m_46859_(p_220740_.m_7494_()) && p_220739_.m_45524_(p_220740_.m_7494_(), 0) >= 9) { - int i = this.m_48932_(p_220739_, p_220740_) + 1; -- if (i < 16) { -+ if (i < 16 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_220739_, p_220740_, p_220738_, p_220741_.m_188503_(3) == 0)) { - this.m_220731_(p_220738_, p_220739_, p_220740_, p_220741_, i); -+ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_220739_, p_220740_, p_220738_); - } - } - -@@ -167,7 +_,7 @@ - } - - public float m_5880_(BlockState p_48901_, Player p_48902_, BlockGetter p_48903_, BlockPos p_48904_) { -- return p_48902_.m_21205_().m_41720_() instanceof SwordItem ? 1.0F : super.m_5880_(p_48901_, p_48902_, p_48903_, p_48904_); -+ return p_48902_.m_21205_().canPerformAction(net.minecraftforge.common.ToolActions.SWORD_DIG) ? 1.0F : super.m_5880_(p_48901_, p_48902_, p_48903_, p_48904_); - } - - protected void m_220731_(BlockState p_220732_, Level p_220733_, BlockPos p_220734_, RandomSource p_220735_, int p_220736_) { -@@ -208,5 +_,12 @@ - } - - return i; -+ } -+ -+ @Override -+ public BlockState getPlant(BlockGetter world, BlockPos pos) { -+ BlockState state = world.m_8055_(pos); -+ if (state.m_60734_() != this) return m_49966_(); -+ return state; - } - } diff --git a/patches/minecraft/net/minecraft/world/level/block/BambooStalkBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BambooStalkBlock.java.patch new file mode 100644 index 0000000000..8f0926db72 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/BambooStalkBlock.java.patch @@ -0,0 +1,47 @@ +--- a/net/minecraft/world/level/block/BambooStalkBlock.java ++++ b/net/minecraft/world/level/block/BambooStalkBlock.java +@@ -26,7 +_,7 @@ + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; + +-public class BambooStalkBlock extends Block implements BonemealableBlock { ++public class BambooStalkBlock extends Block implements BonemealableBlock, net.minecraftforge.common.IPlantable { + protected static final float f_260434_ = 3.0F; + protected static final float f_260643_ = 5.0F; + protected static final float f_260619_ = 1.5F; +@@ -110,10 +_,11 @@ + + public void m_213898_(BlockState p_261931_, ServerLevel p_261751_, BlockPos p_261616_, RandomSource p_261766_) { + if (p_261931_.m_61143_(f_260694_) == 0) { +- if (p_261766_.m_188503_(3) == 0 && p_261751_.m_46859_(p_261616_.m_7494_()) && p_261751_.m_45524_(p_261616_.m_7494_(), 0) >= 9) { ++ if (p_261751_.m_46859_(p_261616_.m_7494_()) && p_261751_.m_45524_(p_261616_.m_7494_(), 0) >= 9) { + int i = this.m_261132_(p_261751_, p_261616_) + 1; +- if (i < 16) { ++ if (i < 16 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_261751_, p_261616_, p_261931_, p_261766_.m_188503_(3) == 0)) { + this.m_261305_(p_261931_, p_261751_, p_261616_, p_261766_, i); ++ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_261751_, p_261616_, p_261931_); + } + } + +@@ -167,7 +_,7 @@ + } + + public float m_5880_(BlockState p_261691_, Player p_262171_, BlockGetter p_261621_, BlockPos p_261500_) { +- return p_262171_.m_21205_().m_41720_() instanceof SwordItem ? 1.0F : super.m_5880_(p_261691_, p_262171_, p_261621_, p_261500_); ++ return p_262171_.m_21205_().canPerformAction(net.minecraftforge.common.ToolActions.SWORD_DIG) ? 1.0F : super.m_5880_(p_261691_, p_262171_, p_261621_, p_261500_); + } + + protected void m_261305_(BlockState p_261855_, Level p_262076_, BlockPos p_262109_, RandomSource p_261633_, int p_261759_) { +@@ -208,5 +_,12 @@ + } + + return i; ++ } ++ ++ @Override ++ public BlockState getPlant(BlockGetter world, BlockPos pos) { ++ BlockState state = world.m_8055_(pos); ++ if (state.m_60734_() != this) return m_49966_(); ++ return state; + } + } diff --git a/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch index 77e6ef2042..7955fcd448 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch @@ -24,6 +24,6 @@ Item item = itemstack.m_41720_(); - if (itemstack.m_150930_(Items.f_42574_)) { + if (itemstack.canPerformAction(net.minecraftforge.common.ToolActions.SHEARS_HARVEST)) { - p_49625_.m_6263_(p_49627_, p_49627_.m_20185_(), p_49627_.m_20186_(), p_49627_.m_20189_(), SoundEvents.f_11697_, SoundSource.NEUTRAL, 1.0F, 1.0F); + p_49625_.m_6263_(p_49627_, p_49627_.m_20185_(), p_49627_.m_20186_(), p_49627_.m_20189_(), SoundEvents.f_11697_, SoundSource.BLOCKS, 1.0F, 1.0F); m_49600_(p_49625_, p_49626_); itemstack.m_41622_(1, p_49627_, (p_49571_) -> { diff --git a/patches/minecraft/net/minecraft/world/level/block/Block.java.patch b/patches/minecraft/net/minecraft/world/level/block/Block.java.patch index 47be29cd50..4cb069b95d 100644 --- a/patches/minecraft/net/minecraft/world/level/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/Block.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -64,10 +_,11 @@ +@@ -62,10 +_,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.slf4j.Logger; -public class Block extends BlockBehaviour implements ItemLike { +public class Block extends BlockBehaviour implements ItemLike, net.minecraftforge.common.extensions.IForgeBlock { private static final Logger f_49790_ = LogUtils.getLogger(); - private final Holder.Reference f_204296_ = Registry.f_122824_.m_203693_(this); + private final Holder.Reference f_204296_ = BuiltInRegistries.f_256975_.m_203693_(this); - public static final IdMapper f_49791_ = new IdMapper<>(); + @Deprecated //Forge: Do not use, use GameRegistry + public static final IdMapper f_49791_ = net.minecraftforge.registries.GameData.getBlockStateIDMap(); private static final LoadingCache f_49785_ = CacheBuilder.newBuilder().maximumSize(512L).weakKeys().build(new CacheLoader() { public Boolean load(VoxelShape p_49972_) { return !Shapes.m_83157_(Shapes.m_83144_(), p_49972_, BooleanOp.f_82687_); -@@ -180,7 +_,7 @@ +@@ -178,7 +_,7 @@ f_49790_.error("Block classes should end with Block and {} doesn't.", (Object)s); } } @@ -23,7 +23,7 @@ } public static boolean m_152463_(BlockState p_152464_) { -@@ -195,6 +_,8 @@ +@@ -193,6 +_,8 @@ BlockState blockstate = p_152446_.m_8055_(p_152449_); if (p_152445_.m_60719_(blockstate, p_152448_)) { return false; @@ -32,7 +32,7 @@ } else if (blockstate.m_60815_()) { Block.BlockStatePairKey block$blockstatepairkey = new Block.BlockStatePairKey(p_152445_, blockstate, p_152448_); Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap = f_49789_.get(); -@@ -326,7 +_,7 @@ +@@ -324,7 +_,7 @@ } private static void m_152440_(Level p_152441_, Supplier p_152442_, ItemStack p_152443_) { @@ -41,7 +41,7 @@ ItemEntity itementity = p_152442_.get(); itementity.m_32060_(); p_152441_.m_7967_(itementity); -@@ -334,12 +_,13 @@ +@@ -332,12 +_,13 @@ } public void m_49805_(ServerLevel p_49806_, BlockPos p_49807_, int p_49808_) { @@ -56,7 +56,7 @@ public float m_7325_() { return this.f_60444_; } -@@ -386,8 +_,10 @@ +@@ -384,8 +_,10 @@ public void m_5548_(BlockGetter p_49821_, Entity p_49822_) { p_49822_.m_20256_(p_49822_.m_20184_().m_82542_(1.0D, 0.0D, 1.0D)); @@ -67,7 +67,7 @@ public ItemStack m_7397_(BlockGetter p_49823_, BlockPos p_49824_, BlockState p_49825_) { return new ItemStack(this); } -@@ -424,6 +_,7 @@ +@@ -418,6 +_,7 @@ public void m_141997_(BlockState p_152450_, Level p_152451_, BlockPos p_152452_, Biome.Precipitation p_152453_) { } @@ -75,7 +75,7 @@ public boolean m_6903_(Explosion p_49826_) { return true; } -@@ -459,6 +_,7 @@ +@@ -453,6 +_,7 @@ return p_152456_.m_61124_(p_152457_, p_152455_.m_61143_(p_152457_)); } @@ -83,7 +83,7 @@ public SoundType m_49962_(BlockState p_49963_) { return this.f_60446_; } -@@ -468,7 +_,7 @@ +@@ -462,7 +_,7 @@ this.f_49788_ = Item.m_41439_(this); } @@ -92,7 +92,7 @@ } public boolean m_49967_() { -@@ -489,6 +_,75 @@ +@@ -483,6 +_,75 @@ protected ImmutableMap m_152458_(Function p_152459_) { return this.f_49792_.m_61056_().stream().collect(ImmutableMap.toImmutableMap(Function.identity(), p_152459_)); } diff --git a/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch b/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch index ed4927ee3f..2827d53bfb 100644 --- a/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/Blocks.java +++ b/net/minecraft/world/level/block/Blocks.java -@@ -144,7 +_,7 @@ +@@ -153,7 +_,7 @@ public static final Block f_50027_ = m_50795_("green_bed", m_50764_(DyeColor.GREEN)); public static final Block f_50028_ = m_50795_("red_bed", m_50764_(DyeColor.RED)); public static final Block f_50029_ = m_50795_("black_bed", m_50764_(DyeColor.BLACK)); @@ -9,16 +9,17 @@ public static final Block f_50031_ = m_50795_("detector_rail", new DetectorRailBlock(BlockBehaviour.Properties.m_60939_(Material.f_76310_).m_60910_().m_60978_(0.7F).m_60918_(SoundType.f_56743_))); public static final Block f_50032_ = m_50795_("sticky_piston", m_50798_(true)); public static final Block f_50033_ = m_50795_("cobweb", new WebBlock(BlockBehaviour.Properties.m_60939_(Material.f_76311_).m_60910_().m_60999_().m_60978_(4.0F))); -@@ -1153,16 +_,5 @@ +@@ -1207,17 +_,5 @@ public static void m_50758_() { Block.f_49791_.forEach(BlockBehaviour.BlockStateBase::m_60611_); - } - - static { -- for(Block block : Registry.f_122824_) { +- for(Block block : BuiltInRegistries.f_256975_) { - for(BlockState blockstate : block.m_49965_().m_61056_()) { - Block.f_49791_.m_122667_(blockstate); +- blockstate.m_60611_(); - } - - block.m_60589_(); diff --git a/patches/minecraft/net/minecraft/world/level/block/DoublePlantBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DoublePlantBlock.java.patch index a56887ac4a..e9304c3d92 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DoublePlantBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DoublePlantBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DoublePlantBlock.java +++ b/net/minecraft/world/level/block/DoublePlantBlock.java -@@ -53,6 +_,7 @@ +@@ -54,6 +_,7 @@ return super.m_7898_(p_52887_, p_52888_, p_52889_); } else { BlockState blockstate = p_52888_.m_8055_(p_52889_.m_7495_()); diff --git a/patches/minecraft/net/minecraft/world/level/block/FungusBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FungusBlock.java.patch index e213c51de4..1ebd106226 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FungusBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FungusBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/FungusBlock.java +++ b/net/minecraft/world/level/block/FungusBlock.java -@@ -44,6 +_,8 @@ - } +@@ -52,6 +_,8 @@ public void m_214148_(ServerLevel p_221243_, RandomSource p_221244_, BlockPos p_221245_, BlockState p_221246_) { -+ net.minecraftforge.event.level.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_221243_, p_221244_, p_221245_, this.f_53597_.get()); -+ if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY)) return; - this.f_53597_.get().m_203334_().m_224953_(p_221243_, p_221243_.m_7726_().m_8481_(), p_221244_, p_221245_); + this.m_255216_(p_221243_).ifPresent((p_256352_) -> { ++ net.minecraftforge.event.level.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_221243_, p_221244_, p_221245_, p_256352_); ++ if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY)) return; + p_256352_.m_203334_().m_224953_(p_221243_, p_221243_.m_7726_().m_8481_(), p_221244_, p_221245_); + }); } - } diff --git a/patches/minecraft/net/minecraft/world/level/block/MushroomBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/MushroomBlock.java.patch index caeb54fac4..887ce9fbef 100644 --- a/patches/minecraft/net/minecraft/world/level/block/MushroomBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/MushroomBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/MushroomBlock.java +++ b/net/minecraft/world/level/block/MushroomBlock.java -@@ -70,13 +_,15 @@ +@@ -72,7 +_,7 @@ if (blockstate.m_204336_(BlockTags.f_13057_)) { return true; } else { @@ -9,12 +9,15 @@ } } - public boolean m_221773_(ServerLevel p_221774_, BlockPos p_221775_, BlockState p_221776_, RandomSource p_221777_) { -+ net.minecraftforge.event.level.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_221774_, p_221777_, p_221775_, this.f_153981_.get()); -+ if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY)) return false; - p_221774_.m_7471_(p_221775_, false); -- if (this.f_153981_.get().m_203334_().m_224953_(p_221774_, p_221774_.m_7726_().m_8481_(), p_221777_, p_221775_)) { -+ if (event.getFeature().m_203334_().m_224953_(p_221774_, p_221774_.m_7726_().m_8481_(), p_221777_, p_221775_)) { - return true; +@@ -81,8 +_,10 @@ + if (optional.isEmpty()) { + return false; } else { - p_221774_.m_7731_(p_221775_, p_221776_, 3); ++ net.minecraftforge.event.level.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_221774_, p_221777_, p_221775_, optional.get()); ++ if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY)) return false; + p_221774_.m_7471_(p_221775_, false); +- if (optional.get().m_203334_().m_224953_(p_221774_, p_221774_.m_7726_().m_8481_(), p_221777_, p_221775_)) { ++ if (event.getFeature().m_203334_().m_224953_(p_221774_, p_221774_.m_7726_().m_8481_(), p_221777_, p_221775_)) { + return true; + } else { + p_221774_.m_7731_(p_221775_, p_221776_, 3); diff --git a/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch index d9c1424cb3..cc84053a80 100644 --- a/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/NoteBlock.java +++ b/net/minecraft/world/level/block/NoteBlock.java -@@ -65,7 +_,9 @@ +@@ -89,7 +_,9 @@ if (p_55035_.f_46443_) { return InteractionResult.SUCCESS; } else { @@ -9,15 +9,15 @@ + if (_new == -1) return InteractionResult.FAIL; + p_55034_ = p_55034_.m_61124_(f_55013_, _new); p_55035_.m_7731_(p_55036_, p_55034_, 3); - this.m_221820_(p_55037_, p_55035_, p_55036_); + this.m_260916_(p_55037_, p_55034_, p_55035_, p_55036_); p_55037_.m_36220_(Stats.f_12960_); -@@ -81,6 +_,9 @@ +@@ -105,6 +_,9 @@ } public boolean m_8133_(BlockState p_55023_, Level p_55024_, BlockPos p_55025_, int p_55026_, int p_55027_) { + net.minecraftforge.event.level.NoteBlockEvent.Play e = new net.minecraftforge.event.level.NoteBlockEvent.Play(p_55024_, p_55025_, p_55023_, p_55023_.m_61143_(f_55013_), p_55023_.m_61143_(f_55011_)); + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(e)) return false; + p_55023_ = p_55023_.m_61124_(f_55013_, e.getVanillaNoteId()).m_61124_(f_55011_, e.getInstrument()); - int i = p_55023_.m_61143_(f_55013_); - float f = (float)Math.pow(2.0D, (double)(i - 12) / 12.0D); - p_55024_.m_5594_((Player)null, p_55025_, p_55023_.m_61143_(f_55011_).m_61668_(), SoundSource.RECORDS, 3.0F, f); + NoteBlockInstrument noteblockinstrument = p_55023_.m_61143_(f_55011_); + float f; + if (noteblockinstrument.m_262503_()) { diff --git a/patches/minecraft/net/minecraft/world/level/block/RedStoneWireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/RedStoneWireBlock.java.patch index bd6bf719b6..8f0a163ff9 100644 --- a/patches/minecraft/net/minecraft/world/level/block/RedStoneWireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/RedStoneWireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -197,7 +_,7 @@ +@@ -196,7 +_,7 @@ BlockState blockstate = p_55523_.m_8055_(blockpos); if (p_55526_) { boolean flag = this.m_55612_(p_55523_, blockpos, blockstate); @@ -9,7 +9,7 @@ if (blockstate.m_60783_(p_55523_, blockpos, p_55525_.m_122424_())) { return RedstoneSide.UP; } -@@ -206,7 +_,14 @@ +@@ -205,7 +_,14 @@ } } diff --git a/patches/minecraft/net/minecraft/world/level/block/SaplingBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SaplingBlock.java.patch index 578cc2aee7..2fba62fb7a 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SaplingBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SaplingBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SaplingBlock.java +++ b/net/minecraft/world/level/block/SaplingBlock.java -@@ -31,6 +_,7 @@ +@@ -32,6 +_,7 @@ } public void m_213898_(BlockState p_222011_, ServerLevel p_222012_, BlockPos p_222013_, RandomSource p_222014_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/SculkSensorBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SculkSensorBlock.java.patch index 6bfbc8a3ec..2daf8cd246 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SculkSensorBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SculkSensorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkSensorBlock.java +++ b/net/minecraft/world/level/block/SculkSensorBlock.java -@@ -275,9 +_,11 @@ +@@ -228,9 +_,11 @@ public void m_213646_(BlockState p_222142_, ServerLevel p_222143_, BlockPos p_222144_, ItemStack p_222145_, boolean p_222146_) { super.m_213646_(p_222142_, p_222143_, p_222144_, p_222145_, p_222146_); diff --git a/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch index 28f28317d7..08eb44fb2c 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SeagrassBlock.java +++ b/net/minecraft/world/level/block/SeagrassBlock.java -@@ -19,7 +_,7 @@ +@@ -20,7 +_,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; diff --git a/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch b/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch index 2990d77ba7..9a39c1123f 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SoundType.java +++ b/net/minecraft/world/level/block/SoundType.java -@@ -99,6 +_,7 @@ +@@ -105,6 +_,7 @@ private final SoundEvent f_56737_; private final SoundEvent f_56738_; diff --git a/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch index 6b5129926b..a4e174b4c1 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SpawnerBlock.java +++ b/net/minecraft/world/level/block/SpawnerBlock.java -@@ -29,11 +_,12 @@ +@@ -39,11 +_,12 @@ public void m_213646_(BlockState p_222477_, ServerLevel p_222478_, BlockPos p_222479_, ItemStack p_222480_, boolean p_222481_) { super.m_213646_(p_222477_, p_222478_, p_222479_, p_222480_, p_222481_); diff --git a/patches/minecraft/net/minecraft/world/level/block/StemBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/StemBlock.java.patch index 9b8443fd53..f6aefdbf5d 100644 --- a/patches/minecraft/net/minecraft/world/level/block/StemBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/StemBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/StemBlock.java +++ b/net/minecraft/world/level/block/StemBlock.java -@@ -43,22 +_,24 @@ +@@ -44,22 +_,24 @@ } public void m_213898_(BlockState p_222538_, ServerLevel p_222539_, BlockPos p_222540_, RandomSource p_222541_) { @@ -29,7 +29,7 @@ } } -@@ -92,5 +_,11 @@ +@@ -93,5 +_,11 @@ public StemGrownBlock m_57056_() { return this.f_57015_; diff --git a/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch index ad740156f5..dfec107788 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SweetBerryBushBlock.java +++ b/net/minecraft/world/level/block/SweetBerryBushBlock.java -@@ -57,10 +_,11 @@ +@@ -58,10 +_,11 @@ public void m_213898_(BlockState p_222563_, ServerLevel p_222564_, BlockPos p_222565_, RandomSource p_222566_) { int i = p_222563_.m_61143_(f_57244_); diff --git a/patches/minecraft/net/minecraft/world/level/block/TallGrassBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TallGrassBlock.java.patch index c5c157348a..d6b0a64d28 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TallGrassBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TallGrassBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TallGrassBlock.java +++ b/net/minecraft/world/level/block/TallGrassBlock.java -@@ -10,7 +_,7 @@ +@@ -11,7 +_,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; diff --git a/patches/minecraft/net/minecraft/world/level/block/TrapDoorBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TrapDoorBlock.java.patch index c4f339c994..1b7e22b9c3 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TrapDoorBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TrapDoorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TrapDoorBlock.java +++ b/net/minecraft/world/level/block/TrapDoorBlock.java -@@ -152,4 +_,17 @@ +@@ -151,4 +_,17 @@ return super.m_7417_(p_57554_, p_57555_, p_57556_, p_57557_, p_57558_, p_57559_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch index aa5726d32b..499d47da19 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TurtleEggBlock.java +++ b/net/minecraft/world/level/block/TurtleEggBlock.java -@@ -156,7 +_,7 @@ +@@ -158,7 +_,7 @@ if (!(p_57769_ instanceof LivingEntity)) { return false; } else { diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch index b3e8e84a23..e475d63735 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch @@ -19,7 +19,7 @@ public static Map m_58423_() { Map map = Maps.newLinkedHashMap(); m_58374_(map, Items.f_42448_, 20000); -@@ -210,9 +_,9 @@ +@@ -204,9 +_,9 @@ super.m_142466_(p_155025_); this.f_58310_ = NonNullList.m_122780_(this.m_6643_(), ItemStack.f_41583_); ContainerHelper.m_18980_(p_155025_, this.f_58310_); @@ -32,7 +32,7 @@ this.f_58317_ = this.m_7743_(this.f_58310_.get(1)); CompoundTag compoundtag = p_155025_.m_128469_("RecipesUsed"); -@@ -224,9 +_,9 @@ +@@ -218,9 +_,9 @@ protected void m_183515_(CompoundTag p_187452_) { super.m_183515_(p_187452_); @@ -45,7 +45,7 @@ ContainerHelper.m_18973_(p_187452_, this.f_58310_); CompoundTag compoundtag = new CompoundTag(); this.f_58320_.forEach((p_187449_, p_187450_) -> { -@@ -254,28 +_,30 @@ +@@ -248,28 +_,30 @@ } int i = p_155017_.m_6893_(); @@ -81,7 +81,7 @@ p_155017_.m_6029_(recipe); } -@@ -300,9 +_,9 @@ +@@ -294,9 +_,9 @@ } @@ -93,7 +93,7 @@ if (itemstack.m_41619_()) { return false; } else { -@@ -311,10 +_,10 @@ +@@ -305,10 +_,10 @@ return true; } else if (!itemstack1.m_41656_(itemstack)) { return false; @@ -106,7 +106,7 @@ } } } else { -@@ -322,15 +_,15 @@ +@@ -316,15 +_,15 @@ } } @@ -126,7 +126,7 @@ } if (itemstack.m_150930_(Blocks.f_50057_.m_5456_()) && !p_155028_.get(1).m_41619_() && p_155028_.get(1).m_150930_(Items.f_42446_)) { -@@ -349,7 +_,7 @@ +@@ -343,7 +_,7 @@ return 0; } else { Item item = p_58343_.m_41720_(); @@ -135,7 +135,7 @@ } } -@@ -358,7 +_,7 @@ +@@ -352,7 +_,7 @@ } public static boolean m_58399_(ItemStack p_58400_) { @@ -144,7 +144,7 @@ } public int[] m_7071_(Direction p_58363_) { -@@ -438,7 +_,7 @@ +@@ -432,7 +_,7 @@ return true; } else { ItemStack itemstack = this.f_58310_.get(1); @@ -153,7 +153,7 @@ } } -@@ -496,5 +_,34 @@ +@@ -490,5 +_,34 @@ p_58342_.m_36491_(itemstack); } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch index da70404338..a13d9d4a89 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -@@ -80,4 +_,27 @@ +@@ -81,4 +_,27 @@ } protected abstract AbstractContainerMenu m_6555_(int p_58627_, Inventory p_58628_); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch index 56b641f9ec..3e4092a91c 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BeaconBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -@@ -122,8 +_,8 @@ +@@ -124,8 +_,8 @@ for(int i1 = 0; i1 < 10 && blockpos.m_123342_() <= l; ++i1) { BlockState blockstate = p_155108_.m_8055_(blockpos); Block block = blockstate.m_60734_(); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/SpawnerBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/SpawnerBlockEntity.java.patch index c660e53d5e..05851cdb9c 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/SpawnerBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/SpawnerBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/SpawnerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SpawnerBlockEntity.java -@@ -25,6 +_,9 @@ +@@ -27,6 +_,9 @@ } } diff --git a/patches/minecraft/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java.patch b/patches/minecraft/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java.patch index e0dbe46de4..41cecca3bc 100644 --- a/patches/minecraft/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java.patch @@ -1,30 +1,33 @@ --- a/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java +++ b/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java -@@ -25,15 +_,24 @@ +@@ -27,6 +_,14 @@ return super.m_213817_(p_222891_, p_222892_, p_222893_, p_222894_, p_222895_); } -+ // Forge: context-sensitive version to be able to use data pack provided features ++ /** ++ * Forge: context-sensitive version to be able to use data pack provided features ++ */ + @Nullable -+ protected Holder> getConfiguredMegaFeature(ServerLevel level, ChunkGenerator chunkGenerator, BlockPos pos, BlockState state, RandomSource random) { -+ return m_213566_(random); ++ protected Holder> getConfiguredMegaFeature(ServerLevel level, ChunkGenerator chunkGenerator, BlockPos pos, BlockState state, RandomSource random, ResourceKey> featureKey) { ++ return level.m_8891_().m_175515_(Registries.f_256911_).m_203636_(featureKey).orElse(null); + } + -+ /** @deprecated Forge: Use {@link #getConfiguredMegaFeature(ServerLevel, ChunkGenerator, BlockPos, BlockState, RandomSource)} instead */ -+ @Deprecated @Nullable - protected abstract Holder> m_213566_(RandomSource p_222904_); + protected abstract ResourceKey> m_213566_(RandomSource p_222904_); - public boolean m_222896_(ServerLevel p_222897_, ChunkGenerator p_222898_, BlockPos p_222899_, BlockState p_222900_, RandomSource p_222901_, int p_222902_, int p_222903_) { -- Holder> holder = this.m_213566_(p_222901_); -- if (holder == null) { -+ Holder> holder = this.getConfiguredMegaFeature(p_222897_, p_222898_, p_222899_, p_222900_, p_222901_); -+ net.minecraftforge.event.level.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_222897_, p_222901_, p_222899_, holder); -+ if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY) || event.getFeature() == null) { +@@ -35,11 +_,12 @@ + if (resourcekey == null) { return false; } else { -- ConfiguredFeature configuredfeature = holder.m_203334_(); -+ ConfiguredFeature configuredfeature = event.getFeature().m_203334_(); - BlockState blockstate = Blocks.f_50016_.m_49966_(); - p_222897_.m_7731_(p_222899_.m_7918_(p_222902_, 0, p_222903_), blockstate, 4); - p_222897_.m_7731_(p_222899_.m_7918_(p_222902_ + 1, 0, p_222903_), blockstate, 4); +- Holder> holder = p_222897_.m_8891_().m_175515_(Registries.f_256911_).m_203636_(resourcekey).orElse((Holder.Reference>)null); +- if (holder == null) { ++ Holder> holder = this.getConfiguredMegaFeature(p_222897_, p_222898_, p_222899_, p_222900_, p_222901_, resourcekey); ++ net.minecraftforge.event.level.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_222897_, p_222901_, p_222899_, holder); ++ if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY) || event.getFeature() == null) { + return false; + } else { +- ConfiguredFeature configuredfeature = holder.m_203334_(); ++ ConfiguredFeature configuredfeature = event.getFeature().m_203334_(); + BlockState blockstate = Blocks.f_50016_.m_49966_(); + p_222897_.m_7731_(p_222899_.m_7918_(p_222902_, 0, p_222903_), blockstate, 4); + p_222897_.m_7731_(p_222899_.m_7918_(p_222902_ + 1, 0, p_222903_), blockstate, 4); diff --git a/patches/minecraft/net/minecraft/world/level/block/grower/AbstractTreeGrower.java.patch b/patches/minecraft/net/minecraft/world/level/block/grower/AbstractTreeGrower.java.patch index 4fe8f88170..1868d0181e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/grower/AbstractTreeGrower.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/grower/AbstractTreeGrower.java.patch @@ -1,30 +1,33 @@ --- a/net/minecraft/world/level/block/grower/AbstractTreeGrower.java +++ b/net/minecraft/world/level/block/grower/AbstractTreeGrower.java -@@ -12,15 +_,24 @@ +@@ -14,6 +_,14 @@ import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; public abstract class AbstractTreeGrower { -+ // Forge: context-sensitive version to be able to use data pack provided features ++ /** ++ * Forge: context-sensitive version to be able to use data pack provided features ++ */ + @Nullable -+ protected Holder> getConfiguredFeature(ServerLevel level, ChunkGenerator chunkGenerator, BlockPos pos, BlockState state, RandomSource random, boolean hasFlowers) { -+ return m_213888_(random, hasFlowers); ++ protected Holder> getConfiguredFeature(ServerLevel level, ChunkGenerator chunkGenerator, BlockPos pos, BlockState state, RandomSource random, boolean hasFlowers, ResourceKey> featureKey) { ++ return level.m_8891_().m_175515_(Registries.f_256911_).m_203636_(featureKey).orElse(null); + } + -+ /** @deprecated Forge: Use {@link #getConfiguredFeature(ServerLevel, ChunkGenerator, BlockPos, BlockState, RandomSource, boolean)} instead */ -+ @Deprecated @Nullable - protected abstract Holder> m_213888_(RandomSource p_222910_, boolean p_222911_); + protected abstract ResourceKey> m_213888_(RandomSource p_222910_, boolean p_222911_); - public boolean m_213817_(ServerLevel p_222905_, ChunkGenerator p_222906_, BlockPos p_222907_, BlockState p_222908_, RandomSource p_222909_) { -- Holder> holder = this.m_213888_(p_222909_, this.m_60011_(p_222905_, p_222907_)); -- if (holder == null) { -+ Holder> holder = this.getConfiguredFeature(p_222905_, p_222906_, p_222907_, p_222908_, p_222909_, this.m_60011_(p_222905_, p_222907_)); -+ net.minecraftforge.event.level.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_222905_, p_222909_, p_222907_, holder); -+ if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY) || event.getFeature() == null) { +@@ -22,11 +_,12 @@ + if (resourcekey == null) { return false; } else { -- ConfiguredFeature configuredfeature = holder.m_203334_(); -+ ConfiguredFeature configuredfeature = event.getFeature().m_203334_(); - BlockState blockstate = p_222905_.m_6425_(p_222907_).m_76188_(); - p_222905_.m_7731_(p_222907_, blockstate, 4); - if (configuredfeature.m_224953_(p_222905_, p_222906_, p_222909_, p_222907_)) { +- Holder> holder = p_222905_.m_8891_().m_175515_(Registries.f_256911_).m_203636_(resourcekey).orElse((Holder.Reference>)null); +- if (holder == null) { ++ Holder> holder = this.getConfiguredFeature(p_222905_, p_222906_, p_222907_, p_222908_, p_222909_, this.m_60011_(p_222905_, p_222907_), resourcekey); ++ net.minecraftforge.event.level.SaplingGrowTreeEvent event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_222905_, p_222909_, p_222907_, holder); ++ if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY) || event.getFeature() == null) { + return false; + } else { +- ConfiguredFeature configuredfeature = holder.m_203334_(); ++ ConfiguredFeature configuredfeature = event.getFeature().m_203334_(); + BlockState blockstate = p_222905_.m_6425_(p_222907_).m_76188_(); + p_222905_.m_7731_(p_222907_, blockstate, 4); + if (configuredfeature.m_224953_(p_222905_, p_222906_, p_222909_, p_222907_)) { diff --git a/patches/minecraft/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch index d07ada5c2c..72c1eee50b 100644 --- a/patches/minecraft/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -@@ -106,7 +_,7 @@ +@@ -109,7 +_,7 @@ List list = p_155911_.m_45933_((Entity)null, PistonMath.m_60328_(aabb, direction, d0).m_82367_(aabb)); if (!list.isEmpty()) { List list1 = voxelshape.m_83299_(); diff --git a/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch b/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch index 49ef6da116..93a1d8ff78 100644 --- a/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -95,6 +_,17 @@ - this.f_60449_ = p_60452_.f_60893_; +@@ -101,6 +_,17 @@ this.f_60438_ = p_60452_.f_60903_; + this.f_243733_ = p_60452_.f_244138_; this.f_60439_ = p_60452_; + final ResourceLocation lootTableCache = p_60452_.f_60894_; + if (lootTableCache != null) { @@ -18,7 +18,7 @@ } /** @deprecated */ -@@ -143,7 +_,7 @@ +@@ -149,7 +_,7 @@ /** @deprecated */ @Deprecated public void m_6810_(BlockState p_60515_, Level p_60516_, BlockPos p_60517_, BlockState p_60518_, boolean p_60519_) { @@ -27,7 +27,7 @@ p_60516_.m_46747_(p_60517_); } -@@ -220,7 +_,7 @@ +@@ -230,7 +_,7 @@ /** @deprecated */ @Deprecated public boolean m_6864_(BlockState p_60470_, BlockPlaceContext p_60471_) { @@ -36,7 +36,7 @@ } /** @deprecated */ -@@ -350,8 +_,8 @@ +@@ -360,8 +_,8 @@ if (f == -1.0F) { return 0.0F; } else { @@ -47,17 +47,17 @@ } } -@@ -384,8 +_,7 @@ +@@ -394,8 +_,7 @@ public final ResourceLocation m_60589_() { if (this.f_60440_ == null) { -- ResourceLocation resourcelocation = Registry.f_122824_.m_7981_(this.m_7374_()); -- this.f_60440_ = new ResourceLocation(resourcelocation.m_135827_(), "blocks/" + resourcelocation.m_135815_()); +- ResourceLocation resourcelocation = BuiltInRegistries.f_256975_.m_7981_(this.m_7374_()); +- this.f_60440_ = resourcelocation.m_246208_("blocks/"); + this.f_60440_ = this.lootTableSupplier.get(); } return this.f_60440_; -@@ -408,6 +_,14 @@ +@@ -418,6 +_,14 @@ return this.f_60439_.f_60888_; } @@ -72,7 +72,7 @@ public abstract static class BlockStateBase extends StateHolder { private final int f_60594_; private final boolean f_60595_; -@@ -492,18 +_,22 @@ +@@ -508,18 +_,22 @@ return this.f_60595_; } @@ -97,10 +97,10 @@ public BlockState m_60717_(Rotation p_60718_) { return this.m_60734_().m_6843_(this.m_7160_(), p_60718_); } -@@ -886,8 +_,9 @@ - ResourceLocation f_60894_; +@@ -911,8 +_,9 @@ boolean f_60895_ = true; boolean f_60896_; + boolean f_243850_ = true; + private java.util.function.Supplier lootTableSupplier; BlockBehaviour.StateArgumentPredicate> f_60897_ = (p_60935_, p_60936_, p_60937_, p_60938_) -> { - return p_60935_.m_60783_(p_60936_, p_60937_, Direction.UP) && p_60935_.m_60791_() < 14; @@ -108,7 +108,7 @@ }; BlockBehaviour.StatePredicate f_60898_ = (p_60985_, p_60986_, p_60987_) -> { return p_60985_.m_60767_().m_76337_() && p_60985_.m_60838_(p_60986_, p_60987_); -@@ -1018,9 +_,15 @@ +@@ -1046,9 +_,15 @@ return this; } diff --git a/patches/minecraft/net/minecraft/world/level/block/state/BlockState.java.patch b/patches/minecraft/net/minecraft/world/level/block/state/BlockState.java.patch index acf7303c9c..180564bd00 100644 --- a/patches/minecraft/net/minecraft/world/level/block/state/BlockState.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/state/BlockState.java.patch @@ -6,6 +6,6 @@ -public class BlockState extends BlockBehaviour.BlockStateBase { +public class BlockState extends BlockBehaviour.BlockStateBase implements net.minecraftforge.common.extensions.IForgeBlockState { - public static final Codec f_61039_ = m_61127_(Registry.f_122824_.m_194605_(), Block::m_49966_).stable(); + public static final Codec f_61039_ = m_61127_(BuiltInRegistries.f_256975_.m_194605_(), Block::m_49966_).stable(); public BlockState(Block p_61042_, ImmutableMap, Comparable> p_61043_, MapCodec p_61044_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/state/properties/WoodType.java.patch b/patches/minecraft/net/minecraft/world/level/block/state/properties/WoodType.java.patch index eff028bb21..6106183fc5 100644 --- a/patches/minecraft/net/minecraft/world/level/block/state/properties/WoodType.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/state/properties/WoodType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/state/properties/WoodType.java +++ b/net/minecraft/world/level/block/state/properties/WoodType.java -@@ -33,4 +_,11 @@ +@@ -34,4 +_,11 @@ public String m_61846_() { return this.f_61839_; } diff --git a/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch index ed6da7ceee..64bb2071c2 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -112,7 +112,7 @@ this.f_187610_.values().forEach((p_187988_) -> { Level level = this.f_62776_; if (level instanceof ServerLevel serverlevel) { -@@ -619,6 +_,41 @@ +@@ -618,6 +_,41 @@ this.f_196848_ = p_196865_; } @@ -154,7 +154,7 @@ class BoundTickingBlockEntity implements TickingBlockEntity { private final T f_156428_; private final BlockEntityTicker f_156429_; -@@ -635,6 +_,7 @@ +@@ -634,6 +_,7 @@ if (LevelChunk.this.m_156410_(blockpos)) { try { ProfilerFiller profilerfiller = LevelChunk.this.f_62776_.m_46473_(); @@ -162,7 +162,7 @@ profilerfiller.m_6521_(this::m_142280_); BlockState blockstate = LevelChunk.this.m_8055_(blockpos); if (this.f_156428_.m_58903_().m_155262_(blockstate)) { -@@ -650,6 +_,12 @@ +@@ -649,6 +_,12 @@ CrashReport crashreport = CrashReport.m_127521_(throwable, "Ticking block entity"); CrashReportCategory crashreportcategory = crashreport.m_127514_("Block entity being ticked"); this.f_156428_.m_58886_(crashreportcategory); @@ -175,7 +175,7 @@ throw new ReportedException(crashreport); } } -@@ -678,6 +_,34 @@ +@@ -677,6 +_,34 @@ IMMEDIATE, QUEUED, CHECK; diff --git a/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch index 4bd00e0e32..3d1cea2de5 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +++ b/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -@@ -156,6 +_,7 @@ - return Registry.f_122822_.m_6612_(ResourceLocation.m_135820_(p_188285_)); +@@ -158,6 +_,7 @@ + return BuiltInRegistries.f_257020_.m_6612_(ResourceLocation.m_135820_(p_258990_)); }, p_188233_); chunkaccess = new LevelChunk(p_188231_.m_6018_(), p_188233_, upgradedata, levelchunkticks, levelchunkticks1, j1, alevelchunksection, m_196890_(p_188231_, p_188234_), blendingdata); + if (p_188234_.m_128441_("ForgeCaps")) ((LevelChunk)chunkaccess).readCapsFromNBT(p_188234_.m_128469_("ForgeCaps")); } else { - ProtoChunkTicks protochunkticks = ProtoChunkTicks.m_193302_(p_188234_.m_128437_("block_ticks", 10), (p_196906_) -> { - return Registry.f_122824_.m_6612_(ResourceLocation.m_135820_(p_196906_)); -@@ -180,7 +_,7 @@ + ProtoChunkTicks protochunkticks = ProtoChunkTicks.m_193302_(p_188234_.m_128437_("block_ticks", 10), (p_258992_) -> { + return BuiltInRegistries.f_256975_.m_6612_(ResourceLocation.m_135820_(p_258992_)); +@@ -182,7 +_,7 @@ boolean flag3 = chunkstatus.m_62427_(ChunkStatus.f_62323_) || belowzeroretrogen != null && belowzeroretrogen.m_188466_().m_62427_(ChunkStatus.f_62323_); if (!flag && flag3) { for(BlockPos blockpos : BlockPos.m_121976_(p_188233_.m_45604_(), p_188231_.m_141937_(), p_188233_.m_45605_(), p_188233_.m_45608_(), p_188231_.m_151558_() - 1, p_188233_.m_45609_())) { @@ -17,7 +17,7 @@ protochunk.m_63277_(blockpos); } } -@@ -219,6 +_,7 @@ +@@ -221,6 +_,7 @@ } if (chunkstatus$chunktype == ChunkStatus.ChunkType.LEVELCHUNK) { @@ -25,7 +25,7 @@ return new ImposterProtoChunk((LevelChunk)chunkaccess, false); } else { ProtoChunk protochunk1 = (ProtoChunk)chunkaccess; -@@ -252,6 +_,7 @@ +@@ -257,6 +_,7 @@ protochunk1.m_188186_(generationstep$carving, new CarvingMask(compoundtag4.m_128467_(s1), chunkaccess.m_141937_())); } @@ -33,7 +33,7 @@ return protochunk1; } } -@@ -359,6 +_,15 @@ +@@ -364,6 +_,15 @@ } compoundtag.m_128365_("CarvingMasks", compoundtag4); diff --git a/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch b/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch index 3df4e7ee73..ef712951ce 100644 --- a/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch +++ b/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/dimension/end/EndDragonFight.java +++ b/net/minecraft/world/level/dimension/end/EndDragonFight.java -@@ -101,6 +_,7 @@ +@@ -102,6 +_,7 @@ this.f_64068_ = p_64080_.m_128471_("DragonKilled"); this.f_64069_ = p_64080_.m_128471_("PreviouslyKilled"); @@ -8,7 +8,7 @@ if (p_64080_.m_128471_("IsRespawning")) { this.f_64073_ = DragonRespawnAnimation.START; } -@@ -136,6 +_,7 @@ +@@ -137,6 +_,7 @@ compoundtag.m_128379_("DragonKilled", this.f_64068_); compoundtag.m_128379_("PreviouslyKilled", this.f_64069_); @@ -16,7 +16,7 @@ if (this.f_64072_ != null) { compoundtag.m_128365_("ExitPortalLocation", NbtUtils.m_129224_(this.f_64072_)); } -@@ -508,6 +_,13 @@ +@@ -518,6 +_,13 @@ endcrystal.m_31052_((BlockPos)null); } } diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/DebugLevelSource.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/DebugLevelSource.java.patch index 217ca48ea4..0d8f0572be 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/DebugLevelSource.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/DebugLevelSource.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/levelgen/DebugLevelSource.java +++ b/net/minecraft/world/level/levelgen/DebugLevelSource.java -@@ -112,6 +_,12 @@ - +@@ -104,6 +_,12 @@ return blockstate; } -+ + + public static void initValidStates() { -+ f_64114_ = StreamSupport.stream(Registry.f_122824_.spliterator(), false).flatMap(block -> block.m_49965_().m_61056_().stream()).collect(Collectors.toList()); ++ f_64114_ = StreamSupport.stream(BuiltInRegistries.f_256975_.spliterator(), false).flatMap(block -> block.m_49965_().m_61056_().stream()).collect(Collectors.toList()); + f_64115_ = Mth.m_14167_(Mth.m_14116_(f_64114_.size())); + f_64116_ = Mth.m_14167_((float) (f_64114_.size() / f_64115_)); + } - ++ public void m_213679_(WorldGenRegion p_223970_, long p_223971_, RandomState p_223972_, BiomeManager p_223973_, StructureManager p_223974_, ChunkAccess p_223975_, GenerationStep.Carving p_223976_) { } + diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch index ee004ececd..7a3aea6c86 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch @@ -1,10 +1,13 @@ --- a/net/minecraft/world/level/levelgen/PhantomSpawner.java +++ b/net/minecraft/world/level/levelgen/PhantomSpawner.java -@@ -60,6 +_,7 @@ - for(int i1 = 0; i1 < l; ++i1) { +@@ -61,6 +_,10 @@ Phantom phantom = EntityType.f_20509_.m_20615_(p_64576_); - phantom.m_20035_(blockpos1, 0.0F, 0.0F); -+ if(net.minecraftforge.common.ForgeHooks.canEntitySpawn(phantom, p_64576_, blockpos1.m_123341_(), blockpos1.m_123342_(), blockpos1.m_123343_(), null, MobSpawnType.NATURAL) == -1) { i--; continue; } - spawngroupdata = phantom.m_6518_(p_64576_, difficultyinstance, MobSpawnType.NATURAL, spawngroupdata, (CompoundTag)null); - p_64576_.m_47205_(phantom); - } + if (phantom != null) { + phantom.m_20035_(blockpos1, 0.0F, 0.0F); ++ if (net.minecraftforge.common.ForgeHooks.canEntitySpawn(phantom, p_64576_, blockpos1.m_123341_(), blockpos1.m_123342_(), blockpos1.m_123343_(), null, MobSpawnType.NATURAL) == -1) { ++ i--; ++ continue; ++ } + spawngroupdata = phantom.m_6518_(p_64576_, difficultyinstance, MobSpawnType.NATURAL, spawngroupdata, (CompoundTag)null); + p_64576_.m_47205_(phantom); + ++i; diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch index 5d6c28da7d..a496c1b031 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/feature/Feature.java +++ b/net/minecraft/world/level/levelgen/feature/Feature.java -@@ -155,7 +_,7 @@ +@@ -156,7 +_,7 @@ } protected static boolean m_159747_(BlockState p_159748_) { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java.patch index 12ac41c69b..20eb487b0a 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java +++ b/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java -@@ -129,6 +_,6 @@ +@@ -130,6 +_,6 @@ } private EntityType m_225153_(RandomSource p_225154_) { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/Structure.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/Structure.java.patch index c6bb057e58..a9b18ac3a4 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/Structure.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/Structure.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/levelgen/structure/Structure.java +++ b/net/minecraft/world/level/levelgen/structure/Structure.java -@@ -40,11 +_,12 @@ +@@ -41,11 +_,12 @@ public abstract class Structure { - public static final Codec f_226553_ = Registry.f_235740_.m_194605_().dispatch(Structure::m_213658_, StructureType::m_226884_); - public static final Codec> f_226554_ = RegistryFileCodec.m_135589_(Registry.f_235725_, f_226553_); + public static final Codec f_226553_ = BuiltInRegistries.f_256763_.m_194605_().dispatch(Structure::m_213658_, StructureType::m_226884_); + public static final Codec> f_226554_ = RegistryFileCodec.m_135589_(Registries.f_256944_, f_226553_); - protected final Structure.StructureSettings f_226555_; + //Forge: Make this field private so that the redirect coremod can target it + private final Structure.StructureSettings f_226555_; @@ -15,7 +15,7 @@ }); } -@@ -56,6 +_,7 @@ +@@ -57,6 +_,7 @@ protected Structure(Structure.StructureSettings p_226558_) { this.f_226555_ = p_226558_; @@ -23,8 +23,8 @@ } public HolderSet m_226559_() { -@@ -149,6 +_,29 @@ - public abstract Optional m_214086_(Structure.GenerationContext p_226571_); +@@ -157,6 +_,29 @@ + } public abstract StructureType m_213658_(); + diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch index 8a089bfb3b..637a6b4158 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch @@ -4,9 +4,9 @@ } public final CompoundTag m_192644_(StructurePieceSerializationContext p_192645_) { -+ if (Registry.f_122843_.m_7981_(this.m_210000_()) == null) { // FORGE: Friendlier error then the Null String error below. -+ throw new RuntimeException("StructurePiece \"" + this.getClass().getName() + "\": \"" + this.m_210000_() + "\" missing ID Mapping, Modder see MapGenStructureIO"); ++ if (BuiltInRegistries.f_257014_.m_7981_(this.m_210000_()) == null) { // FORGE: Friendlier error then the Null String error below. ++ throw new RuntimeException("StructurePiece \"" + this.getClass().getName() + "\": \"" + this.m_210000_() + "\" unregistered, serializing impossible."); + } CompoundTag compoundtag = new CompoundTag(); - compoundtag.m_128359_("id", Registry.f_122843_.m_7981_(this.m_210000_()).toString()); + compoundtag.m_128359_("id", BuiltInRegistries.f_257014_.m_7981_(this.m_210000_()).toString()); BoundingBox.f_162354_.encodeStart(NbtOps.f_128958_, this.f_73383_).resultOrPartial(f_163536_::error).ifPresent((p_163579_) -> { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch index 27e7442a64..4d09bb217e 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/levelgen/structure/StructureStart.java +++ b/net/minecraft/world/level/levelgen/structure/StructureStart.java -@@ -97,6 +_,9 @@ +@@ -98,6 +_,9 @@ public CompoundTag m_192660_(StructurePieceSerializationContext p_192661_, ChunkPos p_192662_) { CompoundTag compoundtag = new CompoundTag(); if (this.m_73603_()) { -+ if (p_192661_.f_192763_().m_175515_(Registry.f_235725_).m_7981_(this.m_226861_()) == null) { // FORGE: This is just a more friendly error instead of the 'Null String' below -+ throw new RuntimeException("StructureStart \"" + this.getClass().getName() + "\": \"" + this.m_226861_() + "\" missing ID Mapping, Modder see MapGenStructureIO"); ++ if (p_192661_.f_192763_().m_175515_(Registries.f_256944_).m_7981_(this.m_226861_()) == null) { // FORGE: This is just a more friendly error instead of the 'Null String' below ++ throw new RuntimeException("StructureStart \"" + this.getClass().getName() + "\": \"" + this.m_226861_() + "\" unregistered, serializing impossible."); + } - compoundtag.m_128359_("id", p_192661_.f_192763_().m_175515_(Registry.f_235725_).m_7981_(this.f_226844_).toString()); + compoundtag.m_128359_("id", p_192661_.f_192763_().m_175515_(Registries.f_256944_).m_7981_(this.f_226844_).toString()); compoundtag.m_128405_("ChunkX", p_192662_.f_45578_); compoundtag.m_128405_("ChunkZ", p_192662_.f_45579_); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch index 792df96bc7..8756f652ac 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java -@@ -201,6 +_,10 @@ +@@ -202,6 +_,10 @@ return m_74593_(p_74565_, p_74564_.m_74401_(), p_74564_.m_74404_(), p_74564_.m_74407_()); } @@ -11,7 +11,7 @@ public boolean m_230328_(ServerLevelAccessor p_230329_, BlockPos p_230330_, BlockPos p_230331_, StructurePlaceSettings p_230332_, RandomSource p_230333_, int p_230334_) { if (this.f_74482_.isEmpty()) { return false; -@@ -218,7 +_,7 @@ +@@ -219,7 +_,7 @@ int i1 = Integer.MIN_VALUE; int j1 = Integer.MIN_VALUE; @@ -20,7 +20,7 @@ BlockPos blockpos = structuretemplate$structureblockinfo.f_74675_; if (boundingbox == null || boundingbox.m_71051_(blockpos)) { FluidState fluidstate = p_230332_.m_74413_() ? p_230329_.m_6425_(blockpos) : null; -@@ -330,7 +_,7 @@ +@@ -331,7 +_,7 @@ } if (!p_230332_.m_74408_()) { @@ -29,7 +29,7 @@ } return true; -@@ -359,14 +_,19 @@ +@@ -360,14 +_,19 @@ }); } @@ -50,7 +50,7 @@ } if (structuretemplate$structureblockinfo1 != null) { -@@ -377,13 +_,29 @@ +@@ -378,13 +_,29 @@ return list; } @@ -86,7 +86,7 @@ ListTag listtag = new ListTag(); listtag.add(DoubleTag.m_128500_(vec31.f_82479_)); listtag.add(DoubleTag.m_128500_(vec31.f_82480_)); -@@ -391,10 +_,10 @@ +@@ -392,10 +_,10 @@ compoundtag.m_128365_("Pos", listtag); compoundtag.m_128473_("UUID"); m_74543_(p_74524_, compoundtag).ifPresent((p_205061_) -> { diff --git a/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch b/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch index 5daadbdec9..6c9e206a2e 100644 --- a/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/material/FlowingFluid.java +++ b/net/minecraft/world/level/material/FlowingFluid.java @@ -158,7 +_,7 @@ - BlockState blockstate = p_76036_.m_8055_(blockpos); + BlockState blockstate = p_256464_.m_8055_(blockpos); FluidState fluidstate = blockstate.m_60819_(); - if (fluidstate.m_76152_().m_6212_(this) && this.m_76061_(direction, p_76036_, p_76037_, p_76038_, blockpos, blockstate)) { + if (fluidstate.m_76152_().m_6212_(this) && this.m_76061_(direction, p_256464_, p_76037_, p_76038_, blockpos, blockstate)) { - if (fluidstate.m_76170_()) { -+ if (fluidstate.m_76170_() && net.minecraftforge.event.ForgeEventFactory.canCreateFluidSource(p_76036_, blockpos, blockstate, fluidstate.canConvertToSource(p_76036_, blockpos))) { ++ if (fluidstate.m_76170_() && net.minecraftforge.event.ForgeEventFactory.canCreateFluidSource(p_256464_, blockpos, blockstate, fluidstate.canConvertToSource(p_256464_, blockpos))) { ++j; } @@ -13,21 +13,24 @@ } } -- if (this.m_6760_() && j >= 2) { +- if (this.m_6760_(p_256464_) && j >= 2) { + if (j >= 2) { - BlockState blockstate1 = p_76036_.m_8055_(p_76037_.m_7495_()); + BlockState blockstate1 = p_256464_.m_8055_(p_76037_.m_7495_()); FluidState fluidstate1 = blockstate1.m_60819_(); if (blockstate1.m_60767_().m_76333_() || this.m_76096_(fluidstate1)) { -@@ -230,6 +_,12 @@ +@@ -230,6 +_,15 @@ return this.m_5613_().m_76145_().m_61124_(f_75947_, Boolean.valueOf(p_76069_)); } + @Override -+ public boolean canConvertToSource(FluidState state, LevelReader reader, BlockPos pos) { -+ return this.m_6760_(); ++ public boolean canConvertToSource(FluidState state, Level level, BlockPos pos) { ++ return this.m_6760_(level); + } + -+ @Deprecated //FORGE: Use state and level sensitive version instead - protected abstract boolean m_6760_(); ++ /** ++ * @deprecated Forge: Use {@link #canConvertToSource(FluidState, Level, BlockPos)} instead. ++ */ ++ @Deprecated + protected abstract boolean m_6760_(Level p_256009_); protected void m_6364_(LevelAccessor p_76005_, BlockPos p_76006_, BlockState p_76007_, Direction p_76008_, FluidState p_76009_) { diff --git a/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch b/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch index 0568b8e884..d4c547d428 100644 --- a/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch @@ -6,7 +6,7 @@ -public final class FluidState extends StateHolder { +public final class FluidState extends StateHolder implements net.minecraftforge.common.extensions.IForgeFluidState { - public static final Codec f_76146_ = m_61127_(Registry.f_122822_.m_194605_(), Fluid::m_76145_).stable(); + public static final Codec f_76146_ = m_61127_(BuiltInRegistries.f_257020_.m_194605_(), Fluid::m_76145_).stable(); public static final int f_164510_ = 9; public static final int f_164511_ = 8; @@ -113,6 +_,7 @@ diff --git a/patches/minecraft/net/minecraft/world/level/pathfinder/AmphibiousNodeEvaluator.java.patch b/patches/minecraft/net/minecraft/world/level/pathfinder/AmphibiousNodeEvaluator.java.patch index b968f4f544..e15f11e1cd 100644 --- a/patches/minecraft/net/minecraft/world/level/pathfinder/AmphibiousNodeEvaluator.java.patch +++ b/patches/minecraft/net/minecraft/world/level/pathfinder/AmphibiousNodeEvaluator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/pathfinder/AmphibiousNodeEvaluator.java +++ b/net/minecraft/world/level/pathfinder/AmphibiousNodeEvaluator.java -@@ -48,7 +_,7 @@ +@@ -46,7 +_,7 @@ BlockPathTypes blockpathtypes1 = this.m_77567_(this.f_77313_, p_164677_.f_77271_, p_164677_.f_77272_, p_164677_.f_77273_); int j; if (this.f_77313_.m_21439_(blockpathtypes) >= 0.0F && blockpathtypes1 != BlockPathTypes.STICKY_HONEY) { diff --git a/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch b/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch index cc2cc9b94a..f26b93a7bf 100644 --- a/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch +++ b/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java +++ b/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java -@@ -120,7 +_,7 @@ +@@ -114,7 +_,7 @@ BlockPathTypes blockpathtypes = this.m_77567_(this.f_77313_, p_77641_.f_77271_, p_77641_.f_77272_ + 1, p_77641_.f_77273_); BlockPathTypes blockpathtypes1 = this.m_77567_(this.f_77313_, p_77641_.f_77271_, p_77641_.f_77272_, p_77641_.f_77273_); if (this.f_77313_.m_21439_(blockpathtypes) >= 0.0F && blockpathtypes1 != BlockPathTypes.STICKY_HONEY) { @@ -9,7 +9,7 @@ } double d0 = this.m_142213_(new BlockPos(p_77641_.f_77271_, p_77641_.f_77272_, p_77641_.f_77273_)); -@@ -471,6 +_,11 @@ +@@ -459,6 +_,11 @@ if (l != 0 || j1 != 0) { p_77609_.m_122178_(i + l, j + i1, k + j1); BlockState blockstate = p_77608_.m_8055_(p_77609_); @@ -21,7 +21,7 @@ if (blockstate.m_60713_(Blocks.f_50128_)) { return BlockPathTypes.DANGER_CACTUS; } -@@ -496,6 +_,8 @@ +@@ -484,6 +_,8 @@ protected static BlockPathTypes m_77643_(BlockGetter p_77644_, BlockPos p_77645_) { BlockState blockstate = p_77644_.m_8055_(p_77645_); @@ -30,7 +30,7 @@ Block block = blockstate.m_60734_(); Material material = blockstate.m_60767_(); if (blockstate.m_60795_()) { -@@ -513,6 +_,8 @@ +@@ -501,6 +_,8 @@ return BlockPathTypes.COCOA; } else { FluidState fluidstate = p_77644_.m_6425_(p_77645_); @@ -39,7 +39,7 @@ if (fluidstate.m_205070_(FluidTags.f_13132_)) { return BlockPathTypes.LAVA; } else if (m_77622_(blockstate)) { -@@ -531,6 +_,8 @@ +@@ -519,6 +_,8 @@ if (!blockstate.m_60647_(p_77644_, p_77645_, PathComputationType.LAND)) { return BlockPathTypes.BLOCKED; } else { diff --git a/patches/minecraft/net/minecraft/world/level/portal/PortalShape.java.patch b/patches/minecraft/net/minecraft/world/level/portal/PortalShape.java.patch index 411d337509..3973462010 100644 --- a/patches/minecraft/net/minecraft/world/level/portal/PortalShape.java.patch +++ b/patches/minecraft/net/minecraft/world/level/portal/PortalShape.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/portal/PortalShape.java +++ b/net/minecraft/world/level/portal/PortalShape.java -@@ -24,7 +_,7 @@ +@@ -28,7 +_,7 @@ private static final int f_164753_ = 3; public static final int f_164751_ = 21; private static final BlockBehaviour.StatePredicate f_77685_ = (p_77720_, p_77721_, p_77722_) -> { - return p_77720_.m_60713_(Blocks.f_50080_); + return p_77720_.isPortalFrame(p_77721_, p_77722_); }; - private final LevelAccessor f_77686_; - private final Direction.Axis f_77687_; + private static final float f_256985_ = 4.0F; + private static final double f_256802_ = 1.0D; diff --git a/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch b/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch index b5d88618c5..8f6095f45b 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch @@ -1,21 +1,7 @@ --- a/net/minecraft/world/level/storage/LevelStorageSource.java +++ b/net/minecraft/world/level/storage/LevelStorageSource.java -@@ -96,6 +_,13 @@ - } - - Dynamic dynamic1 = p_78206_.update(References.f_16795_, dynamic, p_78207_, SharedConstants.m_183709_().getWorldVersion()); -+ // The above line is modified (via the patch in V2832), such that the data fixer upper will retain dimensions that don't exist in the schema, in the dynamic. -+ // When we parse the WorldGenSettings below, in vanilla, this uses the same call paths that can cause things to register (such as dimension types). -+ // However, since at this point all resource data will have been loaded, anything that *would* register now is going to error later, because it'll create a Holder<> reference, that is not bound to anything. This unbound reference will then throw an error when the registries are frozen. -+ // So, we freeze the registries before this call to parse(). This prevents them from leaking any new unbound holders into the registry. -+ // Attempting to register to a frozen registry throws an exception, which we resolve via a patch in RegistryLoader, causing it to return DataResult.error() instead, and prevent the faulty dimension from registering without aborting the parsing of the WorldGenSettings -+ // Finally, the resultOrPartial() promotes only the dimensions which successfully parsed, and the LenientUnboundedMapCodec which is patched into the WorldGenSettings codec ensures that *only* the invalid dimensions will fail to parse (see MC-197860), and not discard other dimensions as well. -+ if (p_78205_.getOps() instanceof net.minecraft.resources.RegistryOps ops) ops.f_206806_.m_203610_().forEach(e -> e.f_206234_().m_203521_()); - DataResult dataresult = WorldGenSettings.f_64600_.parse(dynamic1); - return Pair.of(dataresult.resultOrPartial(Util.m_137489_("WorldGenSettings: ", f_78191_::error)).orElseGet(() -> { - RegistryAccess registryaccess = RegistryAccess.m_206154_(dynamic1); -@@ -372,6 +_,19 @@ - return LevelStorageSource.this.m_230817_(this.f_230867_, LevelStorageSource.m_211737_(p_211748_, p_211749_, p_211750_)); +@@ -389,6 +_,19 @@ + return LevelStorageSource.this.m_230817_(this.f_230867_, LevelStorageSource.m_245503_(p_248747_, p_251873_, p_249187_, p_249736_)); } + public void readAdditionalLevelSaveData() { @@ -32,9 +18,9 @@ + } + @Nullable - public DataPackConfig m_78309_() { + public WorldDataConfiguration m_247706_() { this.m_78313_(); -@@ -388,6 +_,8 @@ +@@ -405,6 +_,8 @@ CompoundTag compoundtag1 = new CompoundTag(); compoundtag1.m_128365_("Data", compoundtag); @@ -43,7 +29,7 @@ try { File file2 = File.createTempFile("level", ".dat", file1); NbtIo.m_128944_(compoundtag1, file2); -@@ -402,6 +_,10 @@ +@@ -419,6 +_,10 @@ public Optional m_182514_() { return !this.f_78270_.m_13639_() ? Optional.empty() : Optional.of(this.f_230867_.m_230860_()); diff --git a/patches/minecraft/net/minecraft/world/level/storage/LevelSummary.java.patch b/patches/minecraft/net/minecraft/world/level/storage/LevelSummary.java.patch index 37609faf47..be7cef9aed 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/LevelSummary.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/LevelSummary.java.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/world/level/storage/LevelSummary.java +++ b/net/minecraft/world/level/storage/LevelSummary.java -@@ -179,4 +_,7 @@ +@@ -189,4 +_,8 @@ return this.f_164922_; } } -+ public boolean isExperimental() { ++ ++ public boolean isLifecycleExperimental() { + return this.f_78344_.getLifecycle().equals(com.mojang.serialization.Lifecycle.experimental()); + } } diff --git a/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch b/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch index 7cfdb1f9e3..c6d9b3448a 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch @@ -1,34 +1,23 @@ --- a/net/minecraft/world/level/storage/PrimaryLevelData.java +++ b/net/minecraft/world/level/storage/PrimaryLevelData.java -@@ -77,6 +_,7 @@ +@@ -79,6 +_,7 @@ private final Set f_78439_; private boolean f_78440_; private final TimerQueue f_78441_; + private boolean confirmedExperimentalWarning = false; - private PrimaryLevelData(@Nullable DataFixer p_164942_, int p_164943_, @Nullable CompoundTag p_164944_, boolean p_164945_, int p_164946_, int p_164947_, int p_164948_, float p_164949_, long p_164950_, long p_164951_, int p_164952_, int p_164953_, int p_164954_, boolean p_164955_, int p_164956_, boolean p_164957_, boolean p_164958_, boolean p_164959_, WorldBorder.Settings p_164960_, int p_164961_, int p_164962_, @Nullable UUID p_164963_, Set p_164964_, TimerQueue p_164965_, @Nullable CompoundTag p_164966_, CompoundTag p_164967_, LevelSettings p_164968_, WorldGenSettings p_164969_, Lifecycle p_164970_) { - if (!p_164969_.m_204655_().m_142003_(LevelStem.f_63971_)) { -@@ -108,7 +_,9 @@ - this.f_78441_ = p_164965_; - this.f_78466_ = p_164966_; - this.f_78465_ = p_164967_; -- this.f_78443_ = p_164968_; -+ this.f_78443_ = p_164968_.withLifecycle(p_164970_); -+ if (p_164970_ == Lifecycle.stable()) //Reset to unconfirmed if the lifecycle goes back to stable -+ this.confirmedExperimentalWarning = false; - this.f_78444_ = p_164969_; - this.f_78445_ = p_164970_; - } -@@ -125,7 +_,7 @@ + private PrimaryLevelData(@Nullable DataFixer p_249266_, int p_249857_, @Nullable CompoundTag p_249309_, boolean p_251525_, int p_249614_, int p_252310_, int p_250544_, float p_250495_, long p_250393_, long p_252085_, int p_250455_, int p_248981_, int p_249051_, boolean p_249672_, int p_249807_, boolean p_252350_, boolean p_250231_, boolean p_249788_, WorldBorder.Settings p_251494_, int p_249519_, int p_250649_, @Nullable UUID p_248892_, Set p_251898_, TimerQueue p_251119_, @Nullable CompoundTag p_248915_, CompoundTag p_252274_, LevelSettings p_248619_, WorldOptions p_251512_, PrimaryLevelData.SpecialWorldProperty p_251396_, Lifecycle p_252247_) { + this.f_78452_ = p_249266_; +@@ -124,7 +_,7 @@ }); return new PrimaryLevelData(p_78532_, p_78533_, p_78534_, p_78531_.get("WasModded").asBoolean(false), p_78531_.get("SpawnX").asInt(0), p_78531_.get("SpawnY").asInt(0), p_78531_.get("SpawnZ").asInt(0), p_78531_.get("SpawnAngle").asFloat(0.0F), i, p_78531_.get("DayTime").asLong(i), p_78536_.m_78389_(), p_78531_.get("clearWeatherTime").asInt(0), p_78531_.get("rainTime").asInt(0), p_78531_.get("raining").asBoolean(false), p_78531_.get("thunderTime").asInt(0), p_78531_.get("thundering").asBoolean(false), p_78531_.get("initialized").asBoolean(true), p_78531_.get("DifficultyLocked").asBoolean(false), WorldBorder.Settings.m_62037_(p_78531_, WorldBorder.f_61907_), p_78531_.get("WanderingTraderSpawnDelay").asInt(0), p_78531_.get("WanderingTraderSpawnChance").asInt(0), p_78531_.get("WanderingTraderId").read(UUIDUtil.f_235867_).result().orElse((UUID)null), p_78531_.get("ServerBrands").asStream().flatMap((p_78529_) -> { return p_78529_.asString().result().stream(); -- }).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new TimerQueue<>(TimerCallbacks.f_82226_, p_78531_.get("ScheduledEvents").asStream()), (CompoundTag)p_78531_.get("CustomBossEvents").orElseEmptyMap().getValue(), compoundtag, p_78535_, p_78537_, p_78538_); -+ }).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new TimerQueue<>(TimerCallbacks.f_82226_, p_78531_.get("ScheduledEvents").asStream()), (CompoundTag)p_78531_.get("CustomBossEvents").orElseEmptyMap().getValue(), compoundtag, p_78535_, p_78537_, p_78538_).withConfirmedWarning(p_78538_ != Lifecycle.stable() && p_78531_.get("confirmedExperimentalSettings").asBoolean(false)); +- }).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new TimerQueue<>(TimerCallbacks.f_82226_, p_78531_.get("ScheduledEvents").asStream()), (CompoundTag)p_78531_.get("CustomBossEvents").orElseEmptyMap().getValue(), compoundtag, p_78535_, p_251864_, p_250651_, p_78538_); ++ }).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new TimerQueue<>(TimerCallbacks.f_82226_, p_78531_.get("ScheduledEvents").asStream()), (CompoundTag)p_78531_.get("CustomBossEvents").orElseEmptyMap().getValue(), compoundtag, p_78535_, p_251864_, p_250651_, p_78538_).withConfirmedWarning(p_78538_ != Lifecycle.stable() && p_78531_.get("confirmedExperimentalSettings").asBoolean(false)); } public CompoundTag m_6626_(RegistryAccess p_78543_, @Nullable CompoundTag p_78544_) { -@@ -196,6 +_,8 @@ +@@ -198,6 +_,8 @@ p_78547_.m_128362_("WanderingTraderId", this.f_78438_); } @@ -37,17 +26,19 @@ } public int m_6789_() { -@@ -458,5 +_,13 @@ +@@ -468,6 +_,15 @@ public LevelSettings m_5926_() { return this.f_78443_.m_46935_(); + } -+ //FORGE ++ + public boolean hasConfirmedExperimentalWarning() { + return this.confirmedExperimentalWarning; + } -+ public PrimaryLevelData withConfirmedWarning(boolean confirmedWarning) { //Builder-like to not patch ctor ++ ++ public PrimaryLevelData withConfirmedWarning(boolean confirmedWarning) { // Builder-like to not patch ctor + this.confirmedExperimentalWarning = confirmedWarning; + return this; } - } + + /** @deprecated */ diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch index dc42573d09..84b4e2d82b 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch @@ -16,15 +16,15 @@ this.f_79110_ = p_79116_; this.f_79111_ = LootItemFunctions.m_80770_(p_79116_); } -@@ -79,6 +_,7 @@ +@@ -81,6 +_,7 @@ } + @Deprecated //Use other method or manually call ForgeHooks.modifyLoot public void m_79148_(LootContext p_79149_, Consumer p_79150_) { - this.m_79131_(p_79149_, m_79142_(p_79150_)); + this.m_79131_(p_79149_, m_246283_(p_79149_, p_79150_)); } -@@ -86,6 +_,7 @@ +@@ -88,6 +_,7 @@ public ObjectArrayList m_230922_(LootContext p_230923_) { ObjectArrayList objectarraylist = new ObjectArrayList<>(); this.m_79148_(p_230923_, objectarraylist::add); @@ -32,7 +32,7 @@ return objectarraylist; } -@@ -94,8 +_,8 @@ +@@ -96,8 +_,8 @@ } public void m_79136_(ValidationContext p_79137_) { @@ -43,7 +43,7 @@ } for(int j = 0; j < this.f_79110_.length; ++j) { -@@ -177,6 +_,48 @@ +@@ -179,6 +_,48 @@ return new LootTable.Builder(); } @@ -92,7 +92,7 @@ public static class Builder implements FunctionUserBuilder { private final List f_79156_ = Lists.newArrayList(); private final List f_79157_ = Lists.newArrayList(); -@@ -231,7 +_,7 @@ +@@ -233,7 +_,7 @@ } } diff --git a/src/generated/resources/data/minecraft/recipes/acacia_chest_boat.json b/src/generated/resources/data/minecraft/recipes/acacia_chest_boat.json index 8a9b081a74..f20818e69a 100644 --- a/src/generated/resources/data/minecraft/recipes/acacia_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipes/acacia_chest_boat.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "misc", "group": "chest_boat", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/acacia_fence.json b/src/generated/resources/data/minecraft/recipes/acacia_fence.json index 075416e8cb..d545c439a6 100644 --- a/src/generated/resources/data/minecraft/recipes/acacia_fence.json +++ b/src/generated/resources/data/minecraft/recipes/acacia_fence.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_fence", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/acacia_fence_gate.json b/src/generated/resources/data/minecraft/recipes/acacia_fence_gate.json index 50d03541aa..027948967b 100644 --- a/src/generated/resources/data/minecraft/recipes/acacia_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipes/acacia_fence_gate.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "group": "wooden_fence_gate", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/acacia_sign.json b/src/generated/resources/data/minecraft/recipes/acacia_sign.json index d4ef309365..ab7495d12d 100644 --- a/src/generated/resources/data/minecraft/recipes/acacia_sign.json +++ b/src/generated/resources/data/minecraft/recipes/acacia_sign.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_sign", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/activator_rail.json b/src/generated/resources/data/minecraft/recipes/activator_rail.json index 6d5174d5dd..9f682df753 100644 --- a/src/generated/resources/data/minecraft/recipes/activator_rail.json +++ b/src/generated/resources/data/minecraft/recipes/activator_rail.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "item": "minecraft:redstone_torch" diff --git a/src/generated/resources/data/minecraft/recipes/andesite.json b/src/generated/resources/data/minecraft/recipes/andesite.json index 98ceafc0f9..4f70b2cea2 100644 --- a/src/generated/resources/data/minecraft/recipes/andesite.json +++ b/src/generated/resources/data/minecraft/recipes/andesite.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "building", "ingredients": [ { "item": "minecraft:diorite" diff --git a/src/generated/resources/data/minecraft/recipes/anvil.json b/src/generated/resources/data/minecraft/recipes/anvil.json index 0145a6172a..33203f2d58 100644 --- a/src/generated/resources/data/minecraft/recipes/anvil.json +++ b/src/generated/resources/data/minecraft/recipes/anvil.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "I": { "item": "minecraft:iron_block" diff --git a/src/generated/resources/data/minecraft/recipes/armor_stand.json b/src/generated/resources/data/minecraft/recipes/armor_stand.json index a9e98285af..54da4b9a02 100644 --- a/src/generated/resources/data/minecraft/recipes/armor_stand.json +++ b/src/generated/resources/data/minecraft/recipes/armor_stand.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "/": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/arrow.json b/src/generated/resources/data/minecraft/recipes/arrow.json index 7d1a62b638..c4eba0d814 100644 --- a/src/generated/resources/data/minecraft/recipes/arrow.json +++ b/src/generated/resources/data/minecraft/recipes/arrow.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/birch_chest_boat.json b/src/generated/resources/data/minecraft/recipes/birch_chest_boat.json index ce82f9ba22..7fe3c649ab 100644 --- a/src/generated/resources/data/minecraft/recipes/birch_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipes/birch_chest_boat.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "misc", "group": "chest_boat", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/birch_fence.json b/src/generated/resources/data/minecraft/recipes/birch_fence.json index fc1641e89b..170c1c2520 100644 --- a/src/generated/resources/data/minecraft/recipes/birch_fence.json +++ b/src/generated/resources/data/minecraft/recipes/birch_fence.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_fence", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/birch_fence_gate.json b/src/generated/resources/data/minecraft/recipes/birch_fence_gate.json index 6fd7aa8308..325773a2eb 100644 --- a/src/generated/resources/data/minecraft/recipes/birch_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipes/birch_fence_gate.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "group": "wooden_fence_gate", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/birch_sign.json b/src/generated/resources/data/minecraft/recipes/birch_sign.json index e42906a44b..7a98a35feb 100644 --- a/src/generated/resources/data/minecraft/recipes/birch_sign.json +++ b/src/generated/resources/data/minecraft/recipes/birch_sign.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_sign", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/black_banner.json b/src/generated/resources/data/minecraft/recipes/black_banner.json index ff39656c6f..8f0a69aab4 100644 --- a/src/generated/resources/data/minecraft/recipes/black_banner.json +++ b/src/generated/resources/data/minecraft/recipes/black_banner.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "banner", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/blast_furnace.json b/src/generated/resources/data/minecraft/recipes/blast_furnace.json index 3c667add35..1c34a6149c 100644 --- a/src/generated/resources/data/minecraft/recipes/blast_furnace.json +++ b/src/generated/resources/data/minecraft/recipes/blast_furnace.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "item": "minecraft:smooth_stone" diff --git a/src/generated/resources/data/minecraft/recipes/blue_banner.json b/src/generated/resources/data/minecraft/recipes/blue_banner.json index b8fda12803..2270bf926c 100644 --- a/src/generated/resources/data/minecraft/recipes/blue_banner.json +++ b/src/generated/resources/data/minecraft/recipes/blue_banner.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "banner", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/bow.json b/src/generated/resources/data/minecraft/recipes/bow.json index bd12673d24..2cd59d8a45 100644 --- a/src/generated/resources/data/minecraft/recipes/bow.json +++ b/src/generated/resources/data/minecraft/recipes/bow.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/brown_banner.json b/src/generated/resources/data/minecraft/recipes/brown_banner.json index 8702d57074..71bb73f30a 100644 --- a/src/generated/resources/data/minecraft/recipes/brown_banner.json +++ b/src/generated/resources/data/minecraft/recipes/brown_banner.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "banner", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/bucket.json b/src/generated/resources/data/minecraft/recipes/bucket.json index 9f00805294..22912ba151 100644 --- a/src/generated/resources/data/minecraft/recipes/bucket.json +++ b/src/generated/resources/data/minecraft/recipes/bucket.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "forge:ingots/iron" diff --git a/src/generated/resources/data/minecraft/recipes/campfire.json b/src/generated/resources/data/minecraft/recipes/campfire.json index f6743fe112..d329eb4738 100644 --- a/src/generated/resources/data/minecraft/recipes/campfire.json +++ b/src/generated/resources/data/minecraft/recipes/campfire.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "C": { "tag": "minecraft:coals" diff --git a/src/generated/resources/data/minecraft/recipes/cauldron.json b/src/generated/resources/data/minecraft/recipes/cauldron.json index 8fd36095c9..982e8e6aa0 100644 --- a/src/generated/resources/data/minecraft/recipes/cauldron.json +++ b/src/generated/resources/data/minecraft/recipes/cauldron.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "forge:ingots/iron" diff --git a/src/generated/resources/data/minecraft/recipes/chain.json b/src/generated/resources/data/minecraft/recipes/chain.json index 54e54c37dc..0834b8f1ae 100644 --- a/src/generated/resources/data/minecraft/recipes/chain.json +++ b/src/generated/resources/data/minecraft/recipes/chain.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "I": { "tag": "forge:ingots/iron" diff --git a/src/generated/resources/data/minecraft/recipes/chest_minecart.json b/src/generated/resources/data/minecraft/recipes/chest_minecart.json index 1d10263f2f..99c7780621 100644 --- a/src/generated/resources/data/minecraft/recipes/chest_minecart.json +++ b/src/generated/resources/data/minecraft/recipes/chest_minecart.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "misc", "ingredients": [ { "tag": "forge:chests/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/clock.json b/src/generated/resources/data/minecraft/recipes/clock.json index 9533574cc7..31e02ad116 100644 --- a/src/generated/resources/data/minecraft/recipes/clock.json +++ b/src/generated/resources/data/minecraft/recipes/clock.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:ingots/gold" diff --git a/src/generated/resources/data/minecraft/recipes/compass.json b/src/generated/resources/data/minecraft/recipes/compass.json index 2eb80ab73e..f1b6226133 100644 --- a/src/generated/resources/data/minecraft/recipes/compass.json +++ b/src/generated/resources/data/minecraft/recipes/compass.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:ingots/iron" diff --git a/src/generated/resources/data/minecraft/recipes/crimson_fence.json b/src/generated/resources/data/minecraft/recipes/crimson_fence.json index f453778bb7..fd4c99174e 100644 --- a/src/generated/resources/data/minecraft/recipes/crimson_fence.json +++ b/src/generated/resources/data/minecraft/recipes/crimson_fence.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_fence", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/crimson_fence_gate.json b/src/generated/resources/data/minecraft/recipes/crimson_fence_gate.json index 8e3a5429f5..b8d6cb88dd 100644 --- a/src/generated/resources/data/minecraft/recipes/crimson_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipes/crimson_fence_gate.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "group": "wooden_fence_gate", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/crimson_sign.json b/src/generated/resources/data/minecraft/recipes/crimson_sign.json index 2aaa3b7d8d..2d26330c3d 100644 --- a/src/generated/resources/data/minecraft/recipes/crimson_sign.json +++ b/src/generated/resources/data/minecraft/recipes/crimson_sign.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_sign", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/crossbow.json b/src/generated/resources/data/minecraft/recipes/crossbow.json index ce5fb3b7cb..2e6e01d1c9 100644 --- a/src/generated/resources/data/minecraft/recipes/crossbow.json +++ b/src/generated/resources/data/minecraft/recipes/crossbow.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/cyan_banner.json b/src/generated/resources/data/minecraft/recipes/cyan_banner.json index c6f620a87d..2eae740c43 100644 --- a/src/generated/resources/data/minecraft/recipes/cyan_banner.json +++ b/src/generated/resources/data/minecraft/recipes/cyan_banner.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "banner", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/dark_oak_chest_boat.json b/src/generated/resources/data/minecraft/recipes/dark_oak_chest_boat.json index 8f83ab07b9..783c44a9fc 100644 --- a/src/generated/resources/data/minecraft/recipes/dark_oak_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipes/dark_oak_chest_boat.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "misc", "group": "chest_boat", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/dark_oak_fence.json b/src/generated/resources/data/minecraft/recipes/dark_oak_fence.json index 577ef33d77..f25b7a205a 100644 --- a/src/generated/resources/data/minecraft/recipes/dark_oak_fence.json +++ b/src/generated/resources/data/minecraft/recipes/dark_oak_fence.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_fence", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/dark_oak_fence_gate.json b/src/generated/resources/data/minecraft/recipes/dark_oak_fence_gate.json index 6e3bf7940b..53d878a102 100644 --- a/src/generated/resources/data/minecraft/recipes/dark_oak_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipes/dark_oak_fence_gate.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "group": "wooden_fence_gate", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/dark_oak_sign.json b/src/generated/resources/data/minecraft/recipes/dark_oak_sign.json index 55480be9b5..286e275709 100644 --- a/src/generated/resources/data/minecraft/recipes/dark_oak_sign.json +++ b/src/generated/resources/data/minecraft/recipes/dark_oak_sign.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_sign", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/detector_rail.json b/src/generated/resources/data/minecraft/recipes/detector_rail.json index 89abf5bbb0..ddafa7ab5b 100644 --- a/src/generated/resources/data/minecraft/recipes/detector_rail.json +++ b/src/generated/resources/data/minecraft/recipes/detector_rail.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "item": "minecraft:stone_pressure_plate" diff --git a/src/generated/resources/data/minecraft/recipes/diamond_axe.json b/src/generated/resources/data/minecraft/recipes/diamond_axe.json index b53c0898b3..fa33917a09 100644 --- a/src/generated/resources/data/minecraft/recipes/diamond_axe.json +++ b/src/generated/resources/data/minecraft/recipes/diamond_axe.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/diamond_boots.json b/src/generated/resources/data/minecraft/recipes/diamond_boots.json index 45c7fa988a..0ab7eb99fe 100644 --- a/src/generated/resources/data/minecraft/recipes/diamond_boots.json +++ b/src/generated/resources/data/minecraft/recipes/diamond_boots.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "X": { "tag": "forge:gems/diamond" diff --git a/src/generated/resources/data/minecraft/recipes/diamond_chestplate.json b/src/generated/resources/data/minecraft/recipes/diamond_chestplate.json index 22a453c8dc..1cd18f4c75 100644 --- a/src/generated/resources/data/minecraft/recipes/diamond_chestplate.json +++ b/src/generated/resources/data/minecraft/recipes/diamond_chestplate.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "X": { "tag": "forge:gems/diamond" diff --git a/src/generated/resources/data/minecraft/recipes/diamond_helmet.json b/src/generated/resources/data/minecraft/recipes/diamond_helmet.json index 92ea98bf50..9671c540d3 100644 --- a/src/generated/resources/data/minecraft/recipes/diamond_helmet.json +++ b/src/generated/resources/data/minecraft/recipes/diamond_helmet.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "X": { "tag": "forge:gems/diamond" diff --git a/src/generated/resources/data/minecraft/recipes/diamond_hoe.json b/src/generated/resources/data/minecraft/recipes/diamond_hoe.json index 98edd1dcc2..ccd0e48768 100644 --- a/src/generated/resources/data/minecraft/recipes/diamond_hoe.json +++ b/src/generated/resources/data/minecraft/recipes/diamond_hoe.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/diamond_leggings.json b/src/generated/resources/data/minecraft/recipes/diamond_leggings.json index 90dc9d1619..f9cbdcd738 100644 --- a/src/generated/resources/data/minecraft/recipes/diamond_leggings.json +++ b/src/generated/resources/data/minecraft/recipes/diamond_leggings.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "X": { "tag": "forge:gems/diamond" diff --git a/src/generated/resources/data/minecraft/recipes/diamond_pickaxe.json b/src/generated/resources/data/minecraft/recipes/diamond_pickaxe.json index d1ce09d7db..affd0a3083 100644 --- a/src/generated/resources/data/minecraft/recipes/diamond_pickaxe.json +++ b/src/generated/resources/data/minecraft/recipes/diamond_pickaxe.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/diamond_shovel.json b/src/generated/resources/data/minecraft/recipes/diamond_shovel.json index 66ab1ae7e7..cb8282be2c 100644 --- a/src/generated/resources/data/minecraft/recipes/diamond_shovel.json +++ b/src/generated/resources/data/minecraft/recipes/diamond_shovel.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/diamond_sword.json b/src/generated/resources/data/minecraft/recipes/diamond_sword.json index a9d94cbd35..de7b7d161b 100644 --- a/src/generated/resources/data/minecraft/recipes/diamond_sword.json +++ b/src/generated/resources/data/minecraft/recipes/diamond_sword.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/diorite.json b/src/generated/resources/data/minecraft/recipes/diorite.json index 0bd5d34336..6dfb532dcf 100644 --- a/src/generated/resources/data/minecraft/recipes/diorite.json +++ b/src/generated/resources/data/minecraft/recipes/diorite.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "building", "key": { "C": { "tag": "forge:cobblestone/normal" diff --git a/src/generated/resources/data/minecraft/recipes/dispenser.json b/src/generated/resources/data/minecraft/recipes/dispenser.json index f60d9b7117..20076eae31 100644 --- a/src/generated/resources/data/minecraft/recipes/dispenser.json +++ b/src/generated/resources/data/minecraft/recipes/dispenser.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "key": { "#": { "tag": "forge:cobblestone/normal" diff --git a/src/generated/resources/data/minecraft/recipes/dropper.json b/src/generated/resources/data/minecraft/recipes/dropper.json index f740b3ab3d..76c51a4fa6 100644 --- a/src/generated/resources/data/minecraft/recipes/dropper.json +++ b/src/generated/resources/data/minecraft/recipes/dropper.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "key": { "#": { "tag": "forge:cobblestone/normal" diff --git a/src/generated/resources/data/minecraft/recipes/enchanting_table.json b/src/generated/resources/data/minecraft/recipes/enchanting_table.json index 36572d7ed7..a238995fb9 100644 --- a/src/generated/resources/data/minecraft/recipes/enchanting_table.json +++ b/src/generated/resources/data/minecraft/recipes/enchanting_table.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "item": "minecraft:obsidian" diff --git a/src/generated/resources/data/minecraft/recipes/fishing_rod.json b/src/generated/resources/data/minecraft/recipes/fishing_rod.json index 37377fc1da..1bbddf8937 100644 --- a/src/generated/resources/data/minecraft/recipes/fishing_rod.json +++ b/src/generated/resources/data/minecraft/recipes/fishing_rod.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/flint_and_steel.json b/src/generated/resources/data/minecraft/recipes/flint_and_steel.json index 2d86c48925..7181ac5d08 100644 --- a/src/generated/resources/data/minecraft/recipes/flint_and_steel.json +++ b/src/generated/resources/data/minecraft/recipes/flint_and_steel.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "equipment", "ingredients": [ { "tag": "forge:ingots/iron" diff --git a/src/generated/resources/data/minecraft/recipes/golden_apple.json b/src/generated/resources/data/minecraft/recipes/golden_apple.json index 07cefc838c..674bf883d3 100644 --- a/src/generated/resources/data/minecraft/recipes/golden_apple.json +++ b/src/generated/resources/data/minecraft/recipes/golden_apple.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "forge:ingots/gold" diff --git a/src/generated/resources/data/minecraft/recipes/golden_axe.json b/src/generated/resources/data/minecraft/recipes/golden_axe.json index e0d3d34e48..4811c860ad 100644 --- a/src/generated/resources/data/minecraft/recipes/golden_axe.json +++ b/src/generated/resources/data/minecraft/recipes/golden_axe.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/golden_boots.json b/src/generated/resources/data/minecraft/recipes/golden_boots.json index 198126cdc0..d5e15bc24f 100644 --- a/src/generated/resources/data/minecraft/recipes/golden_boots.json +++ b/src/generated/resources/data/minecraft/recipes/golden_boots.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "X": { "tag": "forge:ingots/gold" diff --git a/src/generated/resources/data/minecraft/recipes/golden_chestplate.json b/src/generated/resources/data/minecraft/recipes/golden_chestplate.json index ed7c6b1087..a06e7c25eb 100644 --- a/src/generated/resources/data/minecraft/recipes/golden_chestplate.json +++ b/src/generated/resources/data/minecraft/recipes/golden_chestplate.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "X": { "tag": "forge:ingots/gold" diff --git a/src/generated/resources/data/minecraft/recipes/golden_helmet.json b/src/generated/resources/data/minecraft/recipes/golden_helmet.json index 69210e911e..2161b20de7 100644 --- a/src/generated/resources/data/minecraft/recipes/golden_helmet.json +++ b/src/generated/resources/data/minecraft/recipes/golden_helmet.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "X": { "tag": "forge:ingots/gold" diff --git a/src/generated/resources/data/minecraft/recipes/golden_hoe.json b/src/generated/resources/data/minecraft/recipes/golden_hoe.json index 0e0c30b411..9626f019d7 100644 --- a/src/generated/resources/data/minecraft/recipes/golden_hoe.json +++ b/src/generated/resources/data/minecraft/recipes/golden_hoe.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/golden_leggings.json b/src/generated/resources/data/minecraft/recipes/golden_leggings.json index d29b59385b..a377fbc982 100644 --- a/src/generated/resources/data/minecraft/recipes/golden_leggings.json +++ b/src/generated/resources/data/minecraft/recipes/golden_leggings.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "X": { "tag": "forge:ingots/gold" diff --git a/src/generated/resources/data/minecraft/recipes/golden_pickaxe.json b/src/generated/resources/data/minecraft/recipes/golden_pickaxe.json index 3936604c84..b953212ba9 100644 --- a/src/generated/resources/data/minecraft/recipes/golden_pickaxe.json +++ b/src/generated/resources/data/minecraft/recipes/golden_pickaxe.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/golden_shovel.json b/src/generated/resources/data/minecraft/recipes/golden_shovel.json index cc5cf38ccb..5e4bbd536c 100644 --- a/src/generated/resources/data/minecraft/recipes/golden_shovel.json +++ b/src/generated/resources/data/minecraft/recipes/golden_shovel.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/golden_sword.json b/src/generated/resources/data/minecraft/recipes/golden_sword.json index 0c3da42abe..c237f1afa5 100644 --- a/src/generated/resources/data/minecraft/recipes/golden_sword.json +++ b/src/generated/resources/data/minecraft/recipes/golden_sword.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/gray_banner.json b/src/generated/resources/data/minecraft/recipes/gray_banner.json index 5b1d0df531..3a0bb04ef4 100644 --- a/src/generated/resources/data/minecraft/recipes/gray_banner.json +++ b/src/generated/resources/data/minecraft/recipes/gray_banner.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "banner", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/green_banner.json b/src/generated/resources/data/minecraft/recipes/green_banner.json index aca24fe341..000083bcf5 100644 --- a/src/generated/resources/data/minecraft/recipes/green_banner.json +++ b/src/generated/resources/data/minecraft/recipes/green_banner.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "banner", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/grindstone.json b/src/generated/resources/data/minecraft/recipes/grindstone.json index c1274e2b7b..beb54f35ee 100644 --- a/src/generated/resources/data/minecraft/recipes/grindstone.json +++ b/src/generated/resources/data/minecraft/recipes/grindstone.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "minecraft:planks" diff --git a/src/generated/resources/data/minecraft/recipes/heavy_weighted_pressure_plate.json b/src/generated/resources/data/minecraft/recipes/heavy_weighted_pressure_plate.json index ddb841ee5b..1ffbcccce9 100644 --- a/src/generated/resources/data/minecraft/recipes/heavy_weighted_pressure_plate.json +++ b/src/generated/resources/data/minecraft/recipes/heavy_weighted_pressure_plate.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "key": { "#": { "tag": "forge:ingots/iron" diff --git a/src/generated/resources/data/minecraft/recipes/hopper.json b/src/generated/resources/data/minecraft/recipes/hopper.json index 1736918c49..31bff00da6 100644 --- a/src/generated/resources/data/minecraft/recipes/hopper.json +++ b/src/generated/resources/data/minecraft/recipes/hopper.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "key": { "C": { "tag": "forge:chests/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/iron_axe.json b/src/generated/resources/data/minecraft/recipes/iron_axe.json index 170bd860ad..09ad3b86e2 100644 --- a/src/generated/resources/data/minecraft/recipes/iron_axe.json +++ b/src/generated/resources/data/minecraft/recipes/iron_axe.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/iron_bars.json b/src/generated/resources/data/minecraft/recipes/iron_bars.json index 8449f515e1..37a55f1b4d 100644 --- a/src/generated/resources/data/minecraft/recipes/iron_bars.json +++ b/src/generated/resources/data/minecraft/recipes/iron_bars.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "forge:ingots/iron" diff --git a/src/generated/resources/data/minecraft/recipes/iron_boots.json b/src/generated/resources/data/minecraft/recipes/iron_boots.json index e0d51d9300..a5b13c1270 100644 --- a/src/generated/resources/data/minecraft/recipes/iron_boots.json +++ b/src/generated/resources/data/minecraft/recipes/iron_boots.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "X": { "tag": "forge:ingots/iron" diff --git a/src/generated/resources/data/minecraft/recipes/iron_chestplate.json b/src/generated/resources/data/minecraft/recipes/iron_chestplate.json index 6dc916734e..c22d896eca 100644 --- a/src/generated/resources/data/minecraft/recipes/iron_chestplate.json +++ b/src/generated/resources/data/minecraft/recipes/iron_chestplate.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "X": { "tag": "forge:ingots/iron" diff --git a/src/generated/resources/data/minecraft/recipes/iron_door.json b/src/generated/resources/data/minecraft/recipes/iron_door.json index 2474b80122..f138c8898a 100644 --- a/src/generated/resources/data/minecraft/recipes/iron_door.json +++ b/src/generated/resources/data/minecraft/recipes/iron_door.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "key": { "#": { "tag": "forge:ingots/iron" diff --git a/src/generated/resources/data/minecraft/recipes/iron_helmet.json b/src/generated/resources/data/minecraft/recipes/iron_helmet.json index 124ee80d4d..fc376406b6 100644 --- a/src/generated/resources/data/minecraft/recipes/iron_helmet.json +++ b/src/generated/resources/data/minecraft/recipes/iron_helmet.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "X": { "tag": "forge:ingots/iron" diff --git a/src/generated/resources/data/minecraft/recipes/iron_hoe.json b/src/generated/resources/data/minecraft/recipes/iron_hoe.json index c323331f9b..d9ddbbf1a5 100644 --- a/src/generated/resources/data/minecraft/recipes/iron_hoe.json +++ b/src/generated/resources/data/minecraft/recipes/iron_hoe.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/iron_leggings.json b/src/generated/resources/data/minecraft/recipes/iron_leggings.json index b18b8af46e..9249dfa36e 100644 --- a/src/generated/resources/data/minecraft/recipes/iron_leggings.json +++ b/src/generated/resources/data/minecraft/recipes/iron_leggings.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "X": { "tag": "forge:ingots/iron" diff --git a/src/generated/resources/data/minecraft/recipes/iron_pickaxe.json b/src/generated/resources/data/minecraft/recipes/iron_pickaxe.json index 8483713259..381e76055b 100644 --- a/src/generated/resources/data/minecraft/recipes/iron_pickaxe.json +++ b/src/generated/resources/data/minecraft/recipes/iron_pickaxe.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/iron_shovel.json b/src/generated/resources/data/minecraft/recipes/iron_shovel.json index b74b8e5dd4..fa186c42f6 100644 --- a/src/generated/resources/data/minecraft/recipes/iron_shovel.json +++ b/src/generated/resources/data/minecraft/recipes/iron_shovel.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/iron_sword.json b/src/generated/resources/data/minecraft/recipes/iron_sword.json index 2fd427ba3e..d1b1fa9ff4 100644 --- a/src/generated/resources/data/minecraft/recipes/iron_sword.json +++ b/src/generated/resources/data/minecraft/recipes/iron_sword.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/iron_trapdoor.json b/src/generated/resources/data/minecraft/recipes/iron_trapdoor.json index 93442513fd..71777b8ca6 100644 --- a/src/generated/resources/data/minecraft/recipes/iron_trapdoor.json +++ b/src/generated/resources/data/minecraft/recipes/iron_trapdoor.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "key": { "#": { "tag": "forge:ingots/iron" diff --git a/src/generated/resources/data/minecraft/recipes/item_frame.json b/src/generated/resources/data/minecraft/recipes/item_frame.json index 0c6d69dc2d..7383dc21ac 100644 --- a/src/generated/resources/data/minecraft/recipes/item_frame.json +++ b/src/generated/resources/data/minecraft/recipes/item_frame.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/jukebox.json b/src/generated/resources/data/minecraft/recipes/jukebox.json index d40922e829..23851e3783 100644 --- a/src/generated/resources/data/minecraft/recipes/jukebox.json +++ b/src/generated/resources/data/minecraft/recipes/jukebox.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "minecraft:planks" diff --git a/src/generated/resources/data/minecraft/recipes/jungle_chest_boat.json b/src/generated/resources/data/minecraft/recipes/jungle_chest_boat.json index 0d1fff4aa2..3d03d82aae 100644 --- a/src/generated/resources/data/minecraft/recipes/jungle_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipes/jungle_chest_boat.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "misc", "group": "chest_boat", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/jungle_fence.json b/src/generated/resources/data/minecraft/recipes/jungle_fence.json index 1e88c5c0b0..28ab3e0b5b 100644 --- a/src/generated/resources/data/minecraft/recipes/jungle_fence.json +++ b/src/generated/resources/data/minecraft/recipes/jungle_fence.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_fence", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/jungle_fence_gate.json b/src/generated/resources/data/minecraft/recipes/jungle_fence_gate.json index 82ff1a0a89..eeb195ecbe 100644 --- a/src/generated/resources/data/minecraft/recipes/jungle_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipes/jungle_fence_gate.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "group": "wooden_fence_gate", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/jungle_sign.json b/src/generated/resources/data/minecraft/recipes/jungle_sign.json index 46f8608e36..5c14ff95ef 100644 --- a/src/generated/resources/data/minecraft/recipes/jungle_sign.json +++ b/src/generated/resources/data/minecraft/recipes/jungle_sign.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_sign", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/ladder.json b/src/generated/resources/data/minecraft/recipes/ladder.json index 727396227d..50326bf053 100644 --- a/src/generated/resources/data/minecraft/recipes/ladder.json +++ b/src/generated/resources/data/minecraft/recipes/ladder.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/lever.json b/src/generated/resources/data/minecraft/recipes/lever.json index b9a9ec88e0..23666a3173 100644 --- a/src/generated/resources/data/minecraft/recipes/lever.json +++ b/src/generated/resources/data/minecraft/recipes/lever.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "key": { "#": { "tag": "forge:cobblestone/normal" diff --git a/src/generated/resources/data/minecraft/recipes/light_blue_banner.json b/src/generated/resources/data/minecraft/recipes/light_blue_banner.json index ea1dd2b2fb..2f7d401abc 100644 --- a/src/generated/resources/data/minecraft/recipes/light_blue_banner.json +++ b/src/generated/resources/data/minecraft/recipes/light_blue_banner.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "banner", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/light_gray_banner.json b/src/generated/resources/data/minecraft/recipes/light_gray_banner.json index 8be7b2e17f..0564f26f74 100644 --- a/src/generated/resources/data/minecraft/recipes/light_gray_banner.json +++ b/src/generated/resources/data/minecraft/recipes/light_gray_banner.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "banner", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/light_weighted_pressure_plate.json b/src/generated/resources/data/minecraft/recipes/light_weighted_pressure_plate.json index 6044d7d325..8c0044b28c 100644 --- a/src/generated/resources/data/minecraft/recipes/light_weighted_pressure_plate.json +++ b/src/generated/resources/data/minecraft/recipes/light_weighted_pressure_plate.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "key": { "#": { "tag": "forge:ingots/gold" diff --git a/src/generated/resources/data/minecraft/recipes/lightning_rod.json b/src/generated/resources/data/minecraft/recipes/lightning_rod.json index fba6e33394..8d1a5eca19 100644 --- a/src/generated/resources/data/minecraft/recipes/lightning_rod.json +++ b/src/generated/resources/data/minecraft/recipes/lightning_rod.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "key": { "#": { "tag": "forge:ingots/copper" diff --git a/src/generated/resources/data/minecraft/recipes/lime_banner.json b/src/generated/resources/data/minecraft/recipes/lime_banner.json index c7d21ed5f1..603a2a1ae2 100644 --- a/src/generated/resources/data/minecraft/recipes/lime_banner.json +++ b/src/generated/resources/data/minecraft/recipes/lime_banner.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "banner", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/lodestone.json b/src/generated/resources/data/minecraft/recipes/lodestone.json index 241a3d5855..8741c3f76e 100644 --- a/src/generated/resources/data/minecraft/recipes/lodestone.json +++ b/src/generated/resources/data/minecraft/recipes/lodestone.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "forge:ingots/netherite" diff --git a/src/generated/resources/data/minecraft/recipes/magenta_banner.json b/src/generated/resources/data/minecraft/recipes/magenta_banner.json index 055e61de02..5b02fea383 100644 --- a/src/generated/resources/data/minecraft/recipes/magenta_banner.json +++ b/src/generated/resources/data/minecraft/recipes/magenta_banner.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "banner", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/mangrove_chest_boat.json b/src/generated/resources/data/minecraft/recipes/mangrove_chest_boat.json index e62c7c33bb..ef18815307 100644 --- a/src/generated/resources/data/minecraft/recipes/mangrove_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipes/mangrove_chest_boat.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "misc", "group": "chest_boat", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/mangrove_fence.json b/src/generated/resources/data/minecraft/recipes/mangrove_fence.json index a0b3d497a8..a799b071ac 100644 --- a/src/generated/resources/data/minecraft/recipes/mangrove_fence.json +++ b/src/generated/resources/data/minecraft/recipes/mangrove_fence.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_fence", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/mangrove_fence_gate.json b/src/generated/resources/data/minecraft/recipes/mangrove_fence_gate.json index 6f39d7f17a..a3bcbde9ff 100644 --- a/src/generated/resources/data/minecraft/recipes/mangrove_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipes/mangrove_fence_gate.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "group": "wooden_fence_gate", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/mangrove_sign.json b/src/generated/resources/data/minecraft/recipes/mangrove_sign.json index 3b6e384c3c..9fce4bbc44 100644 --- a/src/generated/resources/data/minecraft/recipes/mangrove_sign.json +++ b/src/generated/resources/data/minecraft/recipes/mangrove_sign.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_sign", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/minecart.json b/src/generated/resources/data/minecraft/recipes/minecart.json index b085f9d4d7..aa5a1ea93d 100644 --- a/src/generated/resources/data/minecraft/recipes/minecart.json +++ b/src/generated/resources/data/minecraft/recipes/minecart.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "forge:ingots/iron" diff --git a/src/generated/resources/data/minecraft/recipes/mossy_cobblestone_from_moss_block.json b/src/generated/resources/data/minecraft/recipes/mossy_cobblestone_from_moss_block.json index 8efc93ccfd..a59fa3296a 100644 --- a/src/generated/resources/data/minecraft/recipes/mossy_cobblestone_from_moss_block.json +++ b/src/generated/resources/data/minecraft/recipes/mossy_cobblestone_from_moss_block.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "building", "group": "mossy_cobblestone", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/mossy_cobblestone_from_vine.json b/src/generated/resources/data/minecraft/recipes/mossy_cobblestone_from_vine.json index 01f166d9ff..79051c2fa1 100644 --- a/src/generated/resources/data/minecraft/recipes/mossy_cobblestone_from_vine.json +++ b/src/generated/resources/data/minecraft/recipes/mossy_cobblestone_from_vine.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "building", "group": "mossy_cobblestone", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/netherite_ingot.json b/src/generated/resources/data/minecraft/recipes/netherite_ingot.json index 7404c866f6..21ffad1650 100644 --- a/src/generated/resources/data/minecraft/recipes/netherite_ingot.json +++ b/src/generated/resources/data/minecraft/recipes/netherite_ingot.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "misc", "group": "netherite_ingot", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/oak_chest_boat.json b/src/generated/resources/data/minecraft/recipes/oak_chest_boat.json index cd6d059134..638735a211 100644 --- a/src/generated/resources/data/minecraft/recipes/oak_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipes/oak_chest_boat.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "misc", "group": "chest_boat", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/oak_fence.json b/src/generated/resources/data/minecraft/recipes/oak_fence.json index 4a042e78e6..e3f9961507 100644 --- a/src/generated/resources/data/minecraft/recipes/oak_fence.json +++ b/src/generated/resources/data/minecraft/recipes/oak_fence.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_fence", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/oak_fence_gate.json b/src/generated/resources/data/minecraft/recipes/oak_fence_gate.json index 02499c520f..956d67d1a1 100644 --- a/src/generated/resources/data/minecraft/recipes/oak_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipes/oak_fence_gate.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "group": "wooden_fence_gate", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/oak_sign.json b/src/generated/resources/data/minecraft/recipes/oak_sign.json index 70be3a28ad..13132c63a0 100644 --- a/src/generated/resources/data/minecraft/recipes/oak_sign.json +++ b/src/generated/resources/data/minecraft/recipes/oak_sign.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_sign", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/observer.json b/src/generated/resources/data/minecraft/recipes/observer.json index 80c290c0cb..f9304ff07a 100644 --- a/src/generated/resources/data/minecraft/recipes/observer.json +++ b/src/generated/resources/data/minecraft/recipes/observer.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "key": { "#": { "tag": "forge:cobblestone/normal" diff --git a/src/generated/resources/data/minecraft/recipes/orange_banner.json b/src/generated/resources/data/minecraft/recipes/orange_banner.json index 98420a615c..c260165899 100644 --- a/src/generated/resources/data/minecraft/recipes/orange_banner.json +++ b/src/generated/resources/data/minecraft/recipes/orange_banner.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "banner", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/painting.json b/src/generated/resources/data/minecraft/recipes/painting.json index 5711eab303..dfe4ad0caa 100644 --- a/src/generated/resources/data/minecraft/recipes/painting.json +++ b/src/generated/resources/data/minecraft/recipes/painting.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/pink_banner.json b/src/generated/resources/data/minecraft/recipes/pink_banner.json index ea396e58e5..1965e7dffc 100644 --- a/src/generated/resources/data/minecraft/recipes/pink_banner.json +++ b/src/generated/resources/data/minecraft/recipes/pink_banner.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "banner", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/piston.json b/src/generated/resources/data/minecraft/recipes/piston.json index fd4acf67fd..74f40060e5 100644 --- a/src/generated/resources/data/minecraft/recipes/piston.json +++ b/src/generated/resources/data/minecraft/recipes/piston.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "key": { "#": { "tag": "forge:cobblestone/normal" diff --git a/src/generated/resources/data/minecraft/recipes/polished_deepslate.json b/src/generated/resources/data/minecraft/recipes/polished_deepslate.json index f94c439ed2..2163aba74f 100644 --- a/src/generated/resources/data/minecraft/recipes/polished_deepslate.json +++ b/src/generated/resources/data/minecraft/recipes/polished_deepslate.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "building", "key": { "S": { "tag": "forge:cobblestone/deepslate" diff --git a/src/generated/resources/data/minecraft/recipes/powered_rail.json b/src/generated/resources/data/minecraft/recipes/powered_rail.json index 771c674bda..c8b5b6e014 100644 --- a/src/generated/resources/data/minecraft/recipes/powered_rail.json +++ b/src/generated/resources/data/minecraft/recipes/powered_rail.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/purple_banner.json b/src/generated/resources/data/minecraft/recipes/purple_banner.json index de3f1b057a..9c9baa1d93 100644 --- a/src/generated/resources/data/minecraft/recipes/purple_banner.json +++ b/src/generated/resources/data/minecraft/recipes/purple_banner.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "banner", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/rail.json b/src/generated/resources/data/minecraft/recipes/rail.json index 1e450b79e0..a14f5d7786 100644 --- a/src/generated/resources/data/minecraft/recipes/rail.json +++ b/src/generated/resources/data/minecraft/recipes/rail.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/red_banner.json b/src/generated/resources/data/minecraft/recipes/red_banner.json index e89daa75c7..ece467fb8a 100644 --- a/src/generated/resources/data/minecraft/recipes/red_banner.json +++ b/src/generated/resources/data/minecraft/recipes/red_banner.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "banner", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/redstone_torch.json b/src/generated/resources/data/minecraft/recipes/redstone_torch.json index 4dcf2d8936..3fef11c1ec 100644 --- a/src/generated/resources/data/minecraft/recipes/redstone_torch.json +++ b/src/generated/resources/data/minecraft/recipes/redstone_torch.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/shears.json b/src/generated/resources/data/minecraft/recipes/shears.json index 4295705b2f..920ff4fd1d 100644 --- a/src/generated/resources/data/minecraft/recipes/shears.json +++ b/src/generated/resources/data/minecraft/recipes/shears.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:ingots/iron" diff --git a/src/generated/resources/data/minecraft/recipes/shield.json b/src/generated/resources/data/minecraft/recipes/shield.json index 9f03554702..d746ab4ede 100644 --- a/src/generated/resources/data/minecraft/recipes/shield.json +++ b/src/generated/resources/data/minecraft/recipes/shield.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "W": { "tag": "minecraft:planks" diff --git a/src/generated/resources/data/minecraft/recipes/shulker_box.json b/src/generated/resources/data/minecraft/recipes/shulker_box.json index 74d5a6bf16..15c67ec58d 100644 --- a/src/generated/resources/data/minecraft/recipes/shulker_box.json +++ b/src/generated/resources/data/minecraft/recipes/shulker_box.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "forge:chests/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/smithing_table.json b/src/generated/resources/data/minecraft/recipes/smithing_table.json index 69c864a6ee..e1ba2b4749 100644 --- a/src/generated/resources/data/minecraft/recipes/smithing_table.json +++ b/src/generated/resources/data/minecraft/recipes/smithing_table.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "minecraft:planks" diff --git a/src/generated/resources/data/minecraft/recipes/soul_campfire.json b/src/generated/resources/data/minecraft/recipes/soul_campfire.json index 6829fa6f3c..4e1d80e502 100644 --- a/src/generated/resources/data/minecraft/recipes/soul_campfire.json +++ b/src/generated/resources/data/minecraft/recipes/soul_campfire.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "minecraft:soul_fire_base_blocks" diff --git a/src/generated/resources/data/minecraft/recipes/soul_torch.json b/src/generated/resources/data/minecraft/recipes/soul_torch.json index 322dc99912..55f4104c79 100644 --- a/src/generated/resources/data/minecraft/recipes/soul_torch.json +++ b/src/generated/resources/data/minecraft/recipes/soul_torch.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/spruce_chest_boat.json b/src/generated/resources/data/minecraft/recipes/spruce_chest_boat.json index c73c0989c6..399ef2beab 100644 --- a/src/generated/resources/data/minecraft/recipes/spruce_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipes/spruce_chest_boat.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "misc", "group": "chest_boat", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/spruce_fence.json b/src/generated/resources/data/minecraft/recipes/spruce_fence.json index d806938a0f..b4eab9c13f 100644 --- a/src/generated/resources/data/minecraft/recipes/spruce_fence.json +++ b/src/generated/resources/data/minecraft/recipes/spruce_fence.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_fence", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/spruce_fence_gate.json b/src/generated/resources/data/minecraft/recipes/spruce_fence_gate.json index c1c3ff4450..258057d801 100644 --- a/src/generated/resources/data/minecraft/recipes/spruce_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipes/spruce_fence_gate.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "group": "wooden_fence_gate", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/spruce_sign.json b/src/generated/resources/data/minecraft/recipes/spruce_sign.json index 17ffbd86a2..fb28d8c03e 100644 --- a/src/generated/resources/data/minecraft/recipes/spruce_sign.json +++ b/src/generated/resources/data/minecraft/recipes/spruce_sign.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_sign", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/spyglass.json b/src/generated/resources/data/minecraft/recipes/spyglass.json index 0ed3c459e8..f649bfc44a 100644 --- a/src/generated/resources/data/minecraft/recipes/spyglass.json +++ b/src/generated/resources/data/minecraft/recipes/spyglass.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:gems/amethyst" diff --git a/src/generated/resources/data/minecraft/recipes/stone_axe.json b/src/generated/resources/data/minecraft/recipes/stone_axe.json index e1693151eb..58ce1597f6 100644 --- a/src/generated/resources/data/minecraft/recipes/stone_axe.json +++ b/src/generated/resources/data/minecraft/recipes/stone_axe.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/stone_hoe.json b/src/generated/resources/data/minecraft/recipes/stone_hoe.json index a5da911f79..2827ae1eab 100644 --- a/src/generated/resources/data/minecraft/recipes/stone_hoe.json +++ b/src/generated/resources/data/minecraft/recipes/stone_hoe.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/stone_pickaxe.json b/src/generated/resources/data/minecraft/recipes/stone_pickaxe.json index 0c01cb15c9..8d02352c43 100644 --- a/src/generated/resources/data/minecraft/recipes/stone_pickaxe.json +++ b/src/generated/resources/data/minecraft/recipes/stone_pickaxe.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/stone_shovel.json b/src/generated/resources/data/minecraft/recipes/stone_shovel.json index b65e12519c..609f6e511a 100644 --- a/src/generated/resources/data/minecraft/recipes/stone_shovel.json +++ b/src/generated/resources/data/minecraft/recipes/stone_shovel.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/stone_sword.json b/src/generated/resources/data/minecraft/recipes/stone_sword.json index 474339f890..7afc9ceec6 100644 --- a/src/generated/resources/data/minecraft/recipes/stone_sword.json +++ b/src/generated/resources/data/minecraft/recipes/stone_sword.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/stonecutter.json b/src/generated/resources/data/minecraft/recipes/stonecutter.json index 0cc370dc22..4fa791814f 100644 --- a/src/generated/resources/data/minecraft/recipes/stonecutter.json +++ b/src/generated/resources/data/minecraft/recipes/stonecutter.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "item": "minecraft:stone" diff --git a/src/generated/resources/data/minecraft/recipes/tinted_glass.json b/src/generated/resources/data/minecraft/recipes/tinted_glass.json index 01324c6020..2017014aff 100644 --- a/src/generated/resources/data/minecraft/recipes/tinted_glass.json +++ b/src/generated/resources/data/minecraft/recipes/tinted_glass.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "building", "key": { "G": { "item": "minecraft:glass" diff --git a/src/generated/resources/data/minecraft/recipes/torch.json b/src/generated/resources/data/minecraft/recipes/torch.json index d14d1cc6b7..71147ae0aa 100644 --- a/src/generated/resources/data/minecraft/recipes/torch.json +++ b/src/generated/resources/data/minecraft/recipes/torch.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/trapped_chest.json b/src/generated/resources/data/minecraft/recipes/trapped_chest.json index 0c129b48c3..0ccc058c06 100644 --- a/src/generated/resources/data/minecraft/recipes/trapped_chest.json +++ b/src/generated/resources/data/minecraft/recipes/trapped_chest.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "redstone", "ingredients": [ { "tag": "forge:chests/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/tripwire_hook.json b/src/generated/resources/data/minecraft/recipes/tripwire_hook.json index f7279b1e08..a02479f770 100644 --- a/src/generated/resources/data/minecraft/recipes/tripwire_hook.json +++ b/src/generated/resources/data/minecraft/recipes/tripwire_hook.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "key": { "#": { "tag": "minecraft:planks" diff --git a/src/generated/resources/data/minecraft/recipes/warped_fence.json b/src/generated/resources/data/minecraft/recipes/warped_fence.json index ca6961725c..052fa02e71 100644 --- a/src/generated/resources/data/minecraft/recipes/warped_fence.json +++ b/src/generated/resources/data/minecraft/recipes/warped_fence.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_fence", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/warped_fence_gate.json b/src/generated/resources/data/minecraft/recipes/warped_fence_gate.json index 3673bd554d..f176822579 100644 --- a/src/generated/resources/data/minecraft/recipes/warped_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipes/warped_fence_gate.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "group": "wooden_fence_gate", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/warped_sign.json b/src/generated/resources/data/minecraft/recipes/warped_sign.json index ce4202b50c..cbaa3b7b87 100644 --- a/src/generated/resources/data/minecraft/recipes/warped_sign.json +++ b/src/generated/resources/data/minecraft/recipes/warped_sign.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "wooden_sign", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/white_banner.json b/src/generated/resources/data/minecraft/recipes/white_banner.json index 487d7209e8..9957dc5b0a 100644 --- a/src/generated/resources/data/minecraft/recipes/white_banner.json +++ b/src/generated/resources/data/minecraft/recipes/white_banner.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "banner", "key": { "#": { diff --git a/src/generated/resources/data/minecraft/recipes/wooden_axe.json b/src/generated/resources/data/minecraft/recipes/wooden_axe.json index 5ddfd7781f..1f6cabc9b3 100644 --- a/src/generated/resources/data/minecraft/recipes/wooden_axe.json +++ b/src/generated/resources/data/minecraft/recipes/wooden_axe.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/wooden_hoe.json b/src/generated/resources/data/minecraft/recipes/wooden_hoe.json index c0c64a2217..0faec2df65 100644 --- a/src/generated/resources/data/minecraft/recipes/wooden_hoe.json +++ b/src/generated/resources/data/minecraft/recipes/wooden_hoe.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/wooden_pickaxe.json b/src/generated/resources/data/minecraft/recipes/wooden_pickaxe.json index 3407fae1a9..70c46788bc 100644 --- a/src/generated/resources/data/minecraft/recipes/wooden_pickaxe.json +++ b/src/generated/resources/data/minecraft/recipes/wooden_pickaxe.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/wooden_shovel.json b/src/generated/resources/data/minecraft/recipes/wooden_shovel.json index c9013d6912..e5d95dbe8f 100644 --- a/src/generated/resources/data/minecraft/recipes/wooden_shovel.json +++ b/src/generated/resources/data/minecraft/recipes/wooden_shovel.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/wooden_sword.json b/src/generated/resources/data/minecraft/recipes/wooden_sword.json index 86ad338b15..f16e202780 100644 --- a/src/generated/resources/data/minecraft/recipes/wooden_sword.json +++ b/src/generated/resources/data/minecraft/recipes/wooden_sword.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "tag": "forge:rods/wooden" diff --git a/src/generated/resources/data/minecraft/recipes/yellow_banner.json b/src/generated/resources/data/minecraft/recipes/yellow_banner.json index c2f5974207..80eb283553 100644 --- a/src/generated/resources/data/minecraft/recipes/yellow_banner.json +++ b/src/generated/resources/data/minecraft/recipes/yellow_banner.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "misc", "group": "banner", "key": { "#": { diff --git a/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_bottom_left.json b/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_bottom_left.json new file mode 100644 index 0000000000..aeab9dd0c1 --- /dev/null +++ b/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_bottom_left.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:block/door_bottom_left", + "textures": { + "bottom": "minecraft:block/acacia_door_bottom", + "top": "minecraft:block/acacia_door_top" + } +} \ No newline at end of file diff --git a/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_bottom_left_open.json b/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_bottom_left_open.json new file mode 100644 index 0000000000..0e71dd5851 --- /dev/null +++ b/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_bottom_left_open.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:block/door_bottom_left_open", + "textures": { + "bottom": "minecraft:block/acacia_door_bottom", + "top": "minecraft:block/acacia_door_top" + } +} \ No newline at end of file diff --git a/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_bottom_right.json b/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_bottom_right.json new file mode 100644 index 0000000000..d4f4be3e7b --- /dev/null +++ b/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_bottom_right.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:block/door_bottom_right", + "textures": { + "bottom": "minecraft:block/acacia_door_bottom", + "top": "minecraft:block/acacia_door_top" + } +} \ No newline at end of file diff --git a/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_bottom_right_open.json b/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_bottom_right_open.json new file mode 100644 index 0000000000..c39619d16b --- /dev/null +++ b/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_bottom_right_open.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:block/door_bottom_right_open", + "textures": { + "bottom": "minecraft:block/acacia_door_bottom", + "top": "minecraft:block/acacia_door_top" + } +} \ No newline at end of file diff --git a/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_top_left.json b/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_top_left.json new file mode 100644 index 0000000000..ba9356a019 --- /dev/null +++ b/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_top_left.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:block/door_top_left", + "textures": { + "bottom": "minecraft:block/acacia_door_bottom", + "top": "minecraft:block/acacia_door_top" + } +} \ No newline at end of file diff --git a/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_top_left_open.json b/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_top_left_open.json new file mode 100644 index 0000000000..a279c8a478 --- /dev/null +++ b/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_top_left_open.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:block/door_top_left_open", + "textures": { + "bottom": "minecraft:block/acacia_door_bottom", + "top": "minecraft:block/acacia_door_top" + } +} \ No newline at end of file diff --git a/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_top_right.json b/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_top_right.json new file mode 100644 index 0000000000..751739267d --- /dev/null +++ b/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_top_right.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:block/door_top_right", + "textures": { + "bottom": "minecraft:block/acacia_door_bottom", + "top": "minecraft:block/acacia_door_top" + } +} \ No newline at end of file diff --git a/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_top_right_open.json b/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_top_right_open.json new file mode 100644 index 0000000000..dc29f13a19 --- /dev/null +++ b/src/generated_test/resources/assets/data_gen_test/models/block/acacia_door_top_right_open.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:block/door_top_right_open", + "textures": { + "bottom": "minecraft:block/acacia_door_bottom", + "top": "minecraft:block/acacia_door_top" + } +} \ No newline at end of file diff --git a/src/generated_test/resources/assets/data_gen_test/models/item/test_block_model.json b/src/generated_test/resources/assets/data_gen_test/models/item/test_block_model.json deleted file mode 100644 index f730eb78c5..0000000000 --- a/src/generated_test/resources/assets/data_gen_test/models/item/test_block_model.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "parent": "minecraft:block/block", - "elements": [ - { - "faces": { - "down": { - "cullface": "down", - "texture": "#all" - }, - "east": { - "cullface": "east", - "texture": "#all" - }, - "north": { - "cullface": "north", - "texture": "#all" - }, - "south": { - "cullface": "south", - "texture": "#all" - }, - "up": { - "cullface": "up", - "texture": "#top", - "tintindex": 0 - }, - "west": { - "cullface": "west", - "texture": "#all" - } - }, - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ] - } - ], - "textures": { - "all": "minecraft:block/dirt", - "top": "minecraft:block/stone" - } -} \ No newline at end of file diff --git a/src/generated_test/resources/assets/minecraft/blockstates/acacia_door.json b/src/generated_test/resources/assets/minecraft/blockstates/acacia_door.json new file mode 100644 index 0000000000..29ccf34314 --- /dev/null +++ b/src/generated_test/resources/assets/minecraft/blockstates/acacia_door.json @@ -0,0 +1,124 @@ +{ + "variants": { + "facing=east,half=lower,hinge=left,open=false": { + "model": "data_gen_test:block/acacia_door_bottom_left" + }, + "facing=east,half=lower,hinge=left,open=true": { + "model": "data_gen_test:block/acacia_door_bottom_left_open", + "y": 90 + }, + "facing=east,half=lower,hinge=right,open=false": { + "model": "data_gen_test:block/acacia_door_bottom_right" + }, + "facing=east,half=lower,hinge=right,open=true": { + "model": "data_gen_test:block/acacia_door_bottom_right_open", + "y": 270 + }, + "facing=east,half=upper,hinge=left,open=false": { + "model": "data_gen_test:block/acacia_door_top_left" + }, + "facing=east,half=upper,hinge=left,open=true": { + "model": "data_gen_test:block/acacia_door_top_left_open", + "y": 90 + }, + "facing=east,half=upper,hinge=right,open=false": { + "model": "data_gen_test:block/acacia_door_top_right" + }, + "facing=east,half=upper,hinge=right,open=true": { + "model": "data_gen_test:block/acacia_door_top_right_open", + "y": 270 + }, + "facing=north,half=lower,hinge=left,open=false": { + "model": "data_gen_test:block/acacia_door_bottom_left", + "y": 270 + }, + "facing=north,half=lower,hinge=left,open=true": { + "model": "data_gen_test:block/acacia_door_bottom_left_open" + }, + "facing=north,half=lower,hinge=right,open=false": { + "model": "data_gen_test:block/acacia_door_bottom_right", + "y": 270 + }, + "facing=north,half=lower,hinge=right,open=true": { + "model": "data_gen_test:block/acacia_door_bottom_right_open", + "y": 180 + }, + "facing=north,half=upper,hinge=left,open=false": { + "model": "data_gen_test:block/acacia_door_top_left", + "y": 270 + }, + "facing=north,half=upper,hinge=left,open=true": { + "model": "data_gen_test:block/acacia_door_top_left_open" + }, + "facing=north,half=upper,hinge=right,open=false": { + "model": "data_gen_test:block/acacia_door_top_right", + "y": 270 + }, + "facing=north,half=upper,hinge=right,open=true": { + "model": "data_gen_test:block/acacia_door_top_right_open", + "y": 180 + }, + "facing=south,half=lower,hinge=left,open=false": { + "model": "data_gen_test:block/acacia_door_bottom_left", + "y": 90 + }, + "facing=south,half=lower,hinge=left,open=true": { + "model": "data_gen_test:block/acacia_door_bottom_left_open", + "y": 180 + }, + "facing=south,half=lower,hinge=right,open=false": { + "model": "data_gen_test:block/acacia_door_bottom_right", + "y": 90 + }, + "facing=south,half=lower,hinge=right,open=true": { + "model": "data_gen_test:block/acacia_door_bottom_right_open" + }, + "facing=south,half=upper,hinge=left,open=false": { + "model": "data_gen_test:block/acacia_door_top_left", + "y": 90 + }, + "facing=south,half=upper,hinge=left,open=true": { + "model": "data_gen_test:block/acacia_door_top_left_open", + "y": 180 + }, + "facing=south,half=upper,hinge=right,open=false": { + "model": "data_gen_test:block/acacia_door_top_right", + "y": 90 + }, + "facing=south,half=upper,hinge=right,open=true": { + "model": "data_gen_test:block/acacia_door_top_right_open" + }, + "facing=west,half=lower,hinge=left,open=false": { + "model": "data_gen_test:block/acacia_door_bottom_left", + "y": 180 + }, + "facing=west,half=lower,hinge=left,open=true": { + "model": "data_gen_test:block/acacia_door_bottom_left_open", + "y": 270 + }, + "facing=west,half=lower,hinge=right,open=false": { + "model": "data_gen_test:block/acacia_door_bottom_right", + "y": 180 + }, + "facing=west,half=lower,hinge=right,open=true": { + "model": "data_gen_test:block/acacia_door_bottom_right_open", + "y": 90 + }, + "facing=west,half=upper,hinge=left,open=false": { + "model": "data_gen_test:block/acacia_door_top_left", + "y": 180 + }, + "facing=west,half=upper,hinge=left,open=true": { + "model": "data_gen_test:block/acacia_door_top_left_open", + "y": 270 + }, + "facing=west,half=upper,hinge=right,open=false": { + "model": "data_gen_test:block/acacia_door_top_right", + "y": 180 + }, + "facing=west,half=upper,hinge=right,open=true": { + "model": "data_gen_test:block/acacia_door_top_right_open", + "y": 90 + } + } +} \ No newline at end of file diff --git a/src/generated_test/resources/assets/new_model_loader_test/models/block/obj_block.json b/src/generated_test/resources/assets/new_model_loader_test/models/block/obj_block.json index c65b02d36a..855c9f7b7c 100644 --- a/src/generated_test/resources/assets/new_model_loader_test/models/block/obj_block.json +++ b/src/generated_test/resources/assets/new_model_loader_test/models/block/obj_block.json @@ -1,5 +1,5 @@ { - "flip-v": true, + "flip_v": true, "loader": "forge:obj", "model": "new_model_loader_test:models/item/sugar_glider.obj", "textures": { diff --git a/src/generated_test/resources/assets/new_model_loader_test/models/item/item_layers.json b/src/generated_test/resources/assets/new_model_loader_test/models/item/item_layers.json index 2a00daeb3a..d000eacd85 100644 --- a/src/generated_test/resources/assets/new_model_loader_test/models/item/item_layers.json +++ b/src/generated_test/resources/assets/new_model_loader_test/models/item/item_layers.json @@ -1,9 +1,10 @@ { "parent": "forge:item/default", - "fullbright_layers": [ + "emissive_layers": [ 1 ], - "loader": "forge:item-layers", + "loader": "forge:item_layers", + "render_types": {}, "textures": { "layer0": "minecraft:item/coal", "layer1": "minecraft:item/stick" diff --git a/src/generated_test/resources/assets/new_model_loader_test/models/item/separate_perspective.json b/src/generated_test/resources/assets/new_model_loader_test/models/item/separate_perspective.json index 68610609c6..71569c18b2 100644 --- a/src/generated_test/resources/assets/new_model_loader_test/models/item/separate_perspective.json +++ b/src/generated_test/resources/assets/new_model_loader_test/models/item/separate_perspective.json @@ -3,7 +3,7 @@ "base": { "parent": "minecraft:item/coal" }, - "loader": "forge:separate-perspective", + "loader": "forge:separate_transforms", "perspectives": { "firstperson_lefthand": { "parent": "minecraft:item/bone" diff --git a/src/generated_test/resources/assets/tag_based_tool_types/models/item/test_stone.json b/src/generated_test/resources/assets/tag_based_tool_types/models/item/test_stone.json deleted file mode 100644 index e74daa5bae..0000000000 --- a/src/generated_test/resources/assets/tag_based_tool_types/models/item/test_stone.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "parent": "tag_based_tool_types:block/test_stone" -} \ No newline at end of file diff --git a/src/generated_test/resources/data/biome_modifiers_test/forge/biome_modifier/add_basalt.json b/src/generated_test/resources/data/biome_modifiers_test/forge/biome_modifier/add_basalt.json deleted file mode 100644 index 4d1a1f99e2..0000000000 --- a/src/generated_test/resources/data/biome_modifiers_test/forge/biome_modifier/add_basalt.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "forge:add_features", - "biomes": "#minecraft:is_badlands", - "features": "biome_modifiers_test:large_basalt_columns", - "step": "top_layer_modification" -} \ No newline at end of file diff --git a/src/generated_test/resources/data/biome_modifiers_test/forge/biome_modifier/add_magma_cubes.json b/src/generated_test/resources/data/biome_modifiers_test/forge/biome_modifier/add_magma_cubes.json deleted file mode 100644 index 2f6f0a039e..0000000000 --- a/src/generated_test/resources/data/biome_modifiers_test/forge/biome_modifier/add_magma_cubes.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "type": "forge:add_spawns", - "biomes": "#minecraft:is_badlands", - "spawners": { - "type": "minecraft:magma_cube", - "maxCount": 4, - "minCount": 1, - "weight": 100 - } -} \ No newline at end of file diff --git a/src/generated_test/resources/data/biome_modifiers_test/forge/biome_modifier/modify_badlands.json b/src/generated_test/resources/data/biome_modifiers_test/forge/biome_modifier/modify_badlands.json deleted file mode 100644 index 1b6b2c2d9e..0000000000 --- a/src/generated_test/resources/data/biome_modifiers_test/forge/biome_modifier/modify_badlands.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "biome_modifiers_test:modify_biomes", - "biomes": "#minecraft:is_badlands", - "precipitation": "snow", - "water_color": 16711680 -} \ No newline at end of file diff --git a/src/generated_test/resources/data/biome_modifiers_test/forge/biome_modifier/remove_forest_skeletons.json b/src/generated_test/resources/data/biome_modifiers_test/forge/biome_modifier/remove_forest_skeletons.json deleted file mode 100644 index 5262cccec0..0000000000 --- a/src/generated_test/resources/data/biome_modifiers_test/forge/biome_modifier/remove_forest_skeletons.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "forge:remove_spawns", - "biomes": "#minecraft:is_forest", - "entity_types": "#minecraft:skeletons" -} \ No newline at end of file diff --git a/src/generated_test/resources/data/biome_modifiers_test/forge/biome_modifier/remove_forest_trees.json b/src/generated_test/resources/data/biome_modifiers_test/forge/biome_modifier/remove_forest_trees.json deleted file mode 100644 index 7dd978a205..0000000000 --- a/src/generated_test/resources/data/biome_modifiers_test/forge/biome_modifier/remove_forest_trees.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "forge:remove_features", - "biomes": "#minecraft:is_forest", - "features": "minecraft:trees_birch_and_oak" -} \ No newline at end of file diff --git a/src/generated_test/resources/data/biome_modifiers_test/worldgen/placed_feature/large_basalt_columns.json b/src/generated_test/resources/data/biome_modifiers_test/worldgen/placed_feature/large_basalt_columns.json deleted file mode 100644 index 8b5ee4dc46..0000000000 --- a/src/generated_test/resources/data/biome_modifiers_test/worldgen/placed_feature/large_basalt_columns.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "feature": "minecraft:large_basalt_columns", - "placement": [ - { - "type": "minecraft:count_on_every_layer", - "count": 1 - }, - { - "type": "minecraft:biome" - } - ] -} \ No newline at end of file diff --git a/src/generated_test/resources/data/data_gen_test/recipes/compound_ingredient_custom_types.json b/src/generated_test/resources/data/data_gen_test/recipes/compound_ingredient_custom_types.json index 68bd401f63..a8c4a8c42e 100644 --- a/src/generated_test/resources/data/data_gen_test/recipes/compound_ingredient_custom_types.json +++ b/src/generated_test/resources/data/data_gen_test/recipes/compound_ingredient_custom_types.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "building", "key": { "#": [ { diff --git a/src/generated_test/resources/data/data_gen_test/recipes/compound_ingredient_only_vanilla.json b/src/generated_test/resources/data/data_gen_test/recipes/compound_ingredient_only_vanilla.json index 7d255fd195..8c082a4cb0 100644 --- a/src/generated_test/resources/data/data_gen_test/recipes/compound_ingredient_only_vanilla.json +++ b/src/generated_test/resources/data/data_gen_test/recipes/compound_ingredient_only_vanilla.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "building", "key": { "#": [ { diff --git a/src/generated_test/resources/data/data_gen_test/recipes/conditional.json b/src/generated_test/resources/data/data_gen_test/recipes/conditional.json index 866fe43a99..8d8936f732 100644 --- a/src/generated_test/resources/data/data_gen_test/recipes/conditional.json +++ b/src/generated_test/resources/data/data_gen_test/recipes/conditional.json @@ -25,6 +25,7 @@ ], "recipe": { "type": "minecraft:crafting_shaped", + "category": "building", "key": { "X": { "item": "minecraft:dirt" diff --git a/src/generated_test/resources/data/data_gen_test/recipes/conditional2.json b/src/generated_test/resources/data/data_gen_test/recipes/conditional2.json index 320ce0dc51..48f82bc5d6 100644 --- a/src/generated_test/resources/data/data_gen_test/recipes/conditional2.json +++ b/src/generated_test/resources/data/data_gen_test/recipes/conditional2.json @@ -28,6 +28,7 @@ ], "recipe": { "type": "minecraft:crafting_shaped", + "category": "building", "key": { "X": { "item": "minecraft:dirt" diff --git a/src/generated_test/resources/data/data_gen_test/recipes/conditional3.json b/src/generated_test/resources/data/data_gen_test/recipes/conditional3.json index 945c081ea1..75fd27421e 100644 --- a/src/generated_test/resources/data/data_gen_test/recipes/conditional3.json +++ b/src/generated_test/resources/data/data_gen_test/recipes/conditional3.json @@ -10,6 +10,7 @@ ], "recipe": { "type": "minecraft:crafting_shaped", + "category": "building", "key": { "X": { "item": "minecraft:diamond_block" @@ -36,6 +37,7 @@ ], "recipe": { "type": "minecraft:crafting_shaped", + "category": "building", "key": { "X": { "item": "minecraft:diamond_block" diff --git a/src/generated_test/resources/data/data_gen_test/recipes/contains_nbt_ingredient_item_set.json b/src/generated_test/resources/data/data_gen_test/recipes/contains_nbt_ingredient_item_set.json index 70f123a0e0..7e171a4013 100644 --- a/src/generated_test/resources/data/data_gen_test/recipes/contains_nbt_ingredient_item_set.json +++ b/src/generated_test/resources/data/data_gen_test/recipes/contains_nbt_ingredient_item_set.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "equipment", "ingredients": [ { "type": "forge:partial_nbt", diff --git a/src/generated_test/resources/data/data_gen_test/recipes/contains_nbt_ingredient_single_item.json b/src/generated_test/resources/data/data_gen_test/recipes/contains_nbt_ingredient_single_item.json index 861116b77a..67602094d8 100644 --- a/src/generated_test/resources/data/data_gen_test/recipes/contains_nbt_ingredient_single_item.json +++ b/src/generated_test/resources/data/data_gen_test/recipes/contains_nbt_ingredient_single_item.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "equipment", "ingredients": [ { "type": "forge:partial_nbt", diff --git a/src/generated_test/resources/data/data_gen_test/recipes/difference_ingredient.json b/src/generated_test/resources/data/data_gen_test/recipes/difference_ingredient.json index 79a2dcbe8b..509035be7e 100644 --- a/src/generated_test/resources/data/data_gen_test/recipes/difference_ingredient.json +++ b/src/generated_test/resources/data/data_gen_test/recipes/difference_ingredient.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "#": { "type": "forge:difference", diff --git a/src/generated_test/resources/data/data_gen_test/recipes/exact_nbt_ingredient.json b/src/generated_test/resources/data/data_gen_test/recipes/exact_nbt_ingredient.json index cd065079f1..b66c537a90 100644 --- a/src/generated_test/resources/data/data_gen_test/recipes/exact_nbt_ingredient.json +++ b/src/generated_test/resources/data/data_gen_test/recipes/exact_nbt_ingredient.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shapeless", + "category": "equipment", "ingredients": [ { "type": "forge:nbt", diff --git a/src/generated_test/resources/data/data_gen_test/recipes/intersection_ingredient.json b/src/generated_test/resources/data/data_gen_test/recipes/intersection_ingredient.json index 7b122fac04..ddb4a0422f 100644 --- a/src/generated_test/resources/data/data_gen_test/recipes/intersection_ingredient.json +++ b/src/generated_test/resources/data/data_gen_test/recipes/intersection_ingredient.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "building", "key": { "#": { "type": "forge:intersection", diff --git a/src/generated_test/resources/data/data_pack_registries_test/data_pack_registries_test/unsyncable/datagen_test.json b/src/generated_test/resources/data/data_pack_registries_test/data_pack_registries_test/unsyncable/datagen_test.json deleted file mode 100644 index 5ca03ce3ca..0000000000 --- a/src/generated_test/resources/data/data_pack_registries_test/data_pack_registries_test/unsyncable/datagen_test.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "value": "Datagen Success" -} \ No newline at end of file diff --git a/src/generated_test/resources/data/structure_modifiers_test/forge/structure_modifier/modify_stronghold.json b/src/generated_test/resources/data/structure_modifiers_test/forge/structure_modifier/modify_stronghold.json deleted file mode 100644 index 86b69c4019..0000000000 --- a/src/generated_test/resources/data/structure_modifiers_test/forge/structure_modifier/modify_stronghold.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "type": "structure_modifiers_test:test", - "category": "monster", - "spawn": { - "type": "minecraft:wither_skeleton", - "maxCount": 15, - "minCount": 5, - "weight": 100 - }, - "structures": "minecraft:stronghold" -} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/ClientCommandHandler.java b/src/main/java/net/minecraftforge/client/ClientCommandHandler.java index f68c283df5..ad9729b6fe 100644 --- a/src/main/java/net/minecraftforge/client/ClientCommandHandler.java +++ b/src/main/java/net/minecraftforge/client/ClientCommandHandler.java @@ -29,6 +29,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.server.command.CommandHelper; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.ApiStatus; import java.util.IdentityHashMap; import java.util.Map; @@ -45,13 +46,10 @@ public class ClientCommandHandler private static void handleClientPlayerLogin(ClientPlayerNetworkEvent.LoggingIn event) { - // some custom server implementations do not send ClientboundCommandsPacket, provide a fallback - var suggestionDispatcher = mergeServerCommands(new CommandDispatcher<>(), new CommandBuildContext(event.getPlayer().connection.registryAccess())); - if (event.getConnection().getPacketListener() instanceof ClientPacketListener listener) - { - // Must set this, so that suggestions for client-only commands work, if server never sends commands packet - listener.commands = suggestionDispatcher; - } + final ClientPacketListener connection = event.getPlayer().connection; + // Some custom server implementations do not send ClientboundCommandsPacket, so we provide a fallback: + // Must set this, so that suggestions for client-only commands work, if server never sends commands packet + connection.commands = mergeServerCommands(new CommandDispatcher<>(), CommandBuildContext.simple(connection.registryAccess(), connection.enabledFeatures())); } /* @@ -60,6 +58,7 @@ public class ClientCommandHandler * Merges command dispatcher use for suggestions to the command dispatcher used for client commands so they can be sent to the server, and vice versa so client commands appear * with server commands in suggestions */ + @ApiStatus.Internal public static CommandDispatcher mergeServerCommands(CommandDispatcher serverCommands, CommandBuildContext buildContext) { CommandDispatcher commandsTemp = new CommandDispatcher<>(); @@ -143,10 +142,10 @@ public class ClientCommandHandler } /** - * Always try to execute the cached parsing of a typed command as a clientside command. Requires that the execute field of the commands to be set to send to server so that they aren't\ + * Always try to execute the cached parsing of a typed command as a clientside command. Requires that the execute field of the commands to be set to send to server so that they aren't * treated as client command's that do nothing. * - * {@link net.minecraft.commands.Commands#performCommand(CommandSourceStack, String)} for reference + * {@link net.minecraft.commands.Commands#performCommand(ParseResults, String)} for reference * * @param command the full command to execute, no preceding slash * @return {@code false} leaves the message to be sent to the server, while {@code true} means it should be caught before LocalPlayer#sendCommand diff --git a/src/main/java/net/minecraftforge/client/CreativeModeTabSearchRegistry.java b/src/main/java/net/minecraftforge/client/CreativeModeTabSearchRegistry.java new file mode 100644 index 0000000000..1617e58f54 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/CreativeModeTabSearchRegistry.java @@ -0,0 +1,78 @@ +package net.minecraftforge.client; + +import java.util.IdentityHashMap; +import java.util.Map; +import net.minecraft.client.Minecraft; +import net.minecraft.client.searchtree.SearchRegistry; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.common.CreativeModeTabRegistry; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +public class CreativeModeTabSearchRegistry +{ + private static final Map> NAME_SEARCH_KEYS = new IdentityHashMap<>(); + private static final Map> TAG_SEARCH_KEYS = new IdentityHashMap<>(); + + public static Map> getNameSearchKeys() { + Map> nameSearchKeys = new IdentityHashMap<>(); + + nameSearchKeys.put(CreativeModeTabs.searchTab(), getNameSearchKey(CreativeModeTabs.searchTab())); + + for (CreativeModeTab tab : CreativeModeTabRegistry.getSortedCreativeModeTabs()) + { + SearchRegistry.Key nameSearchKey = getNameSearchKey(tab); + if (nameSearchKey != null) + nameSearchKeys.put(tab, nameSearchKey); + } + + return nameSearchKeys; + } + + public static Map> getTagSearchKeys() { + Map> tagSearchKeys = new IdentityHashMap<>(); + + tagSearchKeys.put(CreativeModeTabs.searchTab(), getTagSearchKey(CreativeModeTabs.searchTab())); + + for (CreativeModeTab tab : CreativeModeTabRegistry.getSortedCreativeModeTabs()) + { + SearchRegistry.Key tagSearchKey = getTagSearchKey(tab); + if (tagSearchKey != null) + tagSearchKeys.put(tab, tagSearchKey); + } + + return tagSearchKeys; + } + + @Nullable + public static SearchRegistry.Key getNameSearchKey(CreativeModeTab tab) + { + if (tab == CreativeModeTabs.searchTab()) + return SearchRegistry.CREATIVE_NAMES; + + if (!tab.hasSearchBar()) + return null; + + return NAME_SEARCH_KEYS.computeIfAbsent(tab, k -> new SearchRegistry.Key<>()); + } + + @Nullable + public static SearchRegistry.Key getTagSearchKey(CreativeModeTab tab) + { + if (tab == CreativeModeTabs.searchTab()) + return SearchRegistry.CREATIVE_TAGS; + + if (!tab.hasSearchBar()) + return null; + + return TAG_SEARCH_KEYS.computeIfAbsent(tab, k -> new SearchRegistry.Key<>()); + } + + // We do it this way to prevent unwanted classloading + @ApiStatus.Internal + public static void createSearchTrees() { + Minecraft.getInstance().createSearchTrees(); + } +} diff --git a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java index b735b85394..80275c1106 100644 --- a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java +++ b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java @@ -6,6 +6,10 @@ package net.minecraftforge.client; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import com.google.common.graph.ElementOrder; +import com.google.common.graph.GraphBuilder; +import com.google.common.graph.MutableGraph; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.shaders.FogShape; @@ -14,8 +18,6 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.datafixers.util.Either; -import com.mojang.math.Matrix4f; -import com.mojang.math.Vector3f; import net.minecraft.ChatFormatting; import net.minecraft.FileUtil; import net.minecraft.client.Camera; @@ -53,14 +55,16 @@ import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.ShaderInstance; -import net.minecraft.client.renderer.Sheets; import net.minecraft.client.renderer.block.BlockRenderDispatcher; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.culling.Frustum; +import net.minecraft.client.renderer.texture.SpriteContents; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.language.I18n; +import net.minecraft.client.resources.metadata.animation.AnimationMetadataSection; +import net.minecraft.client.resources.metadata.animation.FrameSize; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.Material; import net.minecraft.client.resources.model.ModelBakery; @@ -70,18 +74,16 @@ import net.minecraft.client.sounds.SoundEngine; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.locale.Language; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.Connection; -import net.minecraft.network.chat.ChatSender; import net.minecraft.network.chat.ChatType; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; -import net.minecraft.network.chat.MessageSigner; import net.minecraft.network.chat.PlayerChatMessage; import net.minecraft.network.protocol.status.ServerStatus; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.Resource; -import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; @@ -93,6 +95,7 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeInstance; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.tooltip.TooltipComponent; +import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.world.level.BlockAndTintGetter; @@ -100,7 +103,6 @@ import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.FogType; import net.minecraft.world.phys.BlockHitResult; @@ -142,17 +144,19 @@ import net.minecraftforge.client.textures.ForgeTextureMetadata; import net.minecraftforge.common.ForgeI18n; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ItemStackMap; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.IExtensionPoint; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.ModLoader; -import net.minecraftforge.fml.StartupMessageManager; import net.minecraftforge.fml.VersionChecker; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.loading.toposort.CyclePresentException; +import net.minecraftforge.fml.loading.toposort.TopologicalSort; import net.minecraftforge.network.NetworkConstants; import net.minecraftforge.network.NetworkRegistry; -import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.GameData; import net.minecraftforge.versions.forge.ForgeVersion; import org.apache.commons.lang3.tuple.Pair; @@ -163,6 +167,8 @@ import org.apache.logging.log4j.MarkerManager; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.joml.Matrix4f; +import org.joml.Vector3f; import java.io.File; import java.io.IOException; @@ -170,12 +176,14 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.Stack; +import java.util.UUID; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; import java.util.function.Supplier; @@ -298,16 +306,6 @@ public class ForgeHooksClient return MinecraftForge.EVENT_BUS.post(new RenderArmEvent(poseStack, multiBufferSource, packedLight, player, arm)); } - public static void onTextureStitchedPre(TextureAtlas map, Set resourceLocations) - { - StartupMessageManager.mcLoaderConsumer().ifPresent(c->c.accept("Atlas Stitching : "+map.location().toString())); - ModLoader.get().postEvent(new TextureStitchEvent.Pre(map, resourceLocations)); -// ModelLoader.White.INSTANCE.register(map); // TODO Custom TAS - Sheets.SIGN_MATERIALS.values().stream() - .filter(rm -> rm.atlasLocation().equals(map.location())) - .forEach(rm -> resourceLocations.add(rm.texture())); - } - public static void onTextureStitchedPost(TextureAtlas map) { ModLoader.get().postEvent(new TextureStitchEvent.Post(map)); @@ -502,22 +500,6 @@ public class ForgeHooksClient }; } - public static void gatherFluidTextures(Set textures) - { - if (!ModLoader.isLoadingStateValid()) return; - - ForgeRegistries.FLUIDS.getValues().stream() - .flatMap(ForgeHooksClient::getFluidMaterials) - .forEach(textures::add); - } - - public static Stream getFluidMaterials(Fluid fluid) - { - return IClientFluidTypeExtensions.of(fluid).getTextures() - .filter(Objects::nonNull) - .map(ForgeHooksClient::getBlockMaterial); - } - @SuppressWarnings("deprecation") public static Material getBlockMaterial(ResourceLocation loc) { @@ -785,17 +767,39 @@ public class ForgeHooksClient } @Nullable - public static TextureAtlasSprite loadTextureAtlasSprite( - TextureAtlas textureAtlas, - ResourceManager resourceManager, TextureAtlasSprite.Info textureInfo, + public static SpriteContents loadSpriteContents( + ResourceLocation name, Resource resource, - int atlasWidth, int atlasHeight, - int spriteX, int spriteY, int mipmapLevel, - NativeImage image - ) throws IOException + FrameSize frameSize, + NativeImage image, + AnimationMetadataSection animationMeta + ) { - ForgeTextureMetadata metadata = ForgeTextureMetadata.forResource(resource); - return metadata.getLoader() == null ? null : metadata.getLoader().load(textureAtlas, resourceManager, textureInfo, resource, atlasWidth, atlasHeight, spriteX, spriteY, mipmapLevel, image); + try + { + ForgeTextureMetadata forgeMeta = ForgeTextureMetadata.forResource(resource); + return forgeMeta.getLoader() == null ? null : forgeMeta.getLoader().loadContents(name, resource, frameSize, image, animationMeta, forgeMeta); + } + catch (IOException e) + { + LOGGER.error("Unable to get Forge metadata for {}, falling back to vanilla loading", name); + e.printStackTrace(); + return null; + } + } + + @Nullable + public static TextureAtlasSprite loadTextureAtlasSprite( + ResourceLocation atlasName, + SpriteContents contents, + int atlasWidth, int atlasHeight, + int spriteX, int spriteY, int mipmapLevel + ) + { + if (contents.forgeMeta == null || contents.forgeMeta.getLoader() == null) + return null; + + return contents.forgeMeta.getLoader().makeSprite(atlasName, contents, atlasWidth, atlasHeight, spriteX, spriteY, mipmapLevel); } @@ -957,9 +961,16 @@ public class ForgeHooksClient } @Nullable - public static Component onClientChat(ChatType.Bound boundChatType, Component message, PlayerChatMessage playerChatMessage, MessageSigner messageSigner) + public static Component onClientChat(ChatType.Bound boundChatType, Component message, UUID sender) { - ClientChatReceivedEvent event = new ClientChatReceivedEvent(boundChatType, message, playerChatMessage, messageSigner); + ClientChatReceivedEvent event = new ClientChatReceivedEvent(boundChatType, message, sender); + return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage(); + } + + @Nullable + public static Component onClientPlayerChat(ChatType.Bound boundChatType, Component message, PlayerChatMessage playerChatMessage, UUID sender) + { + ClientChatReceivedEvent.Player event = new ClientChatReceivedEvent.Player(boundChatType, message, playerChatMessage, sender); return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage(); } @@ -994,7 +1005,7 @@ public class ForgeHooksClient @SubscribeEvent public static void registerShaders(RegisterShadersEvent event) throws IOException { - event.registerShader(new ShaderInstance(event.getResourceManager(), new ResourceLocation("forge","rendertype_entity_unlit_translucent"), DefaultVertexFormat.NEW_ENTITY), (p_172645_) -> { + event.registerShader(new ShaderInstance(event.getResourceProvider(), new ResourceLocation("forge","rendertype_entity_unlit_translucent"), DefaultVertexFormat.NEW_ENTITY), (p_172645_) -> { rendertypeEntityTranslucentUnlitShader = p_172645_; }); } @@ -1177,4 +1188,107 @@ public class ForgeHooksClient (isRelative ? basePath : "shaders/include/") + loc.getPath()); return new ResourceLocation(loc.getNamespace(), normalised); } + + public static CreativeModeTab.DisplayItemsGenerator onCreativeModeTabBuildContents(CreativeModeTab tab, CreativeModeTab.DisplayItemsGenerator originalGenerator) { + Set customGenerators = new HashSet<>(); + CreativeModeTabEvent.BuildContents event = ModLoader.get().postEventWithReturn(new net.minecraftforge.event.CreativeModeTabEvent.BuildContents(tab, customGenerators)); + + record ModificationEntry(CreativeModeTab.TabVisibility tabVisibility, ItemStack before, ItemStack after) {} + + return (featureFlagSet, output, hasPermissions) -> { + final Map originalEntries = ItemStackMap.createTypeAndTagLinkedMap(); + final Map entries = ItemStackMap.createTypeAndTagMap(); + + originalGenerator.accept(featureFlagSet, originalEntries::put, hasPermissions); + customGenerators.forEach(generator -> generator.accept(featureFlagSet, (stack, visibility, before, after) -> { + if (stack.getCount() != 1) + throw new IllegalArgumentException("The stack count must be 1"); + + entries.put(stack, new ModificationEntry(visibility, before, after)); + }, hasPermissions)); + + // We switch to the stacks tag here, as we need to be able to compare and hash them for the graph! + // We could not handle this with an open hashset since the builder does not support this internally. + final MutableGraph graph = GraphBuilder.directed().nodeOrder(ElementOrder.insertion()).build(); + final Map tagToStack = Maps.newHashMap(); + + CompoundTag lastStackTag = null; + for (ItemStack stack : originalEntries.keySet()) + { + final CompoundTag tag = stack.serializeNBT(); + tagToStack.put(tag, stack); + if (!stack.isEmpty()) + { + graph.addNode(tag); + } + if (lastStackTag != null) + { + graph.putEdge(lastStackTag, tag); + } + lastStackTag = tag; + } + + CompoundTag finalLastStackTag = lastStackTag; + entries.forEach((stack, modificationEntry) -> { + final CompoundTag tag = stack.serializeNBT(); + if (!stack.isEmpty()) + { + graph.addNode(tag); + tagToStack.put(tag, stack); + } + if (!modificationEntry.after.isEmpty()) + { + final CompoundTag afterTag = modificationEntry.after.serializeNBT(); + graph.putEdge(afterTag, tag); + tagToStack.put(afterTag, modificationEntry.after); + } + else if (finalLastStackTag != null) + { + // If the user does not specify an after, we assume it is the last stack and put it after that. + graph.putEdge(finalLastStackTag, tag); + } + if (!modificationEntry.before.isEmpty()) + { + final CompoundTag beforeTag = modificationEntry.before.serializeNBT(); + graph.putEdge(tag, beforeTag); + tagToStack.put(beforeTag, modificationEntry.before); + } + }); + + try + { + List tierList = TopologicalSort.topologicalSort(graph, null); + + // Now we unwind the tags again so that they are sorted neatly. + for (CompoundTag tag : tierList) + { + final ItemStack stack = tagToStack.get(tag); + if (originalEntries.containsKey(stack)) + { + output.accept(stack, originalEntries.get(stack)); + } + else if (entries.containsKey(stack)) + { + output.accept(stack, entries.get(stack).tabVisibility); + } + } + } + catch (CyclePresentException cyclePresentException) + { + LOGGER.error("Failed to inject custom items into creative mode tab {} due to a cycle in the dependency graph", tab, cyclePresentException); + LOGGER.warn("Detected cycles:"); + for (Set cycle : cyclePresentException.getCycles()) + { + graph.edges().forEach(edge -> { + if (cycle.contains(edge.nodeU()) && cycle.contains(edge.nodeV())) + { + LOGGER.warn(" - {} -> {}", tagToStack.get(edge.nodeU()), tagToStack.get(edge.nodeV())); + } + }); + } + LOGGER.error("Falling back to default!"); + originalGenerator.accept(featureFlagSet, output, hasPermissions); + } + }; + } } diff --git a/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java b/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java index eb0bf7a1c7..8a2294f8f7 100644 --- a/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java @@ -8,13 +8,13 @@ package net.minecraftforge.client.event; import net.minecraft.Util; import net.minecraft.network.chat.ChatType; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MessageSigner; import net.minecraft.network.chat.PlayerChatMessage; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; +import java.util.UUID; /** * Fired when a chat message is received on the client. @@ -33,16 +33,14 @@ public class ClientChatReceivedEvent extends Event { private Component message; private final ChatType.Bound boundChatType; - private final PlayerChatMessage playerChatMessage; - private final MessageSigner messageSigner; + private final UUID sender; @ApiStatus.Internal - public ClientChatReceivedEvent(ChatType.Bound boundChatType, Component message, PlayerChatMessage playerChatMessage, MessageSigner messageSigner) + public ClientChatReceivedEvent(ChatType.Bound boundChatType, Component message, UUID sender) { this.boundChatType = boundChatType; this.message = message; - this.playerChatMessage = playerChatMessage; - this.messageSigner = messageSigner; + this.sender = sender; } /** @@ -73,22 +71,12 @@ public class ClientChatReceivedEvent extends Event } /** - * {@return the full player chat message}. - * This contains the sender UUID, various signing data, and the optional unsigned contents. + * {@return the message sender}. + * This will be {@link Util#NIL_UUID} if the message is a system message. */ - public PlayerChatMessage getPlayerChatMessage() + public UUID getSender() { - return this.playerChatMessage; - } - - /** - * {@return the message signer}. - * This contains the sender UUID, timestamp of message creation, and signature salt. - * The {@linkplain MessageSigner#profileId() sender UUID} will be {@link Util#NIL_UUID} if the message is a system message. - */ - public MessageSigner getMessageSigner() - { - return this.messageSigner; + return this.sender; } /** @@ -96,6 +84,38 @@ public class ClientChatReceivedEvent extends Event */ public boolean isSystem() { - return this.messageSigner.isSystem(); + return this.sender.equals(Util.NIL_UUID); } -} + + /** + * Fired when a player chat message is received on the client. + * + *

This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + * If the event is cancelled, the message is not displayed in the chat message window.

+ * + *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, + * only on the {@linkplain LogicalSide#CLIENT logical client}.

+ * + * @see ChatType + */ + public static class Player extends ClientChatReceivedEvent + { + private final PlayerChatMessage playerChatMessage; + + @ApiStatus.Internal + public Player(ChatType.Bound boundChatType, Component message, PlayerChatMessage playerChatMessage, UUID sender) + { + super(boundChatType, message, sender); + this.playerChatMessage = playerChatMessage; + } + + /** + * {@return the full player chat message}. + * This contains the sender UUID, various signing data, and the optional unsigned contents. + */ + public PlayerChatMessage getPlayerChatMessage() + { + return this.playerChatMessage; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/event/RegisterShadersEvent.java b/src/main/java/net/minecraftforge/client/event/RegisterShadersEvent.java index 7b7079a56c..ed6ea20b7e 100644 --- a/src/main/java/net/minecraftforge/client/event/RegisterShadersEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RegisterShadersEvent.java @@ -8,6 +8,7 @@ package net.minecraftforge.client.event; import com.mojang.datafixers.util.Pair; import net.minecraft.client.renderer.ShaderInstance; import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.server.packs.resources.ResourceProvider; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.LogicalSide; @@ -29,29 +30,29 @@ import java.util.function.Consumer; */ public class RegisterShadersEvent extends Event implements IModBusEvent { - private final ResourceManager resourceManager; + private final ResourceProvider resourceProvider; private final List>> shaderList; @ApiStatus.Internal - public RegisterShadersEvent(ResourceManager resourceManager, List>> shaderList) + public RegisterShadersEvent(ResourceProvider resourceProvider, List>> shaderList) { - this.resourceManager = resourceManager; + this.resourceProvider = resourceProvider; this.shaderList = shaderList; } /** - * {@return the client-side resource manager} + * {@return the client-side resource provider} */ - public ResourceManager getResourceManager() + public ResourceProvider getResourceProvider() { - return resourceManager; + return resourceProvider; } /** * Registers a shader, and a callback for when the shader is loaded. * - *

When creating a {@link ShaderInstance}, pass in the {@linkplain #getResourceManager() - * client-side resource manager} as the resource provider.

+ *

When creating a {@link ShaderInstance}, pass in the {@linkplain #getResourceProvider() + * client-side resource provider} as the resource provider.

* *

Mods should not store the shader instance passed into this method. Instead, mods should store the shader * passed into the registered load callback.

diff --git a/src/main/java/net/minecraftforge/client/event/RenderLevelLastEvent.java b/src/main/java/net/minecraftforge/client/event/RenderLevelLastEvent.java index e9280d78e9..0368dc8f57 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderLevelLastEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderLevelLastEvent.java @@ -6,13 +6,13 @@ package net.minecraftforge.client.event; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.LevelRenderer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; +import org.joml.Matrix4f; /** * Fired after all level rendering. diff --git a/src/main/java/net/minecraftforge/client/event/RenderLevelStageEvent.java b/src/main/java/net/minecraftforge/client/event/RenderLevelStageEvent.java index 4896eee70b..a4900c2653 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderLevelStageEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderLevelStageEvent.java @@ -11,7 +11,6 @@ import java.util.Map; import javax.annotation.Nullable; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; import net.minecraft.client.Camera; import net.minecraft.client.renderer.LevelRenderer; @@ -21,13 +20,14 @@ import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.ForgeRenderTypes; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.event.IModBusEvent; +import org.joml.Matrix4f; /** - * Fires at various times during LevelRenderer.renderLevel. + * Fires at various times during LevelRenderer.renderLevel. * Check {@link #getStage} to render during the appropriate time for your use case. - * + * *

This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

- * + * *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @@ -122,9 +122,9 @@ public class RenderLevelStageEvent extends Event /** * Use to create a custom {@linkplain RenderLevelStageEvent.Stage stages}. * Fired after the LevelRenderer has been created. - * + * *

This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

- * + * *

This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @@ -184,7 +184,7 @@ public class RenderLevelStageEvent extends Event * Use this to render custom effects into the world, such as custom entity-like objects or special rendering effects. * Called within a fabulous graphics target. * Happens after entities render. - * + * * @see ForgeRenderTypes#TRANSLUCENT_ON_PARTICLES_TARGET */ public static final Stage AFTER_PARTICLES = register("after_particles", null); diff --git a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java index cbb0aed679..db97875be6 100644 --- a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java +++ b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java @@ -6,7 +6,6 @@ package net.minecraftforge.client.event; import net.minecraft.client.renderer.texture.TextureAtlas; -import net.minecraft.resources.ResourceLocation; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.LogicalSide; @@ -17,10 +16,8 @@ import org.jetbrains.annotations.ApiStatus; import java.util.Set; /** - * Fired before and after a texture atlas stitched together. - * See the two subclasses to listen for before and after stitching. + * Fired after a texture atlas is stitched together. * - * @see TextureStitchEvent.Pre * @see TextureStitchEvent.Post * @see TextureAtlas */ @@ -42,39 +39,40 @@ public class TextureStitchEvent extends Event implements IModBusEvent return atlas; } - /** - *

Fired before a texture atlas is stitched together. - * This can be used to add custom sprites to be stitched into the atlas.

- * - *

This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

- * - *

This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus()} mod-specific event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

- */ - public static class Pre extends TextureStitchEvent - { - private final Set sprites; - - @ApiStatus.Internal - public Pre(TextureAtlas map, Set sprites) - { - super(map); - this.sprites = sprites; - } - - /** - * Adds a sprite to be stitched into the texture atlas. - * - *

Callers should check that the atlas which the event is fired for is the atlas they wish to stitch the - * sprite into, as otherwise they would be stitching the sprite into all atlases.

- * - * @param sprite the location of the sprite - */ - public boolean addSprite(ResourceLocation sprite) - { - return this.sprites.add(sprite); - } - } + // Use atlas info JSON files instead + // /** + // *

Fired before a texture atlas is stitched together. + // * This can be used to add custom sprites to be stitched into the atlas.

+ // * + // *

This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.

+ // * + // *

This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus()} mod-specific event bus}, + // * only on the {@linkplain LogicalSide#CLIENT logical client}.

+ // */ + // public static class Pre extends TextureStitchEvent + // { + // private final Set sprites; + // + // @ApiStatus.Internal + // public Pre(TextureAtlas map, Set sprites) + // { + // super(map); + // this.sprites = sprites; + // } + // + // /** + // * Adds a sprite to be stitched into the texture atlas. + // * + // *

Callers should check that the atlas which the event is fired for is the atlas they wish to stitch the + // * sprite into, as otherwise they would be stitching the sprite into all atlases.

+ // * + // * @param sprite the location of the sprite + // */ + // public boolean addSprite(ResourceLocation sprite) + // { + // return this.sprites.add(sprite); + // } + // } /** * Fired after a texture atlas is stitched together and all textures therein has been loaded. diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeDimensionSpecialEffects.java b/src/main/java/net/minecraftforge/client/extensions/IForgeDimensionSpecialEffects.java index c2161e328b..faa2c94c7e 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeDimensionSpecialEffects.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeDimensionSpecialEffects.java @@ -6,12 +6,12 @@ package net.minecraftforge.client.extensions; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; -import com.mojang.math.Vector3f; import net.minecraft.client.Camera; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.DimensionSpecialEffects; import net.minecraft.client.renderer.LightTexture; +import org.joml.Matrix4f; +import org.joml.Vector3f; /** * Extension interface for {@link DimensionSpecialEffects}. diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeModelBaker.java b/src/main/java/net/minecraftforge/client/extensions/IForgeModelBaker.java new file mode 100644 index 0000000000..fb15970e58 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeModelBaker.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) Forge Development LLC and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.minecraftforge.client.extensions; + +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.Nullable; +import java.util.function.Function; + +public interface IForgeModelBaker +{ + @Nullable + BakedModel bake(ResourceLocation location, ModelState state, Function sprites); + + Function getModelTextureGetter(); +} diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgePoseStack.java b/src/main/java/net/minecraftforge/client/extensions/IForgePoseStack.java index 5b96d9ebe6..94e73a5cc5 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgePoseStack.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgePoseStack.java @@ -7,7 +7,7 @@ package net.minecraftforge.client.extensions; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Transformation; -import com.mojang.math.Vector3f; +import org.joml.Vector3f; /** * Extension interface for {@link com.mojang.blaze3d.vertex.PoseStack}. diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeTransformation.java b/src/main/java/net/minecraftforge/client/extensions/IForgeTransformation.java index f63bb1a477..ebf4d7616f 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeTransformation.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeTransformation.java @@ -8,12 +8,12 @@ package net.minecraftforge.client.extensions; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.core.Direction; -import com.mojang.math.Matrix4f; import com.mojang.math.Transformation; -import com.mojang.math.Vector3f; -import com.mojang.math.Vector4f; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import org.joml.Matrix4f; +import org.joml.Vector3f; +import org.joml.Vector4f; /** * Extension interface for {@link Transformation}. @@ -58,7 +58,7 @@ public interface IForgeTransformation */ default void transformPosition(Vector4f position) { - position.transform(self().getMatrix()); + position.mul(self().getMatrix()); } /** @@ -68,7 +68,7 @@ public interface IForgeTransformation */ default void transformNormal(Vector3f normal) { - normal.transform(self().getNormalMatrix()); + normal.mul(self().getNormalMatrix()); normal.normalize(); } @@ -120,11 +120,10 @@ public interface IForgeTransformation if (transform.isIdentity()) return Transformation.identity(); Matrix4f ret = transform.getMatrix(); - Matrix4f tmp = Matrix4f.createTranslateMatrix(origin.x(), origin.y(), origin.z()); - ret.multiplyBackward(tmp); - tmp.setIdentity(); - tmp.setTranslation(-origin.x(), -origin.y(), -origin.z()); - ret.multiply(tmp); + Matrix4f tmp = new Matrix4f().translation(origin.x(), origin.y(), origin.z()); + tmp.mul(ret, ret); + tmp.translation(-origin.x(), -origin.y(), -origin.z()); + ret.mul(tmp); return new Transformation(ret); } } diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeVertexConsumer.java b/src/main/java/net/minecraftforge/client/extensions/IForgeVertexConsumer.java index 9739aee367..e758cd22d7 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeVertexConsumer.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeVertexConsumer.java @@ -8,10 +8,10 @@ package net.minecraftforge.client.extensions; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexFormatElement; -import com.mojang.math.Matrix3f; -import com.mojang.math.Vector3f; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraftforge.client.model.IQuadTransformer; +import org.joml.Matrix3f; +import org.joml.Vector3f; import java.nio.ByteBuffer; @@ -63,7 +63,7 @@ public interface IForgeVertexConsumer if (nx != 0 || ny != 0 || nz != 0) { generated.set(nx / 127f, ny / 127f, nz / 127f); - generated.transform(normalTransform); + generated.mul(normalTransform); } } } diff --git a/src/main/java/net/minecraftforge/client/extensions/common/IClientBlockExtensions.java b/src/main/java/net/minecraftforge/client/extensions/common/IClientBlockExtensions.java index 24ed17844b..ea72ce34e7 100644 --- a/src/main/java/net/minecraftforge/client/extensions/common/IClientBlockExtensions.java +++ b/src/main/java/net/minecraftforge/client/extensions/common/IClientBlockExtensions.java @@ -5,7 +5,6 @@ package net.minecraftforge.client.extensions.common; -import com.mojang.math.Vector3d; import net.minecraft.client.particle.ParticleEngine; import net.minecraft.core.BlockPos; import net.minecraft.world.effect.MobEffects; @@ -19,6 +18,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.HitResult; import net.minecraftforge.fml.LogicalSide; +import org.joml.Vector3d; import java.util.function.Consumer; @@ -71,7 +71,7 @@ public interface IClientBlockExtensions */ default boolean addDestroyEffects(BlockState state, Level Level, BlockPos pos, ParticleEngine manager) { - return false; + return !state.shouldSpawnParticlesOnBreak(); } /** diff --git a/src/main/java/net/minecraftforge/client/extensions/common/IClientFluidTypeExtensions.java b/src/main/java/net/minecraftforge/client/extensions/common/IClientFluidTypeExtensions.java index c2d6fb9a5b..cee69a2cac 100644 --- a/src/main/java/net/minecraftforge/client/extensions/common/IClientFluidTypeExtensions.java +++ b/src/main/java/net/minecraftforge/client/extensions/common/IClientFluidTypeExtensions.java @@ -6,21 +6,14 @@ package net.minecraftforge.client.extensions.common; import com.mojang.blaze3d.shaders.FogShape; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.BufferUploader; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.Tesselator; -import com.mojang.blaze3d.vertex.VertexFormat; -import com.mojang.math.Matrix4f; -import com.mojang.math.Vector3f; +import java.util.Objects; +import java.util.function.Consumer; +import java.util.stream.Stream; import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.FogRenderer; -import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.ScreenEffectRenderer; import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceLocation; @@ -33,10 +26,7 @@ import net.minecraftforge.fluids.FluidType; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; - -import java.util.Objects; -import java.util.function.Consumer; -import java.util.stream.Stream; +import org.joml.Vector3f; /** * {@linkplain LogicalSide#CLIENT Client-only} extensions to {@link FluidType}. @@ -130,19 +120,20 @@ public interface IClientFluidTypeExtensions return null; } - /** - * Returns a stream of textures applied to a fluid. - * - *

This is used by the {@link net.minecraft.client.resources.model.ModelBakery} to load in all textures that - * can be applied on reload. - * - * @return a stream of textures applied to a fluid - */ - default Stream getTextures() - { - return Stream.of(this.getStillTexture(), this.getFlowingTexture(), this.getOverlayTexture()) - .filter(Objects::nonNull); - } + // Add entries to assets/minecraft/atlases/blocks.json if your texture location is not already covered by the default atlas search locations. + // /** + // * Returns a stream of textures applied to a fluid. + // * + // *

This is used by the {@link net.minecraft.client.resources.model.ModelBakery} to load in all textures that + // * can be applied on reload. + // * + // * @return a stream of textures applied to a fluid + // */ + // default Stream getTextures() + // { + // return Stream.of(this.getStillTexture(), this.getFlowingTexture(), this.getOverlayTexture()) + // .filter(Objects::nonNull); + // } /** * Returns the location of the texture to apply to the camera when it is diff --git a/src/main/java/net/minecraftforge/client/gui/CreativeTabsScreenPage.java b/src/main/java/net/minecraftforge/client/gui/CreativeTabsScreenPage.java new file mode 100644 index 0000000000..d3e47fdd02 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/gui/CreativeTabsScreenPage.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) Forge Development LLC and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.minecraftforge.client.gui; + +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; +import net.minecraftforge.common.util.ConcatenatedListView; + +import java.util.ArrayList; +import java.util.List; + +public final class CreativeTabsScreenPage +{ + private final List tabs; + private final List topTabs; + private final List bottomTabs; + private final ConcatenatedListView visibleTabs; + + public CreativeTabsScreenPage(List tabs) + { + this.tabs = tabs; + this.topTabs = new ArrayList<>(); + this.bottomTabs = new ArrayList<>(); + this.visibleTabs = ConcatenatedListView.of(tabs, CreativeModeTabs.defaultTabs()); + + int maxLength = 10; + int topLength = maxLength / 2; + int length = Math.min(10, tabs.size()); + + for (int i = 0; i < length; i++) + { + CreativeModeTab tab = tabs.get(i); + (i < topLength ? this.topTabs : this.bottomTabs).add(tab); + } + } + + public List getVisibleTabs() + { + return this.visibleTabs.stream().filter(CreativeModeTab::shouldDisplay).toList(); + } + + public boolean isTop(CreativeModeTab tab) + { + if (!this.tabs.contains(tab)) + return CreativeModeTabs.defaultTabs().indexOf(tab) < (CreativeModeTabs.defaultTabs().size() / 2); + + return this.topTabs.contains(tab); + } + + public int getColumn(CreativeModeTab tab) + { + if (!this.tabs.contains(tab)) + return (CreativeModeTabs.defaultTabs().indexOf(tab) % (CreativeModeTabs.defaultTabs().size() / 2)) + 5; + + return this.topTabs.contains(tab) ? this.topTabs.indexOf(tab) : this.bottomTabs.indexOf(tab); + } + + public CreativeModeTab getDefaultTab() + { + return this.tabs.get(0); + } +} diff --git a/src/main/java/net/minecraftforge/client/gui/ModListScreen.java b/src/main/java/net/minecraftforge/client/gui/ModListScreen.java index e09991368c..7426092168 100644 --- a/src/main/java/net/minecraftforge/client/gui/ModListScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/ModListScreen.java @@ -19,6 +19,7 @@ import java.util.stream.Collectors; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.server.packs.resources.IoSupplier; import net.minecraftforge.client.ConfigScreenHandler; import net.minecraftforge.client.gui.widget.ModListWidget; import net.minecraftforge.client.gui.widget.ScrollPanel; @@ -264,14 +265,14 @@ public class ModListScreen extends Screen int y = this.height - 20 - PADDING; int fullButtonHeight = PADDING + 20 + PADDING; - doneButton = new Button(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, 20, Component.translatable("gui.done"), b -> ModListScreen.this.onClose()); - openModsFolderButton = new Button(6, y, this.listWidth, 20, Component.translatable("fml.menu.mods.openmodsfolder"), b -> Util.getPlatform().openFile(FMLPaths.MODSDIR.get().toFile())); + doneButton = Button.builder(Component.translatable("gui.done"), b -> ModListScreen.this.onClose()).bounds(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, 20).build(); + openModsFolderButton = Button.builder(Component.translatable("fml.menu.mods.openmodsfolder"), b -> Util.getPlatform().openFile(FMLPaths.MODSDIR.get().toFile())).bounds(6, y, this.listWidth, 20).build(); y -= 20 + PADDING; - configButton = new Button(6, y, this.listWidth, 20, Component.translatable("fml.menu.mods.config"), b -> ModListScreen.this.displayModConfig()); + configButton = Button.builder(Component.translatable("fml.menu.mods.config"), b -> ModListScreen.this.displayModConfig()).bounds(6, y, this.listWidth, 20).build(); y -= 14 + PADDING; search = new EditBox(getFontRenderer(), PADDING + 1, y, listWidth - 2, 14, Component.translatable("fml.menu.mods.search")); - this.modList = new ModListWidget(this, listWidth, fullButtonHeight, search.y - getFontRenderer().lineHeight - PADDING); + this.modList = new ModListWidget(this, listWidth, fullButtonHeight, search.getY() - getFontRenderer().lineHeight - PADDING); this.modList.setLeftPos(6); this.modInfo = new InfoPanel(this.minecraft, modInfoWidth, this.height - PADDING - fullButtonHeight, PADDING); @@ -288,11 +289,11 @@ public class ModListScreen extends Screen final int width = listWidth / numButtons; int x = PADDING; - addRenderableWidget(SortType.NORMAL.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.NORMAL.getButtonText(), b -> resortMods(SortType.NORMAL))); + addRenderableWidget(SortType.NORMAL.button = Button.builder(SortType.NORMAL.getButtonText(), b -> resortMods(SortType.NORMAL)).bounds(x, PADDING, width - buttonMargin, 20).build()); x += width + buttonMargin; - addRenderableWidget(SortType.A_TO_Z.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.A_TO_Z.getButtonText(), b -> resortMods(SortType.A_TO_Z))); + addRenderableWidget(SortType.A_TO_Z.button = Button.builder(SortType.A_TO_Z.getButtonText(), b -> resortMods(SortType.A_TO_Z)).bounds(x, PADDING, width - buttonMargin, 20).build()); x += width + buttonMargin; - addRenderableWidget(SortType.Z_TO_A.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.Z_TO_A.getButtonText(), b -> resortMods(SortType.Z_TO_A))); + addRenderableWidget(SortType.Z_TO_A.button = Button.builder(SortType.Z_TO_A.getButtonText(), b -> resortMods(SortType.Z_TO_A)).bounds(x, PADDING, width - buttonMargin, 20).build()); resortMods(SortType.NORMAL); updateCache(); } @@ -371,7 +372,7 @@ public class ModListScreen extends Screen int x = modList.getLeft() + ((modList.getRight() - modList.getLeft()) / 2) - (getFontRenderer().width(text) / 2); this.search.render(poseStack, mouseX , mouseY, partialTick); super.render(poseStack, mouseX, mouseY, partialTick); - getFontRenderer().draw(poseStack, text.getVisualOrderText(), x, search.y - getFontRenderer().lineHeight, 0xFFFFFF); + getFontRenderer().draw(poseStack, text.getVisualOrderText(), x, search.getY() - getFontRenderer().lineHeight, 0xFFFFFF); } public Minecraft getMinecraftInstance() @@ -412,9 +413,9 @@ public class ModListScreen extends Screen try { NativeImage logo = null; - InputStream logoResource = resourcePack.getRootResource(logoFile); + IoSupplier logoResource = resourcePack.getRootResource(logoFile); if (logoResource != null) - logo = NativeImage.read(logoResource); + logo = NativeImage.read(logoResource.get()); if (logo != null) { diff --git a/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java b/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java index c3086b6861..d1183dcb78 100644 --- a/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java @@ -90,9 +90,15 @@ public class ModMismatchDisconnectedScreen extends Screen this.addRenderableWidget(new MismatchInfoPanel(minecraft, listWidth, listHeight, (this.height - this.listHeight) / 2, listLeft)); int buttonWidth = Math.min(210, this.width / 2 - 20); - this.addRenderableWidget(new Button(Math.max(this.width / 4 - buttonWidth / 2, listLeft), upperButtonHeight, buttonWidth, 20, Component.literal(ForgeI18n.parseMessage("fml.button.open.file", logFile.getFileName())), button -> Util.getPlatform().openFile(logFile.toFile()))); - this.addRenderableWidget(new Button(Math.min(this.width * 3 / 4 - buttonWidth / 2, listLeft + listWidth - buttonWidth), upperButtonHeight, buttonWidth, 20, Component.literal(ForgeI18n.parseMessage("fml.button.open.mods.folder")), button -> Util.getPlatform().openFile(modsDir.toFile()))); - this.addRenderableWidget(new Button((this.width - buttonWidth) / 2, lowerButtonHeight, buttonWidth, 20, Component.translatable("gui.toMenu"), button -> this.minecraft.setScreen(this.parent))); + this.addRenderableWidget(Button.builder(Component.literal(ForgeI18n.parseMessage("fml.button.open.file", logFile.getFileName())), button -> Util.getPlatform().openFile(logFile.toFile())) + .bounds(Math.max(this.width / 4 - buttonWidth / 2, listLeft), upperButtonHeight, buttonWidth, 20) + .build()); + this.addRenderableWidget(Button.builder(Component.literal(ForgeI18n.parseMessage("fml.button.open.mods.folder")), button -> Util.getPlatform().openFile(modsDir.toFile())) + .bounds(Math.min(this.width * 3 / 4 - buttonWidth / 2, listLeft + listWidth - buttonWidth), upperButtonHeight, buttonWidth, 20) + .build()); + this.addRenderableWidget(Button.builder(Component.translatable("gui.toMenu"), button -> this.minecraft.setScreen(this.parent)) + .bounds((this.width - buttonWidth) / 2, lowerButtonHeight, buttonWidth, 20) + .build()); } @Override diff --git a/src/main/java/net/minecraftforge/client/gui/ScreenUtils.java b/src/main/java/net/minecraftforge/client/gui/ScreenUtils.java index 1cc04add9c..babda8d2ee 100644 --- a/src/main/java/net/minecraftforge/client/gui/ScreenUtils.java +++ b/src/main/java/net/minecraftforge/client/gui/ScreenUtils.java @@ -12,10 +12,10 @@ import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.DefaultVertexFormat; import net.minecraft.resources.ResourceLocation; -import com.mojang.math.Matrix4f; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; +import org.joml.Matrix4f; /** * This class provides several methods and constants used by the Config GUI classes. diff --git a/src/main/java/net/minecraftforge/client/gui/TitleScreenModUpdateIndicator.java b/src/main/java/net/minecraftforge/client/gui/TitleScreenModUpdateIndicator.java index 92a99031a8..9304b831a3 100644 --- a/src/main/java/net/minecraftforge/client/gui/TitleScreenModUpdateIndicator.java +++ b/src/main/java/net/minecraftforge/client/gui/TitleScreenModUpdateIndicator.java @@ -59,8 +59,8 @@ public class TitleScreenModUpdateIndicator extends Screen RenderSystem.setShaderTexture(0, VERSION_CHECK_ICONS); - int x = modButton.x; - int y = modButton.y; + int x = modButton.getX(); + int y = modButton.getY(); int w = modButton.getWidth(); int h = modButton.getHeight(); diff --git a/src/main/java/net/minecraftforge/client/gui/overlay/ForgeGui.java b/src/main/java/net/minecraftforge/client/gui/overlay/ForgeGui.java index 9e5c9e10d8..ff234d5f2c 100644 --- a/src/main/java/net/minecraftforge/client/gui/overlay/ForgeGui.java +++ b/src/main/java/net/minecraftforge/client/gui/overlay/ForgeGui.java @@ -5,6 +5,7 @@ package net.minecraftforge.client.gui.overlay; +import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; @@ -22,6 +23,7 @@ import net.minecraft.util.StringUtil; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.PlayerRideableJumping; import net.minecraft.world.entity.ai.attributes.AttributeInstance; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.player.Player; @@ -420,13 +422,13 @@ public class ForgeGui extends Gui } @Override - public void renderJumpMeter(PoseStack poseStack, int x) + public void renderJumpMeter(PlayerRideableJumping playerRideableJumping, PoseStack poseStack, int x) { bind(GUI_ICONS_LOCATION); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.disableBlend(); - super.renderJumpMeter(poseStack, x); + super.renderJumpMeter(playerRideableJumping, poseStack, x); RenderSystem.enableBlend(); minecraft.getProfiler().pop(); @@ -572,12 +574,16 @@ public class ForgeGui extends Gui { minecraft.getProfiler().push("chat"); - var event = new CustomizeGuiOverlayEvent.Chat(minecraft.getWindow(), pStack, minecraft.getFrameTime(), 0, height - 48); + Window window = minecraft.getWindow(); + var event = new CustomizeGuiOverlayEvent.Chat(window, pStack, minecraft.getFrameTime(), 0, height - 48); MinecraftForge.EVENT_BUS.post(event); pStack.pushPose(); - pStack.translate(event.getPosX(), event.getPosY(), 0.0D); - chat.render(pStack, tickCount); + // We give the absolute Y position of the chat component in the event and account for the chat component's own offsetting here. + pStack.translate(event.getPosX(), (event.getPosY() - height + 40) / chat.getScale(), 0.0D); + int mouseX = Mth.floor(minecraft.mouseHandler.xpos() * window.getGuiScaledWidth() / window.getScreenWidth()); + int mouseY = Mth.floor(minecraft.mouseHandler.ypos() * window.getGuiScaledHeight() / window.getScreenHeight()); + chat.render(pStack, tickCount, mouseX, mouseY); pStack.popPose(); minecraft.getProfiler().pop(); diff --git a/src/main/java/net/minecraftforge/client/gui/overlay/VanillaGuiOverlay.java b/src/main/java/net/minecraftforge/client/gui/overlay/VanillaGuiOverlay.java index 0f65052b56..b8f536b8d3 100644 --- a/src/main/java/net/minecraftforge/client/gui/overlay/VanillaGuiOverlay.java +++ b/src/main/java/net/minecraftforge/client/gui/overlay/VanillaGuiOverlay.java @@ -10,6 +10,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.PlayerRideableJumping; import net.minecraft.world.level.GameType; import net.minecraft.world.scores.Objective; import net.minecraft.world.scores.PlayerTeam; @@ -119,14 +120,15 @@ public enum VanillaGuiOverlay } }), JUMP_BAR("jump_bar", (gui, poseStack, partialTick, screenWidth, screenHeight) -> { - if (gui.getMinecraft().player.isRidingJumpable() && !gui.getMinecraft().options.hideGui) + PlayerRideableJumping playerRideableJumping = gui.getMinecraft().player.jumpableVehicle(); + if (playerRideableJumping != null && !gui.getMinecraft().options.hideGui) { gui.setupOverlayRenderState(true, false); - gui.renderJumpMeter(poseStack, screenWidth / 2 - 91); + gui.renderJumpMeter(playerRideableJumping, poseStack, screenWidth / 2 - 91); } }), EXPERIENCE_BAR("experience_bar", (gui, poseStack, partialTick, screenWidth, screenHeight) -> { - if (!gui.getMinecraft().player.isRidingJumpable() && !gui.getMinecraft().options.hideGui) + if (gui.getMinecraft().player.jumpableVehicle() == null && !gui.getMinecraft().options.hideGui) { gui.setupOverlayRenderState(true, false); gui.renderExperience(screenWidth / 2 - 91, poseStack); diff --git a/src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java b/src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java index 5beb2763cf..ac7201b6f6 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java @@ -25,7 +25,12 @@ public class ExtendedButton extends Button { public ExtendedButton(int xPos, int yPos, int width, int height, Component displayString, OnPress handler) { - super(xPos, yPos, width, height, displayString, handler); + this(xPos, yPos, width, height, displayString, handler, DEFAULT_NARRATION); + } + + public ExtendedButton(int xPos, int yPos, int width, int height, Component displayString, OnPress handler, CreateNarration createNarration) + { + super(xPos, yPos, width, height, displayString, handler, createNarration); } /** @@ -36,7 +41,7 @@ public class ExtendedButton extends Button { Minecraft mc = Minecraft.getInstance(); int k = this.getYImage(this.isHovered); - ScreenUtils.blitWithBorder(poseStack, WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset()); + ScreenUtils.blitWithBorder(poseStack, WIDGETS_LOCATION, this.getX(), this.getY(), 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset()); this.renderBg(poseStack, mc, mouseX, mouseY); Component buttonText = this.getMessage(); @@ -47,6 +52,6 @@ public class ExtendedButton extends Button //TODO, srg names make it hard to figure out how to append to an ITextProperties from this trim operation, wraping this in StringTextComponent is kinda dirty. buttonText = Component.literal(mc.font.substrByWidth(buttonText, width - 6 - ellipsisWidth).getString() + "..."); - drawCenteredString(poseStack, mc.font, buttonText, this.x + this.width / 2, this.y + (this.height - 8) / 2, getFGColor()); + drawCenteredString(poseStack, mc.font, buttonText, this.getX() + this.width / 2, this.getY() + (this.height - 8) / 2, getFGColor()); } } diff --git a/src/main/java/net/minecraftforge/client/gui/widget/ForgeSlider.java b/src/main/java/net/minecraftforge/client/gui/widget/ForgeSlider.java index 0c66fd0356..4d5198ff49 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ForgeSlider.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ForgeSlider.java @@ -160,7 +160,7 @@ public class ForgeSlider extends AbstractSliderButton private void setValueFromMouse(double mouseX) { - this.setSliderValue((mouseX - (this.x + 4)) / (this.width - 8)); + this.setSliderValue((mouseX - (this.getX() + 4)) / (this.width - 8)); } /** diff --git a/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java b/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java index fd37f21400..fc20aa5a56 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java @@ -13,6 +13,7 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexFormat; +import net.minecraft.client.gui.components.Renderable; import net.minecraft.client.gui.narration.NarratableEntry; import net.minecraft.client.renderer.GameRenderer; @@ -22,13 +23,12 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiComponent; import net.minecraft.client.gui.components.events.AbstractContainerEventHandler; import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.gui.components.Widget; import net.minecraftforge.client.gui.ScreenUtils; /** * Abstract scroll panel class. */ -public abstract class ScrollPanel extends AbstractContainerEventHandler implements Widget, NarratableEntry +public abstract class ScrollPanel extends AbstractContainerEventHandler implements Renderable, NarratableEntry { private final Minecraft client; protected final int width; diff --git a/src/main/java/net/minecraftforge/client/gui/widget/UnicodeGlyphButton.java b/src/main/java/net/minecraftforge/client/gui/widget/UnicodeGlyphButton.java index 1c5a84ba8e..6efadeba9b 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/UnicodeGlyphButton.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/UnicodeGlyphButton.java @@ -34,9 +34,9 @@ public class UnicodeGlyphButton extends ExtendedButton if (this.visible) { Minecraft mc = Minecraft.getInstance(); - this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; + this.isHovered = mouseX >= this.getX() && mouseY >= this.getY() && mouseX < this.getX() + this.width && mouseY < this.getY() + this.height; int k = this.getYImage(this.isHovered); - ScreenUtils.blitWithBorder(poseStack, WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset()); + ScreenUtils.blitWithBorder(poseStack, WIDGETS_LOCATION, this.getX(), this.getY(), 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset()); this.renderBg(poseStack, mc, mouseX, mouseY); Component buttonText = this.createNarrationMessage(); @@ -54,12 +54,12 @@ public class UnicodeGlyphButton extends ExtendedButton poseStack.pushPose(); poseStack.scale(glyphScale, glyphScale, 1.0F); this.drawCenteredString(poseStack, mc.font, Component.literal(glyph), - (int) (((this.x + (this.width / 2) - (strWidth / 2)) / glyphScale) - (glyphWidth / (2 * glyphScale)) + 2), - (int) (((this.y + ((this.height - 8) / glyphScale) / 2) - 1) / glyphScale), getFGColor()); + (int) (((this.getX() + (this.width / 2) - (strWidth / 2)) / glyphScale) - (glyphWidth / (2 * glyphScale)) + 2), + (int) (((this.getY() + ((this.height - 8) / glyphScale) / 2) - 1) / glyphScale), getFGColor()); poseStack.popPose(); - this.drawCenteredString(poseStack, mc.font, buttonText, (int) (this.x + (this.width / 2) + (glyphWidth / glyphScale)), - this.y + (this.height - 8) / 2, getFGColor()); + this.drawCenteredString(poseStack, mc.font, buttonText, (int) (this.getX() + (this.width / 2) + (glyphWidth / glyphScale)), + this.getY() + (this.height - 8) / 2, getFGColor()); } } diff --git a/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java b/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java index c1be2ec31f..4da23531b6 100644 --- a/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java +++ b/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java @@ -79,7 +79,7 @@ public class ClientModLoader } } } - public static void begin(final Minecraft minecraft, final PackRepository defaultResourcePacks, final ReloadableResourceManager mcResourceManager, ClientPackSource metadataSerializer) + public static void begin(final Minecraft minecraft, final PackRepository defaultResourcePacks, final ReloadableResourceManager mcResourceManager) { // force log4j to shutdown logging in a shutdown hook. This is because we disable default shutdown hook so the server properly logs it's shutdown Runtime.getRuntime().addShutdownHook(new Thread(LogManager::shutdown)); @@ -183,31 +183,34 @@ public class ClientModLoader } private static RepositorySource buildPackFinder(Map modResourcePacks) { - return (packList, factory) -> clientPackFinder(modResourcePacks, packList, factory); + return packAcceptor -> clientPackFinder(modResourcePacks, packAcceptor); } - private static void clientPackFinder(Map modResourcePacks, Consumer consumer, Pack.PackConstructor factory) { + private static void clientPackFinder(Map modResourcePacks, Consumer packAcceptor) { List hiddenPacks = new ArrayList<>(); for (Entry e : modResourcePacks.entrySet()) { IModInfo mod = e.getKey().getModInfos().get(0); final String name = "mod:" + mod.getModId(); - final Pack packInfo = Pack.create(name, false, e::getValue, factory, Pack.Position.BOTTOM, PackSource.DEFAULT); - if (packInfo == null) { + final Pack modPack = Pack.readMetaAndCreate(name, Component.literal(e.getValue().packId()), false, id -> e.getValue(), PackType.CLIENT_RESOURCES, Pack.Position.BOTTOM, PackSource.DEFAULT); + if (modPack == null) { // Vanilla only logs an error, instead of propagating, so handle null and warn that something went wrong ModLoader.get().addWarning(new ModLoadingWarning(mod, ModLoadingStage.ERROR, "fml.modloading.brokenresources", e.getKey())); continue; } LOGGER.debug(CORE, "Generating PackInfo named {} for mod file {}", name, e.getKey().getFilePath()); if (mod.getOwningFile().showAsResourcePack()) { - consumer.accept(packInfo); + packAcceptor.accept(modPack); } else { hiddenPacks.add(e.getValue()); } } - final Pack packInfo = Pack.create("mod_resources", true, () -> new DelegatingPackResources("mod_resources", "Mod Resources", - new PackMetadataSection(Component.translatable("fml.resources.modresources", hiddenPacks.size()), PackType.CLIENT_RESOURCES.getVersion(SharedConstants.getCurrentVersion())), - hiddenPacks), factory, Pack.Position.BOTTOM, PackSource.DEFAULT); - consumer.accept(packInfo); + + // Create a resource pack merging all mod resources that should be hidden + final Pack modResourcesPack = Pack.readMetaAndCreate("mod_resources", Component.literal("Mod Resources"), true, + id -> new DelegatingPackResources(id, false, new PackMetadataSection(Component.translatable("fml.resources.modresources", hiddenPacks.size()), + PackType.CLIENT_RESOURCES.getVersion(SharedConstants.getCurrentVersion())), hiddenPacks), + PackType.CLIENT_RESOURCES, Pack.Position.BOTTOM, PackSource.DEFAULT); + packAcceptor.accept(modResourcesPack); } } diff --git a/src/main/java/net/minecraftforge/client/model/CompositeModel.java b/src/main/java/net/minecraftforge/client/model/CompositeModel.java index 3415f7f72e..d2e268f4ac 100644 --- a/src/main/java/net/minecraftforge/client/model/CompositeModel.java +++ b/src/main/java/net/minecraftforge/client/model/CompositeModel.java @@ -11,7 +11,15 @@ import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; -import com.mojang.datafixers.util.Pair; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.function.Function; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BlockModel; @@ -20,9 +28,8 @@ import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.Material; -import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelState; -import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; @@ -43,17 +50,6 @@ import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.IdentityHashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.function.Function; - /** * A model composed of several named children. *

@@ -81,7 +77,7 @@ public class CompositeModel implements IUnbakedGeometry } @Override - public BakedModel bake(IGeometryBakingContext context, ModelBakery bakery, Function spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) { if (logWarning) LOGGER.warn("Model \"" + modelLocation + "\" is using the deprecated \"parts\" field in its composite model instead of \"children\". This field will be removed in 1.20."); @@ -100,7 +96,7 @@ public class CompositeModel implements IUnbakedGeometry if (!context.isComponentVisible(name, true)) continue; var model = entry.getValue(); - bakedPartsBuilder.put(name, model.bake(bakery, model, spriteGetter, modelState, modelLocation, true)); + bakedPartsBuilder.put(name, model.bake(baker, model, spriteGetter, modelState, modelLocation, true)); } var bakedParts = bakedPartsBuilder.build(); @@ -116,17 +112,6 @@ public class CompositeModel implements IUnbakedGeometry return new Baked(context.isGui3d(), context.useBlockLight(), context.useAmbientOcclusion(), particle, context.getTransforms(), overrides, bakedParts, itemPassesBuilder.build()); } - @Override - public Collection getMaterials(IGeometryBakingContext context, Function modelGetter, Set> missingTextureErrors) - { - Set textures = new HashSet<>(); - if (context.hasMaterial("particle")) - textures.add(context.getMaterial("particle")); - for (BlockModel part : children.values()) - textures.addAll(part.getMaterials(modelGetter, missingTextureErrors)); - return textures; - } - @Override public Set getConfigurableComponentNames() { diff --git a/src/main/java/net/minecraftforge/client/model/DynamicFluidContainerModel.java b/src/main/java/net/minecraftforge/client/model/DynamicFluidContainerModel.java index f0a23682c2..59c5efb97f 100644 --- a/src/main/java/net/minecraftforge/client/model/DynamicFluidContainerModel.java +++ b/src/main/java/net/minecraftforge/client/model/DynamicFluidContainerModel.java @@ -11,9 +11,7 @@ import com.google.common.collect.Sets; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.mojang.datafixers.util.Pair; -import com.mojang.math.Quaternion; import com.mojang.math.Transformation; -import com.mojang.math.Vector3f; import net.minecraft.client.color.item.ItemColor; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.RenderType; @@ -22,7 +20,7 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.BlockModelRotation; import net.minecraft.client.resources.model.Material; -import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelState; import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.resources.ResourceLocation; @@ -46,6 +44,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.joml.Quaternionf; +import org.joml.Vector3f; import java.util.Collection; import java.util.Map; @@ -67,8 +67,8 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) { if (deprecatedLoader) LOGGER.warn("Model \"" + modelLocation + "\" is using the deprecated loader \"forge:bucket\" instead of \"forge:fluid_container\". This loader will be removed in 1.20."); @@ -134,19 +134,19 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry baseSprite, modelState, modelLocation); modelBuilder.addQuads(normalRenderTypes, quads); } @@ -158,7 +158,7 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry fluidSprite, transformedState, modelLocation); // Bake with fluid texture var emissive = applyFluidLuminosity && fluid.getFluidType().getLightLevel() > 0; @@ -176,7 +176,7 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry sprite, transformedState, modelLocation); // Bake with selected texture modelBuilder.addQuads(normalRenderTypes, quads); } @@ -187,17 +187,6 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry getMaterials(IGeometryBakingContext context, Function modelGetter, Set> missingTextureErrors) - { - Set textures = Sets.newHashSet(); - if (context.hasMaterial("particle")) textures.add(context.getMaterial("particle")); - if (context.hasMaterial("base")) textures.add(context.getMaterial("base")); - if (context.hasMaterial("fluid")) textures.add(context.getMaterial("fluid")); - if (context.hasMaterial("cover")) textures.add(context.getMaterial("cover")); - return textures; - } - public static final class Loader implements IGeometryLoader { public static final Loader INSTANCE = new Loader(false); @@ -252,14 +241,14 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry cache = Maps.newHashMap(); // contains all the baked models since they'll never change private final ItemOverrides nested; - private final ModelBakery bakery; + private final ModelBaker baker; private final IGeometryBakingContext owner; private final DynamicFluidContainerModel parent; - private ContainedFluidOverrideHandler(ItemOverrides nested, ModelBakery bakery, IGeometryBakingContext owner, DynamicFluidContainerModel parent) + private ContainedFluidOverrideHandler(ItemOverrides nested, ModelBaker baker, IGeometryBakingContext owner, DynamicFluidContainerModel parent) { this.nested = nested; - this.bakery = bakery; + this.baker = baker; this.owner = owner; this.parent = parent; } @@ -277,7 +266,7 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry } @Override - protected void addQuads(IGeometryBakingContext context, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, ModelState modelState, ResourceLocation modelLocation) + protected void addQuads(IGeometryBakingContext context, IModelBuilder modelBuilder, ModelBaker baker, Function spriteGetter, ModelState modelState, ResourceLocation modelLocation) { if (deprecatedLoader) LOGGER.warn("Model \"" + modelLocation + "\" is using the deprecated loader \"minecraft:elements\" instead of \"forge:elements\". This loader will be removed in 1.20."); @@ -85,26 +84,6 @@ public class ElementsModel extends SimpleUnbakedGeometry } } - @Override - public Collection getMaterials(IGeometryBakingContext context, Function modelGetter, Set> missingTextureErrors) - { - Set textures = Sets.newHashSet(); - if (context.hasMaterial("particle")) - textures.add(context.getMaterial("particle")); - for (BlockElement part : elements) - { - for (BlockElementFace face : part.faces.values()) - { - Material texture = context.getMaterial(face.texture); - if (texture.texture().equals(MissingTextureAtlasSprite.getLocation())) - missingTextureErrors.add(Pair.of(face.texture, context.getModelName())); - textures.add(texture); - } - } - - return textures; - } - public static final class Loader implements IGeometryLoader { public static final Loader INSTANCE = new Loader(false); diff --git a/src/main/java/net/minecraftforge/client/model/EmptyModel.java b/src/main/java/net/minecraftforge/client/model/EmptyModel.java index f77d9c3181..cf87096f3a 100644 --- a/src/main/java/net/minecraftforge/client/model/EmptyModel.java +++ b/src/main/java/net/minecraftforge/client/model/EmptyModel.java @@ -6,6 +6,11 @@ package net.minecraftforge.client.model; import com.mojang.datafixers.util.Pair; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; import net.minecraft.client.renderer.block.model.ItemOverrides; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; @@ -13,7 +18,7 @@ import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.Material; -import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelState; import net.minecraft.client.resources.model.SimpleBakedModel; import net.minecraft.client.resources.model.UnbakedModel; @@ -25,12 +30,6 @@ import net.minecraftforge.client.model.geometry.IUnbakedGeometry; import net.minecraftforge.client.model.geometry.SimpleUnbakedGeometry; import net.minecraftforge.client.textures.UnitTextureAtlasSprite; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; - /** * A completely empty model with no quads or texture dependencies. *

@@ -47,23 +46,17 @@ public class EmptyModel extends SimpleUnbakedGeometry } @Override - protected void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) + protected void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBaker baker, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) { // NO-OP } @Override - public BakedModel bake(IGeometryBakingContext context, ModelBakery bakery, Function spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) { return BAKED; } - @Override - public Collection getMaterials(IGeometryBakingContext context, Function modelGetter, Set> missingTextureErrors) - { - return List.of(); // NO-OP - } - private static class Baked extends SimpleBakedModel { private static final Material MISSING_TEXTURE = new Material(TextureAtlas.LOCATION_BLOCKS, MissingTextureAtlasSprite.getLocation()); diff --git a/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java b/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java index 1ae76fd56a..42010da45d 100644 --- a/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java +++ b/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java @@ -21,7 +21,7 @@ import net.minecraft.client.renderer.block.model.ItemOverrides; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.Material; -import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelState; import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.resources.ResourceLocation; @@ -71,10 +71,18 @@ public class ItemLayerModel implements IUnbakedGeometry } @Override - public BakedModel bake(IGeometryBakingContext context, ModelBakery bakery, Function spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) { - if (textures == null) - throw new IllegalStateException("Textures have not been initialized. Either pass them in through the constructor or call getMaterials(...) first."); + if (textures == null) { + ImmutableList.Builder builder = ImmutableList.builder(); + if (context.hasMaterial("particle")) + builder.add(context.getMaterial("particle")); + for (int i = 0; context.hasMaterial("layer" + i); i++) + { + builder.add(context.getMaterial("layer" + i)); + } + textures = builder.build(); + } if (deprecatedLoader) LOGGER.warn("Model \"" + modelLocation + "\" is using the deprecated loader \"forge:item-layers\" instead of \"forge:item_layers\". This loader will be removed in 1.20."); @@ -93,7 +101,7 @@ public class ItemLayerModel implements IUnbakedGeometry for (int i = 0; i < textures.size(); i++) { TextureAtlasSprite sprite = spriteGetter.apply(textures.get(i)); - var unbaked = UnbakedGeometryHelper.createUnbakedItemElements(i, sprite); + var unbaked = UnbakedGeometryHelper.createUnbakedItemElements(i, sprite.contents()); var quads = UnbakedGeometryHelper.bakeElements(unbaked, $ -> sprite, modelState, modelLocation); if (emissiveLayers.contains(i)) QuadTransformers.settingMaxEmissivity().processInPlace(quads); var renderTypeName = renderTypeNames.get(i); @@ -104,22 +112,6 @@ public class ItemLayerModel implements IUnbakedGeometry return builder.build(); } - @Override - public Collection getMaterials(IGeometryBakingContext context, Function modelGetter, Set> missingTextureErrors) - { - if (textures != null) - return textures; - - ImmutableList.Builder builder = ImmutableList.builder(); - if (context.hasMaterial("particle")) - builder.add(context.getMaterial("particle")); - for (int i = 0; context.hasMaterial("layer" + i); i++) - { - builder.add(context.getMaterial("layer" + i)); - } - return textures = builder.build(); - } - public static final class Loader implements IGeometryLoader { public static final Loader INSTANCE = new Loader(false); diff --git a/src/main/java/net/minecraftforge/client/model/QuadTransformers.java b/src/main/java/net/minecraftforge/client/model/QuadTransformers.java index b413738b58..0a004fbed4 100644 --- a/src/main/java/net/minecraftforge/client/model/QuadTransformers.java +++ b/src/main/java/net/minecraftforge/client/model/QuadTransformers.java @@ -7,11 +7,11 @@ package net.minecraftforge.client.model; import com.google.common.base.Preconditions; import com.mojang.math.Transformation; -import com.mojang.math.Vector3f; -import com.mojang.math.Vector4f; import net.minecraft.Util; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.block.model.BakedQuad; +import org.joml.Vector3f; +import org.joml.Vector4f; import java.util.Arrays; @@ -53,7 +53,7 @@ public final class QuadTransformers { Vector4f pos = new Vector4f(x, y, z, 1); transform.transformPosition(pos); - pos.perspectiveDivide(); + pos.div(pos.w); vertices[offset] = Float.floatToRawIntBits(pos.x()); vertices[offset + 1] = Float.floatToRawIntBits(pos.y()); diff --git a/src/main/java/net/minecraftforge/client/model/SeparateTransformsModel.java b/src/main/java/net/minecraftforge/client/model/SeparateTransformsModel.java index 291eed28b9..d1b513c907 100644 --- a/src/main/java/net/minecraftforge/client/model/SeparateTransformsModel.java +++ b/src/main/java/net/minecraftforge/client/model/SeparateTransformsModel.java @@ -7,11 +7,13 @@ package net.minecraftforge.client.model; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.datafixers.util.Pair; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BlockModel; @@ -20,9 +22,8 @@ import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.Material; -import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelState; -import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.GsonHelper; @@ -38,13 +39,6 @@ import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; - /** * A model composed of multiple sub-models which are picked based on the {@link ItemTransforms.TransformType} being used. */ @@ -69,7 +63,7 @@ public class SeparateTransformsModel implements IUnbakedGeometry spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) { if (deprecatedLoader) LOGGER.warn("Model \"" + modelLocation + "\" is using the deprecated loader \"forge:separate-perspective\" instead of \"forge:separate_transforms\". This loader will be removed in 1.20."); @@ -77,25 +71,13 @@ public class SeparateTransformsModel implements IUnbakedGeometry { - return value.bake(bakery, value, spriteGetter, modelState, modelLocation, context.useBlockLight()); + return value.bake(baker, value, spriteGetter, modelState, modelLocation, context.useBlockLight()); })) ); } - @Override - public Collection getMaterials(IGeometryBakingContext context, Function modelGetter, Set> missingTextureErrors) - { - Set textures = Sets.newHashSet(); - if (context.hasMaterial("particle")) - textures.add(context.getMaterial("particle")); - textures.addAll(baseModel.getMaterials(modelGetter, missingTextureErrors)); - for (BlockModel model : perspectives.values()) - textures.addAll(model.getMaterials(modelGetter, missingTextureErrors)); - return textures; - } - public static class Baked implements IDynamicBakedModel { private final boolean isAmbientOcclusion; diff --git a/src/main/java/net/minecraftforge/client/model/generators/BlockModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/BlockModelBuilder.java index ea14af72c3..6269a8eee6 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/BlockModelBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/BlockModelBuilder.java @@ -8,20 +8,21 @@ package net.minecraftforge.client.model.generators; import com.google.common.base.Preconditions; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import com.mojang.math.Quaternion; import com.mojang.math.Transformation; -import com.mojang.math.Vector3f; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.StringRepresentable; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.common.util.TransformationHelper; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.joml.Quaternionf; +import org.joml.Vector3f; /** * Builder for block models, does not currently provide any additional * functionality over {@link ModelBuilder}, purely a stub class with a concrete * generic. - * + * * @see ModelProvider * @see ModelBuilder */ @@ -58,9 +59,9 @@ public class BlockModelBuilder extends ModelBuilder { private static final Vector3f ONE = new Vector3f(1, 1, 1); - private Vector3f translation = Vector3f.ZERO; - private Quaternion leftRotation = Quaternion.ONE.copy(); - private Quaternion rightRotation = Quaternion.ONE.copy(); + private Vector3f translation = new Vector3f(); + private Quaternionf leftRotation = new Quaternionf(); + private Quaternionf rightRotation = new Quaternionf(); private Vector3f scale = ONE; private @Nullable TransformOrigin origin; @@ -103,7 +104,7 @@ public class BlockModelBuilder extends ModelBuilder * @return this builder * @throws NullPointerException if {@code rotation} is {@code null} */ - public RootTransformBuilder rotation(Quaternion rotation) + public RootTransformBuilder rotation(Quaternionf rotation) { this.leftRotation = Preconditions.checkNotNull(rotation, "Rotation must not be null"); return this; @@ -120,7 +121,7 @@ public class BlockModelBuilder extends ModelBuilder */ public RootTransformBuilder rotation(float x, float y, float z, boolean isDegrees) { - return rotation(new Quaternion(x, y, z, isDegrees)); + return rotation(TransformationHelper.quatFromXYZ(x, y, z, isDegrees)); } /** @@ -130,7 +131,7 @@ public class BlockModelBuilder extends ModelBuilder * @return this builder * @throws NullPointerException if {@code leftRotation} is {@code null} */ - public RootTransformBuilder leftRotation(Quaternion leftRotation) + public RootTransformBuilder leftRotation(Quaternionf leftRotation) { return rotation(leftRotation); } @@ -146,7 +147,7 @@ public class BlockModelBuilder extends ModelBuilder */ public RootTransformBuilder leftRotation(float x, float y, float z, boolean isDegrees) { - return leftRotation(new Quaternion(x, y, z, isDegrees)); + return leftRotation(TransformationHelper.quatFromXYZ(x, y, z, isDegrees)); } /** @@ -156,7 +157,7 @@ public class BlockModelBuilder extends ModelBuilder * @return this builder * @throws NullPointerException if {@code rightRotation} is {@code null} */ - public RootTransformBuilder rightRotation(Quaternion rightRotation) + public RootTransformBuilder rightRotation(Quaternionf rightRotation) { this.rightRotation = Preconditions.checkNotNull(rightRotation, "Rotation must not be null"); return this; @@ -173,7 +174,7 @@ public class BlockModelBuilder extends ModelBuilder */ public RootTransformBuilder rightRotation(float x, float y, float z, boolean isDegrees) { - return rightRotation(new Quaternion(x, y, z, isDegrees)); + return rightRotation(TransformationHelper.quatFromXYZ(x, y, z, isDegrees)); } /** @@ -183,7 +184,7 @@ public class BlockModelBuilder extends ModelBuilder * @return this builder * @throws NullPointerException if {@code rightRotation} is {@code null} */ - public RootTransformBuilder postRotation(Quaternion postRotation) + public RootTransformBuilder postRotation(Quaternionf postRotation) { return rightRotation(postRotation); } @@ -199,7 +200,7 @@ public class BlockModelBuilder extends ModelBuilder */ public RootTransformBuilder postRotation(float x, float y, float z, boolean isDegrees) { - return postRotation(new Quaternion(x, y, z, isDegrees)); + return postRotation(TransformationHelper.quatFromXYZ(x, y, z, isDegrees)); } /** @@ -299,7 +300,7 @@ public class BlockModelBuilder extends ModelBuilder // Write the transform to an object JsonObject transform = new JsonObject(); - if (!translation.equals(Vector3f.ZERO)) + if (!translation.equals(0, 0, 0)) { transform.add("translation", writeVec3(translation)); } @@ -309,12 +310,12 @@ public class BlockModelBuilder extends ModelBuilder transform.add("scale", writeVec3(scale)); } - if (!leftRotation.equals(Quaternion.ONE)) + if (!leftRotation.equals(0, 0, 0, 1)) { transform.add("rotation", writeQuaternion(leftRotation)); } - if (!rightRotation.equals(Quaternion.ONE)) + if (!rightRotation.equals(0, 0, 0, 1)) { transform.add("post_rotation", writeQuaternion(rightRotation)); } @@ -323,7 +324,7 @@ public class BlockModelBuilder extends ModelBuilder { transform.addProperty("origin", origin.getSerializedName()); } - else if (originVec != null && !originVec.equals(Vector3f.ZERO)) + else if (originVec != null && !originVec.equals(0, 0, 0)) { transform.add("origin", writeVec3(originVec)); } @@ -334,7 +335,7 @@ public class BlockModelBuilder extends ModelBuilder public enum TransformOrigin implements StringRepresentable { CENTER(new Vector3f(.5f, .5f, .5f), "center"), - CORNER(Vector3f.ZERO, "corner"), + CORNER(new Vector3f(), "corner"), OPPOSING_CORNER(ONE, "opposing-corner"); private final Vector3f vec; @@ -385,13 +386,13 @@ public class BlockModelBuilder extends ModelBuilder return array; } - private JsonArray writeQuaternion(Quaternion quaternion) + private JsonArray writeQuaternion(Quaternionf quaternion) { JsonArray array = new JsonArray(); - array.add(quaternion.i()); - array.add(quaternion.j()); - array.add(quaternion.k()); - array.add(quaternion.r()); + array.add(quaternion.x()); + array.add(quaternion.y()); + array.add(quaternion.z()); + array.add(quaternion.w()); return array; } } diff --git a/src/main/java/net/minecraftforge/client/model/generators/BlockStateProvider.java b/src/main/java/net/minecraftforge/client/model/generators/BlockStateProvider.java index aaaad5032a..621cf28706 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/BlockStateProvider.java +++ b/src/main/java/net/minecraftforge/client/model/generators/BlockStateProvider.java @@ -5,23 +5,6 @@ package net.minecraftforge.client.model.generators; -import java.io.IOException; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - -import net.minecraft.data.CachedOutput; -import net.minecraft.world.level.block.ButtonBlock; -import net.minecraft.world.level.block.PressurePlateBlock; -import net.minecraft.world.level.block.StandingSignBlock; -import net.minecraft.world.level.block.WallSignBlock; -import net.minecraftforge.registries.ForgeRegistries; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -31,35 +14,51 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; - +import java.io.IOException; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.data.CachedOutput; +import net.minecraft.data.DataGenerator; +import net.minecraft.data.DataProvider; +import net.minecraft.data.PackOutput; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.ButtonBlock; +import net.minecraft.world.level.block.CrossCollisionBlock; import net.minecraft.world.level.block.DoorBlock; import net.minecraft.world.level.block.FenceBlock; import net.minecraft.world.level.block.FenceGateBlock; -import net.minecraft.world.level.block.CrossCollisionBlock; import net.minecraft.world.level.block.IronBarsBlock; -import net.minecraft.world.level.block.RotatedPillarBlock; import net.minecraft.world.level.block.PipeBlock; +import net.minecraft.world.level.block.PressurePlateBlock; +import net.minecraft.world.level.block.RotatedPillarBlock; import net.minecraft.world.level.block.SlabBlock; import net.minecraft.world.level.block.StairBlock; +import net.minecraft.world.level.block.StandingSignBlock; import net.minecraft.world.level.block.TrapDoorBlock; import net.minecraft.world.level.block.WallBlock; -import net.minecraft.world.level.block.state.properties.WallSide; -import net.minecraft.data.DataGenerator; -import net.minecraft.data.DataProvider; -import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.WallSignBlock; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.AttachFace; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.DoorHingeSide; import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; import net.minecraft.world.level.block.state.properties.Half; +import net.minecraft.world.level.block.state.properties.Property; import net.minecraft.world.level.block.state.properties.SlabType; import net.minecraft.world.level.block.state.properties.StairsShape; -import net.minecraft.core.Direction; -import net.minecraft.core.Direction.Axis; +import net.minecraft.world.level.block.state.properties.WallSide; import net.minecraftforge.common.data.ExistingFileHelper; -import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.registries.ForgeRegistries; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; /** @@ -83,28 +82,31 @@ public abstract class BlockStateProvider implements DataProvider { this.generator = gen; this.modid = modid; this.blockModels = new BlockModelProvider(gen, modid, exFileHelper) { - @Override public void run(CachedOutput p_236071_) throws IOException {} + @Override public CompletableFuture run(CachedOutput cache) { return CompletableFuture.allOf(); } @Override protected void registerModels() {} }; this.itemModels = new ItemModelProvider(gen, modid, this.blockModels.existingFileHelper) { @Override protected void registerModels() {} - @Override public void run(CachedOutput p_236071_) throws IOException {} + @Override public CompletableFuture run(CachedOutput cache) { return CompletableFuture.allOf(); } }; } @Override - public void run(CachedOutput cache) throws IOException { + public CompletableFuture run(CachedOutput cache) { models().clear(); itemModels().clear(); registeredBlocks.clear(); registerStatesAndModels(); models().generateAll(cache); itemModels().generateAll(cache); + CompletableFuture[] futures = new CompletableFuture[this.registeredBlocks.size()]; + int i = 0; for (Map.Entry entry : registeredBlocks.entrySet()) { - saveBlockState(cache, entry.getValue().toJson(), entry.getKey()); + futures[i++] = saveBlockState(cache, entry.getValue().toJson(), entry.getKey()); } + return CompletableFuture.allOf(futures); } protected abstract void registerStatesAndModels(); @@ -853,16 +855,11 @@ public abstract class BlockStateProvider implements DataProvider { }, TrapDoorBlock.POWERED, TrapDoorBlock.WATERLOGGED); } - private void saveBlockState(CachedOutput cache, JsonObject stateJson, Block owner) { + private CompletableFuture saveBlockState(CachedOutput cache, JsonObject stateJson, Block owner) { ResourceLocation blockName = Preconditions.checkNotNull(key(owner)); - Path mainOutput = generator.getOutputFolder(); - String pathSuffix = "assets/" + blockName.getNamespace() + "/blockstates/" + blockName.getPath() + ".json"; - Path outputPath = mainOutput.resolve(pathSuffix); - try { - DataProvider.saveStable(cache, stateJson, outputPath); - } catch (IOException e) { - LOGGER.error("Couldn't save blockstate to {}", outputPath, e); - } + Path outputPath = this.generator.getPackOutput().getOutputFolder(PackOutput.Target.RESOURCE_PACK) + .resolve(blockName.getNamespace()).resolve("blockstates").resolve(blockName.getPath() + ".json"); + return DataProvider.saveStable(cache, stateJson, outputPath); } @NotNull diff --git a/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java index bbd9e564bf..a5de22e450 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java @@ -32,9 +32,9 @@ import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; -import com.mojang.math.Vector3f; import net.minecraftforge.common.data.ExistingFileHelper; import org.jetbrains.annotations.Nullable; +import org.joml.Vector3f; /** * General purpose model builder, contains all the commonalities between item @@ -285,11 +285,11 @@ public class ModelBuilder> extends ModelFile { if (part.rotation != null) { JsonObject rotation = new JsonObject(); - rotation.add("origin", serializeVector3f(part.rotation.origin)); - rotation.addProperty("axis", part.rotation.axis.getSerializedName()); - rotation.addProperty("angle", part.rotation.angle); - if (part.rotation.rescale) { - rotation.addProperty("rescale", part.rotation.rescale); + rotation.add("origin", serializeVector3f(part.rotation.origin())); + rotation.addProperty("axis", part.rotation.axis().getSerializedName()); + rotation.addProperty("angle", part.rotation.angle()); + if (part.rotation.rescale()) { + rotation.addProperty("rescale", part.rotation.rescale()); } partObj.add("rotation", rotation); } @@ -695,10 +695,10 @@ public class ModelBuilder> extends ModelFile { public class TransformVecBuilder { - private Vector3f rotation = ItemTransform.Deserializer.DEFAULT_ROTATION.copy(); - private Vector3f translation = ItemTransform.Deserializer.DEFAULT_TRANSLATION.copy(); - private Vector3f scale = ItemTransform.Deserializer.DEFAULT_SCALE.copy(); - private Vector3f rightRotation = ItemTransform.Deserializer.DEFAULT_ROTATION.copy(); + private Vector3f rotation = new Vector3f(ItemTransform.Deserializer.DEFAULT_ROTATION); + private Vector3f translation = new Vector3f(ItemTransform.Deserializer.DEFAULT_TRANSLATION); + private Vector3f scale = new Vector3f(ItemTransform.Deserializer.DEFAULT_SCALE); + private Vector3f rightRotation = new Vector3f(ItemTransform.Deserializer.DEFAULT_ROTATION); TransformVecBuilder(TransformType type) { // param unused for functional match diff --git a/src/main/java/net/minecraftforge/client/model/generators/ModelProvider.java b/src/main/java/net/minecraftforge/client/model/generators/ModelProvider.java index 8bdc3a6f77..fdafad5eb6 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/ModelProvider.java +++ b/src/main/java/net/minecraftforge/client/model/generators/ModelProvider.java @@ -5,24 +5,22 @@ package net.minecraftforge.client.model.generators; -import java.io.IOException; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.Map; -import java.util.function.BiFunction; -import java.util.function.Function; - import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.gson.Gson; import com.google.gson.GsonBuilder; - +import java.nio.file.Path; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.function.BiFunction; +import java.util.function.Function; import net.minecraft.data.CachedOutput; import net.minecraft.data.DataGenerator; -import net.minecraft.data.HashCache; import net.minecraft.data.DataProvider; -import net.minecraft.server.packs.PackType; +import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.PackType; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.common.data.ExistingFileHelper.ResourceType; @@ -262,7 +260,7 @@ public abstract class ModelProvider> implements DataPr public T wallSide(String name, ResourceLocation wall) { return singleTexture(name, BLOCK_FOLDER + "/template_wall_side", "wall", wall); } - + public T wallSideTall(String name, ResourceLocation wall) { return singleTexture(name, BLOCK_FOLDER + "/template_wall_side_tall", "wall", wall); } @@ -384,31 +382,32 @@ public abstract class ModelProvider> implements DataPr ret.assertExistence(); return ret; } - + protected void clear() { generatedModels.clear(); } @Override - public void run(CachedOutput cache) throws IOException { + public CompletableFuture run(CachedOutput cache) { clear(); registerModels(); - generateAll(cache); + return generateAll(cache); } - protected void generateAll(CachedOutput cache) { - for (T model : generatedModels.values()) { + protected CompletableFuture generateAll(CachedOutput cache) { + CompletableFuture[] futures = new CompletableFuture[this.generatedModels.size()]; + int i = 0; + + for (T model : this.generatedModels.values()) { Path target = getPath(model); - try { - DataProvider.saveStable(cache, model.toJson(), target); - } catch (IOException e) { - throw new RuntimeException(e); - } + futures[i++] = DataProvider.saveStable(cache, model.toJson(), target); } + + return CompletableFuture.allOf(futures); } - private Path getPath(T model) { + protected Path getPath(T model) { ResourceLocation loc = model.getLocation(); - return generator.getOutputFolder().resolve("assets/" + loc.getNamespace() + "/models/" + loc.getPath() + ".json"); + return this.generator.getPackOutput().getOutputFolder(PackOutput.Target.RESOURCE_PACK).resolve(loc.getNamespace()).resolve("models").resolve(loc.getPath() + ".json"); } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/model/geometry/BlockGeometryBakingContext.java b/src/main/java/net/minecraftforge/client/model/geometry/BlockGeometryBakingContext.java index 37c003a537..948d6b4120 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/BlockGeometryBakingContext.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/BlockGeometryBakingContext.java @@ -7,25 +7,24 @@ package net.minecraftforge.client.model.geometry; import com.mojang.datafixers.util.Pair; import com.mojang.math.Transformation; -import net.minecraft.client.renderer.block.model.BlockModel; -import net.minecraft.client.renderer.block.model.ItemOverrides; -import net.minecraft.client.renderer.block.model.ItemTransforms; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.client.resources.model.Material; -import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelState; -import net.minecraft.client.resources.model.UnbakedModel; -import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; - import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.function.Function; +import net.minecraft.client.renderer.block.model.BlockModel; +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBaker; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; /** * A {@linkplain IGeometryBakingContext geometry baking context} that is bound to a {@link BlockModel}. @@ -150,19 +149,12 @@ public class BlockGeometryBakingContext implements IGeometryBakingContext this.renderTypeHint = other.renderTypeHint; } - public Collection getTextureDependencies(Function modelGetter, Set> missingTextureErrors) - { - IUnbakedGeometry geometry = getCustomGeometry(); - return geometry == null ? Collections.emptySet() : - geometry.getMaterials(this, modelGetter, missingTextureErrors); - } - - public BakedModel bake(ModelBakery bakery, Function bakedTextureGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation) + public BakedModel bake(ModelBaker baker, Function bakedTextureGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation) { IUnbakedGeometry geometry = getCustomGeometry(); if (geometry == null) throw new IllegalStateException("Can not use custom baking without custom geometry"); - return geometry.bake(this, bakery, bakedTextureGetter, modelTransform, overrides, modelLocation); + return geometry.bake(this, baker, bakedTextureGetter, modelTransform, overrides, modelLocation); } public static class VisibilityData diff --git a/src/main/java/net/minecraftforge/client/model/geometry/IUnbakedGeometry.java b/src/main/java/net/minecraftforge/client/model/geometry/IUnbakedGeometry.java index 78bdb56114..a6ea924fe8 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/IUnbakedGeometry.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/IUnbakedGeometry.java @@ -5,20 +5,17 @@ package net.minecraftforge.client.model.geometry; -import com.mojang.datafixers.util.Pair; +import java.util.Set; +import java.util.function.Function; import net.minecraft.client.renderer.block.model.ItemOverrides; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.Material; -import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelState; import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.resources.ResourceLocation; -import java.util.Collection; -import java.util.Set; -import java.util.function.Function; - /** * General interface for any model that can be baked, superset of vanilla {@link UnbakedModel}. *

@@ -29,9 +26,7 @@ import java.util.function.Function; */ public interface IUnbakedGeometry> { - BakedModel bake(IGeometryBakingContext context, ModelBakery bakery, Function spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation); - - Collection getMaterials(IGeometryBakingContext context, Function modelGetter, Set> missingTextureErrors); + BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation); /** * {@return a set of all the components whose visibility may be configured via {@link IGeometryBakingContext}} diff --git a/src/main/java/net/minecraftforge/client/model/geometry/SimpleUnbakedGeometry.java b/src/main/java/net/minecraftforge/client/model/geometry/SimpleUnbakedGeometry.java index 5a73213363..d178b9813f 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/SimpleUnbakedGeometry.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/SimpleUnbakedGeometry.java @@ -5,23 +5,18 @@ package net.minecraftforge.client.model.geometry; -import com.mojang.datafixers.util.Pair; +import java.util.function.Function; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.ItemOverrides; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.Material; -import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelState; -import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.RenderTypeGroup; import net.minecraftforge.client.model.IModelBuilder; -import java.util.Collection; -import java.util.Set; -import java.util.function.Function; - /** * Base class for implementations of {@link IUnbakedGeometry} which do not wish to handle model creation themselves, * instead supplying {@linkplain BakedQuad baked quads} through a builder. @@ -29,7 +24,7 @@ import java.util.function.Function; public abstract class SimpleUnbakedGeometry> implements IUnbakedGeometry { @Override - public BakedModel bake(IGeometryBakingContext context, ModelBakery bakery, Function spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) { TextureAtlasSprite particle = spriteGetter.apply(context.getMaterial("particle")); @@ -38,13 +33,10 @@ public abstract class SimpleUnbakedGeometry> IModelBuilder builder = IModelBuilder.of(context.useAmbientOcclusion(), context.useBlockLight(), context.isGui3d(), context.getTransforms(), overrides, particle, renderTypes); - addQuads(context, builder, bakery, spriteGetter, modelState, modelLocation); + addQuads(context, builder, baker, spriteGetter, modelState, modelLocation); return builder.build(); } - protected abstract void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation); - - @Override - public abstract Collection getMaterials(IGeometryBakingContext context, Function modelGetter, Set> missingTextureErrors); + protected abstract void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBaker baker, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation); } diff --git a/src/main/java/net/minecraftforge/client/model/geometry/UnbakedGeometryHelper.java b/src/main/java/net/minecraftforge/client/model/geometry/UnbakedGeometryHelper.java index 8a2ebab11e..0ae7202efc 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/UnbakedGeometryHelper.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/UnbakedGeometryHelper.java @@ -6,7 +6,6 @@ package net.minecraftforge.client.model.geometry; import com.mojang.math.Transformation; -import com.mojang.math.Vector3f; import net.minecraft.Util; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BlockElement; @@ -16,11 +15,13 @@ import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.FaceBakery; import net.minecraft.client.renderer.block.model.ItemModelGenerator; import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; +import net.minecraft.client.renderer.texture.SpriteContents; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.BuiltInModel; import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelState; import net.minecraft.core.Direction; @@ -30,6 +31,7 @@ import net.minecraftforge.client.model.IModelBuilder; import net.minecraftforge.client.model.SimpleModelState; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import org.joml.Vector3f; import java.util.ArrayList; import java.util.BitSet; @@ -93,17 +95,17 @@ public class UnbakedGeometryHelper * Helper for baking {@link BlockModel} instances. Handles baking custom geometries and deferring item model baking. */ @ApiStatus.Internal - public static BakedModel bake(BlockModel blockModel, ModelBakery modelBakery, BlockModel owner, Function spriteGetter, ModelState modelState, ResourceLocation modelLocation, boolean guiLight3d) + public static BakedModel bake(BlockModel blockModel, ModelBaker modelBaker, BlockModel owner, Function spriteGetter, ModelState modelState, ResourceLocation modelLocation, boolean guiLight3d) { IUnbakedGeometry customModel = blockModel.customData.getCustomGeometry(); if (customModel != null) - return customModel.bake(blockModel.customData, modelBakery, spriteGetter, modelState, blockModel.getOverrides(modelBakery, owner, spriteGetter), modelLocation); + return customModel.bake(blockModel.customData, modelBaker, spriteGetter, modelState, blockModel.getOverrides(modelBaker, owner, spriteGetter), modelLocation); // Handle vanilla item models here, since vanilla has a shortcut for them if (blockModel.getRootModel() == ModelBakery.GENERATION_MARKER) - return ITEM_MODEL_GENERATOR.generateBlockModel(spriteGetter, blockModel).bake(modelBakery, blockModel, spriteGetter, modelState, modelLocation, guiLight3d); + return ITEM_MODEL_GENERATOR.generateBlockModel(spriteGetter, blockModel).bake(modelBaker, blockModel, spriteGetter, modelState, modelLocation, guiLight3d); - return bakeVanilla(blockModel, modelBakery, owner, spriteGetter, modelState, modelLocation); + return bakeVanilla(blockModel, modelBaker, owner, spriteGetter, modelState, modelLocation); } /** @@ -113,48 +115,48 @@ public class UnbakedGeometryHelper */ @ApiStatus.Internal @Deprecated(forRemoval = true, since = "1.19.2") - public static BakedModel bakeVanilla(BlockModel blockModel, ModelBakery modelBakery, BlockModel owner, Function spriteGetter, ModelState modelState, ResourceLocation modelLocation) + public static BakedModel bakeVanilla(BlockModel blockModel, ModelBaker modelBaker, BlockModel owner, Function spriteGetter, ModelState modelState, ResourceLocation modelLocation) { if (blockModel.getRootModel() == ModelBakery.BLOCK_ENTITY_MARKER) { var particleSprite = spriteGetter.apply(blockModel.getMaterial("particle")); - return new BuiltInModel(blockModel.getTransforms(), blockModel.getOverrides(modelBakery, owner, spriteGetter), particleSprite, blockModel.getGuiLight().lightLikeBlock()); + return new BuiltInModel(blockModel.getTransforms(), blockModel.getOverrides(modelBaker, owner, spriteGetter), particleSprite, blockModel.getGuiLight().lightLikeBlock()); } var elementsModel = new ElementsModel(blockModel.getElements()); - return elementsModel.bake(blockModel.customData, modelBakery, spriteGetter, modelState, blockModel.getOverrides(modelBakery, owner, spriteGetter), modelLocation); + return elementsModel.bake(blockModel.customData, modelBaker, spriteGetter, modelState, blockModel.getOverrides(modelBaker, owner, spriteGetter), modelLocation); } /** - * Creates a list of {@linkplain BlockElement block elements} in the shape of the specified sprite. + * Creates a list of {@linkplain BlockElement block elements} in the shape of the specified sprite contents. * These can later be baked using the same, or another texture. *

* The {@link Direction#NORTH} and {@link Direction#SOUTH} faces take up the whole surface. */ - public static List createUnbakedItemElements(int layerIndex, TextureAtlasSprite sprite) + public static List createUnbakedItemElements(int layerIndex, SpriteContents spriteContents) { - return ITEM_MODEL_GENERATOR.processFrames(layerIndex, "layer" + layerIndex, sprite); + return ITEM_MODEL_GENERATOR.processFrames(layerIndex, "layer" + layerIndex, spriteContents); } /** - * Creates a list of {@linkplain BlockElement block elements} in the shape of the specified sprite. + * Creates a list of {@linkplain BlockElement block elements} in the shape of the specified sprite contents. * These can later be baked using the same, or another texture. *

* The {@link Direction#NORTH} and {@link Direction#SOUTH} faces take up only the pixels the texture uses. */ - public static List createUnbakedItemMaskElements(int layerIndex, TextureAtlasSprite sprite) + public static List createUnbakedItemMaskElements(int layerIndex, SpriteContents spriteContents) { - var elements = createUnbakedItemElements(layerIndex, sprite); + var elements = createUnbakedItemElements(layerIndex, spriteContents); elements.remove(0); // Remove north and south faces - int width = sprite.getWidth(), height = sprite.getHeight(); + int width = spriteContents.width(), height = spriteContents.height(); var bits = new BitSet(width * height); // For every frame in the texture, mark all the opaque pixels (this is what vanilla does too) - sprite.getUniqueFrames().forEach(frame -> { + spriteContents.getUniqueFrames().forEach(frame -> { for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) - if (!sprite.isTransparent(frame, x, y)) + if (!spriteContents.isTransparent(frame, x, y)) bits.set(x + y * width); }); @@ -244,4 +246,4 @@ public class UnbakedGeometryHelper { return FACE_BAKERY.bakeQuad(element.from, element.to, face, sprite, direction, state, element.rotation, element.shade, modelLocation); } -} +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/model/lighting/QuadLighter.java b/src/main/java/net/minecraftforge/client/model/lighting/QuadLighter.java index 209d2ce6c7..3dc9d25b34 100644 --- a/src/main/java/net/minecraftforge/client/model/lighting/QuadLighter.java +++ b/src/main/java/net/minecraftforge/client/model/lighting/QuadLighter.java @@ -7,12 +7,12 @@ package net.minecraftforge.client.model.lighting; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Vector3f; import net.minecraft.client.color.block.BlockColors; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; +import org.joml.Vector3f; import java.util.Objects; diff --git a/src/main/java/net/minecraftforge/client/model/obj/ObjMaterialLibrary.java b/src/main/java/net/minecraftforge/client/model/obj/ObjMaterialLibrary.java index df967b7896..25566dfd1b 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/ObjMaterialLibrary.java +++ b/src/main/java/net/minecraftforge/client/model/obj/ObjMaterialLibrary.java @@ -6,8 +6,8 @@ package net.minecraftforge.client.model.obj; import com.google.common.collect.Maps; -import com.mojang.math.Vector4f; import joptsimple.internal.Strings; +import org.joml.Vector4f; import java.io.IOException; import java.util.Arrays; @@ -100,11 +100,11 @@ public class ObjMaterialLibrary public static class Material { public final String name; - public Vector4f ambientColor = new Vector4f(0, 0, 0, 1); + public Vector4f ambientColor = new Vector4f(); public String ambientColorMap; public Vector4f diffuseColor = new Vector4f(1, 1, 1, 1); public String diffuseColorMap; - public Vector4f specularColor = new Vector4f(0, 0, 0, 1); + public Vector4f specularColor = new Vector4f(); public float specularHighlight = 0; public String specularColorMap; diff --git a/src/main/java/net/minecraftforge/client/model/obj/ObjModel.java b/src/main/java/net/minecraftforge/client/model/obj/ObjModel.java index 96bfcfb3d3..607c8769d3 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/ObjModel.java +++ b/src/main/java/net/minecraftforge/client/model/obj/ObjModel.java @@ -9,14 +9,12 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.mojang.math.Transformation; -import com.mojang.math.Vector3f; -import com.mojang.math.Vector4f; import joptsimple.internal.Strings; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.Material; -import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelState; import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.core.Direction; @@ -35,6 +33,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.joml.Vector3f; +import org.joml.Vector4f; import java.io.IOException; import java.util.ArrayList; @@ -326,7 +326,7 @@ public class ObjModel extends SimpleUnbakedGeometry { return switch (line.length) { - case 1 -> new Vector3f(0, 0, 0); + case 1 -> new Vector3f(); case 2 -> new Vector3f(Float.parseFloat(line[1]), 0, 0); case 3 -> new Vector3f(Float.parseFloat(line[1]), Float.parseFloat(line[2]), 0); default -> new Vector3f(Float.parseFloat(line[1]), Float.parseFloat(line[2]), Float.parseFloat(line[3])); @@ -337,7 +337,7 @@ public class ObjModel extends SimpleUnbakedGeometry { return switch (line.length) { - case 1 -> new Vector4f(0, 0, 0, 1); + case 1 -> new Vector4f(); case 2 -> new Vector4f(Float.parseFloat(line[1]), 0, 0, 1); case 3 -> new Vector4f(Float.parseFloat(line[1]), Float.parseFloat(line[2]), 0, 1); case 4 -> new Vector4f(Float.parseFloat(line[1]), Float.parseFloat(line[2]), Float.parseFloat(line[3]), 1); @@ -346,22 +346,13 @@ public class ObjModel extends SimpleUnbakedGeometry } @Override - protected void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) + protected void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBaker baker, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) { for (var entry : deprecationWarnings.entrySet()) LOGGER.warn("Model \"" + modelLocation + "\" is using the deprecated \"" + entry.getKey() + "\" field in its OBJ model instead of \"" + entry.getValue() + "\". This field will be removed in 1.20."); parts.values().stream().filter(part -> owner.isComponentVisible(part.name(), true)) - .forEach(part -> part.addQuads(owner, modelBuilder, bakery, spriteGetter, modelTransform, modelLocation)); - } - - @Override - public Collection getMaterials(IGeometryBakingContext context, Function modelGetter, Set> missingTextureErrors) - { - Set combined = Sets.newHashSet(); - for (ModelGroup part : parts.values()) - combined.addAll(part.getTextures(context, modelGetter, missingTextureErrors)); - return combined; + .forEach(part -> part.addQuads(owner, modelBuilder, baker, spriteGetter, modelTransform, modelLocation)); } public Set getRootComponentNames() @@ -387,15 +378,15 @@ public class ObjModel extends SimpleUnbakedGeometry { needsNormalRecalculation |= ints.length < 3; } - Vector3f faceNormal = new Vector3f(0, 0, 0); + Vector3f faceNormal = new Vector3f(); if (needsNormalRecalculation) { Vector3f a = positions.get(indices[0][0]); Vector3f ab = positions.get(indices[1][0]); Vector3f ac = positions.get(indices[2][0]); - Vector3f abs = ab.copy(); + Vector3f abs = new Vector3f(ab); abs.sub(a); - Vector3f acs = ac.copy(); + Vector3f acs = new Vector3f(ac); acs.sub(a); abs.cross(acs); abs.normalize(); @@ -429,14 +420,14 @@ public class ObjModel extends SimpleUnbakedGeometry for (int i = 0; i < 4; i++) { int[] index = indices[Math.min(i, indices.length - 1)]; - Vector4f position = new Vector4f(positions.get(index[0])); + Vector4f position = new Vector4f(positions.get(index[0]), 1); Vec2 texCoord = index.length >= 2 && texCoords.size() > 0 ? texCoords.get(index[1]) : DEFAULT_COORDS[i]; Vector3f norm0 = !needsNormalRecalculation && index.length >= 3 && normals.size() > 0 ? normals.get(index[2]) : faceNormal; Vector3f normal = norm0; Vector4f color = index.length >= 4 && colors.size() > 0 ? colors.get(index[3]) : COLOR_WHITE; if (hasTransform) { - normal = norm0.copy(); + normal = new Vector3f(norm0); transformation.transformPosition(position); transformation.transformNormal(normal); } @@ -548,7 +539,7 @@ public class ObjModel extends SimpleUnbakedGeometry return name; } - public void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) + public void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBaker baker, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) { for (ModelMesh mesh : meshes) { @@ -589,12 +580,12 @@ public class ObjModel extends SimpleUnbakedGeometry } @Override - public void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) + public void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBaker baker, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) { - super.addQuads(owner, modelBuilder, bakery, spriteGetter, modelTransform, modelLocation); + super.addQuads(owner, modelBuilder, baker, spriteGetter, modelTransform, modelLocation); parts.values().stream().filter(part -> owner.isComponentVisible(part.name(), true)) - .forEach(part -> part.addQuads(owner, modelBuilder, bakery, spriteGetter, modelTransform, modelLocation)); + .forEach(part -> part.addQuads(owner, modelBuilder, baker, spriteGetter, modelTransform, modelLocation)); } @Override diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/RemappingVertexPipeline.java b/src/main/java/net/minecraftforge/client/model/pipeline/RemappingVertexPipeline.java index f7bc43f64d..be6820eee0 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/RemappingVertexPipeline.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/RemappingVertexPipeline.java @@ -9,9 +9,9 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexFormat; import com.mojang.blaze3d.vertex.VertexFormatElement; -import com.mojang.math.Vector3d; -import com.mojang.math.Vector3f; import net.minecraft.client.renderer.texture.OverlayTexture; +import org.joml.Vector3d; +import org.joml.Vector3f; import java.util.Arrays; import java.util.IdentityHashMap; @@ -31,8 +31,8 @@ public class RemappingVertexPipeline implements VertexConsumer private final VertexConsumer parent; private final VertexFormat targetFormat; - private final Vector3d position = new Vector3d(0, 0, 0); - private final Vector3f normal = new Vector3f(0, 0, 0); + private final Vector3d position = new Vector3d(); + private final Vector3f normal = new Vector3f(); private final int[] color = new int[] { 255, 255, 255, 255 }; private final float[] uv0 = new float[] { 0, 0 }; private final int[] uv1 = new int[] { OverlayTexture.NO_WHITE_U, OverlayTexture.WHITE_OVERLAY_V }; diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/TransformingVertexPipeline.java b/src/main/java/net/minecraftforge/client/model/pipeline/TransformingVertexPipeline.java index 86e5e51319..d1029c8707 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/TransformingVertexPipeline.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/TransformingVertexPipeline.java @@ -7,8 +7,8 @@ package net.minecraftforge.client.model.pipeline; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Transformation; -import com.mojang.math.Vector3f; -import com.mojang.math.Vector4f; +import org.joml.Vector3f; +import org.joml.Vector4f; /** * Vertex pipeline element that applies a transformation to incoming geometry. @@ -28,7 +28,7 @@ public class TransformingVertexPipeline extends VertexConsumerWrapper { var vec = new Vector4f((float) x, (float) y, (float) z, 1); transformation.transformPosition(vec); - vec.perspectiveDivide(); + vec.div(vec.w); return super.vertex(vec.x(), vec.y(), vec.z()); } diff --git a/src/main/java/net/minecraftforge/client/model/renderable/BakedModelRenderable.java b/src/main/java/net/minecraftforge/client/model/renderable/BakedModelRenderable.java index 252e5684ea..a6622f9e4a 100644 --- a/src/main/java/net/minecraftforge/client/model/renderable/BakedModelRenderable.java +++ b/src/main/java/net/minecraftforge/client/model/renderable/BakedModelRenderable.java @@ -6,7 +6,6 @@ package net.minecraftforge.client.model.renderable; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector4f; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.block.model.BakedQuad; @@ -19,6 +18,7 @@ import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.client.model.data.ModelData; import org.jetbrains.annotations.Nullable; +import org.joml.Vector4f; import java.util.Arrays; diff --git a/src/main/java/net/minecraftforge/client/model/renderable/CompositeRenderable.java b/src/main/java/net/minecraftforge/client/model/renderable/CompositeRenderable.java index f845077115..f7adc8b82c 100644 --- a/src/main/java/net/minecraftforge/client/model/renderable/CompositeRenderable.java +++ b/src/main/java/net/minecraftforge/client/model/renderable/CompositeRenderable.java @@ -7,11 +7,11 @@ package net.minecraftforge.client.model.renderable; import com.google.common.collect.ImmutableMap; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.Nullable; +import org.joml.Matrix4f; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java b/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java index 1e9f09ad05..13ce84d41b 100644 --- a/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java +++ b/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java @@ -6,10 +6,13 @@ package net.minecraftforge.client.textures; import com.mojang.blaze3d.platform.NativeImage; -import net.minecraft.client.renderer.texture.TextureAtlas; +import net.minecraft.client.renderer.texture.SpriteContents; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.resources.metadata.animation.AnimationMetadataSection; +import net.minecraft.client.resources.metadata.animation.FrameSize; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.Resource; -import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraftforge.client.event.RegisterTextureAtlasSpriteLoadersEvent; import org.jetbrains.annotations.NotNull; /** @@ -24,15 +27,16 @@ import org.jetbrains.annotations.NotNull; * } * * - * @see net.minecraftforge.client.event.RegisterTextureAtlasSpriteLoadersEvent + * @see RegisterTextureAtlasSpriteLoadersEvent */ public interface ITextureAtlasSpriteLoader { + SpriteContents loadContents(ResourceLocation name, Resource resource, FrameSize frameSize, NativeImage image, + AnimationMetadataSection animationMeta, ForgeTextureMetadata forgeMeta); + /** - * Load a {@link TextureAtlasSprite} for the given resource. + * Creates a {@link TextureAtlasSprite} from the given {@link SpriteContents}. */ @NotNull - TextureAtlasSprite load(TextureAtlas atlas, ResourceManager resourceManager, TextureAtlasSprite.Info textureInfo, - Resource resource, int atlasWidth, int atlasHeight, int spriteX, int spriteY, - int mipmapLevel, NativeImage image); + TextureAtlasSprite makeSprite(ResourceLocation atlasName, SpriteContents contents, int atlasWidth, int atlasHeight, int spriteX, int spriteY, int mipmapLevel); } diff --git a/src/main/java/net/minecraftforge/client/textures/UnitTextureAtlasSprite.java b/src/main/java/net/minecraftforge/client/textures/UnitTextureAtlasSprite.java index 3cc111b46e..cc73a5947e 100644 --- a/src/main/java/net/minecraftforge/client/textures/UnitTextureAtlasSprite.java +++ b/src/main/java/net/minecraftforge/client/textures/UnitTextureAtlasSprite.java @@ -6,9 +6,11 @@ package net.minecraftforge.client.textures; import com.mojang.blaze3d.platform.NativeImage; +import net.minecraft.client.renderer.texture.SpriteContents; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.metadata.animation.AnimationMetadataSection; +import net.minecraft.client.resources.metadata.animation.FrameSize; import net.minecraft.resources.ResourceLocation; /** @@ -23,10 +25,7 @@ public class UnitTextureAtlasSprite extends TextureAtlasSprite private UnitTextureAtlasSprite() { - super(new TextureAtlas(LOCATION), - new Info(LOCATION, 1, 1, AnimationMetadataSection.EMPTY), - 0, 1, 1, - 0, 0, new NativeImage(1, 1, false)); + super(LOCATION, new SpriteContents(LOCATION, new FrameSize(1, 1), new NativeImage(1, 1, false), AnimationMetadataSection.EMPTY, null), 1, 1, 0, 0); } @Override diff --git a/src/main/java/net/minecraftforge/common/CreativeModeTabRegistry.java b/src/main/java/net/minecraftforge/common/CreativeModeTabRegistry.java new file mode 100644 index 0000000000..e4141a343b --- /dev/null +++ b/src/main/java/net/minecraftforge/common/CreativeModeTabRegistry.java @@ -0,0 +1,282 @@ +/* + * Copyright (c) Forge Development LLC and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.minecraftforge.common; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import com.google.common.graph.ElementOrder; +import com.google.common.graph.GraphBuilder; +import com.google.common.graph.MutableGraph; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.mojang.logging.LogUtils; +import it.unimi.dsi.fastutil.booleans.BooleanConsumer; +import java.io.IOException; +import java.io.Reader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.packs.resources.PreparableReloadListener; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.server.packs.resources.SimplePreparableReloadListener; +import net.minecraft.util.GsonHelper; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.client.CreativeModeTabSearchRegistry; +import net.minecraftforge.event.CreativeModeTabEvent; +import net.minecraftforge.fml.ModLoader; +import net.minecraftforge.fml.loading.FMLEnvironment; +import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.fml.loading.toposort.TopologicalSort; +import net.minecraftforge.server.ServerLifecycleHooks; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; + +public final class CreativeModeTabRegistry +{ + private static final Logger LOGGER = LogUtils.getLogger(); + private static final ResourceLocation CREATIVE_MODE_TAB_ORDERING_JSON = new ResourceLocation("forge", "creative_mode_tab_ordering.json"); + private static final List SORTED_TABS = new ArrayList<>(); + private static final List SORTED_TABS_VIEW = Collections.unmodifiableList(SORTED_TABS); + + /** + * {@return an unmodifiable view of the sorted list of creative mode tabs in ascending order} + */ + public static List getSortedCreativeModeTabs() + { + return SORTED_TABS_VIEW; + } + + /** + * {@return the {@linkplain CreativeModeTab} with the given name, or null} + * + * @param name the name to look up + */ + @Nullable + public static CreativeModeTab getTab(ResourceLocation name) + { + return creativeModeTabs.get(name); + } + + /** + * {@return the name of the given {@linkplain CreativeModeTab}, or null} + * + * @param tab the tab to look up + */ + @Nullable + public static ResourceLocation getName(CreativeModeTab tab) + { + return creativeModeTabs.inverse().get(tab); + } + + private static void processCreativeModeTab(CreativeModeTab creativeModeTab, ResourceLocation name, List afterEntries, List beforeEntries) + { + creativeModeTabs.put(name, creativeModeTab); + for (Object after : afterEntries) + { + ResourceLocation other = getCreativeModeTabName(after); + edges.put(other, name); + } + for (Object before : beforeEntries) + { + ResourceLocation other = getCreativeModeTabName(before); + edges.put(name, other); + } + } + + private static ResourceLocation getCreativeModeTabName(Object entry) + { + if (entry instanceof String s) + return new ResourceLocation(s); + if (entry instanceof ResourceLocation rl) + return rl; + if (entry instanceof CreativeModeTab t) + return Objects.requireNonNull(getName(t), "Can't have sorting dependencies for creative mode tabs not registered in the CreativeModeTabSortingRegistry"); + throw new IllegalStateException("Invalid object type passed into the CreativeModeTab dependencies " + entry.getClass()); + } + + private static final BiMap creativeModeTabs = HashBiMap.create(); + private static final BiMap vanillaCreativeModeTabs = HashBiMap.create(); + private static final Multimap edges = HashMultimap.create(); + private static final Multimap vanillaEdges = HashMultimap.create(); + + static + { + final ResourceLocation buildingBlocks = new ResourceLocation("building_blocks"); + final ResourceLocation coloredBlocks = new ResourceLocation("colored_blocks"); + final ResourceLocation naturalBlocks = new ResourceLocation("natural_blocks"); + final ResourceLocation functionalBlocks = new ResourceLocation("functional_blocks"); + final ResourceLocation redstoneBlocks = new ResourceLocation("redstone_blocks"); + final ResourceLocation toolsAndUtilities = new ResourceLocation("tools_and_utilities"); + final ResourceLocation combat = new ResourceLocation("combat"); + final ResourceLocation foodAndDrinks = new ResourceLocation("food_and_drinks"); + final ResourceLocation ingredients = new ResourceLocation("ingredients"); + final ResourceLocation spawnEggs = new ResourceLocation("spawn_eggs"); + + processCreativeModeTab(CreativeModeTabs.BUILDING_BLOCKS, buildingBlocks, List.of(), List.of()); + processCreativeModeTab(CreativeModeTabs.COLORED_BLOCKS, coloredBlocks, List.of(buildingBlocks), List.of(naturalBlocks)); + processCreativeModeTab(CreativeModeTabs.NATURAL_BLOCKS, naturalBlocks, List.of(coloredBlocks), List.of(functionalBlocks)); + processCreativeModeTab(CreativeModeTabs.FUNCTIONAL_BLOCKS, functionalBlocks, List.of(naturalBlocks), List.of(redstoneBlocks)); + processCreativeModeTab(CreativeModeTabs.REDSTONE_BLOCKS, redstoneBlocks, List.of(functionalBlocks), List.of(toolsAndUtilities)); + processCreativeModeTab(CreativeModeTabs.TOOLS_AND_UTILITIES, toolsAndUtilities, List.of(redstoneBlocks), List.of(combat)); + processCreativeModeTab(CreativeModeTabs.COMBAT, combat, List.of(toolsAndUtilities), List.of(foodAndDrinks)); + processCreativeModeTab(CreativeModeTabs.FOOD_AND_DRINKS, foodAndDrinks, List.of(combat), List.of(ingredients)); + processCreativeModeTab(CreativeModeTabs.INGREDIENTS, ingredients, List.of(foodAndDrinks), List.of(spawnEggs)); + processCreativeModeTab(CreativeModeTabs.SPAWN_EGGS, spawnEggs, List.of(ingredients), List.of()); + + vanillaEdges.putAll(edges); + vanillaCreativeModeTabs.putAll(creativeModeTabs); + } + + static PreparableReloadListener getReloadListener() + { + return new SimplePreparableReloadListener() + { + final Gson gson = new GsonBuilder().create(); + + @NotNull + @Override + protected JsonObject prepare(@NotNull ResourceManager resourceManager, ProfilerFiller profiler) + { + Optional res = resourceManager.getResource(CREATIVE_MODE_TAB_ORDERING_JSON); + if (res.isEmpty()) + return new JsonObject(); + + try (Reader reader = res.get().openAsReader()) + { + return this.gson.fromJson(reader, JsonObject.class); + } + catch (IOException e) + { + LOGGER.error("Could not read CreativeModeTab sorting file " + CREATIVE_MODE_TAB_ORDERING_JSON, e); + return new JsonObject(); + } + } + + @Override + protected void apply(@NotNull JsonObject data, @NotNull ResourceManager resourceManager, ProfilerFiller p) + { + try + { + if (data.size() > 0) + { + JsonArray order = GsonHelper.getAsJsonArray(data, "order"); + List customOrder = new ArrayList<>(); + for (JsonElement entry : order) + { + ResourceLocation id = new ResourceLocation(entry.getAsString()); + CreativeModeTab CreativeModeTab = getTab(id); + if (CreativeModeTab == null) + throw new IllegalStateException("CreativeModeTab not found with name " + id); + customOrder.add(CreativeModeTab); + } + + List missingCreativeModeTabs = creativeModeTabs.values().stream().filter(CreativeModeTab -> !customOrder.contains(CreativeModeTab)).toList(); + if (!missingCreativeModeTabs.isEmpty()) + throw new IllegalStateException("CreativeModeTabs missing from the ordered list: " + missingCreativeModeTabs.stream() + .map(CreativeModeTab -> Objects.toString(CreativeModeTabRegistry.getName(CreativeModeTab))).collect(Collectors.joining(", "))); + + setCreativeModeTabOrder(customOrder); + return; + } + } + catch (Exception e) + { + LOGGER.error("Error parsing CreativeModeTab sorting file " + CREATIVE_MODE_TAB_ORDERING_JSON, e); + } + + recalculateItemCreativeModeTabs(); + } + }; + } + + @SuppressWarnings("UnstableApiUsage") + private static void recalculateItemCreativeModeTabs() + { + final MutableGraph graph = GraphBuilder.directed().nodeOrder(ElementOrder.insertion()).build(); + + for (CreativeModeTab CreativeModeTab : creativeModeTabs.values()) + { + graph.addNode(CreativeModeTab); + } + edges.forEach((key, value) -> { + if (creativeModeTabs.containsKey(key) && creativeModeTabs.containsKey(value)) + graph.putEdge(creativeModeTabs.get(key), creativeModeTabs.get(value)); + }); + List tierList = TopologicalSort.topologicalSort(graph, null); + + setCreativeModeTabOrder(tierList); + } + + private static void setCreativeModeTabOrder(List tierList) + { + runInServerThreadIfPossible(hasServer -> { + SORTED_TABS.clear(); + SORTED_TABS.addAll(tierList); + }); + } + + private static void runInServerThreadIfPossible(BooleanConsumer runnable) + { + MinecraftServer server = ServerLifecycleHooks.getCurrentServer(); + if (server != null) + server.execute(() -> runnable.accept(true)); + else + runnable.accept(false); + } + + @ApiStatus.Internal + public static void fireCollectionEvent() + { + edges.clear(); + edges.putAll(vanillaEdges); + + creativeModeTabs.clear(); + creativeModeTabs.putAll(vanillaCreativeModeTabs); + + ModLoader.get().postEvent(new CreativeModeTabEvent.Register(CreativeModeTabRegistry::registerCreativeModeTab)); + + recalculateItemCreativeModeTabs(); + + if (FMLEnvironment.dist == Dist.CLIENT && !FMLLoader.getLaunchHandler().isData()) + CreativeModeTabSearchRegistry.createSearchTrees(); + } + + @ApiStatus.Internal + private static CreativeModeTab registerCreativeModeTab(Consumer configurator, ResourceLocation name, List afterEntries, List beforeEntries) + { + if (creativeModeTabs.containsKey(name)) + throw new IllegalStateException("Duplicate creative mode tab with name: " + name); + + // The initial values for the builder do not matter + CreativeModeTab.Builder builder = new CreativeModeTab.Builder(CreativeModeTab.Row.TOP, 0); + configurator.accept(builder); + CreativeModeTab creativeModeTab = builder.build(); + + if (creativeModeTab.isAlignedRight()) + throw new IllegalStateException("CreativeModeTab " + name + " is aligned right, this is not supported!"); + + processCreativeModeTab(creativeModeTab, name, afterEntries, beforeEntries); + + return creativeModeTab; + } +} diff --git a/src/main/java/net/minecraftforge/common/ForgeHooks.java b/src/main/java/net/minecraftforge/common/ForgeHooks.java index 81f14903f5..18d7e084e1 100644 --- a/src/main/java/net/minecraftforge/common/ForgeHooks.java +++ b/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -7,17 +7,25 @@ package net.minecraftforge.common; import java.net.URI; import java.net.URISyntaxException; -import java.util.*; -import java.util.Map.Entry; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Deque; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; -import java.util.function.Supplier; import java.util.regex.Matcher; import java.util.regex.Pattern; import com.google.common.base.Strings; -import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; @@ -27,8 +35,6 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; -import com.mojang.serialization.Codec; -import com.mojang.serialization.JsonOps; import com.mojang.serialization.Lifecycle; import it.unimi.dsi.fastutil.objects.ObjectArrayList; @@ -37,14 +43,24 @@ import net.minecraft.advancements.Advancement; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.commands.SharedSuggestionProvider; -import net.minecraft.core.*; -import net.minecraft.network.chat.*; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.network.chat.ChatDecorator; +import net.minecraft.network.chat.ClickEvent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.TextColor; import net.minecraft.network.chat.contents.LiteralContents; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.packs.PackType; import net.minecraft.tags.BlockTags; import net.minecraft.tags.TagEntry; import net.minecraft.tags.TagKey; +import net.minecraft.util.CrudeIncrementalIntIdentityHashBiMap; +import net.minecraft.util.GsonHelper; +import net.minecraft.util.Mth; import net.minecraft.util.datafix.fixes.StructuresBecomeConfiguredFix; import net.minecraft.world.Difficulty; import net.minecraft.world.InteractionHand; @@ -77,15 +93,11 @@ import net.minecraft.world.level.storage.WorldData; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.LootTables; -import net.minecraft.util.*; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.Screen; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.AnvilMenu; import net.minecraft.world.Container; import net.minecraft.world.item.context.UseOnContext; @@ -104,12 +116,10 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.BiomeSpecialEffects; import net.minecraft.world.level.biome.BiomeGenerationSettings; import net.minecraft.world.level.biome.MobSpawnSettings; -import net.minecraftforge.common.crafting.conditions.ICondition; import net.minecraftforge.common.loot.IGlobalLootModifier; import net.minecraftforge.common.loot.LootModifierManager; import net.minecraftforge.common.loot.LootTableIdCondition; @@ -174,16 +184,13 @@ import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; import net.minecraft.ChatFormatting; -import net.minecraft.resources.RegistryResourceAccess; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; -import net.minecraft.resources.RegistryResourceAccess.EntryThunk; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.material.Fluid; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; @@ -215,66 +222,6 @@ public class ForgeHooks return player.hasCorrectToolForDrops(state); } - /** - * Called when a player uses 'pick block', calls new Entity and Block hooks. - */ - @SuppressWarnings("resource") - @Deprecated(forRemoval = true, since = "1.19") - public static boolean onPickBlock(HitResult target, Player player, Level level) - { - ItemStack result = ItemStack.EMPTY; - boolean isCreative = player.getAbilities().instabuild; - BlockEntity te = null; - - if (target.getType() == HitResult.Type.BLOCK) - { - BlockPos pos = ((BlockHitResult)target).getBlockPos(); - BlockState state = level.getBlockState(pos); - - if (state.isAir()) - return false; - - if (isCreative && Screen.hasControlDown() && state.hasBlockEntity()) - te = level.getBlockEntity(pos); - - result = state.getCloneItemStack(target, level, pos, player); - - if (result.isEmpty()) - LOGGER.warn("Picking on: [{}] {} gave null item", target.getType(), ForgeRegistries.BLOCKS.getKey(state.getBlock())); - } - else if (target.getType() == HitResult.Type.ENTITY) - { - Entity entity = ((EntityHitResult)target).getEntity(); - result = entity.getPickedResult(target); - - if (result.isEmpty()) - LOGGER.warn("Picking on: [{}] {} gave null item", target.getType(), ForgeRegistries.ENTITY_TYPES.getKey(entity.getType())); - } - - if (result.isEmpty()) - return false; - - if (te != null) - Minecraft.getInstance().addCustomNbtData(result, te); - - if (isCreative) - { - player.getInventory().setPickedItem(result); - Minecraft.getInstance().gameMode.handleCreativeModeItemAdd(player.getItemInHand(InteractionHand.MAIN_HAND), 36 + player.getInventory().selected); - return true; - } - int slot = player.getInventory().findSlotMatchingItem(result); - if (slot != -1) - { - if (Inventory.isHotbarSlot(slot)) - player.getInventory().selected = slot; - else - Minecraft.getInstance().gameMode.handlePickItem(slot); - return true; - } - return false; - } - public static boolean onItemStackedOn(ItemStack carriedItem, ItemStack stackedOnItem, Slot slot, ClickAction action, Player player, SlotAccess carriedSlotAccess) { return MinecraftForge.EVENT_BUS.post(new ItemStackedOnOtherEvent(carriedItem, stackedOnItem, slot, action, player, carriedSlotAccess)); @@ -301,12 +248,12 @@ public class ForgeHooks { MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target, targetType)); } - + public static LivingChangeTargetEvent onLivingChangeTarget(LivingEntity entity, LivingEntity originalTarget, ILivingTargetType targetType) { LivingChangeTargetEvent event = new LivingChangeTargetEvent(entity, originalTarget, targetType); MinecraftForge.EVENT_BUS.post(event); - + return event; } @@ -457,71 +404,23 @@ public class ForgeHooks } @Nullable - public static Component onServerChatSubmittedEvent(ServerPlayer player, String plain, Component decorated, boolean canChangeMessage) + public static Component onServerChatSubmittedEvent(ServerPlayer player, String plain, Component decorated) { - ServerChatEvent.Submitted event = new ServerChatEvent.Submitted(player, plain, decorated, canChangeMessage); + ServerChatEvent event = new ServerChatEvent(player, plain, decorated); return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage(); } - private static final ChatDecorator SERVER_CHAT_SUBMITTED_DECORATOR = new ChatDecorator() - { - @NotNull - @Override - public CompletableFuture decorate(@Nullable ServerPlayer sender, Component message) - { - return CompletableFuture.supplyAsync(() -> { - if (sender == null) - return message; // Vanilla should never get here with the patches we use, but let's be safe with dumb mods - - return onServerChatSubmittedEvent(sender, getRawText(message), message, true); - }); - } - - @NotNull - @Override - public CompletableFuture decorate(@Nullable ServerPlayer sender, PlayerChatMessage message) - { - if (message.signedContent().isDecorated()) - { - return CompletableFuture.supplyAsync(() -> { - if (sender != null) - return onServerChatSubmittedEvent(sender, message.signedContent().plain(), message.signedContent().decorated(), false) == null; - - return false; - }).thenApply(canceled -> canceled == Boolean.TRUE ? null : message); - } - - return this.decorate(sender, message.serverContent()).thenApply(component -> component == null ? null : message.withUnsignedContent(component)); - } - }; - @NotNull public static ChatDecorator getServerChatSubmittedDecorator() { - return SERVER_CHAT_SUBMITTED_DECORATOR; - } - - @Nullable - public static Component onServerChatPreviewEvent(@NotNull ServerPlayer player, @NotNull Component message) - { - ServerChatEvent.Preview event = new ServerChatEvent.Preview(player, getRawText(message), message); - return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage(); - } - - @NotNull - public static ChatDecorator getServerChatPreviewDecorator() - { - return (player, message) -> CompletableFuture.supplyAsync(() -> { - if (player == null) + return (sender, message) -> CompletableFuture.supplyAsync(() -> { + if (sender == null) return message; // Vanilla should never get here with the patches we use, but let's be safe with dumb mods - Component preview = onServerChatPreviewEvent(player, message); - // Send the input message back to the client if the event was cancelled - return preview == null ? message : preview; + return onServerChatSubmittedEvent(sender, getRawText(message), message); }); } - static final Pattern URL_PATTERN = Pattern.compile( // schema ipv4 OR namespace port path ends // |-----------------| |-------------------------| |-------------------------| |---------| |--| |---------------| @@ -615,7 +514,7 @@ public class ForgeHooks if (!entityPlayer.mayBuild()) { - if (itemstack.isEmpty() || !itemstack.hasAdventureModeBreakTagForBlock(level.registryAccess().registryOrThrow(Registry.BLOCK_REGISTRY), new BlockInWorld(level, pos, false))) + if (itemstack.isEmpty() || !itemstack.hasAdventureModeBreakTagForBlock(level.registryAccess().registryOrThrow(Registries.BLOCK), new BlockInWorld(level, pos, false))) preCancelEvent = true; } } @@ -658,7 +557,7 @@ public class ForgeHooks Level level = context.getLevel(); Player player = context.getPlayer(); - if (player != null && !player.getAbilities().mayBuild && !itemstack.hasAdventureModePlaceTagForBlock(level.registryAccess().registryOrThrow(Registry.BLOCK_REGISTRY), new BlockInWorld(level, context.getClickedPos(), false))) + if (player != null && !player.getAbilities().mayBuild && !itemstack.hasAdventureModePlaceTagForBlock(level.registryAccess().registryOrThrow(Registries.BLOCK), new BlockInWorld(level, context.getClickedPos(), false))) return InteractionResult.PASS; // handle all placement events here @@ -978,6 +877,11 @@ public class ForgeHooks }; } + public static Collection onCheckCreativeTabs(CreativeModeTab... vanillaTabs) { + final List tabs = new ArrayList<>(Arrays.asList(vanillaTabs)); + return tabs; + } + @FunctionalInterface public interface BiomeCallbackFunction { @@ -1340,8 +1244,6 @@ public class ForgeHooks private static final Set VANILLA_DIMS = Sets.newHashSet("minecraft:overworld", "minecraft:the_nether", "minecraft:the_end"); private static final String DIMENSIONS_KEY = "dimensions"; private static final String SEED_KEY = "seed"; - //No to static init! - private static final Supplier>> CODEC = Suppliers.memoize(() -> RegistryCodecs.dataPackAwareCodec(Registry.LEVEL_STEM_REGISTRY, Lifecycle.stable(), LevelStem.CODEC).xmap(LevelStem::sortMap, Function.identity())); private static final Map, AttributeSupplier> FORGE_ATTRIBUTES = new HashMap<>(); /** FOR INTERNAL USE ONLY, DO NOT CALL DIRECTLY */ @@ -1665,12 +1567,4 @@ public class ForgeHooks } return false; } - - @SuppressWarnings("unchecked") - public static Collection, EntryThunk>> filterThunks(Map, RegistryResourceAccess.EntryThunk> map) - { - return map.entrySet().stream().filter(e -> - ((EntryThunk)e.getValue()).parseElement(JsonOps.INSTANCE, ICondition.DECODER) - .get().left().get().value()).toList(); // Validity of this .get() call is enforced by the above Decoder object, which only returns DataResult.success. - } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java index a50708dfa6..d1c04820eb 100644 --- a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java +++ b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java @@ -133,6 +133,7 @@ public class ForgeInternalHandler public void resourceReloadListeners(AddReloadListenerEvent event) { event.addListener(TierSortingRegistry.getReloadListener()); + event.addListener(CreativeModeTabRegistry.getReloadListener()); } } diff --git a/src/main/java/net/minecraftforge/common/ForgeMod.java b/src/main/java/net/minecraftforge/common/ForgeMod.java index f93a2254bc..ee9400c8c7 100644 --- a/src/main/java/net/minecraftforge/common/ForgeMod.java +++ b/src/main/java/net/minecraftforge/common/ForgeMod.java @@ -11,6 +11,9 @@ import net.minecraft.commands.synchronization.ArgumentTypeInfo; import net.minecraft.commands.synchronization.ArgumentTypeInfos; import net.minecraft.commands.synchronization.SingletonArgumentInfo; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.PackOutput; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Mob; @@ -29,13 +32,11 @@ import net.minecraft.world.level.material.Fluid; import net.minecraft.world.item.Items; import net.minecraft.sounds.SoundEvent; import net.minecraft.util.ExtraCodecs; -import net.minecraft.core.Registry; import net.minecraft.core.RegistryCodecs; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.pathfinder.BlockPathTypes; import net.minecraft.world.phys.Vec3; import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions; -import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent; import net.minecraftforge.common.crafting.PartialNBTIngredient; import net.minecraftforge.common.crafting.DifferenceIngredient; import net.minecraftforge.common.crafting.IntersectionIngredient; @@ -54,7 +55,6 @@ import net.minecraftforge.common.world.ForgeBiomeModifiers.RemoveSpawnsBiomeModi import net.minecraftforge.common.world.NoneBiomeModifier; import net.minecraftforge.common.world.NoneStructureModifier; import net.minecraftforge.common.world.StructureModifier; -import net.minecraftforge.event.ServerChatEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fluids.FluidType; import net.minecraftforge.fluids.ForgeFlowingFluid; @@ -103,9 +103,6 @@ import net.minecraftforge.common.data.ForgeEntityTypeTagsProvider; import net.minecraftforge.common.data.ForgeItemTagsProvider; import net.minecraftforge.common.data.ForgeLootTableProvider; import net.minecraftforge.common.data.ForgeRecipeProvider; -import net.minecraftforge.energy.CapabilityEnergy; -import net.minecraftforge.fluids.capability.CapabilityFluidHandler; -import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.fml.common.Mod; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; @@ -116,6 +113,7 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import org.jetbrains.annotations.Nullable; import java.util.*; +import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import java.util.function.Function; @@ -127,7 +125,7 @@ public class ForgeMod private static final Marker FORGEMOD = MarkerManager.getMarker("FORGEMOD"); private static final DeferredRegister ATTRIBUTES = DeferredRegister.create(ForgeRegistries.Keys.ATTRIBUTES, "forge"); - private static final DeferredRegister> COMMAND_ARGUMENT_TYPES = DeferredRegister.create(Registry.COMMAND_ARGUMENT_TYPE_REGISTRY, "forge"); + private static final DeferredRegister> COMMAND_ARGUMENT_TYPES = DeferredRegister.create(Registries.COMMAND_ARGUMENT_TYPE, "forge"); private static final DeferredRegister> BIOME_MODIFIER_SERIALIZERS = DeferredRegister.create(ForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS, "forge"); private static final DeferredRegister> STRUCTURE_MODIFIER_SERIALIZERS = DeferredRegister.create(ForgeRegistries.Keys.STRUCTURE_MODIFIER_SERIALIZERS, "forge"); private static final DeferredRegister HOLDER_SET_TYPES = DeferredRegister.create(ForgeRegistries.Keys.HOLDER_SET_TYPES, "forge"); @@ -384,7 +382,6 @@ public class ForgeMod }); private static boolean enableMilkFluid = false; - private static boolean serverChatPreviewEnabled = false; public static final RegistryObject MILK_TYPE = RegistryObject.createOptional(new ResourceLocation("milk"), ForgeRegistries.Keys.FLUID_TYPES.location(), "minecraft"); public static final RegistryObject MILK = RegistryObject.create(new ResourceLocation("milk"), ForgeRegistries.FLUIDS); public static final RegistryObject FLOWING_MILK = RegistryObject.create(new ResourceLocation("flowing_milk"), ForgeRegistries.FLUIDS); @@ -403,25 +400,6 @@ public class ForgeMod enableMilkFluid = true; } - /** - * Run this method during mod constructor to enable chat previews for the server. - * Recommended for mods which modify the chat message in {@link ServerChatEvent}. - * - * @see ServerChatEvent - */ - public static void enableServerChatPreview() - { - serverChatPreviewEnabled = true; - } - - /** - * @return {@code true} if server chat previews are enabled - */ - public static boolean isServerChatPreviewEnabled() - { - return serverChatPreviewEnabled; - } - public ForgeMod() { LOGGER.info(FORGEMOD,"Forge mod loading, version {}, for MC {} with MCP {}", ForgeVersion.getVersion(), MCPVersion.getMCVersion(), MCPVersion.getMCPVersion()); @@ -438,6 +416,11 @@ public class ForgeMod CrashReportCallables.registerCrashCallable("Forge", ()->ForgeVersion.getGroup()+":"+ForgeVersion.getVersion()); final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + // Forge-provided datapack registries + modEventBus.addListener((DataPackRegistryEvent.NewRegistry event) -> { + event.dataPackRegistry(ForgeRegistries.Keys.BIOME_MODIFIERS, BiomeModifier.DIRECT_CODEC); + event.dataPackRegistry(ForgeRegistries.Keys.STRUCTURE_MODIFIERS, StructureModifier.DIRECT_CODEC); + }); modEventBus.addListener(this::preInit); modEventBus.addListener(this::gatherData); modEventBus.addListener(this::loadComplete); @@ -493,16 +476,18 @@ public class ForgeMod public void gatherData(GatherDataEvent event) { DataGenerator gen = event.getGenerator(); + PackOutput packOutput = gen.getPackOutput(); + CompletableFuture lookupProvider = event.getLookupProvider(); ExistingFileHelper existingFileHelper = event.getExistingFileHelper(); - ForgeBlockTagsProvider blockTags = new ForgeBlockTagsProvider(gen, existingFileHelper); + ForgeBlockTagsProvider blockTags = new ForgeBlockTagsProvider(packOutput, lookupProvider, existingFileHelper); gen.addProvider(event.includeServer(), blockTags); - gen.addProvider(event.includeServer(), new ForgeItemTagsProvider(gen, blockTags, existingFileHelper)); - gen.addProvider(event.includeServer(), new ForgeEntityTypeTagsProvider(gen, existingFileHelper)); - gen.addProvider(event.includeServer(), new ForgeFluidTagsProvider(gen, existingFileHelper)); - gen.addProvider(event.includeServer(), new ForgeRecipeProvider(gen)); - gen.addProvider(event.includeServer(), new ForgeLootTableProvider(gen)); - gen.addProvider(event.includeServer(), new ForgeBiomeTagsProvider(gen, existingFileHelper)); + gen.addProvider(event.includeServer(), new ForgeItemTagsProvider(packOutput, lookupProvider, blockTags, existingFileHelper)); + gen.addProvider(event.includeServer(), new ForgeEntityTypeTagsProvider(packOutput, lookupProvider, existingFileHelper)); + gen.addProvider(event.includeServer(), new ForgeFluidTagsProvider(packOutput, lookupProvider, existingFileHelper)); + gen.addProvider(event.includeServer(), new ForgeRecipeProvider(packOutput)); + gen.addProvider(event.includeServer(), new ForgeLootTableProvider(packOutput)); + gen.addProvider(event.includeServer(), new ForgeBiomeTagsProvider(packOutput, lookupProvider, existingFileHelper)); } public void missingSoundMapping(MissingMappingsEvent event) @@ -595,11 +580,11 @@ public class ForgeMod public void registerLootData(RegisterEvent event) { - if (!event.getRegistryKey().equals(Registry.LOOT_ITEM_REGISTRY)) + if (!event.getRegistryKey().equals(Registries.LOOT_CONDITION_TYPE)) return; - event.register(Registry.LOOT_ITEM_REGISTRY, new ResourceLocation("forge:loot_table_id"), () -> LootTableIdCondition.LOOT_TABLE_ID); - event.register(Registry.LOOT_ITEM_REGISTRY, new ResourceLocation("forge:can_tool_perform_action"), () -> CanToolPerformAction.LOOT_CONDITION_TYPE); + event.register(Registries.LOOT_CONDITION_TYPE, new ResourceLocation("forge:loot_table_id"), () -> LootTableIdCondition.LOOT_TABLE_ID); + event.register(Registries.LOOT_CONDITION_TYPE, new ResourceLocation("forge:can_tool_perform_action"), () -> CanToolPerformAction.LOOT_CONDITION_TYPE); } public static final PermissionNode USE_SELECTORS_PERMISSION = new PermissionNode<>("forge", "use_entity_selectors", diff --git a/src/main/java/net/minecraftforge/common/ForgeSpawnEggItem.java b/src/main/java/net/minecraftforge/common/ForgeSpawnEggItem.java index 971f92673b..cb671c14fa 100644 --- a/src/main/java/net/minecraftforge/common/ForgeSpawnEggItem.java +++ b/src/main/java/net/minecraftforge/common/ForgeSpawnEggItem.java @@ -63,7 +63,10 @@ public class ForgeSpawnEggItem extends SpawnEggItem return ret != null ? ret : SpawnEggItem.byId(type); } - + @Override + protected EntityType getDefaultType() { + return this.typeSupplier.get(); + } private static final DispenseItemBehavior DEFAULT_DISPENSE_BEHAVIOR = (source, stack) -> { diff --git a/src/main/java/net/minecraftforge/common/Tags.java b/src/main/java/net/minecraftforge/common/Tags.java index b96668fccb..0b1ceb6880 100644 --- a/src/main/java/net/minecraftforge/common/Tags.java +++ b/src/main/java/net/minecraftforge/common/Tags.java @@ -6,6 +6,7 @@ package net.minecraftforge.common; import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BiomeTags; import net.minecraft.tags.BlockTags; @@ -191,7 +192,7 @@ public class Tags private static TagKey> tag(String name) { - return TagKey.create(Registry.ENTITY_TYPE_REGISTRY, new ResourceLocation("forge", name)); + return TagKey.create(Registries.ENTITY_TYPE, new ResourceLocation("forge", name)); } } @@ -614,7 +615,7 @@ public class Tags private static TagKey tag(String name) { - return TagKey.create(Registry.BIOME_REGISTRY, new ResourceLocation("forge", name)); + return TagKey.create(Registries.BIOME, new ResourceLocation("forge", name)); } } } diff --git a/src/main/java/net/minecraftforge/common/crafting/conditions/ICondition.java b/src/main/java/net/minecraftforge/common/crafting/conditions/ICondition.java index 1483af722e..5a6f5e9946 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/ICondition.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/ICondition.java @@ -5,11 +5,8 @@ package net.minecraftforge.common.crafting.conditions; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.mojang.datafixers.util.Pair; -import com.mojang.serialization.DataResult; -import com.mojang.serialization.Decoder; -import com.mojang.serialization.DynamicOps; import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; @@ -24,27 +21,13 @@ import java.util.Set; public interface ICondition { + static boolean shouldRegisterEntry(JsonElement json) + { + if (!(json instanceof JsonObject obj) || !obj.has("forge:conditions")) + return true; - Decoder DECODER = new Decoder<>() { - @Override - public DataResult> decode(DynamicOps ops, T input) - { - if(input instanceof JsonObject obj && obj.has("forge:conditions")) - { - try - { - boolean result = CraftingHelper.processConditions(obj, "forge:conditions", IContext.TAGS_INVALID); - return DataResult.success(Pair.of(result, input)); - } - catch(Exception ex) - { - ex.printStackTrace(); - return DataResult.success(Pair.of(false, input)); // Print stacktrace and do not load errored conditions. - } - } - return DataResult.success(Pair.of(true, input)); - } - }; + return CraftingHelper.processConditions(obj, "forge:conditions", IContext.TAGS_INVALID); + } ResourceLocation getID(); diff --git a/src/main/java/net/minecraftforge/common/crafting/conditions/TagEmptyCondition.java b/src/main/java/net/minecraftforge/common/crafting/conditions/TagEmptyCondition.java index fb9bdd6842..1ceb158a89 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/TagEmptyCondition.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/TagEmptyCondition.java @@ -8,6 +8,7 @@ package net.minecraftforge.common.crafting.conditions; import com.google.gson.JsonObject; import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraft.util.GsonHelper; @@ -30,7 +31,7 @@ public class TagEmptyCondition implements ICondition public TagEmptyCondition(ResourceLocation tag) { - this.tag = TagKey.create(Registry.ITEM_REGISTRY, tag); + this.tag = TagKey.create(Registries.ITEM, tag); } @Override diff --git a/src/main/java/net/minecraftforge/common/data/BlockTagsProvider.java b/src/main/java/net/minecraftforge/common/data/BlockTagsProvider.java new file mode 100644 index 0000000000..d6c7afbc8b --- /dev/null +++ b/src/main/java/net/minecraftforge/common/data/BlockTagsProvider.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) Forge Development LLC and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.minecraftforge.common.data; + +import java.util.concurrent.CompletableFuture; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.PackOutput; +import net.minecraft.data.tags.IntrinsicHolderTagsProvider; +import net.minecraft.world.level.block.Block; +import org.jetbrains.annotations.Nullable; + +public abstract class BlockTagsProvider extends IntrinsicHolderTagsProvider +{ + @SuppressWarnings("deprecation") + public BlockTagsProvider(PackOutput output, CompletableFuture lookupProvider, String modId, @Nullable ExistingFileHelper existingFileHelper) + { + super(output, Registries.BLOCK, lookupProvider, block -> block.builtInRegistryHolder().key(), modId, existingFileHelper); + } +} diff --git a/src/main/java/net/minecraftforge/common/data/DatapackBuiltinEntriesProvider.java b/src/main/java/net/minecraftforge/common/data/DatapackBuiltinEntriesProvider.java new file mode 100644 index 0000000000..8574440d81 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/data/DatapackBuiltinEntriesProvider.java @@ -0,0 +1,28 @@ +package net.minecraftforge.common.data; + +import net.minecraft.Util; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.RegistrySetBuilder; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.data.PackOutput; +import net.minecraft.data.registries.RegistriesDatapackGenerator; +import java.util.concurrent.CompletableFuture; +import java.util.function.Supplier; + +public class DatapackBuiltinEntriesProvider extends RegistriesDatapackGenerator +{ + public DatapackBuiltinEntriesProvider(PackOutput output, Supplier registriesSupplier) + { + super(output, CompletableFuture.supplyAsync(registriesSupplier, Util.backgroundExecutor())); + } + + public DatapackBuiltinEntriesProvider(PackOutput output, RegistrySetBuilder datapackEntriesBuilder) + { + this(output, () -> createLookup(datapackEntriesBuilder)); + } + + public static HolderLookup.Provider createLookup(RegistrySetBuilder datapackEntriesBuilder) { + return datapackEntriesBuilder.build(RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY)); + } +} diff --git a/src/main/java/net/minecraftforge/common/data/ExistingFileHelper.java b/src/main/java/net/minecraftforge/common/data/ExistingFileHelper.java index 4783b767dd..def0270162 100644 --- a/src/main/java/net/minecraftforge/common/data/ExistingFileHelper.java +++ b/src/main/java/net/minecraftforge/common/data/ExistingFileHelper.java @@ -18,12 +18,10 @@ import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import net.minecraft.client.resources.ClientPackSource; -import net.minecraft.client.resources.AssetIndex; -import net.minecraft.client.resources.DefaultClientPackResources; +import net.minecraft.client.resources.IndexedAssetSource; import net.minecraft.data.DataProvider; -import net.minecraft.data.HashCache; import net.minecraft.server.packs.FilePackResources; -import net.minecraft.server.packs.FolderPackResources; +import net.minecraft.server.packs.PathPackResources; import net.minecraft.server.packs.repository.ServerPacksSource; import net.minecraft.server.packs.resources.MultiPackResourceManager; import net.minecraft.server.packs.resources.Resource; @@ -98,15 +96,14 @@ public class ExistingFileHelper { List candidateClientResources = new ArrayList<>(); List candidateServerResources = new ArrayList<>(); - candidateClientResources.add(new VanillaPackResources(ClientPackSource.BUILT_IN, "minecraft", "realms")); - if (assetIndex != null && assetsDir != null) + if (assetIndex != null && assetsDir != null && assetsDir.exists()) { - candidateClientResources.add(new DefaultClientPackResources(ClientPackSource.BUILT_IN, new AssetIndex(assetsDir, assetIndex))); + candidateClientResources.add(ClientPackSource.createVanillaPackSource(IndexedAssetSource.createIndexFs(assetsDir.toPath(), assetIndex))); } - candidateServerResources.add(new VanillaPackResources(ServerPacksSource.BUILT_IN_METADATA, "minecraft")); + candidateServerResources.add(ServerPacksSource.createVanillaPackSource()); for (Path existing : existingPacks) { File file = existing.toFile(); - PackResources pack = file.isDirectory() ? new FolderPackResources(file) : new FilePackResources(file); + PackResources pack = file.isDirectory() ? new PathPackResources(file.getName(), file.toPath(), false) : new FilePackResources(file.getName(), file, false); candidateClientResources.add(pack); candidateServerResources.add(pack); } diff --git a/src/main/java/net/minecraftforge/common/data/ForgeBiomeTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeBiomeTagsProvider.java index e812ca2f58..d69fdd28cb 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeBiomeTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeBiomeTagsProvider.java @@ -5,7 +5,8 @@ package net.minecraftforge.common.data; -import net.minecraft.data.DataGenerator; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.PackOutput; import net.minecraft.data.tags.BiomeTagsProvider; import net.minecraft.resources.ResourceKey; import net.minecraft.tags.BiomeTags; @@ -14,16 +15,18 @@ import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biomes; import net.minecraftforge.common.Tags; +import java.util.concurrent.CompletableFuture; + public final class ForgeBiomeTagsProvider extends BiomeTagsProvider { - public ForgeBiomeTagsProvider(DataGenerator arg, ExistingFileHelper existingFileHelper) + public ForgeBiomeTagsProvider(PackOutput output, CompletableFuture lookupProvider, ExistingFileHelper existingFileHelper) { - super(arg, "forge", existingFileHelper); + super(output, lookupProvider, "forge", existingFileHelper); } @Override - protected void addTags() + protected void addTags(HolderLookup.Provider lookupProvider) { tag(Biomes.PLAINS, Tags.Biomes.IS_PLAINS); tag(Biomes.DESERT, Tags.Biomes.IS_HOT_OVERWORLD, Tags.Biomes.IS_DRY_OVERWORLD, Tags.Biomes.IS_SANDY, Tags.Biomes.IS_DESERT); diff --git a/src/main/java/net/minecraftforge/common/data/ForgeBlockTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeBlockTagsProvider.java index 56175e479c..e0e01464d8 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeBlockTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeBlockTagsProvider.java @@ -5,8 +5,10 @@ package net.minecraftforge.common.data; -import net.minecraft.data.DataGenerator; -import net.minecraft.data.tags.BlockTagsProvider; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.PackOutput; +import net.minecraft.data.tags.IntrinsicHolderTagsProvider; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; import net.minecraft.tags.TagKey; @@ -15,22 +17,24 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraftforge.common.Tags; import net.minecraftforge.registries.ForgeRegistries; +import org.jetbrains.annotations.Nullable; import java.util.Locale; +import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import static net.minecraftforge.common.Tags.Blocks.*; public final class ForgeBlockTagsProvider extends BlockTagsProvider { - public ForgeBlockTagsProvider(DataGenerator gen, ExistingFileHelper existingFileHelper) + public ForgeBlockTagsProvider(PackOutput output, CompletableFuture lookupProvider, @Nullable ExistingFileHelper existingFileHelper) { - super(gen, "forge", existingFileHelper); + super(output, lookupProvider, "forge", existingFileHelper); } @SuppressWarnings("unchecked") @Override - public void addTags() + public void addTags(HolderLookup.Provider p_256380_) { tag(BARRELS).addTag(BARRELS_WOODEN); tag(BARRELS_WOODEN).add(Blocks.BARREL); diff --git a/src/main/java/net/minecraftforge/common/data/ForgeEntityTypeTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeEntityTypeTagsProvider.java index 055cdd005c..fa86c00421 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeEntityTypeTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeEntityTypeTagsProvider.java @@ -5,21 +5,24 @@ package net.minecraftforge.common.data; -import net.minecraft.data.DataGenerator; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.PackOutput; import net.minecraft.data.tags.EntityTypeTagsProvider; import net.minecraft.world.entity.EntityType; import net.minecraftforge.common.Tags; +import java.util.concurrent.CompletableFuture; + public class ForgeEntityTypeTagsProvider extends EntityTypeTagsProvider { - - public ForgeEntityTypeTagsProvider(DataGenerator generator, ExistingFileHelper existingFileHelper) + + public ForgeEntityTypeTagsProvider(PackOutput output, CompletableFuture lookupProvider, ExistingFileHelper existingFileHelper) { - super(generator, "forge", existingFileHelper); + super(output, lookupProvider, "forge", existingFileHelper); } @Override - public void addTags() + public void addTags(HolderLookup.Provider lookupProvider) { tag(Tags.EntityTypes.BOSSES).add(EntityType.ENDER_DRAGON, EntityType.WITHER); } diff --git a/src/main/java/net/minecraftforge/common/data/ForgeFluidTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeFluidTagsProvider.java index 673183a4e0..152ac09b6e 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeFluidTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeFluidTagsProvider.java @@ -5,21 +5,24 @@ package net.minecraftforge.common.data; -import net.minecraft.data.DataGenerator; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.PackOutput; import net.minecraft.data.tags.FluidTagsProvider; import net.minecraftforge.common.ForgeMod; +import java.util.concurrent.CompletableFuture; + import static net.minecraftforge.common.Tags.Fluids.MILK; public final class ForgeFluidTagsProvider extends FluidTagsProvider { - public ForgeFluidTagsProvider(DataGenerator gen, ExistingFileHelper existingFileHelper) + public ForgeFluidTagsProvider(PackOutput output, CompletableFuture lookupProvider, ExistingFileHelper existingFileHelper) { - super(gen, "forge", existingFileHelper); + super(output, lookupProvider, "forge", existingFileHelper); } @Override - public void addTags() + public void addTags(HolderLookup.Provider lookupProvider) { tag(MILK).addOptional(ForgeMod.MILK.getId()).addOptional(ForgeMod.FLOWING_MILK.getId()); } diff --git a/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java index 227295fd9b..70f81e9ade 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java @@ -5,9 +5,10 @@ package net.minecraftforge.common.data; -import net.minecraft.data.DataGenerator; -import net.minecraft.data.tags.BlockTagsProvider; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.PackOutput; import net.minecraft.data.tags.ItemTagsProvider; +import net.minecraft.data.tags.TagsProvider; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.item.DyeColor; @@ -18,18 +19,19 @@ import net.minecraftforge.common.Tags; import net.minecraftforge.registries.ForgeRegistries; import java.util.Locale; +import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; public final class ForgeItemTagsProvider extends ItemTagsProvider { - public ForgeItemTagsProvider(DataGenerator gen, BlockTagsProvider blockTagProvider, ExistingFileHelper existingFileHelper) + public ForgeItemTagsProvider(PackOutput output, CompletableFuture lookupProvider, TagsProvider blockTagProvider, ExistingFileHelper existingFileHelper) { - super(gen, blockTagProvider, "forge", existingFileHelper); + super(output, lookupProvider, blockTagProvider, "forge", existingFileHelper); } @SuppressWarnings("unchecked") @Override - public void addTags() + public void addTags(HolderLookup.Provider lookupProvider) { copy(Tags.Blocks.BARRELS, Tags.Items.BARRELS); copy(Tags.Blocks.BARRELS_WOODEN, Tags.Items.BARRELS_WOODEN); diff --git a/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java index 84baa9eabb..414807373b 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java @@ -5,10 +5,11 @@ package net.minecraftforge.common.data; -import com.mojang.datafixers.util.Pair; import net.minecraft.advancements.critereon.ItemPredicate; -import net.minecraft.data.DataGenerator; +import net.minecraft.data.PackOutput; import net.minecraft.data.loot.LootTableProvider; +import net.minecraft.data.loot.LootTableSubProvider; +import net.minecraft.data.loot.packs.VanillaLootTableProvider; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; import net.minecraft.resources.ResourceLocation; @@ -24,9 +25,6 @@ import net.minecraftforge.fml.util.ObfuscationReflectionHelper; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.function.Supplier; import java.util.stream.Collectors; import net.minecraft.world.level.storage.loot.LootPool; @@ -34,32 +32,30 @@ import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.ValidationContext; import net.minecraft.world.level.storage.loot.entries.CompositeEntryBase; import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer; -import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet; /** * Currently used only for replacing shears item to shears_dig tool action */ public final class ForgeLootTableProvider extends LootTableProvider { - - public ForgeLootTableProvider(DataGenerator gen) { - super(gen); + public ForgeLootTableProvider(PackOutput packOutput) { + super(packOutput, Set.of(), VanillaLootTableProvider.create(packOutput).getTables()); } @Override - protected void validate(Map map, ValidationContext validationtracker) { - // do not validate against all registered loot tables + protected void validate(Map map, ValidationContext validationcontext) { + // Do not validate against all registered loot tables } @Override - protected List>>, LootContextParamSet>> getTables() { - return super.getTables().stream().map(pair -> { - // provides new consumer with filtering only changed loot tables and replacing condition item to condition tag - return new Pair>>, LootContextParamSet>(() -> replaceAndFilterChangesOnly(pair.getFirst().get()), pair.getSecond()); + public List getTables() { + return super.getTables().stream().map(entry -> { + // Provides new sub provider with filtering only changed loot tables and replacing condition item to condition tag + return new LootTableProvider.SubProviderEntry(() -> replaceAndFilterChangesOnly(entry.provider().get()), entry.paramSet()); }).collect(Collectors.toList()); } - private Consumer> replaceAndFilterChangesOnly(Consumer> consumer) { - return (newConsumer) -> consumer.accept((resourceLocation, builder) -> { + private LootTableSubProvider replaceAndFilterChangesOnly(LootTableSubProvider subProvider) { + return newConsumer -> subProvider.generate((resourceLocation, builder) -> { if (findAndReplaceInLootTableBuilder(builder, Items.SHEARS, ToolActions.SHEARS_DIG)) { newConsumer.accept(resourceLocation, builder); } diff --git a/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java index b44c358f9c..bcde2aa192 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java @@ -6,12 +6,13 @@ package net.minecraftforge.common.data; import com.google.gson.JsonObject; +import net.minecraft.advancements.Advancement; import net.minecraft.data.CachedOutput; -import net.minecraft.data.DataGenerator; +import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.FinishedRecipe; -import net.minecraft.data.recipes.RecipeProvider; import net.minecraft.data.recipes.ShapedRecipeBuilder; import net.minecraft.data.recipes.ShapelessRecipeBuilder; +import net.minecraft.data.recipes.packs.VanillaRecipeProvider; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; @@ -30,16 +31,17 @@ import org.jetbrains.annotations.Nullable; import java.lang.reflect.Field; import java.nio.file.Path; import java.util.*; +import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; -public final class ForgeRecipeProvider extends RecipeProvider +public final class ForgeRecipeProvider extends VanillaRecipeProvider { private final Map> replacements = new HashMap<>(); private final Set excludes = new HashSet<>(); - public ForgeRecipeProvider(DataGenerator generatorIn) + public ForgeRecipeProvider(PackOutput packOutput) { - super(generatorIn); + super(packOutput); } private void exclude(ItemLike item) @@ -53,7 +55,7 @@ public final class ForgeRecipeProvider extends RecipeProvider } @Override - protected void buildCraftingRecipes(Consumer consumer) + protected void buildRecipes(Consumer consumer) { replace(Items.STICK, Tags.Items.RODS_WOODEN); replace(Items.GOLD_INGOT, Tags.Items.INGOTS_GOLD); @@ -84,7 +86,7 @@ public final class ForgeRecipeProvider extends RecipeProvider exclude(Blocks.COBBLED_DEEPSLATE_SLAB); exclude(Blocks.COBBLED_DEEPSLATE_WALL); - super.buildCraftingRecipes(vanilla -> { + super.buildRecipes(vanilla -> { FinishedRecipe modified = enhance(vanilla); if (modified != null) consumer.accept(modified); @@ -118,10 +120,19 @@ public final class ForgeRecipeProvider extends RecipeProvider return modified ? vanilla : null; } + @Nullable @Override - protected void saveAdvancement(CachedOutput output, JsonObject advancementJson, Path pathIn) + protected CompletableFuture saveAdvancement(CachedOutput output, FinishedRecipe finishedRecipe, JsonObject advancementJson) { - //NOOP - We dont replace any of the advancement things yet... + // NOOP - We don't replace any of the advancement things yet... + return null; + } + + @Override + protected CompletableFuture buildAdvancement(CachedOutput p_253674_, ResourceLocation p_254102_, Advancement.Builder p_253712_) + { + // NOOP - We don't replace any of the advancement things yet... + return CompletableFuture.allOf(); } @Nullable diff --git a/src/main/java/net/minecraftforge/common/data/ForgeRegistryTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeRegistryTagsProvider.java deleted file mode 100644 index a3be0b5a9a..0000000000 --- a/src/main/java/net/minecraftforge/common/data/ForgeRegistryTagsProvider.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.common.data; - -import com.mojang.serialization.Lifecycle; -import net.minecraft.core.Registry; -import net.minecraft.data.DataGenerator; -import net.minecraft.data.tags.TagsProvider; -import net.minecraftforge.registries.GameData; -import net.minecraftforge.registries.IForgeRegistry; -import org.jetbrains.annotations.Nullable; - -public abstract class ForgeRegistryTagsProvider extends TagsProvider -{ - private static Registry wrapRegistry(IForgeRegistry forgeRegistry) - { - if (forgeRegistry.tags() == null) - throw new IllegalArgumentException("Forge registry " + forgeRegistry.getRegistryName() + " does not have support for tags"); - if (forgeRegistry.getDefaultKey() == null) - return GameData.getWrapper(forgeRegistry.getRegistryKey(), Lifecycle.experimental()); - return GameData.getWrapper(forgeRegistry.getRegistryKey(), Lifecycle.experimental(), "default"); - } - - public ForgeRegistryTagsProvider(DataGenerator generator, IForgeRegistry forgeRegistry, String modId, @Nullable ExistingFileHelper existingFileHelper) - { - super(generator, wrapRegistry(forgeRegistry), modId, existingFileHelper); - } -} diff --git a/src/main/java/net/minecraftforge/common/data/GlobalLootModifierProvider.java b/src/main/java/net/minecraftforge/common/data/GlobalLootModifierProvider.java index 9cf4bdbd06..e9a6f6370a 100644 --- a/src/main/java/net/minecraftforge/common/data/GlobalLootModifierProvider.java +++ b/src/main/java/net/minecraftforge/common/data/GlobalLootModifierProvider.java @@ -5,6 +5,7 @@ package net.minecraftforge.common.data; +import com.google.common.collect.ImmutableList; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; @@ -14,6 +15,7 @@ import cpw.mods.modlauncher.api.LamdbaExceptionUtils; import net.minecraft.data.CachedOutput; import net.minecraft.data.DataGenerator; import net.minecraft.data.DataProvider; +import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.loot.IGlobalLootModifier; import net.minecraftforge.common.loot.LootModifier; @@ -24,6 +26,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; /** @@ -59,26 +62,30 @@ public abstract class GlobalLootModifierProvider implements DataProvider protected abstract void start(); @Override - public void run(CachedOutput cache) throws IOException + public CompletableFuture run(CachedOutput cache) { start(); - Path forgePath = gen.getOutputFolder().resolve("data/forge/loot_modifiers/global_loot_modifiers.json"); - String modPath = "data/" + modid + "/loot_modifiers/"; + Path forgePath = this.gen.getPackOutput().getOutputFolder(PackOutput.Target.DATA_PACK).resolve("forge").resolve("loot_modifiers").resolve("global_loot_modifiers.json"); + Path modifierFolderPath = this.gen.getPackOutput().getOutputFolder(PackOutput.Target.DATA_PACK).resolve(this.modid).resolve("loot_modifiers"); List entries = new ArrayList<>(); + ImmutableList.Builder> futuresBuilder = new ImmutableList.Builder<>(); + toSerialize.forEach(LamdbaExceptionUtils.rethrowBiConsumer((name, json) -> { entries.add(new ResourceLocation(modid, name)); - Path modifierPath = gen.getOutputFolder().resolve(modPath + name + ".json"); - DataProvider.saveStable(cache, json, modifierPath); + Path modifierPath = modifierFolderPath.resolve(name + ".json"); + futuresBuilder.add(DataProvider.saveStable(cache, json, modifierPath)); })); JsonObject forgeJson = new JsonObject(); forgeJson.addProperty("replace", this.replace); forgeJson.add("entries", GSON.toJsonTree(entries.stream().map(ResourceLocation::toString).collect(Collectors.toList()))); - DataProvider.saveStable(cache, forgeJson, forgePath); + futuresBuilder.add(DataProvider.saveStable(cache, forgeJson, forgePath)); + + return CompletableFuture.allOf(futuresBuilder.build().toArray(CompletableFuture[]::new)); } /** diff --git a/src/main/java/net/minecraftforge/common/data/JsonCodecProvider.java b/src/main/java/net/minecraftforge/common/data/JsonCodecProvider.java index 9451351205..463ef2b92b 100644 --- a/src/main/java/net/minecraftforge/common/data/JsonCodecProvider.java +++ b/src/main/java/net/minecraftforge/common/data/JsonCodecProvider.java @@ -5,25 +5,26 @@ package net.minecraftforge.common.data; -import com.mojang.logging.LogUtils; -import java.io.IOException; -import java.nio.file.Path; -import java.util.Collections; -import java.util.Map; - +import com.google.common.collect.ImmutableList; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.mojang.logging.LogUtils; import com.mojang.serialization.Codec; import com.mojang.serialization.DynamicOps; import com.mojang.serialization.JsonOps; - -import java.util.function.BiConsumer; import cpw.mods.modlauncher.api.LamdbaExceptionUtils; +import java.nio.file.Path; +import java.util.Collections; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.function.BiConsumer; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.data.CachedOutput; import net.minecraft.data.DataGenerator; import net.minecraft.data.DataProvider; +import net.minecraft.data.PackOutput; +import net.minecraft.resources.RegistryDataLoader; import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; @@ -31,6 +32,8 @@ import net.minecraft.server.packs.PackType; import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.common.crafting.conditions.ICondition; import net.minecraftforge.common.data.ExistingFileHelper.ResourceType; +import net.minecraftforge.data.event.GatherDataEvent; +import net.minecraftforge.registries.DataPackRegistriesHooks; import org.slf4j.Logger; /** @@ -57,7 +60,7 @@ public class JsonCodecProvider implements DataProvider /** * @param dataGenerator DataGenerator provided by {@link GatherDataEvent}. - * @param dynamicOps DynamicOps to encode values to jsons with using the provided Codec, e.g. {@link JsonOps.INSTANCE}. + * @param dynamicOps DynamicOps to encode values to jsons with using the provided Codec, e.g. {@link JsonOps#INSTANCE}. * @param packType PackType specifying whether to generate entries in assets or data. * @param directory String representing the directory to generate jsons in, e.g. "dimension" or "cheesemod/cheese". * @param codec Codec to encode values to jsons with using the provided DynamicOps. @@ -95,6 +98,7 @@ public class JsonCodecProvider implements DataProvider * @param registryKey ResourceKey identifying the registry and its directory. * @param entries Map of entries to encode and their ResourceLocations. Paths for values are derived from the ResourceLocation's entryid:entrypath. */ + @SuppressWarnings("unchecked") public static JsonCodecProvider forDatapackRegistry(DataGenerator dataGenerator, ExistingFileHelper existingFileHelper, String modid, RegistryOps registryOps, ResourceKey> registryKey, Map entries) { @@ -104,21 +108,25 @@ public class JsonCodecProvider implements DataProvider final String registryFolder = registryId.getNamespace().equals("minecraft") ? registryId.getPath() : registryId.getNamespace() + "/" + registryId.getPath(); - final Codec codec = (Codec) RegistryAccess.REGISTRIES.get(registryKey).codec(); + RegistryDataLoader.RegistryData registryData = DataPackRegistriesHooks.getDataPackRegistries().stream().filter(data -> data.key() == registryKey).findAny().orElseThrow(); + final Codec codec = (Codec) registryData.elementCodec(); return new JsonCodecProvider<>(dataGenerator, existingFileHelper, modid, registryOps, PackType.SERVER_DATA, registryFolder, codec, entries); } @Override - public void run(final CachedOutput cache) throws IOException + public CompletableFuture run(final CachedOutput cache) { - final Path outputFolder = this.dataGenerator.getOutputFolder(); - final String dataFolder = this.packType.getDirectory(); + final Path outputFolder = this.dataGenerator.getPackOutput().getOutputFolder(this.packType == PackType.CLIENT_RESOURCES + ? PackOutput.Target.RESOURCE_PACK + : PackOutput.Target.DATA_PACK); + ImmutableList.Builder> futuresBuilder = new ImmutableList.Builder<>(); + gather(LamdbaExceptionUtils.rethrowBiConsumer((id, value) -> { - final Path path = outputFolder.resolve(String.join("/", dataFolder, id.getNamespace(), this.directory, id.getPath() + ".json")); + final Path path = outputFolder.resolve(id.getNamespace()).resolve(this.directory).resolve(id.getPath() + ".json"); JsonElement encoded = this.codec.encodeStart(this.dynamicOps, value) .getOrThrow(false, msg -> LOGGER.error("Failed to encode {}: {}", path, msg)); ICondition[] conditions = this.conditions.get(id); - if (conditions != null && conditions.length > 0) + if (conditions != null && conditions.length > 0) { if(encoded instanceof JsonObject obj) { @@ -129,8 +137,10 @@ public class JsonCodecProvider implements DataProvider LOGGER.error("Attempted to apply conditions to a type that is not a JsonObject! - Path: {}", path); } } - DataProvider.saveStable(cache, encoded, path); + futuresBuilder.add(DataProvider.saveStable(cache, encoded, path)); })); + + return CompletableFuture.allOf(futuresBuilder.build().toArray(CompletableFuture[]::new)); } protected void gather(BiConsumer consumer) diff --git a/src/main/java/net/minecraftforge/common/data/LanguageProvider.java b/src/main/java/net/minecraftforge/common/data/LanguageProvider.java index f2255938c9..c298a09cb3 100644 --- a/src/main/java/net/minecraftforge/common/data/LanguageProvider.java +++ b/src/main/java/net/minecraftforge/common/data/LanguageProvider.java @@ -5,36 +5,24 @@ package net.minecraftforge.common.data; -import java.io.BufferedWriter; -import java.io.IOException; -import java.nio.file.Files; +import com.google.gson.JsonObject; import java.nio.file.Path; import java.util.Map; -import java.util.Objects; import java.util.TreeMap; +import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; - -import com.google.common.hash.Hashing; -import com.google.gson.JsonObject; import net.minecraft.data.CachedOutput; -import org.apache.commons.lang3.text.translate.JavaUnicodeEscaper; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -import net.minecraft.world.level.block.Block; import net.minecraft.data.DataGenerator; -import net.minecraft.data.HashCache; import net.minecraft.data.DataProvider; -import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.data.PackOutput; +import net.minecraft.world.effect.MobEffect; import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.level.block.Block; -@SuppressWarnings("deprecation") public abstract class LanguageProvider implements DataProvider { - private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().setLenient().create(); private final Map data = new TreeMap<>(); private final DataGenerator gen; private final String modid; @@ -49,10 +37,13 @@ public abstract class LanguageProvider implements DataProvider { protected abstract void addTranslations(); @Override - public void run(CachedOutput cache) throws IOException { + public CompletableFuture run(CachedOutput cache) { addTranslations(); + if (!data.isEmpty()) - save(cache, data, this.gen.getOutputFolder().resolve("assets/" + modid + "/lang/" + locale + ".json")); + return save(cache, this.gen.getPackOutput().getOutputFolder(PackOutput.Target.RESOURCE_PACK).resolve(this.modid).resolve("lang").resolve(this.locale + ".json")); + + return CompletableFuture.allOf(); } @Override @@ -60,14 +51,12 @@ public abstract class LanguageProvider implements DataProvider { return "Languages: " + locale; } - private void save(CachedOutput cache, Object object, Path target) throws IOException { + private CompletableFuture save(CachedOutput cache, Path target) { // TODO: DataProvider.saveStable handles the caching and hashing already, but creating the JSON Object this way seems unreliable. -C JsonObject json = new JsonObject(); - for (Map.Entry pair : data.entrySet()) { - json.addProperty(pair.getKey(), pair.getValue()); - } + this.data.forEach(json::addProperty); - DataProvider.saveStable(cache, json, target); + return DataProvider.saveStable(cache, json, target); } public void addBlock(Supplier key, String name) { diff --git a/src/main/java/net/minecraftforge/common/data/SoundDefinitionsProvider.java b/src/main/java/net/minecraftforge/common/data/SoundDefinitionsProvider.java index 0ad437e678..5709806d08 100644 --- a/src/main/java/net/minecraftforge/common/data/SoundDefinitionsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/SoundDefinitionsProvider.java @@ -5,13 +5,17 @@ package net.minecraftforge.common.data; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; +import java.nio.file.Path; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.function.Supplier; import net.minecraft.data.CachedOutput; import net.minecraft.data.DataGenerator; -import net.minecraft.data.HashCache; import net.minecraft.data.DataProvider; +import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.PackType; import net.minecraft.sounds.SoundEvent; @@ -19,14 +23,6 @@ import net.minecraftforge.registries.ForgeRegistries; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.io.IOException; -import java.nio.file.Path; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Supplier; -import java.util.stream.Collectors; - /** * Data provider for the {@code sounds.json} file, which identifies sound definitions * for the various sound events in Minecraft. @@ -34,7 +30,6 @@ import java.util.stream.Collectors; public abstract class SoundDefinitionsProvider implements DataProvider { private static final Logger LOGGER = LogManager.getLogger(); - private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); private final DataGenerator generator; private final String modId; private final ExistingFileHelper helper; @@ -61,15 +56,17 @@ public abstract class SoundDefinitionsProvider implements DataProvider public abstract void registerSounds(); @Override - public void run(CachedOutput cache) throws IOException + public CompletableFuture run(CachedOutput cache) { this.sounds.clear(); this.registerSounds(); this.validate(); if (!this.sounds.isEmpty()) { - this.save(cache, this.generator.getOutputFolder().resolve("assets/" + this.modId + "/sounds.json")); + return this.save(cache, this.generator.getPackOutput().getOutputFolder(PackOutput.Target.RESOURCE_PACK).resolve(this.modId).resolve("sounds.json")); } + + return CompletableFuture.allOf(); } @Override @@ -208,7 +205,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider .filter(it -> !this.validate(it.getKey(), it.getValue())) .map(Map.Entry::getKey) .map(it -> this.modId + ":" + it) - .collect(Collectors.toList()); + .toList(); if (!notValid.isEmpty()) { throw new IllegalStateException("Found invalid sound events: " + notValid); @@ -228,7 +225,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider case EVENT: return this.validateEvent(name, sound.name()); } // Differently from all the other errors, this is not a 'missing sound' but rather something completely different - // that has broken the invariants of this sound definitions provider. In fact, a sound may only be either of + // that has broken the invariants of this sound definition's provider. In fact, a sound may only be either of // SOUND or EVENT type. Any other values is somebody messing with the internals, reflectively adding something // to an enum or passing `null` to a parameter annotated with `@NotNull`. throw new IllegalArgumentException("The given sound '" + sound.name() + "' does not have a valid type: expected either SOUND or EVENT, but found " + sound.type()); @@ -255,9 +252,9 @@ public abstract class SoundDefinitionsProvider implements DataProvider return valid; } - private void save(final CachedOutput cache, final Path targetFile) throws IOException + private CompletableFuture save(final CachedOutput cache, final Path targetFile) { - DataProvider.saveStable(cache, this.mapToJson(this.sounds), targetFile); + return DataProvider.saveStable(cache, this.mapToJson(this.sounds), targetFile); } private JsonObject mapToJson(final Map map) diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java index 450f69d17e..eb64bd3e9c 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java @@ -205,7 +205,7 @@ public interface IForgeBlock { if (isBed(state, levelReader, pos, entity) && levelReader instanceof Level level && BedBlock.canSetSpawn(level)) { - return BedBlock.findStandUpPosition(type, levelReader, pos, orientation); + return BedBlock.findStandUpPosition(type, levelReader, pos, state.getValue(BedBlock.FACING), orientation); } return Optional.empty(); } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeEnchantment.java b/src/main/java/net/minecraftforge/common/extensions/IForgeEnchantment.java index eba456911d..91dba32119 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeEnchantment.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeEnchantment.java @@ -10,6 +10,8 @@ import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentCategory; +import java.util.Set; public interface IForgeEnchantment { @@ -31,25 +33,15 @@ public interface IForgeEnchantment return self().getDamageBonus(level, mobType); } - /** - * Determines what creative tabs this enchantment's variant of an enchanted book or similar item should appear in. - * @param book The item being added to the creative tab - * @param tab The creative tab that items are being added to - * @return whether the given Item's variant for this enchantment should appear in the respective creative tab - */ - default boolean allowedInCreativeTab(Item book, CreativeModeTab tab) - { - if (!self().isAllowedOnBooks()) - { - return false; - } - else if (tab == CreativeModeTab.TAB_SEARCH) - { - return self().category != null; - } - else - { - return tab.hasEnchantmentCategory(self().category); - } - } + /** + * Determines whether item variants of this enchantment can be added to a given creative tab with the allowed categories. + * + * @param book the item being added to the creative tab + * @param allowedCategories the enchantment categories allowed in the creative tab + * @return whether item variants of this enchantment can be added to a given creative tab with the allowed categories + */ + default boolean allowedInCreativeTab(Item book, Set allowedCategories) + { + return self().isAllowedOnBooks() && allowedCategories.contains(self().category); + } } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java b/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java index d48f7b6618..9f463a7a55 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java @@ -11,6 +11,7 @@ import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.vehicle.Boat; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; @@ -72,13 +73,13 @@ public interface IForgeFluid * Returns whether the fluid can create a source. * * @param state the state of the fluid - * @param reader the reader that can get the fluid + * @param level the level that can get the fluid * @param pos the location of the fluid * @return {@code true} if the fluid can create a source, {@code false} otherwise */ - default boolean canConvertToSource(FluidState state, LevelReader reader, BlockPos pos) + default boolean canConvertToSource(FluidState state, Level level, BlockPos pos) { - return getFluidType().canConvertToSource(state, reader, pos); + return getFluidType().canConvertToSource(state, level, pos); } /** diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java b/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java index a267d59a12..d461607851 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java @@ -11,6 +11,7 @@ import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.vehicle.Boat; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.FluidState; @@ -67,13 +68,13 @@ public interface IForgeFluidState /** * Returns whether the fluid can create a source. * - * @param reader the reader that can get the fluid + * @param level the level that can get the fluid * @param pos the location of the fluid * @return {@code true} if the fluid can create a source, {@code false} otherwise */ - default boolean canConvertToSource(LevelReader reader, BlockPos pos) + default boolean canConvertToSource(Level level, BlockPos pos) { - return self().getType().canConvertToSource(self(), reader, pos); + return self().getType().canConvertToSource(self(), level, pos); } /** diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeIntrinsicHolderTagAppender.java b/src/main/java/net/minecraftforge/common/extensions/IForgeIntrinsicHolderTagAppender.java new file mode 100644 index 0000000000..2dedcfc9c6 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeIntrinsicHolderTagAppender.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) Forge Development LLC and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.minecraftforge.common.extensions; + +import net.minecraft.data.tags.IntrinsicHolderTagsProvider; +import net.minecraft.data.tags.TagsProvider; +import net.minecraft.resources.ResourceKey; + +public interface IForgeIntrinsicHolderTagAppender extends IForgeTagAppender +{ + private IntrinsicHolderTagsProvider.IntrinsicTagAppender self() { + return (IntrinsicHolderTagsProvider.IntrinsicTagAppender) this; + } + + ResourceKey getKey(T value); + + /** + * Adds a registry entry to the tag json's remove list. Callable during datageneration. + * + * @param entry The entry to remove + * @return The builder for chaining + */ + default TagsProvider.TagAppender remove(final T entry) + { + return remove(this.getKey(entry)); + } + + /** + * Adds multiple registry entries to the tag json's remove list. Callable during datageneration. + * + * @param entries The entries to remove + * @return The builder for chaining + */ + @SuppressWarnings("unchecked") + default TagsProvider.TagAppender remove(final T first, final T...entries) + { + this.remove(first); + for (T entry : entries) + { + this.remove(entry); + } + return self(); + } +} diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java index 2e79b5249c..0ccb3687da 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java @@ -303,18 +303,6 @@ public interface IForgeItem return false; } - /** - * Gets a list of tabs that items belonging to this class can display on, - * combined properly with getSubItems allows for a single item to span many - * sub-items across many tabs. - * - * @return A list of all tabs that this item could possibly be one. - */ - default java.util.Collection getCreativeTabs() - { - return java.util.Collections.singletonList(self().getItemCategory()); - } - /** * * Should this item, when held, allow sneak-clicks to pass through to the @@ -616,7 +604,7 @@ public interface IForgeItem */ default boolean canContinueUsing(ItemStack oldStack, ItemStack newStack) { - return ItemStack.isSameIgnoreDurability(oldStack, newStack); + return ItemStack.isSame(oldStack, newStack); } /** diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java b/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java index 53b05b4925..d934c30c11 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java @@ -6,6 +6,7 @@ package net.minecraftforge.common.extensions; import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.monster.EnderMan; import net.minecraft.world.entity.player.Inventory; @@ -85,7 +86,7 @@ public interface IForgeItemStack extends ICapabilitySerializable Player entityplayer = context.getPlayer(); BlockPos blockpos = context.getClickedPos(); BlockInWorld blockworldstate = new BlockInWorld(context.getLevel(), blockpos, false); - Registry registry = entityplayer.level.registryAccess().registryOrThrow(Registry.BLOCK_REGISTRY); + Registry registry = entityplayer.level.registryAccess().registryOrThrow(Registries.BLOCK); if (entityplayer != null && !entityplayer.getAbilities().mayBuild && !self().hasAdventureModePlaceTagForBlock(registry, blockworldstate)) { return InteractionResult.PASS; } else { diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgePackResources.java b/src/main/java/net/minecraftforge/common/extensions/IForgePackResources.java index 025626636c..a42e324125 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgePackResources.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgePackResources.java @@ -9,6 +9,9 @@ import net.minecraft.server.packs.PackType; public interface IForgePackResources { + /** + * {@return {@code true} if the pack should be hidden from any user interfaces} + */ default boolean isHidden() { return false; diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgePotion.java b/src/main/java/net/minecraftforge/common/extensions/IForgePotion.java index cf5e0de2ed..69e3612760 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgePotion.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgePotion.java @@ -5,8 +5,6 @@ package net.minecraftforge.common.extensions; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.alchemy.Potion; import net.minecraft.world.item.alchemy.PotionUtils; @@ -18,18 +16,6 @@ public interface IForgePotion return (Potion) this; } - /** - * Determines what creative tabs this potion's variant of a potion-related item (e.g. bottles, tipped arrows) should appear in. - * @param item The item being added to a creative tab - * @param tab The creative tab that items are being added to - * @param isDefaultTab whether the tab is the default tab for this item (e.g. Brewing for bottles, Combat for tipped arrows) - * @return whether the given Item's variant for this enchantment should appear in the respective creative tab - */ - default boolean allowedInCreativeTab(Item item, CreativeModeTab tab, boolean isDefaultTab) - { - return isDefaultTab; - } - /** * Determines whether the potion bottle item should be enchanted. * Not called for tipped arrows or if the item is already enchanted. diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeTagAppender.java b/src/main/java/net/minecraftforge/common/extensions/IForgeTagAppender.java index 5d1884e637..c1bc9dcab7 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeTagAppender.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeTagAppender.java @@ -6,6 +6,7 @@ package net.minecraftforge.common.extensions; import net.minecraft.data.tags.TagsProvider; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; @@ -33,32 +34,6 @@ public interface IForgeTagAppender return self(); } - /** - * Adds a registry entry to the tag json's remove list. Callable during datageneration. - * @param entry The entry to remove - * @return The builder for chaining - */ - default TagsProvider.TagAppender remove(final T entry) - { - return remove(this.self().registry.getKey(entry)); - } - - /** - * Adds multiple registry entries to the tag json's remove list. Callable during datageneration. - * @param entries The entries to remove - * @return The builder for chaining - */ - @SuppressWarnings("unchecked") - default TagsProvider.TagAppender remove(final T first, final T...entries) - { - this.remove(first); - for (T entry : entries) - { - this.remove(entry); - } - return self(); - } - /** * Adds a single element's ID to the tag json's remove list. Callable during datageneration. * @param location The ID of the element to remove @@ -86,6 +61,34 @@ public interface IForgeTagAppender return self(); } + /** + * Adds a resource key to the tag json's remove list. Callable during datageneration. + * + * @param resourceKey The resource key of the element to remove + * @return The appender for chaining + */ + default TagsProvider.TagAppender remove(final ResourceKey resourceKey) + { + this.remove(resourceKey.location()); + return self(); + } + + /** + * Adds multiple resource keys to the tag json's remove list. Callable during datageneration. + * + * @param resourceKeys The resource keys of the elements to remove + * @return The appender for chaining + */ + default TagsProvider.TagAppender remove(final ResourceKey firstResourceKey, final ResourceKey... resourceKeys) + { + this.remove(firstResourceKey.location()); + for (ResourceKey resourceKey : resourceKeys) + { + this.remove(resourceKey.location()); + } + return self(); + } + /** * Adds a tag to the tag json's remove list. Callable during datageneration. * @param tag The ID of the tag to remove diff --git a/src/main/java/net/minecraftforge/common/util/ConcatenatedListView.java b/src/main/java/net/minecraftforge/common/util/ConcatenatedListView.java index d433147cde..55600db154 100644 --- a/src/main/java/net/minecraftforge/common/util/ConcatenatedListView.java +++ b/src/main/java/net/minecraftforge/common/util/ConcatenatedListView.java @@ -20,6 +20,12 @@ import java.util.function.Supplier; */ public class ConcatenatedListView implements List { + @SafeVarargs + public static ConcatenatedListView of(List... lists) + { + return new ConcatenatedListView<>(List.of(lists)); + } + public static List of(List> members) { return switch (members.size()) { diff --git a/src/main/java/net/minecraftforge/common/util/FakePlayer.java b/src/main/java/net/minecraftforge/common/util/FakePlayer.java index 7705f6da83..4c3b5b71e7 100644 --- a/src/main/java/net/minecraftforge/common/util/FakePlayer.java +++ b/src/main/java/net/minecraftforge/common/util/FakePlayer.java @@ -8,17 +8,21 @@ package net.minecraftforge.common.util; import com.mojang.authlib.GameProfile; import java.util.Set; import javax.annotation.ParametersAreNonnullByDefault; -import net.minecraft.core.BlockPos; import net.minecraft.network.Connection; import net.minecraft.network.PacketSendListener; +import net.minecraft.network.chat.ChatType; import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.PlayerChatMessage; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketFlow; import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket; import net.minecraft.network.protocol.game.ServerboundAcceptTeleportationPacket; import net.minecraft.network.protocol.game.ServerboundBlockEntityTagQuery; import net.minecraft.network.protocol.game.ServerboundChangeDifficultyPacket; +import net.minecraft.network.protocol.game.ServerboundChatAckPacket; +import net.minecraft.network.protocol.game.ServerboundChatCommandPacket; import net.minecraft.network.protocol.game.ServerboundChatPacket; +import net.minecraft.network.protocol.game.ServerboundChatSessionUpdatePacket; import net.minecraft.network.protocol.game.ServerboundClientCommandPacket; import net.minecraft.network.protocol.game.ServerboundClientInformationPacket; import net.minecraft.network.protocol.game.ServerboundCommandSuggestionPacket; @@ -66,7 +70,6 @@ import net.minecraft.server.network.ServerGamePacketListenerImpl; import net.minecraft.stats.Stat; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.phys.Vec3; import net.minecraftforge.server.ServerLifecycleHooks; import org.jetbrains.annotations.Nullable; @@ -77,7 +80,7 @@ public class FakePlayer extends ServerPlayer { public FakePlayer(ServerLevel level, GameProfile name) { - super(level.getServer(), level, name, null); + super(level.getServer(), level, name); this.connection = new FakePlayerNetHandler(level.getServer(), this); } @@ -150,5 +153,14 @@ public class FakePlayer extends ServerPlayer @Override public void handleCustomPayload(ServerboundCustomPayloadPacket packet) { } @Override public void handleChangeDifficulty(ServerboundChangeDifficultyPacket packet) { } @Override public void handleLockDifficulty(ServerboundLockDifficultyPacket packet) { } + @Override public void dismount(double x, double y, double z, float yaw, float pitch) { } + @Override public void teleport(double x, double y, double z, float yaw, float pitch, Set relativeSet, boolean dismountVehicle) { } + @Override public void ackBlockChangesUpTo(int sequence) { } + @Override public void handleChatCommand(ServerboundChatCommandPacket packet) { } + @Override public void handleChatAck(ServerboundChatAckPacket packet) { } + @Override public void addPendingMessage(PlayerChatMessage message) { } + @Override public void sendPlayerChatMessage(PlayerChatMessage message, ChatType.Bound boundChatType) { } + @Override public void sendDisguisedChatMessage(Component content, ChatType.Bound boundChatType) { } + @Override public void handleChatSessionUpdate(ServerboundChatSessionUpdatePacket packet) { } } } diff --git a/src/main/java/net/minecraftforge/common/util/ItemStackMap.java b/src/main/java/net/minecraftforge/common/util/ItemStackMap.java new file mode 100644 index 0000000000..99e3beddf1 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/util/ItemStackMap.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) Forge Development LLC and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.minecraftforge.common.util; + +import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenCustomHashMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemStackLinkedSet; + +import java.util.Map; + +public class ItemStackMap { + + public static Map createTypeAndTagLinkedMap() { + return new Object2ObjectLinkedOpenCustomHashMap<>(ItemStackLinkedSet.TYPE_AND_TAG); + } + + public static Map createTypeAndTagMap() { + return new Object2ObjectOpenCustomHashMap<>(ItemStackLinkedSet.TYPE_AND_TAG); + } +} diff --git a/src/main/java/net/minecraftforge/common/util/TransformationHelper.java b/src/main/java/net/minecraftforge/common/util/TransformationHelper.java index 1830d18dd1..a2b162fc65 100644 --- a/src/main/java/net/minecraftforge/common/util/TransformationHelper.java +++ b/src/main/java/net/minecraftforge/common/util/TransformationHelper.java @@ -5,47 +5,58 @@ package net.minecraftforge.common.util; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.mojang.math.Axis; +import com.mojang.math.Transformation; import java.lang.reflect.Type; import java.util.HashSet; import java.util.Map; import java.util.Set; - -import com.google.gson.*; import net.minecraft.util.Mth; - -import com.mojang.math.Matrix4f; -import com.mojang.math.Quaternion; -import com.mojang.math.Transformation; -import com.mojang.math.Vector3f; -import com.mojang.math.Vector4f; import net.minecraftforge.client.model.generators.BlockModelBuilder.RootTransformBuilder.TransformOrigin; +import org.joml.Matrix4f; +import org.joml.Quaternionf; +import org.joml.Quaternionfc; +import org.joml.Vector3f; +import org.joml.Vector4f; public final class TransformationHelper { - public static Quaternion quatFromXYZ(Vector3f xyz, boolean degrees) + public static Quaternionf quatFromXYZ(Vector3f xyz, boolean degrees) { - return new Quaternion(xyz.x(), xyz.y(), xyz.z(), degrees); + return quatFromXYZ(xyz.x, xyz.y, xyz.z, degrees); } - public static Quaternion quatFromXYZ(float[] xyz, boolean degrees) + public static Quaternionf quatFromXYZ(float[] xyz, boolean degrees) { - return new Quaternion(xyz[0], xyz[1], xyz[2], degrees); + return quatFromXYZ(xyz[0], xyz[1], xyz[2], degrees); } - public static Quaternion makeQuaternion(float[] values) + public static Quaternionf quatFromXYZ(float x, float y, float z, boolean degrees) { - return new Quaternion(values[0], values[1], values[2], values[3]); + float conversionFactor = degrees ? (float) Math.PI / 180 : 1; + return new Quaternionf().rotationXYZ(x * conversionFactor, y * conversionFactor, z * conversionFactor); + } + + public static Quaternionf makeQuaternion(float[] values) + { + return new Quaternionf(values[0], values[1], values[2], values[3]); } public static Vector3f lerp(Vector3f from, Vector3f to, float progress) { - Vector3f res = from.copy(); + Vector3f res = new Vector3f(from); res.lerp(to, progress); return res; } private static final double THRESHOLD = 0.9995; - public static Quaternion slerp(Quaternion v0, Quaternion v1, float t) + public static Quaternionf slerp(Quaternionfc v0, Quaternionfc v1, float t) { // From https://en.wikipedia.org/w/index.php?title=Slerp&oldid=928959428 // License: CC BY-SA 3.0 https://creativecommons.org/licenses/by-sa/3.0/ @@ -55,20 +66,20 @@ public final class TransformationHelper // the shorter path. Note that v1 and -v1 are equivalent when // the negation is applied to all four components. Fix by // reversing one quaternion. - float dot = v0.i() * v1.i() + v0.j() * v1.j() + v0.k() * v1.k() + v0.r() * v1.r(); + float dot = v0.x() * v1.x() + v0.y() * v1.y() + v0.z() * v1.z() + v0.w() * v1.w(); if (dot < 0.0f) { - v1 = new Quaternion(-v1.i(), -v1.j(), -v1.k(), -v1.r()); + v1 = new Quaternionf(-v1.x(), -v1.y(), -v1.z(), -v1.w()); dot = -dot; } // If the inputs are too close for comfort, linearly interpolate // and normalize the result. if (dot > THRESHOLD) { - float x = Mth.lerp(t, v0.i(), v1.i()); - float y = Mth.lerp(t, v0.j(), v1.j()); - float z = Mth.lerp(t, v0.k(), v1.k()); - float w = Mth.lerp(t, v0.r(), v1.r()); - return new Quaternion(x,y,z,w); + float x = Mth.lerp(t, v0.x(), v1.x()); + float y = Mth.lerp(t, v0.y(), v1.y()); + float z = Mth.lerp(t, v0.z(), v1.z()); + float w = Mth.lerp(t, v0.w(), v1.w()); + return new Quaternionf(x,y,z,w); } // Since dot is in range [0, DOT_THRESHOLD], acos is safe @@ -81,11 +92,11 @@ public final class TransformationHelper float s1 = sin0t / sin01; float s0 = sin1t / sin01; - return new Quaternion( - s0 * v0.i() + s1 * v1.i(), - s0 * v0.j() + s1 * v1.j(), - s0 * v0.k() + s1 * v1.k(), - s0 * v0.r() + s1 * v1.r() + return new Quaternionf( + s0 * v0.x() + s1 * v1.x(), + s0 * v0.y() + s1 * v1.y(), + s0 * v0.z() + s1 * v1.z(), + s0 * v0.w() + s1 * v1.w() ); } @@ -143,9 +154,9 @@ public final class TransformationHelper return ret; } Vector3f translation = null; - Quaternion leftRot = null; + Quaternionf leftRot = null; Vector3f scale = null; - Quaternion rightRot = null; + Quaternionf rightRot = null; // TODO: Default origin is opposing corner, due to a mistake. // This should probably be replaced with center in future versions. Vector3f origin = TransformOrigin.OPPOSING_CORNER.getVector(); // TODO: Changing this to ORIGIN_CENTER breaks models, function content needs changing too -C @@ -206,7 +217,7 @@ public final class TransformationHelper // Use a different origin if needed. if (!TransformOrigin.CENTER.getVector().equals(origin)) { - Vector3f originFromCenter = origin.copy(); + Vector3f originFromCenter = new Vector3f(origin); originFromCenter.sub(TransformOrigin.CENTER.getVector()); matrix = matrix.applyOrigin(originFromCenter); } @@ -244,25 +255,25 @@ public final class TransformationHelper if (!e.isJsonArray()) throw new JsonParseException("Matrix: expected an array, got: " + e); JsonArray m = e.getAsJsonArray(); if (m.size() != 3) throw new JsonParseException("Matrix: expected an array of length 3, got: " + m.size()); - float[] values = new float[16]; - for (int i = 0; i < 3; i++) + Matrix4f matrix = new Matrix4f().zero(); + for (int rowIdx = 0; rowIdx < 3; rowIdx++) { - if (!m.get(i).isJsonArray()) throw new JsonParseException("Matrix row: expected an array, got: " + m.get(i)); - JsonArray r = m.get(i).getAsJsonArray(); + if (!m.get(rowIdx).isJsonArray()) throw new JsonParseException("Matrix row: expected an array, got: " + m.get(rowIdx)); + JsonArray r = m.get(rowIdx).getAsJsonArray(); if (r.size() != 4) throw new JsonParseException("Matrix row: expected an array of length 4, got: " + r.size()); - for (int j = 0; j < 4; j++) + for (int columnIdx = 0; columnIdx < 4; columnIdx++) { try { - values[j*4+i] = r.get(j).getAsNumber().floatValue(); + matrix.set(columnIdx, rowIdx, r.get(columnIdx).getAsNumber().floatValue()); } catch (ClassCastException ex) { - throw new JsonParseException("Matrix element: expected number, got: " + r.get(j)); + throw new JsonParseException("Matrix element: expected number, got: " + r.get(columnIdx)); } } } - return new Matrix4f(values); + return matrix; } public static float[] parseFloatArray(JsonElement e, int length, String prefix) @@ -285,26 +296,26 @@ public final class TransformationHelper return ret; } - public static Quaternion parseAxisRotation(JsonElement e) + public static Quaternionf parseAxisRotation(JsonElement e) { if (!e.isJsonObject()) throw new JsonParseException("Axis rotation: object expected, got: " + e); JsonObject obj = e.getAsJsonObject(); if (obj.entrySet().size() != 1) throw new JsonParseException("Axis rotation: expected single axis object, got: " + e); Map.Entry entry = obj.entrySet().iterator().next(); - Quaternion ret; + Quaternionf ret; try { if (entry.getKey().equals("x")) { - ret = Vector3f.XP.rotationDegrees(entry.getValue().getAsNumber().floatValue()); + ret = Axis.XP.rotationDegrees(entry.getValue().getAsNumber().floatValue()); } else if (entry.getKey().equals("y")) { - ret = Vector3f.YP.rotationDegrees(entry.getValue().getAsNumber().floatValue()); + ret = Axis.YP.rotationDegrees(entry.getValue().getAsNumber().floatValue()); } else if (entry.getKey().equals("z")) { - ret = Vector3f.ZP.rotationDegrees(entry.getValue().getAsNumber().floatValue()); + ret = Axis.ZP.rotationDegrees(entry.getValue().getAsNumber().floatValue()); } else throw new JsonParseException("Axis rotation: expected single axis key, got: " + entry.getKey()); } @@ -315,13 +326,13 @@ public final class TransformationHelper return ret; } - public static Quaternion parseRotation(JsonElement e) + public static Quaternionf parseRotation(JsonElement e) { if (e.isJsonArray()) { if (e.getAsJsonArray().get(0).isJsonObject()) { - Quaternion ret = Quaternion.ONE.copy(); + Quaternionf ret = new Quaternionf(); for (JsonElement a : e.getAsJsonArray()) { ret.mul(parseAxisRotation(a)); diff --git a/src/main/java/net/minecraftforge/common/world/BiomeGenerationSettingsBuilder.java b/src/main/java/net/minecraftforge/common/world/BiomeGenerationSettingsBuilder.java index 50eb5d6df8..42ca795153 100644 --- a/src/main/java/net/minecraftforge/common/world/BiomeGenerationSettingsBuilder.java +++ b/src/main/java/net/minecraftforge/common/world/BiomeGenerationSettingsBuilder.java @@ -5,18 +5,15 @@ package net.minecraftforge.common.world; +import java.util.ArrayList; +import java.util.List; import net.minecraft.core.Holder; -import net.minecraft.core.HolderSet; import net.minecraft.world.level.biome.BiomeGenerationSettings; import net.minecraft.world.level.levelgen.GenerationStep; import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; import net.minecraft.world.level.levelgen.placement.PlacedFeature; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Supplier; - -public class BiomeGenerationSettingsBuilder extends BiomeGenerationSettings.Builder +public class BiomeGenerationSettingsBuilder extends BiomeGenerationSettings.PlainBuilder { public BiomeGenerationSettingsBuilder(BiomeGenerationSettings orig) { diff --git a/src/main/java/net/minecraftforge/common/world/BiomeSpecialEffectsBuilder.java b/src/main/java/net/minecraftforge/common/world/BiomeSpecialEffectsBuilder.java index 10c482bfbc..ce0832a2a0 100644 --- a/src/main/java/net/minecraftforge/common/world/BiomeSpecialEffectsBuilder.java +++ b/src/main/java/net/minecraftforge/common/world/BiomeSpecialEffectsBuilder.java @@ -7,6 +7,7 @@ package net.minecraftforge.common.world; import java.util.Optional; +import net.minecraft.core.Holder; import net.minecraft.sounds.Music; import net.minecraft.sounds.SoundEvent; import net.minecraft.world.level.biome.AmbientAdditionsSettings; @@ -33,12 +34,12 @@ public class BiomeSpecialEffectsBuilder extends BiomeSpecialEffects.Builder baseEffects.getBackgroundMusic().ifPresent(builder::backgroundMusic); return builder; } - + public static BiomeSpecialEffectsBuilder create(int fogColor, int waterColor, int waterFogColor, int skyColor) { return new BiomeSpecialEffectsBuilder(fogColor, waterColor, waterFogColor, skyColor); } - + protected BiomeSpecialEffectsBuilder(int fogColor, int waterColor, int waterFogColor, int skyColor) { super(); @@ -47,62 +48,62 @@ public class BiomeSpecialEffectsBuilder extends BiomeSpecialEffects.Builder this.waterFogColor(waterFogColor); this.skyColor(skyColor); } - + public int getFogColor() { return this.fogColor.getAsInt(); } - + public int waterColor() { return this.waterColor.getAsInt(); } - + public int getWaterFogColor() { return this.waterFogColor.getAsInt(); } - + public int getSkyColor() { return this.skyColor.getAsInt(); } - + public BiomeSpecialEffects.GrassColorModifier getGrassColorModifier() { return this.grassColorModifier; } - + public Optional getFoliageColorOverride() { return this.foliageColorOverride; } - + public Optional getGrassColorOverride() { return this.grassColorOverride; } - + public Optional getAmbientParticle() { return this.ambientParticle; } - - public Optional getAmbientLoopSound() + + public Optional> getAmbientLoopSound() { return this.ambientLoopSoundEvent; } - + public Optional getAmbientMoodSound() { return this.ambientMoodSettings; } - + public Optional getAmbientAdditionsSound() { return this.ambientAdditionsSettings; } - + public Optional getBackgroundMusic() { return this.backgroundMusic; diff --git a/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java b/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java index df9111b2ad..8497acfe3f 100644 --- a/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java +++ b/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java @@ -26,7 +26,7 @@ import net.minecraftforge.registries.ForgeRegistries; public final class ForgeBiomeModifiers { private ForgeBiomeModifiers() {} // Utility class. - + /** *

Stock biome modifier that adds features to biomes. Has the following json format:

*
@@ -38,7 +38,7 @@ public final class ForgeBiomeModifiers
      * }
      * 
*

Be wary of using this to add vanilla PlacedFeatures to biomes, as doing so may cause a feature cycle violation.

- * + * * @param biomes Biomes to add features to. * @param features PlacedFeatures to add to biomes. * @param step Decoration step to run features in. @@ -62,7 +62,6 @@ public final class ForgeBiomeModifiers } } - /** *

Stock biome modifier that removes features from biomes. Has the following json format:

*
@@ -73,7 +72,7 @@ public final class ForgeBiomeModifiers
      *   "steps": "underground_ores" OR ["underground_ores", "vegetal_decoration"] // one or more decoration steps; optional field, defaults to all steps if not specified
      * }
      * 
- * + * * @param biomes Biomes to remove features from. * @param features PlacedFeatures to remove from biomes. * @param steps Decoration steps to remove features from. @@ -89,7 +88,7 @@ public final class ForgeBiomeModifiers { return new RemoveFeaturesBiomeModifier(biomes, features, EnumSet.allOf(Decoration.class)); } - + @Override public void modify(Holder biome, Phase phase, Builder builder) { @@ -109,7 +108,7 @@ public final class ForgeBiomeModifiers return ForgeMod.REMOVE_FEATURES_BIOME_MODIFIER_TYPE.get(); } } - + /** *

Stock biome modifier that adds a mob spawn to a biome. Has the following json format:

*
@@ -144,7 +143,7 @@ public final class ForgeBiomeModifiers
      *   ]
      * }
      * 
- * + * * @param biomes Biomes to add mob spawns to. * @param spawners List of SpawnerDatas specifying EntityType, weight, and pack size. */ @@ -160,7 +159,7 @@ public final class ForgeBiomeModifiers { return new AddSpawnsBiomeModifier(biomes, List.of(spawner)); } - + @Override public void modify(Holder biome, Phase phase, Builder builder) { @@ -191,7 +190,7 @@ public final class ForgeBiomeModifiers * "entity_types": #namespace:entitytype_tag // Accepts an entity type, [list of entity types], or #namespace:entitytype_tag * } * - * + * * @param biomes Biomes to add mob spawns to. * @param entityTypes EntityTypes to remove from spawn lists. */ diff --git a/src/main/java/net/minecraftforge/data/event/GatherDataEvent.java b/src/main/java/net/minecraftforge/data/event/GatherDataEvent.java index aaa83087be..f549b3e2d6 100644 --- a/src/main/java/net/minecraftforge/data/event/GatherDataEvent.java +++ b/src/main/java/net/minecraftforge/data/event/GatherDataEvent.java @@ -7,6 +7,7 @@ package net.minecraftforge.data.event; import cpw.mods.modlauncher.api.LamdbaExceptionUtils; import net.minecraft.DetectedVersion; +import net.minecraft.core.HolderLookup; import net.minecraft.data.DataGenerator; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.eventbus.api.Event; @@ -20,6 +21,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.CompletableFuture; import java.util.function.Function; import java.util.stream.Collectors; @@ -44,6 +46,7 @@ public class GatherDataEvent extends Event implements IModBusEvent public DataGenerator getGenerator() { return this.dataGenerator; } public ExistingFileHelper getExistingFileHelper() { return existingFileHelper; } + public CompletableFuture getLookupProvider() { return this.config.lookupProvider; } public boolean includeServer() { return this.config.server; } public boolean includeClient() { return this.config.client; } public boolean includeDev() { return this.config.dev; } @@ -54,18 +57,21 @@ public class GatherDataEvent extends Event implements IModBusEvent private final Set mods; private final Path path; private final Collection inputs; + private final CompletableFuture lookupProvider; private final boolean server; private final boolean client; private final boolean dev; private final boolean reports; private final boolean validate; private final boolean flat; - private List generators = new ArrayList<>(); + private final List generators = new ArrayList<>(); - public DataGeneratorConfig(final Set mods, final Path path, final Collection inputs, final boolean server, final boolean client, final boolean dev, final boolean reports, final boolean validate, final boolean flat) { + public DataGeneratorConfig(final Set mods, final Path path, final Collection inputs, final CompletableFuture lookupProvider, + final boolean server, final boolean client, final boolean dev, final boolean reports, final boolean validate, final boolean flat) { this.mods = mods; this.path = path; this.inputs = inputs; + this.lookupProvider = lookupProvider; this.server = server; this.client = client; this.dev = dev; @@ -75,6 +81,10 @@ public class GatherDataEvent extends Event implements IModBusEvent } + public Collection getInputs() { + return this.inputs; + } + public Set getMods() { return mods; } @@ -84,19 +94,19 @@ public class GatherDataEvent extends Event implements IModBusEvent } public DataGenerator makeGenerator(final Function pathEnhancer, final boolean shouldExecute) { - final DataGenerator generator = new DataGenerator(pathEnhancer.apply(path), inputs, DetectedVersion.tryDetectVersion(), shouldExecute); + final DataGenerator generator = new DataGenerator(pathEnhancer.apply(path), DetectedVersion.tryDetectVersion(), shouldExecute); if (shouldExecute) generators.add(generator); return generator; } public void runAll() { - Map> paths = generators.stream().collect(Collectors.groupingBy(DataGenerator::getOutputFolder, LinkedHashMap::new, Collectors.toList())); + Map> paths = generators.stream().collect(Collectors.groupingBy(gen -> gen.getPackOutput().getOutputFolder(), LinkedHashMap::new, Collectors.toList())); paths.values().forEach(LamdbaExceptionUtils.rethrowConsumer(lst -> { DataGenerator parent = lst.get(0); for (int x = 1; x < lst.size(); x++) - lst.get(x).getProviders().forEach(i -> parent.addProvider(true, i)); + lst.get(x).getProvidersView().forEach((name, provider) -> parent.addProvider(true, provider)); parent.run(); })); } diff --git a/src/main/java/net/minecraftforge/data/loading/DatagenModLoader.java b/src/main/java/net/minecraftforge/data/loading/DatagenModLoader.java index 1c24b02779..8442c2f6c2 100644 --- a/src/main/java/net/minecraftforge/data/loading/DatagenModLoader.java +++ b/src/main/java/net/minecraftforge/data/loading/DatagenModLoader.java @@ -5,6 +5,9 @@ package net.minecraftforge.data.loading; +import net.minecraft.Util; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.registries.VanillaRegistries; import net.minecraft.server.Bootstrap; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.fml.ModLoader; @@ -17,6 +20,7 @@ import java.io.File; import java.nio.file.Path; import java.util.Collection; import java.util.Set; +import java.util.concurrent.CompletableFuture; public class DatagenModLoader { private static final Logger LOGGER = LogManager.getLogger(); @@ -28,19 +32,25 @@ public class DatagenModLoader { return runningDataGen; } - public static void begin(final Set mods, final Path path, final Collection inputs, Collection existingPacks, Set existingMods, final boolean serverGenerators, final boolean clientGenerators, final boolean devToolGenerators, final boolean reportsGenerator, final boolean structureValidator, final boolean flat, final String assetIndex, final File assetsDir) { - if (mods.contains("minecraft") && mods.size() == 1) return; + public static void begin(final Set mods, final Path path, final Collection inputs, Collection existingPacks, + Set existingMods, final boolean serverGenerators, final boolean clientGenerators, final boolean devToolGenerators, final boolean reportsGenerator, + final boolean structureValidator, final boolean flat, final String assetIndex, final File assetsDir) { + if (mods.contains("minecraft") && mods.size() == 1) + return; LOGGER.info("Initializing Data Gatherer for mods {}", mods); runningDataGen = true; Bootstrap.bootStrap(); - dataGeneratorConfig = new GatherDataEvent.DataGeneratorConfig(mods, path, inputs, serverGenerators, clientGenerators, devToolGenerators, reportsGenerator, structureValidator, flat); + CompletableFuture lookupProvider = CompletableFuture.supplyAsync(VanillaRegistries::createLookup, Util.backgroundExecutor()); + dataGeneratorConfig = new GatherDataEvent.DataGeneratorConfig(mods, path, inputs, lookupProvider, serverGenerators, + clientGenerators, devToolGenerators, reportsGenerator, structureValidator, flat); ModLoader.get().gatherAndInitializeMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), ()->{}); if (!mods.contains("forge")) { - //If we aren't generating data for forge, automatically add forge as an existing so mods can access forge's data + // If we aren't generating data for forge, automatically add forge as an existing so mods can access forge's data existingMods.add("forge"); } existingFileHelper = new ExistingFileHelper(existingPacks, existingMods, structureValidator, assetIndex, assetsDir); - ModLoader.get().runEventGenerator(mc->new GatherDataEvent(mc, dataGeneratorConfig.makeGenerator(p->dataGeneratorConfig.isFlat() ? p : p.resolve(mc.getModId()), dataGeneratorConfig.getMods().contains(mc.getModId())), dataGeneratorConfig, existingFileHelper)); + ModLoader.get().runEventGenerator(mc -> new GatherDataEvent(mc, dataGeneratorConfig.makeGenerator(p -> dataGeneratorConfig.isFlat() ? p : p.resolve(mc.getModId()), + dataGeneratorConfig.getMods().contains(mc.getModId())), dataGeneratorConfig, existingFileHelper)); dataGeneratorConfig.runAll(); } } diff --git a/src/main/java/net/minecraftforge/entity/PartEntity.java b/src/main/java/net/minecraftforge/entity/PartEntity.java index b30622d0c5..4c606f5155 100644 --- a/src/main/java/net/minecraftforge/entity/PartEntity.java +++ b/src/main/java/net/minecraftforge/entity/PartEntity.java @@ -5,6 +5,7 @@ package net.minecraftforge.entity; +import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.world.entity.Entity; import net.minecraft.network.protocol.Packet; @@ -21,7 +22,7 @@ public abstract class PartEntity extends Entity { } @Override - public Packet getAddEntityPacket() { + public Packet getAddEntityPacket() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/net/minecraftforge/event/AddPackFindersEvent.java b/src/main/java/net/minecraftforge/event/AddPackFindersEvent.java index e5480ded74..d637c53869 100644 --- a/src/main/java/net/minecraftforge/event/AddPackFindersEvent.java +++ b/src/main/java/net/minecraftforge/event/AddPackFindersEvent.java @@ -6,6 +6,7 @@ package net.minecraftforge.event; import net.minecraft.server.packs.PackType; +import net.minecraft.server.packs.repository.PackRepository; import net.minecraft.server.packs.repository.RepositorySource; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.event.IModBusEvent; @@ -13,7 +14,7 @@ import net.minecraftforge.fml.event.IModBusEvent; import java.util.function.Consumer; /** - * Fired on PackRepository creation to allow mods to add new pack finders. + * Fired on {@link PackRepository} creation to allow mods to add new pack finders. */ public class AddPackFindersEvent extends Event implements IModBusEvent { @@ -36,7 +37,7 @@ public class AddPackFindersEvent extends Event implements IModBusEvent } /** - * @return the {@link PackType} of the resource manager being constructed. + * @return the {@link PackType} of the pack repository being constructed. */ public PackType getPackType() { diff --git a/src/main/java/net/minecraftforge/event/CreativeModeTabEvent.java b/src/main/java/net/minecraftforge/event/CreativeModeTabEvent.java new file mode 100644 index 0000000000..aa6a4ce2d3 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/CreativeModeTabEvent.java @@ -0,0 +1,236 @@ +/* + * Copyright (c) Forge Development LLC and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.minecraftforge.event; + +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.function.Consumer; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.flag.FeatureFlagSet; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.ItemLike; +import net.minecraftforge.common.CreativeModeTabRegistry; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.fml.LogicalSide; +import net.minecraftforge.fml.event.IModBusEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +public class CreativeModeTabEvent extends Event implements IModBusEvent +{ + private static final List DEFAULT_AFTER_ENTRIES = List.of(CreativeModeTabs.SPAWN_EGGS); + + @ApiStatus.Internal + public CreativeModeTabEvent() {} + + /** + * A registrar which is capable of registering new tabs. + */ + @FunctionalInterface + public interface Registrar { + + /** + * Register a new tab. + * + * @param configurator The tab configurator to register + * @param name The name of the tab. + * @param afters A list of tab names (String, ResourceLocations) or tabs that need to appear before this tab in the creative mode menu. + * @param befores A list of tab names (String, ResourceLocations) or tabs that need to appear after this tab in the creative mode menu. + * @return The configured tab. + */ + @NotNull + CreativeModeTab registerCreativeModeTab(@NotNull final Consumer configurator, @NotNull final ResourceLocation name, @NotNull final List afters, @NotNull final List befores); + } + + /** + * Fired when creative mode tabs can be registered. + *

+ * This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

+ * This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus}, + * on both {@linkplain LogicalSide logical sides}. + */ + public static final class Register extends CreativeModeTabEvent + { + private final Registrar registrar; + + @ApiStatus.Internal + public Register(Registrar registrar) { + this.registrar = registrar; + } + + /** + * Registers and configures a creative mode tab with the given name and returns the built instance. + * + * @param name the name of the tab. Must be unique. + * @param beforeEntries the list of {@linkplain ResourceLocation tab names} or {@linkplain CreativeModeTab tabs} that should appear before this tab in the creative mode inventory screen + * @param afterEntries the list of {@linkplain ResourceLocation tab names} or {@linkplain CreativeModeTab tabs} that should appear after this tab in the creative mode inventory screen + * @param configurator the configurator which configures the builder + * @return the configured creative mode tab + * @see #registerCreativeModeTab(ResourceLocation, Consumer) + */ + public CreativeModeTab registerCreativeModeTab(ResourceLocation name, List beforeEntries, List afterEntries, Consumer configurator) + { + return registrar.registerCreativeModeTab(configurator, name, afterEntries, beforeEntries); + } + + /** + * Registers and configures a creative mode tab with the given name and returns the built instance. + * The tab is sorted by default to be after {@link CreativeModeTabs#SPAWN_EGGS}. + * + * @param name the name of the tab. Must be unique. + * @param configurator the configurator which configures the builder + * @return the configured creative mode tab + * @see #registerCreativeModeTab(ResourceLocation, List, List, Consumer) + */ + public CreativeModeTab registerCreativeModeTab(ResourceLocation name, Consumer configurator) + { + return registrar.registerCreativeModeTab(configurator, name, DEFAULT_AFTER_ENTRIES, List.of()); + } + } + + /** + * Fired when the contents of a specific creative mode tab are being populated. + * This event may be fired multiple times if the operator status of the local player or enabled feature flags changes. + *

+ * This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

+ * This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus}, + * only on the {@linkplain LogicalSide#CLIENT logical client}. + */ + public static final class BuildContents extends CreativeModeTabEvent + { + private final CreativeModeTab tab; + private final Set customGenerators; + + @ApiStatus.Internal + public BuildContents(CreativeModeTab tab, Set customGenerators) + { + this.tab = tab; + this.customGenerators = customGenerators; + } + + /** + * Registers the given generator. + */ + public void register(DisplayItemsAdapter generator) + { + this.customGenerators.add(generator); + } + + /** + * Registers the given generator if the provided creative mode tab matches this event's currently populating tab. + */ + public void register(CreativeModeTab tab, DisplayItemsAdapter generator) + { + if (this.tab == tab) + this.customGenerators.add(generator); + } + + /** + * Registers the given generator if the provided tab name matches this event's currently populating tab's name. + */ + public void register(ResourceLocation tabName, DisplayItemsAdapter generator) + { + if (this.tab == CreativeModeTabRegistry.getTab(tabName)) + this.customGenerators.add(generator); + } + + /** + * Adds the given item if the provided creative mode tab matches this event's currently populating tab. + */ + public void registerSimple(CreativeModeTab tab, ItemLike item) + { + this.register(tab, (enabledFlags, output, permissions) -> output.accept(item)); + } + + /** + * Adds the given items if the provided creative mode tab matches this event's currently populating tab. + */ + public void registerSimple(CreativeModeTab tab, ItemLike... items) + { + this.register(tab, (enabledFlags, output, permissions) -> output.acceptAll(items)); + } + + /** + * {@return the creative mode tab currently populating its contents} + */ + public CreativeModeTab getTab() + { + return this.tab; + } + } + + @FunctionalInterface + public interface DisplayItemsAdapter + { + void accept(FeatureFlagSet enabledFlags, CreativeModeTabPopulator populator, boolean hasPermissions); + } + + @FunctionalInterface + public interface CreativeModeTabPopulator + { + void accept(ItemStack stack, CreativeModeTab.TabVisibility visibility, ItemStack before, ItemStack after); + + default void accept(ItemStack stack, ItemStack before, ItemStack after) + { + accept(stack, CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS, before, after); + } + + default void accept(ItemLike stack, CreativeModeTab.TabVisibility visibility, ItemStack before, ItemStack after) + { + accept(new ItemStack(stack), visibility, before, after); + } + + default void accept(ItemLike stack, ItemStack before, ItemStack after) + { + accept(stack, CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS, before, after); + } + + default void accept(ItemStack stack, CreativeModeTab.TabVisibility visibility) + { + accept(stack, visibility, ItemStack.EMPTY, ItemStack.EMPTY); + } + + default void accept(ItemStack stack) + { + this.accept(stack, CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS); + } + + default void accept(ItemLike itemLike, CreativeModeTab.TabVisibility visibility) + { + this.accept(new ItemStack(itemLike), visibility); + } + + default void accept(ItemLike itemLike) + { + this.accept(new ItemStack(itemLike), CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS); + } + + default void acceptAll(Collection stacks, CreativeModeTab.TabVisibility visibility) + { + stacks.forEach(stack -> this.accept(stack, visibility)); + } + + default void acceptAll(Collection stacks) + { + this.acceptAll(stacks, CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS); + } + + default void acceptAll(ItemLike... items) + { + for (ItemLike item : items) + { + this.accept(item); + } + } + } +} diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index 6d1503566a..80214a2d77 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -362,7 +362,7 @@ public class ForgeEventFactory return null; } - public static PlayLevelSoundEvent.AtEntity onPlaySoundAtEntity(Entity entity, SoundEvent name, SoundSource category, float volume, float pitch) + public static PlayLevelSoundEvent.AtEntity onPlaySoundAtEntity(Entity entity, Holder name, SoundSource category, float volume, float pitch) { PlayLevelSoundEvent.AtEntity event = new PlayLevelSoundEvent.AtEntity(entity, name, category, volume, pitch); MinecraftForge.EVENT_BUS.post(event); @@ -370,7 +370,7 @@ public class ForgeEventFactory } - public static PlayLevelSoundEvent.AtPosition onPlaySoundAtPosition(Level level, double x, double y, double z, SoundEvent name, SoundSource category, float volume, float pitch) + public static PlayLevelSoundEvent.AtPosition onPlaySoundAtPosition(Level level, double x, double y, double z, Holder name, SoundSource category, float volume, float pitch) { PlayLevelSoundEvent.AtPosition event = new PlayLevelSoundEvent.AtPosition(level, new Vec3(x, y, z), name, category, volume, pitch); MinecraftForge.EVENT_BUS.post(event); @@ -579,7 +579,7 @@ public class ForgeEventFactory return event.getTable(); } - public static boolean canCreateFluidSource(LevelReader level, BlockPos pos, BlockState state, boolean def) + public static boolean canCreateFluidSource(Level level, BlockPos pos, BlockState state, boolean def) { CreateFluidSourceEvent evt = new CreateFluidSourceEvent(level, pos, state); MinecraftForge.EVENT_BUS.post(evt); @@ -606,8 +606,11 @@ public class ForgeEventFactory return !MinecraftForge.EVENT_BUS.post(new LivingDestroyBlockEvent(entity, pos, state)); } - public static boolean getMobGriefingEvent(Level level, Entity entity) + public static boolean getMobGriefingEvent(Level level, @Nullable Entity entity) { + if (entity == null) + return level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); + EntityMobGriefingEvent event = new EntityMobGriefingEvent(entity); MinecraftForge.EVENT_BUS.post(event); @@ -621,7 +624,7 @@ public class ForgeEventFactory return !blockGrowFeature(level, randomSource, pos, null).getResult().equals(Result.DENY); } - public static SaplingGrowTreeEvent blockGrowFeature(LevelAccessor level, RandomSource randomSource, BlockPos pos, Holder> holder) + public static SaplingGrowTreeEvent blockGrowFeature(LevelAccessor level, RandomSource randomSource, BlockPos pos, @Nullable Holder> holder) { SaplingGrowTreeEvent event = new SaplingGrowTreeEvent(level, randomSource, pos, holder); MinecraftForge.EVENT_BUS.post(event); diff --git a/src/main/java/net/minecraftforge/event/PlayLevelSoundEvent.java b/src/main/java/net/minecraftforge/event/PlayLevelSoundEvent.java index c0023fa5d7..508dcd23f5 100644 --- a/src/main/java/net/minecraftforge/event/PlayLevelSoundEvent.java +++ b/src/main/java/net/minecraftforge/event/PlayLevelSoundEvent.java @@ -6,6 +6,7 @@ package net.minecraftforge.event; import net.minecraft.client.player.LocalPlayer; +import net.minecraft.core.Holder; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; import net.minecraft.world.entity.Entity; @@ -42,12 +43,12 @@ public class PlayLevelSoundEvent extends Event private final Level level; private final float originalVolume; private final float originalPitch; - private SoundEvent sound; + private Holder sound; private SoundSource source; private float newVolume; private float newPitch; - public PlayLevelSoundEvent(@NotNull Level level, @NotNull SoundEvent sound, @NotNull SoundSource source, float volume, float pitch) + public PlayLevelSoundEvent(@NotNull Level level, @NotNull Holder sound, @NotNull SoundSource source, float volume, float pitch) { this.level = level; this.sound = sound; @@ -71,7 +72,7 @@ public class PlayLevelSoundEvent extends Event * {@return the sound event to be played} */ @Nullable - public SoundEvent getSound() + public Holder getSound() { return this.sound; } @@ -79,7 +80,7 @@ public class PlayLevelSoundEvent extends Event /** * Sets the sound event to be played. */ - public void setSound(@Nullable SoundEvent sound) + public void setSound(@Nullable Holder sound) { this.sound = sound; } @@ -165,7 +166,7 @@ public class PlayLevelSoundEvent extends Event { private final Entity entity; - public AtEntity(Entity entity, SoundEvent sound, SoundSource source, float volume, float pitch) + public AtEntity(Entity entity, Holder sound, SoundSource source, float volume, float pitch) { super(entity.level, sound, source, volume, pitch); this.entity = entity; @@ -195,7 +196,7 @@ public class PlayLevelSoundEvent extends Event { private final Vec3 position; - public AtPosition(Level level, Vec3 position, SoundEvent sound, SoundSource source, float volume, float pitch) + public AtPosition(Level level, Vec3 position, Holder sound, SoundSource source, float volume, float pitch) { super(level, sound, source, volume, pitch); this.position = position; diff --git a/src/main/java/net/minecraftforge/event/ServerChatEvent.java b/src/main/java/net/minecraftforge/event/ServerChatEvent.java index 78098147d7..4a029628e2 100644 --- a/src/main/java/net/minecraftforge/event/ServerChatEvent.java +++ b/src/main/java/net/minecraftforge/event/ServerChatEvent.java @@ -6,35 +6,24 @@ package net.minecraftforge.event; import java.util.Objects; -import net.minecraft.client.Options; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ServerboundChatPacket; -import net.minecraft.network.protocol.game.ServerboundChatPreviewPacket; import net.minecraft.server.level.ServerPlayer; -import net.minecraftforge.common.ForgeMod; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; /** - * This event is fired whenever a {@link ServerboundChatPreviewPacket} or {@link ServerboundChatPacket} is received. - *

- * Mods that modify chat messages from this event should call {@link ForgeMod#enableServerChatPreview()} - * from their mod constructor to enable the chat preview and allow signing by clients. - * It is recommended to listen to this event class when modifying chat messages - * rather than a subclass to ensure clients with {@link Options#onlyShowSecureChat()} - * enabled can see the modified messages. + * This event is fired whenever a {@link ServerboundChatPacket} is received from a client + * who has submitted their chat message. *

* This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. * If the event is cancelled, the message will not be sent to clients. *

* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#SERVER logical server}. - * - * @see ForgeMod#enableServerChatPreview() **/ @Cancelable public class ServerChatEvent extends Event @@ -42,16 +31,14 @@ public class ServerChatEvent extends Event private final ServerPlayer player; private final String username; private final String rawText; - private final boolean canChangeMessage; private Component message; @ApiStatus.Internal - protected ServerChatEvent(ServerPlayer player, String rawText, Component message, boolean canChangeMessage) + public ServerChatEvent(ServerPlayer player, String rawText, Component message) { this.player = player; this.username = player.getGameProfile().getName(); this.rawText = rawText; - this.canChangeMessage = canChangeMessage; this.message = message; } @@ -79,33 +66,11 @@ public class ServerChatEvent extends Event return this.rawText; } - /** - * {@return whether the message can be changed or not}. - * In vanilla, this will be false if a {@link ServerboundChatPacket} is received - * with signed decorated content already included by the sending player. - * Players who submit a chat message with chat previews disabled will cause this to be true. - */ - public boolean canChangeMessage() - { - return this.canChangeMessage; - } - /** * Set the message to be sent to the relevant clients. - *

- * If {@link #canChangeMessage()} is false, this call will be ignored. - *

- * It is recommended to listen to {@link ServerChatEvent} when modifying chat messages - * rather than a subclass to ensure clients with {@link Options#onlyShowSecureChat()} - * enabled can see the modified messages. - * - * @see ForgeMod#enableServerChatPreview() */ public void setMessage(Component message) { - if (!this.canChangeMessage) - return; - this.message = Objects.requireNonNull(message); } @@ -116,59 +81,4 @@ public class ServerChatEvent extends Event { return this.message; } - - /** - * This event is fired whenever a {@link ServerboundChatPreviewPacket} is received from a client typing a message. - *

- * This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. - * If the event is cancelled, the chat preview sent back to the client will match the original message. - *

- * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#SERVER logical server}. - **/ - public static class Preview extends ServerChatEvent - { - @ApiStatus.Internal - public Preview(ServerPlayer player, String rawText, Component message) - { - super(player, rawText, message, true); - } - - /** - * Set the chat preview to be sent back to the client. - */ - @Override - public void setMessage(Component message) - { - super.setMessage(message); - } - - /** - * {@return the chat preview that will be sent back to the client, if the event is not cancelled} - */ - @Override - public Component getMessage() - { - return super.getMessage(); - } - } - - /** - * This event is fired whenever a {@link ServerboundChatPacket} is received from a client - * who has submitted their chat message. - *

- * This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. - * If the event is cancelled, the message will not be sent to clients. - *

- * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#SERVER logical server}. - **/ - public static class Submitted extends ServerChatEvent - { - @ApiStatus.Internal - public Submitted(ServerPlayer player, String rawText, Component message, boolean canChangeMessage) - { - super(player, rawText, message, canChangeMessage); - } - } } diff --git a/src/main/java/net/minecraftforge/event/level/BlockEvent.java b/src/main/java/net/minecraftforge/event/level/BlockEvent.java index b0634ae8d4..9fa73963b4 100644 --- a/src/main/java/net/minecraftforge/event/level/BlockEvent.java +++ b/src/main/java/net/minecraftforge/event/level/BlockEvent.java @@ -230,18 +230,18 @@ public class BlockEvent extends Event @HasResult public static class CreateFluidSourceEvent extends Event { - private final LevelReader level; + private final Level level; private final BlockPos pos; private final BlockState state; - public CreateFluidSourceEvent(LevelReader level, BlockPos pos, BlockState state) + public CreateFluidSourceEvent(Level level, BlockPos pos, BlockState state) { this.level = level; this.pos = pos; this.state = state; } - public LevelReader getLevel() + public Level getLevel() { return level; } diff --git a/src/main/java/net/minecraftforge/event/level/SaplingGrowTreeEvent.java b/src/main/java/net/minecraftforge/event/level/SaplingGrowTreeEvent.java index d5dc484b2a..d7770db2ab 100644 --- a/src/main/java/net/minecraftforge/event/level/SaplingGrowTreeEvent.java +++ b/src/main/java/net/minecraftforge/event/level/SaplingGrowTreeEvent.java @@ -7,6 +7,8 @@ package net.minecraftforge.event.level; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; import net.minecraft.world.level.LevelAccessor; @@ -16,6 +18,7 @@ import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event.HasResult; +import org.jetbrains.annotations.Nullable; /** * This event is fired whenever a sapling, fungus, mushroom or azalea grows into a tree. @@ -36,6 +39,7 @@ public class SaplingGrowTreeEvent extends LevelEvent { private final RandomSource randomSource; private final BlockPos pos; + @Nullable private Holder> feature; @Deprecated(forRemoval = true, since = "1.19.2") @@ -44,7 +48,7 @@ public class SaplingGrowTreeEvent extends LevelEvent this(level, randomSource, pos, null); } - public SaplingGrowTreeEvent(LevelAccessor level, RandomSource randomSource, BlockPos pos, Holder> feature) + public SaplingGrowTreeEvent(LevelAccessor level, RandomSource randomSource, BlockPos pos, @Nullable Holder> feature) { super(level); this.randomSource = randomSource; @@ -69,13 +73,18 @@ public class SaplingGrowTreeEvent extends LevelEvent } /** - * {@return the holder of the feature which will be placed} + * {@return the holder of the feature which will be placed, possibly null} */ + @Nullable public Holder> getFeature() { return feature; } - public void setFeature(Holder> feature) { + public void setFeature(@Nullable Holder> feature) { this.feature = feature; } + + public void setFeature(ResourceKey> featureKey) { + this.feature = this.getLevel().registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).getHolder(featureKey).orElse(null); + } } diff --git a/src/main/java/net/minecraftforge/fluids/FluidStack.java b/src/main/java/net/minecraftforge/fluids/FluidStack.java index 838ba95687..5c4cfaa881 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidStack.java +++ b/src/main/java/net/minecraftforge/fluids/FluidStack.java @@ -8,6 +8,7 @@ package net.minecraftforge.fluids; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.core.Holder; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.Tag; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluids; @@ -15,7 +16,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; -import net.minecraft.core.Registry; import net.minecraft.network.chat.Component; import net.minecraftforge.registries.ForgeRegistries; @@ -41,7 +41,7 @@ public class FluidStack public static final Codec CODEC = RecordCodecBuilder.create( instance -> instance.group( - Registry.FLUID.byNameCodec().fieldOf("FluidName").forGetter(FluidStack::getFluid), + BuiltInRegistries.FLUID.byNameCodec().fieldOf("FluidName").forGetter(FluidStack::getFluid), Codec.INT.fieldOf("Amount").forGetter(FluidStack::getAmount), CompoundTag.CODEC.optionalFieldOf("Tag").forGetter(stack -> Optional.ofNullable(stack.getTag())) ).apply(instance, (fluid, amount, tag) -> { diff --git a/src/main/java/net/minecraftforge/fluids/ForgeFlowingFluid.java b/src/main/java/net/minecraftforge/fluids/ForgeFlowingFluid.java index 670b1725ba..681f94f153 100644 --- a/src/main/java/net/minecraftforge/fluids/ForgeFlowingFluid.java +++ b/src/main/java/net/minecraftforge/fluids/ForgeFlowingFluid.java @@ -7,6 +7,7 @@ package net.minecraftforge.fluids; import java.util.Optional; import net.minecraft.sounds.SoundEvent; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.Blocks; @@ -75,15 +76,15 @@ public abstract class ForgeFlowingFluid extends FlowingFluid } @Override - protected boolean canConvertToSource() + protected boolean canConvertToSource(Level level) { return false; } @Override - public boolean canConvertToSource(FluidState state, LevelReader reader, BlockPos pos) + public boolean canConvertToSource(FluidState state, Level level, BlockPos pos) { - return this.getFluidType().canConvertToSource(state, reader, pos); + return this.getFluidType().canConvertToSource(state, level, pos); } @Override diff --git a/src/main/java/net/minecraftforge/network/PlayMessages.java b/src/main/java/net/minecraftforge/network/PlayMessages.java index a7a269a8d5..f10c8e1cec 100644 --- a/src/main/java/net/minecraftforge/network/PlayMessages.java +++ b/src/main/java/net/minecraftforge/network/PlayMessages.java @@ -12,6 +12,7 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.MenuAccess; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; @@ -53,7 +54,7 @@ public class PlayMessages SpawnEntity(Entity e) { this.entity = e; - this.typeId = Registry.ENTITY_TYPE.getId(e.getType()); //TODO: Codecs + this.typeId = BuiltInRegistries.ENTITY_TYPE.getId(e.getType()); //TODO: Codecs this.entityId = e.getId(); this.uuid = e.getUUID(); this.posX = e.getX(); @@ -144,7 +145,7 @@ public class PlayMessages ctx.get().enqueueWork(() -> { try { - EntityType type = Registry.ENTITY_TYPE.byId(msg.typeId); + EntityType type = BuiltInRegistries.ENTITY_TYPE.byId(msg.typeId); Optional world = LogicalSidedProvider.CLIENTWORLD.get(ctx.get().getDirection().getReceptionSide()); Entity e = world.map(w -> type.customClientSpawn(msg, w)).orElse(null); if (e == null) @@ -257,7 +258,7 @@ public class PlayMessages OpenContainer(MenuType id, int windowId, Component name, FriendlyByteBuf additionalData) { - this(Registry.MENU.getId(id), windowId, name, additionalData); + this(BuiltInRegistries.MENU.getId(id), windowId, name, additionalData); } private OpenContainer(int id, int windowId, Component name, FriendlyByteBuf additionalData) @@ -304,7 +305,7 @@ public class PlayMessages public final MenuType getType() { - return Registry.MENU.byId(this.id); + return BuiltInRegistries.MENU.byId(this.id); } public int getWindowId() diff --git a/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java b/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java index d98b7f256a..5ce436e0c4 100644 --- a/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java +++ b/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java @@ -13,11 +13,14 @@ import java.util.stream.Collectors; import io.netty.channel.ChannelHandler; import net.minecraft.commands.CommandBuildContext; +import net.minecraft.commands.Commands; import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.synchronization.ArgumentTypeInfo; import net.minecraft.commands.synchronization.ArgumentTypeInfos; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.data.registries.VanillaRegistries; import net.minecraft.gametest.framework.TestClassNameArgument; import net.minecraft.gametest.framework.TestFunctionArgument; import net.minecraft.network.protocol.Packet; @@ -27,11 +30,15 @@ import net.minecraft.network.protocol.game.ClientboundUpdateAttributesPacket; import net.minecraft.network.protocol.game.ClientboundUpdateTagsPacket; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; import net.minecraft.tags.TagNetworkSerialization; +import net.minecraft.world.flag.FeatureFlagSet; +import net.minecraft.world.flag.FeatureFlags; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryManager; +import net.minecraftforge.server.ServerLifecycleHooks; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; @@ -89,15 +96,14 @@ public class VanillaConnectionNetworkFilter extends VanillaPacketFilter @NotNull private static ClientboundCommandsPacket filterCommandList(ClientboundCommandsPacket packet) { - CommandBuildContext commandBuildContext = new CommandBuildContext(RegistryAccess.BUILTIN.get()); - commandBuildContext.missingTagAccessPolicy(CommandBuildContext.MissingTagAccessPolicy.RETURN_EMPTY); + CommandBuildContext commandBuildContext = Commands.createValidationContext(VanillaRegistries.createLookup()); RootCommandNode root = packet.getRoot(commandBuildContext); RootCommandNode newRoot = CommandTreeCleaner.cleanArgumentTypes(root, argType -> { if (argType instanceof TestFunctionArgument || argType instanceof TestClassNameArgument) return false; // Vanilla connections should not have gametest on, so we should filter these out always ArgumentTypeInfo info = ArgumentTypeInfos.byClass(argType); - ResourceLocation id = Registry.COMMAND_ARGUMENT_TYPE.getKey(info); + ResourceLocation id = BuiltInRegistries.COMMAND_ARGUMENT_TYPE.getKey(info); return id != null && (id.getNamespace().equals("minecraft") || id.getNamespace().equals("brigadier")); }); return new ClientboundCommandsPacket(newRoot); @@ -116,8 +122,8 @@ public class VanillaConnectionNetworkFilter extends VanillaPacketFilter private static boolean isVanillaRegistry(ResourceLocation location) { - // Checks if the registry name is contained within the static view of vanilla registries both in Registry and builtin registries + // Checks if the registry name is contained within the static view of both BuiltInRegistries and VanillaRegistries return RegistryManager.getVanillaRegistryKeys().contains(location) - || RegistryAccess.REGISTRIES.keySet().stream().anyMatch(k -> k.location().equals(location)); + || VanillaRegistries.DATAPACK_REGISTRY_KEYS.stream().anyMatch(k -> k.location().equals(location)); } } diff --git a/src/main/java/net/minecraftforge/registries/DataPackRegistriesHooks.java b/src/main/java/net/minecraftforge/registries/DataPackRegistriesHooks.java index 117ec09881..5b97315a93 100644 --- a/src/main/java/net/minecraftforge/registries/DataPackRegistriesHooks.java +++ b/src/main/java/net/minecraftforge/registries/DataPackRegistriesHooks.java @@ -5,51 +5,47 @@ package net.minecraftforge.registries; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -import com.google.common.collect.ImmutableMap; - import net.minecraft.core.Registry; -import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.RegistryDataLoader; import net.minecraft.resources.ResourceKey; +import org.jetbrains.annotations.ApiStatus; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; @ApiStatus.Internal public final class DataPackRegistriesHooks { private DataPackRegistriesHooks() {} // utility class - - private static Map>, RegistryAccess.RegistryData> REGISTRY_ACCESS_REGISTRIES_COPY; - private static final Set>> SYNCED_CUSTOM_REGISTRIES = new HashSet<>(); - private static final Set>> SYNCED_CUSTOM_REGISTRIES_VIEW = Collections.unmodifiableSet(SYNCED_CUSTOM_REGISTRIES); - /* Internal forge hook for retaining mutable access to RegistryAccess's codec registry when it bootstraps. */ - public static Map>, RegistryAccess.RegistryData> grabBuiltinRegistries(ImmutableMap.Builder>, RegistryAccess.RegistryData> builder) - { - REGISTRY_ACCESS_REGISTRIES_COPY = new HashMap<>(builder.build()); - SYNCED_CUSTOM_REGISTRIES.clear(); - return Collections.unmodifiableMap(REGISTRY_ACCESS_REGISTRIES_COPY); - } + private static final List> DATA_PACK_REGISTRIES = new ArrayList<>(RegistryDataLoader.WORLDGEN_REGISTRIES); + private static final List> DATA_PACK_REGISTRIES_VIEW = Collections.unmodifiableList(DATA_PACK_REGISTRIES); + private static final Set>> SYNCED_CUSTOM_REGISTRIES = new HashSet<>(); + private static final Set>> SYNCED_CUSTOM_REGISTRIES_VIEW = Collections.unmodifiableSet(SYNCED_CUSTOM_REGISTRIES); /* Internal forge method, registers a datapack registry codec and folder. */ - public static void addRegistryCodec(@NotNull RegistryAccess.RegistryData data) + static void addRegistryCodec(DataPackRegistryEvent.DataPackRegistryData data) { - ResourceKey> registryKey = data.key(); - REGISTRY_ACCESS_REGISTRIES_COPY.put(registryKey, data); + RegistryDataLoader.RegistryData loaderData = data.loaderData(); + DATA_PACK_REGISTRIES.add(loaderData); if (data.networkCodec() != null) - { - SYNCED_CUSTOM_REGISTRIES.add(registryKey); - } + SYNCED_CUSTOM_REGISTRIES.add(loaderData.key()); } - + /** - * {@return unmodifiable view of the set of synced non-vanilla datapack registry IDs} + * {@return An unmodifiable view of the list of datapack registries}. + * These registries are loaded from per-world datapacks on server startup. + */ + public static List> getDataPackRegistries() + { + return DATA_PACK_REGISTRIES_VIEW; + } + + /** + * {@return An unmodifiable view of the set of synced non-vanilla datapack registry IDs} * Clients must have each of a server's synced datapack registries to be able to connect to that server; * vanilla clients therefore cannot connect if this list is non-empty on the server. */ diff --git a/src/main/java/net/minecraftforge/registries/DataPackRegistryEvent.java b/src/main/java/net/minecraftforge/registries/DataPackRegistryEvent.java new file mode 100644 index 0000000000..912c0a062f --- /dev/null +++ b/src/main/java/net/minecraftforge/registries/DataPackRegistryEvent.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) Forge Development LLC and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.minecraftforge.registries; + +import com.mojang.serialization.Codec; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.client.multiplayer.ClientPacketListener; +import net.minecraft.core.Registry; +import net.minecraft.resources.RegistryDataLoader; +import net.minecraft.resources.ResourceKey; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.fml.LogicalSide; +import net.minecraftforge.fml.event.IModBusEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +public class DataPackRegistryEvent extends Event implements IModBusEvent +{ + @ApiStatus.Internal + public DataPackRegistryEvent() {} + + /** + * Fired when datapack registries can be registered. + * Datapack registries are registries which can only load entries through JSON files from datapacks. + *

+ * Data JSONs will be loaded from {@code data//modid/registryname/}, where {@code modid} is the namespace of the registry key. + *

+ * This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. + *

+ * This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus}, + * on both {@linkplain LogicalSide logical sides}. + */ + public static final class NewRegistry extends DataPackRegistryEvent + { + private final List> registryDataList = new ArrayList<>(); + + @ApiStatus.Internal + public NewRegistry() {} + + /** + * Registers the given registry key as an unsynced datapack registry, which will cause data to be loaded from + * a datapack folder based on the registry's name. The datapack registry is not required to be present + * on clients when connecting to servers with the mod/registry. + *

+ * Data JSONs will be loaded from {@code data//modid/registryname/}, where {@code modid} is the namespace of the registry key. + * + * @param registryKey the root registry key of the new datapack registry + * @param codec the codec to be used for loading data from datapacks on servers + * @see #dataPackRegistry(ResourceKey, Codec, Codec) + */ + public void dataPackRegistry(ResourceKey> registryKey, Codec codec) + { + this.dataPackRegistry(registryKey, codec, null); + } + + /** + * Registers the registry key as a datapack registry, which will cause data to be loaded from + * a datapack folder based on the registry's name. + *

+ * Data JSONs will be loaded from {@code data//modid/registryname/}, where {@code modid} is the namespace of the registry key. + * + * @param registryKey the root registry key of the new datapack registry + * @param codec the codec to be used for loading data from datapacks on servers + * @param networkCodec the codec to be used for syncing loaded data to clients. + * If {@code networkCodec} is null, data will not be synced, and clients are not required to have this + * datapack registry to join a server. + *

+ * If {@code networkCodec} is not null, clients must have this datapack registry/mod + * when joining a server that has this datapack registry/mod. + * The data will be synced using the network codec and accessible via {@link ClientPacketListener#registryAccess()}. + * @see #dataPackRegistry(ResourceKey, Codec) + */ + public void dataPackRegistry(ResourceKey> registryKey, Codec codec, @Nullable Codec networkCodec) + { + this.registryDataList.add(new DataPackRegistryData<>(new RegistryDataLoader.RegistryData<>(registryKey, codec), networkCodec)); + } + + void process() + { + for (DataPackRegistryData registryData : this.registryDataList) + { + DataPackRegistriesHooks.addRegistryCodec(registryData); + } + } + } + + record DataPackRegistryData(RegistryDataLoader.RegistryData loaderData, @Nullable Codec networkCodec) {} +} diff --git a/src/main/java/net/minecraftforge/registries/DeferredRegister.java b/src/main/java/net/minecraftforge/registries/DeferredRegister.java index 3e17879123..4c1b229421 100644 --- a/src/main/java/net/minecraftforge/registries/DeferredRegister.java +++ b/src/main/java/net/minecraftforge/registries/DeferredRegister.java @@ -8,7 +8,7 @@ package net.minecraftforge.registries; import com.google.common.collect.Multimaps; import com.google.common.collect.SetMultimap; import net.minecraft.core.Registry; -import net.minecraft.data.BuiltinRegistries; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; @@ -69,9 +69,8 @@ public class DeferredRegister } /** - * DeferredRegister factory for custom forge registries, {@link Registry vanilla registries}, - * or {@link BuiltinRegistries built-in registries} to lookup based on the provided registry key. - * Supports both registries that already exist or do not exist yet. + * DeferredRegister factory for custom forge registries or {@link BuiltInRegistries vanilla registries} + * to lookup based on the provided registry key. Supports both registries that already exist or do not exist yet. *

* If the registry is never created, any {@link RegistryObject}s made from this DeferredRegister will throw an exception. * To allow the optional existence of a registry without error, use {@link #createOptional(ResourceKey, String)}. @@ -88,8 +87,8 @@ public class DeferredRegister } /** - * DeferredRegister factory for the optional existence of custom forge registries, {@link Registry vanilla registries}, - * or {@link BuiltinRegistries built-in registries} to lookup based on the provided registry key. + * DeferredRegister factory for the optional existence of custom forge registries + * or {@link BuiltInRegistries vanilla registries} to lookup based on the provided registry key. * Supports both registries that already exist or do not exist yet. *

* If the registry is never created, any {@link RegistryObject}s made from this DeferredRegister will never be filled but will not throw an exception. @@ -106,9 +105,8 @@ public class DeferredRegister } /** - * DeferredRegister factory for custom forge registries, {@link Registry vanilla registries}, - * or {@link BuiltinRegistries built-in registries} to lookup based on the provided registry name. - * Supports both registries that already exist or do not exist yet. + * DeferredRegister factory for custom forge registries or {@link BuiltInRegistries vanilla registries} + * to lookup based on the provided registry name. Supports both registries that already exist or do not exist yet. *

* If the registry is never created, any {@link RegistryObject}s made from this DeferredRegister will throw an exception. * To allow the optional existence of a registry without error, use {@link #createOptional(ResourceLocation, String)}. @@ -125,10 +123,10 @@ public class DeferredRegister } /** - * DeferredRegister factory for the optional existence of custom forge registries, {@link Registry vanilla registries}, - * or {@link BuiltinRegistries built-in registries} to lookup based on the provided registry name. + * DeferredRegister factory for the optional existence of custom forge registries + * or {@link BuiltInRegistries vanilla registries} to lookup based on the provided registry name. + * Supports both registries that already exist or do not exist yet. *

- * The registry may not exist at the time this DeferredRegister is created. * If the registry is never created, any {@link RegistryObject}s made from this DeferredRegister will never be filled but will not throw an exception. * * @param registryName The name of the registry, should include namespace. May come from another DeferredRegister through {@link #getRegistryName()}. diff --git a/src/main/java/net/minecraftforge/registries/ForgeDeferredRegistriesSetup.java b/src/main/java/net/minecraftforge/registries/ForgeDeferredRegistriesSetup.java index 951b11a7ab..46770abdd4 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeDeferredRegistriesSetup.java +++ b/src/main/java/net/minecraftforge/registries/ForgeDeferredRegistriesSetup.java @@ -5,6 +5,8 @@ package net.minecraftforge.registries; +import net.minecraftforge.common.world.BiomeModifier; +import net.minecraftforge.common.world.StructureModifier; import net.minecraftforge.eventbus.api.IEventBus; public class ForgeDeferredRegistriesSetup @@ -23,9 +25,7 @@ public class ForgeDeferredRegistriesSetup ForgeRegistries.DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS.register(modEventBus); ForgeRegistries.DEFERRED_BIOME_MODIFIER_SERIALIZERS.register(modEventBus); ForgeRegistries.DEFERRED_FLUID_TYPES.register(modEventBus); - ForgeRegistries.DEFERRED_BIOME_MODIFIERS.register(modEventBus); ForgeRegistries.DEFERRED_STRUCTURE_MODIFIER_SERIALIZERS.register(modEventBus); - ForgeRegistries.DEFERRED_STRUCTURE_MODIFIERS.register(modEventBus); ForgeRegistries.DEFERRED_HOLDER_SET_TYPES.register(modEventBus); setup = true; diff --git a/src/main/java/net/minecraftforge/registries/ForgeRegistries.java b/src/main/java/net/minecraftforge/registries/ForgeRegistries.java index 1549a4f6f0..e18c3a9145 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeRegistries.java +++ b/src/main/java/net/minecraftforge/registries/ForgeRegistries.java @@ -45,8 +45,10 @@ import net.minecraftforge.common.Tags; import net.minecraftforge.common.loot.IGlobalLootModifier; import net.minecraftforge.common.world.BiomeModifier; import net.minecraftforge.fluids.FluidType; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.holdersets.HolderSetType; +import java.util.function.Consumer; import java.util.function.Supplier; import net.minecraftforge.common.world.StructureModifier; @@ -135,12 +137,6 @@ public class ForgeRegistries */ public static final Supplier> HOLDER_SET_TYPES = DEFERRED_HOLDER_SET_TYPES.makeRegistry(GameData::getHolderSetTypeRegistryBuilder); - // Custom forge datapack registries - static final DeferredRegister DEFERRED_BIOME_MODIFIERS = DeferredRegister.create(Keys.BIOME_MODIFIERS, "forge"); - public static final Supplier> BIOME_MODIFIERS_BUILTIN = DEFERRED_BIOME_MODIFIERS.makeRegistry(() -> new RegistryBuilder().disableSaving().dataPackRegistry(BiomeModifier.DIRECT_CODEC)); - static final DeferredRegister DEFERRED_STRUCTURE_MODIFIERS = DeferredRegister.create(Keys.STRUCTURE_MODIFIERS, "forge"); - public static final Supplier> STRUCTURE_MODIFIERS_BUILTIN = DEFERRED_STRUCTURE_MODIFIERS.makeRegistry(() -> new RegistryBuilder().disableSaving().dataPackRegistry(StructureModifier.DIRECT_CODEC)); - public static final class Keys { //Vanilla public static final ResourceKey> BLOCKS = key("block"); diff --git a/src/main/java/net/minecraftforge/registries/ForgeRegistry.java b/src/main/java/net/minecraftforge/registries/ForgeRegistry.java index a3338227e2..4c83885310 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeRegistry.java +++ b/src/main/java/net/minecraftforge/registries/ForgeRegistry.java @@ -233,7 +233,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist @SuppressWarnings("unchecked") @Nullable - Registry getWrapper() + NamespacedWrapper getWrapper() { if (!this.hasWrapper) return null; @@ -244,9 +244,9 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist } @NotNull - Registry getWrapperOrThrow() + NamespacedWrapper getWrapperOrThrow() { - Registry wrapper = getWrapper(); + NamespacedWrapper wrapper = getWrapper(); if (wrapper == null) throw new IllegalStateException("Cannot query wrapper for non-wrapped forge registry!"); @@ -254,18 +254,6 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist return wrapper; } - @SuppressWarnings("unchecked") - @NotNull - Optional> getHolderHelper() - { - Registry wrapper = getWrapper(); - if (!(wrapper instanceof IHolderHelperHolder)) - return Optional.empty(); - - // Unsafe cast means we can't use pattern matching here - return Optional.of(((IHolderHelperHolder) wrapper).getHolderHelper()); - } - void onBindTags(Map, HolderSet.Named> tags, Set> defaultedTags) { if (this.tagManager != null) @@ -276,21 +264,21 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist @Override public Optional> getHolder(ResourceKey key) { - return getHolderHelper().flatMap(h -> h.getHolder(key)); + return Optional.ofNullable(this.getWrapper()).flatMap(wrapper -> wrapper.getHolder(key)); } @NotNull @Override public Optional> getHolder(ResourceLocation location) { - return getHolderHelper().flatMap(h -> h.getHolder(location)); + return Optional.ofNullable(this.getWrapper()).flatMap(wrapper -> wrapper.getHolder(location)); } @NotNull @Override public Optional> getHolder(V value) { - return getHolderHelper().flatMap(h -> h.getHolder(value)); + return Optional.ofNullable(this.getWrapper()).flatMap(wrapper -> wrapper.getHolder(value)); } @Nullable @@ -552,8 +540,9 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist private Holder.Reference bindDelegate(ResourceKey rkey, V value) { - Holder.Reference delegate = delegatesByName.computeIfAbsent(rkey.location(), k -> Holder.Reference.createStandAlone(this.getWrapperOrThrow(), rkey)); - delegate.bind(rkey, value); + Holder.Reference delegate = delegatesByName.computeIfAbsent(rkey.location(), k -> Holder.Reference.createStandAlone(this.getWrapperOrThrow().holderOwner(), rkey)); + delegate.bindKey(rkey); + delegate.bindValue(value); delegatesByValue.put(value, delegate); return delegate; } @@ -914,18 +903,18 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist return false; ForgeRegistry active = RegistryManager.ACTIVE.getRegistry(getRegistryKey()); - Optional> holders = active.getHolderHelper(); - if (holders.isPresent() && holders.get().isIntrusive() && holders.get().isFrozen()) + NamespacedWrapper wrapper = active.getWrapper(); + if (wrapper != null && wrapper.isIntrusive() && wrapper.isFrozen()) { try { // We have to unfreeze the ACTIVE registry because a lot of vanilla objects use intrusive handlers in object init. - holders.get().unfreeze(); + wrapper.unfreeze(); createAndAddDummy(key, id); } finally { - holders.get().freeze(); + wrapper.freeze(); } } else diff --git a/src/main/java/net/minecraftforge/registries/ForgeRegistryTagManager.java b/src/main/java/net/minecraftforge/registries/ForgeRegistryTagManager.java index 12391af600..dabc20f37c 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeRegistryTagManager.java +++ b/src/main/java/net/minecraftforge/registries/ForgeRegistryTagManager.java @@ -133,6 +133,8 @@ class ForgeRegistryTagManager implements ITagManager Objects.requireNonNull(name); Objects.requireNonNull(defaults); - this.owner.getHolderHelper().ifPresent(h -> h.addOptionalTag(name, defaults)); + NamespacedWrapper wrapper = this.owner.getWrapper(); + if (wrapper != null) + wrapper.addOptionalTag(name, defaults); } } diff --git a/src/main/java/net/minecraftforge/registries/GameData.java b/src/main/java/net/minecraftforge/registries/GameData.java index 96ee5b3f01..ae8ed713d0 100644 --- a/src/main/java/net/minecraftforge/registries/GameData.java +++ b/src/main/java/net/minecraftforge/registries/GameData.java @@ -6,19 +6,27 @@ package net.minecraftforge.registries; import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import com.mojang.serialization.Codec; import com.mojang.serialization.Lifecycle; +import java.util.Collection; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.LinkedHashSet; -import net.minecraft.core.DefaultedRegistry; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.stream.Collectors; import net.minecraft.core.IdMapper; import net.minecraft.core.MappedRegistry; import net.minecraft.core.Registry; -import net.minecraft.data.BuiltinRegistries; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.syncher.EntityDataSerializer; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; @@ -36,6 +44,7 @@ import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.levelgen.DebugLevelSource; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Material; +import net.minecraftforge.common.CreativeModeTabRegistry; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.loot.IGlobalLootModifier; @@ -49,27 +58,46 @@ import net.minecraftforge.fml.StartupMessageManager; import net.minecraftforge.fml.util.EnhancedRuntimeException; import net.minecraftforge.fml.util.thread.EffectiveSide; import net.minecraftforge.registries.holdersets.HolderSetType; - import org.apache.commons.lang3.Validate; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; -import java.util.function.BiConsumer; -import java.util.stream.Collectors; - +import static net.minecraftforge.registries.ForgeRegistries.Keys.ACTIVITIES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.ATTRIBUTES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.BIOMES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.BLOCKS; +import static net.minecraftforge.registries.ForgeRegistries.Keys.BLOCK_ENTITY_TYPES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.BLOCK_STATE_PROVIDER_TYPES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.CHUNK_STATUS; +import static net.minecraftforge.registries.ForgeRegistries.Keys.COMMAND_ARGUMENT_TYPES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.ENCHANTMENTS; +import static net.minecraftforge.registries.ForgeRegistries.Keys.ENTITY_DATA_SERIALIZERS; +import static net.minecraftforge.registries.ForgeRegistries.Keys.ENTITY_TYPES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.FEATURES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.FLUIDS; +import static net.minecraftforge.registries.ForgeRegistries.Keys.FLUID_TYPES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.FOLIAGE_PLACER_TYPES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS; +import static net.minecraftforge.registries.ForgeRegistries.Keys.ITEMS; +import static net.minecraftforge.registries.ForgeRegistries.Keys.MEMORY_MODULE_TYPES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.MENU_TYPES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.MOB_EFFECTS; +import static net.minecraftforge.registries.ForgeRegistries.Keys.PAINTING_VARIANTS; +import static net.minecraftforge.registries.ForgeRegistries.Keys.PARTICLE_TYPES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.POI_TYPES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.POTIONS; +import static net.minecraftforge.registries.ForgeRegistries.Keys.RECIPE_SERIALIZERS; +import static net.minecraftforge.registries.ForgeRegistries.Keys.RECIPE_TYPES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.SCHEDULES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.SENSOR_TYPES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.SOUND_EVENTS; +import static net.minecraftforge.registries.ForgeRegistries.Keys.STAT_TYPES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.TREE_DECORATOR_TYPES; +import static net.minecraftforge.registries.ForgeRegistries.Keys.VILLAGER_PROFESSIONS; +import static net.minecraftforge.registries.ForgeRegistries.Keys.WORLD_CARVERS; import static net.minecraftforge.registries.ForgeRegistry.REGISTRIES; -import static net.minecraftforge.registries.ForgeRegistries.Keys.*; /** * INTERNAL ONLY @@ -105,14 +133,14 @@ public class GameData hasInit = true; // Game objects - makeRegistry(BLOCKS, "air").addCallback(BlockCallbacks.INSTANCE).legacyName("blocks").vanillaHolder(Block::builtInRegistryHolder).create(); - makeRegistry(FLUIDS, "empty").vanillaHolder(Fluid::builtInRegistryHolder).create(); - makeRegistry(ITEMS, "air").addCallback(ItemCallbacks.INSTANCE).legacyName("items").vanillaHolder(Item::builtInRegistryHolder).create(); + makeRegistry(BLOCKS, "air").addCallback(BlockCallbacks.INSTANCE).legacyName("blocks").intrusiveHolderCallback(Block::builtInRegistryHolder).create(); + makeRegistry(FLUIDS, "empty").intrusiveHolderCallback(Fluid::builtInRegistryHolder).create(); + makeRegistry(ITEMS, "air").addCallback(ItemCallbacks.INSTANCE).legacyName("items").intrusiveHolderCallback(Item::builtInRegistryHolder).create(); makeRegistry(MOB_EFFECTS).legacyName("potions").create(); makeRegistry(SOUND_EVENTS).legacyName("soundevents").create(); makeRegistry(POTIONS, "empty").legacyName("potiontypes").create(); makeRegistry(ENCHANTMENTS).legacyName("enchantments").create(); - makeRegistry(ENTITY_TYPES, "pig").legacyName("entities").vanillaHolder(EntityType::builtInRegistryHolder).create(); + makeRegistry(ENTITY_TYPES, "pig").legacyName("entities").intrusiveHolderCallback(EntityType::builtInRegistryHolder).create(); makeRegistry(BLOCK_ENTITY_TYPES).disableSaving().legacyName("blockentities").create(); makeRegistry(PARTICLE_TYPES).disableSaving().create(); makeRegistry(MENU_TYPES).disableSaving().create(); @@ -196,12 +224,12 @@ public class GameData return ret; } - public static DefaultedRegistry getWrapper(ResourceKey> key, Lifecycle lifecycle, String defKey) + public static MappedRegistry getWrapper(ResourceKey> key, Lifecycle lifecycle, String defKey) { IForgeRegistry reg = RegistryManager.ACTIVE.getRegistry(key); Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + key.toString()); @SuppressWarnings("unchecked") - DefaultedRegistry ret = reg.getSlaveMap(NamespacedDefaultedWrapper.Factory.ID, NamespacedDefaultedWrapper.class); + MappedRegistry ret = reg.getSlaveMap(NamespacedDefaultedWrapper.Factory.ID, NamespacedDefaultedWrapper.class); Validate.notNull(ret, "Attempted to get vanilla wrapper for registry created incorrectly: " + key.toString()); return ret; } @@ -245,14 +273,14 @@ public class GameData public static void unfreezeData() { LOGGER.debug(REGISTRIES, "Unfreezing vanilla registries"); - Registry.REGISTRY.stream().filter(r -> r instanceof MappedRegistry).forEach(r -> ((MappedRegistry)r).unfreeze()); + BuiltInRegistries.REGISTRY.stream().filter(r -> r instanceof MappedRegistry).forEach(r -> ((MappedRegistry)r).unfreeze()); } @SuppressWarnings({ "rawtypes", "unchecked" }) public static void freezeData() { LOGGER.debug(REGISTRIES, "Freezing registries"); - Registry.REGISTRY.stream().filter(r -> r instanceof MappedRegistry).forEach(r -> ((MappedRegistry)r).freeze()); + BuiltInRegistries.REGISTRY.stream().filter(r -> r instanceof MappedRegistry).forEach(r -> ((MappedRegistry)r).freeze()); for (Map.Entry> r : RegistryManager.ACTIVE.registries.entrySet()) { @@ -317,7 +345,6 @@ public class GameData { Set keySet = new HashSet<>(RegistryManager.ACTIVE.registries.keySet()); keySet.addAll(RegistryManager.getVanillaRegistryKeys()); - keySet.addAll(BuiltinRegistries.REGISTRY.keySet()); Set ordered = new LinkedHashSet<>(MappedRegistry.getKnownRegistries()); ordered.retainAll(keySet); @@ -331,7 +358,7 @@ public class GameData { ResourceKey> registryKey = ResourceKey.createRegistryKey(rootRegistryName); ForgeRegistry forgeRegistry = RegistryManager.ACTIVE.getRegistry(rootRegistryName); - Registry vanillaRegistry = Registry.REGISTRY.containsKey(rootRegistryName) ? Registry.REGISTRY.get(rootRegistryName) : BuiltinRegistries.REGISTRY.get(rootRegistryName); + Registry vanillaRegistry = BuiltInRegistries.REGISTRY.get(rootRegistryName); RegisterEvent registerEvent = new RegisterEvent(registryKey, forgeRegistry, vanillaRegistry); StartupMessageManager.modLoaderConsumer().ifPresent(s -> s.accept("REGISTERING " + registryKey.location())); @@ -362,6 +389,7 @@ public class GameData { ForgeHooks.modifyAttributes(); SpawnPlacements.fireSpawnPlacementEvent(); + CreativeModeTabRegistry.fireCollectionEvent(); } } diff --git a/src/main/java/net/minecraftforge/registries/IHolderHelperHolder.java b/src/main/java/net/minecraftforge/registries/IHolderHelperHolder.java deleted file mode 100644 index b137642e73..0000000000 --- a/src/main/java/net/minecraftforge/registries/IHolderHelperHolder.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.registries; - -interface IHolderHelperHolder -{ - NamespacedHolderHelper getHolderHelper(); -} diff --git a/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java b/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java index fcd5813801..c5cbbf6fe2 100644 --- a/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java +++ b/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java @@ -5,135 +5,42 @@ package net.minecraftforge.registries; -import java.util.Iterator; -import java.util.List; -import java.util.Map; import java.util.Optional; -import java.util.OptionalInt; -import java.util.Set; import java.util.function.Function; -import java.util.stream.Stream; -import com.mojang.serialization.DataResult; +import net.minecraft.core.DefaultedRegistry; import net.minecraft.core.Holder; -import net.minecraft.core.HolderSet; -import net.minecraft.core.Registry; - -import net.minecraft.util.RandomSource; -import org.apache.commons.lang3.Validate; - import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.core.DefaultedRegistry; -import com.mojang.datafixers.util.Pair; -import com.mojang.serialization.Lifecycle; +import net.minecraft.util.RandomSource; import org.jetbrains.annotations.Nullable; -class NamespacedDefaultedWrapper extends DefaultedRegistry implements ILockableRegistry, IHolderHelperHolder +class NamespacedDefaultedWrapper extends NamespacedWrapper implements DefaultedRegistry { private final ForgeRegistry delegate; - private final NamespacedHolderHelper holders; + private final ResourceLocation defaultKey; + private Holder.Reference defaultHolder; - private boolean locked = false; - private Lifecycle elementsLifecycle = Lifecycle.experimental(); - - private NamespacedDefaultedWrapper(ForgeRegistry owner, Function> holderLookup) - { - super("empty", owner.getRegistryKey(), Lifecycle.experimental(), holderLookup); - this.delegate = owner; - this.holders = new NamespacedHolderHelper<>(owner, this, this.delegate.getDefaultKey(), holderLookup); - } - - @Override - public Holder registerMapping(final int id, final ResourceKey key, final T value, final Lifecycle lifecycle) - { - if (locked) - throw new IllegalStateException("Can not register to a locked registry. Modder should use Forge Register methods."); - - Validate.notNull(value); - markKnown(); - this.elementsLifecycle = this.elementsLifecycle.add(lifecycle); - - T oldValue = this.delegate.getRaw(key.location()); - - int realId = this.delegate.add(id, key.location(), value); - - return this.holders.onAdded(RegistryManager.ACTIVE, realId, key, value, oldValue); - } - - @Override - public Holder register(final ResourceKey p_205891_, final T p_205892_, final Lifecycle p_205893_) - { - return registerMapping(-1, p_205891_, p_205892_, p_205893_); - } - - @Override - public Holder registerOrOverride(final OptionalInt id, final ResourceKey p_205885_, final T p_205886_, final Lifecycle p_205887_) - { - int wanted = -1; - if (id.isPresent() && byId(id.getAsInt()) != null) - wanted = id.getAsInt(); - return registerMapping(wanted, p_205885_, p_205886_, p_205887_); + NamespacedDefaultedWrapper(ForgeRegistry fowner, Function> intrusiveHolderCallback, RegistryManager stage) { + super(fowner, intrusiveHolderCallback, stage); + this.delegate = fowner; + this.defaultKey = fowner.getDefaultKey(); } // Reading Functions @Override - public Optional getOptional(@Nullable ResourceLocation name) - { - return Optional.ofNullable( this.delegate.getRaw(name)); //get without default - } - - @Override - @Nullable public T get(@Nullable ResourceLocation name) { return this.delegate.getValue(name); //getOrDefault } @Override - @Nullable - public T get(@Nullable ResourceKey name) + public Optional> getRandom(RandomSource rand) { - return name == null ? null : this.delegate.getRaw(name.location()); //get without default - } + if (this.defaultHolder != null) + return super.getRandom(rand).or(() -> Optional.of(this.defaultHolder)); - @Override - @Nullable - public ResourceLocation getKey(T value) - { - return this.delegate.getKey(value); - } - - @Override - public Optional> getResourceKey(T p_122755_) - { - return this.delegate.getResourceKey(p_122755_); - } - - @Override - public boolean containsKey(ResourceLocation key) - { - return this.delegate.containsKey(key); - } - - @Override - public boolean containsKey(ResourceKey key) - { - return this.delegate.getRegistryName().equals(key.registry()) && containsKey(key.location()); - } - - @Override - public int getId(@Nullable T value) - { - return this.delegate.getID(value); - } - - @Override - @Nullable - public T byId(int id) - { - return this.delegate.getValue(id); + return super.getRandom(rand); } @Override @@ -142,81 +49,18 @@ class NamespacedDefaultedWrapper extends DefaultedRegistry implements ILoc return this.delegate.getDefaultKey(); } + @Nullable @Override - public Lifecycle lifecycle(T value) + Holder.Reference onAdded(RegistryManager stage, int id, ResourceKey key, T newValue, T oldValue) { - return Lifecycle.stable(); + Holder.Reference newHolder = super.onAdded(stage, id, key, newValue, oldValue); + + if (newHolder != null && this.defaultKey != null && this.defaultKey.equals(key.location())) + this.defaultHolder = newHolder; + + return newHolder; } - @Override - public Lifecycle elementsLifecycle() - { - return this.elementsLifecycle; - } - - @Override - public Iterator iterator() - { - return this.delegate.iterator(); - } - - @Override - public Set keySet() - { - return this.delegate.getKeys(); - } - - @Override - public Set> registryKeySet() - { - return this.delegate.getResourceKeys(); - } - - @Override - public Set, T>> entrySet() - { - return this.delegate.getEntries(); - } - - @Override - public boolean isEmpty() - { - return this.delegate.isEmpty(); - } - - @Override - public int size() - { - return this.delegate.size(); - } - - @Override - public NamespacedHolderHelper getHolderHelper() - { - return this.holders; - } - - @Override public Optional> getHolder(int id) { return this.holders.getHolder(id); } - @Override public Optional> getHolder(ResourceKey key) { return this.holders.getHolder(key); } - @Override public DataResult> getOrCreateHolder(ResourceKey key) { return this.holders.getOrCreateHolder(key); } - @Override public Holder getOrCreateHolderOrThrow(ResourceKey key) { return this.holders.getOrCreateHolderOrThrow(key); } - @Override public Optional> getRandom(RandomSource rand) { return this.holders.getRandom(rand); } - @Override public Stream> holders() { return this.holders.holders(); } - @Override public boolean isKnownTagName(TagKey name) { return this.holders.isKnownTagName(name); } - @Override public Stream, HolderSet.Named>> getTags() { return this.holders.getTags(); } - @Override public HolderSet.Named getOrCreateTag(TagKey name) { return this.holders.getOrCreateTag(name); } - @Override public Stream> getTagNames() { return this.holders.getTagNames(); } - @Override public Registry freeze() { return this.holders.freeze(); } - @Override public Holder.Reference createIntrusiveHolder(T value) { return this.holders.createIntrusiveHolder(value); } - @Override public Optional> getTag(TagKey name) { return this.holders.getTag(name); } - @Override public void bindTags(Map, List>> newTags) { this.holders.bindTags(newTags); } - @Override public void resetTags() { this.holders.resetTags(); } - @Deprecated @Override public void unfreeze() { this.holders.unfreeze(); } - - /** @deprecated Forge: For internal use only. Use the Register events when registering values. */ - @Deprecated @Override public void lock(){ this.locked = true; } - - public static class Factory implements IForgeRegistry.CreateCallback, IForgeRegistry.AddCallback { public static final ResourceLocation ID = new ResourceLocation("forge", "registry_defaulted_wrapper"); @@ -224,15 +68,15 @@ class NamespacedDefaultedWrapper extends DefaultedRegistry implements ILoc @Override public void onCreate(IForgeRegistryInternal owner, RegistryManager stage) { - ForgeRegistry fowner = (ForgeRegistry)owner; - owner.setSlaveMap(ID, new NamespacedDefaultedWrapper(fowner, fowner.getBuilder().getVanillaHolder())); + ForgeRegistry fowner = (ForgeRegistry) owner; + owner.setSlaveMap(ID, new NamespacedDefaultedWrapper(fowner, fowner.getBuilder().getIntrusiveHolderCallback(), stage)); } @Override @SuppressWarnings("unchecked") public void onAdd(IForgeRegistryInternal owner, RegistryManager stage, int id, ResourceKey key, V value, V oldValue) { - owner.getSlaveMap(ID, NamespacedDefaultedWrapper.class).holders.onAdded(stage, id, key, value, oldValue); + owner.getSlaveMap(ID, NamespacedDefaultedWrapper.class).onAdded(stage, id, key, value, oldValue); } } } diff --git a/src/main/java/net/minecraftforge/registries/NamespacedHolderHelper.java b/src/main/java/net/minecraftforge/registries/NamespacedHolderHelper.java deleted file mode 100644 index e5633c4f69..0000000000 --- a/src/main/java/net/minecraftforge/registries/NamespacedHolderHelper.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.registries; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.IdentityHashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Random; -import java.util.Set; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; -import com.mojang.serialization.DataResult; -import cpw.mods.modlauncher.api.LamdbaExceptionUtils; -import net.minecraft.util.RandomSource; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.google.common.collect.Sets; -import com.mojang.datafixers.util.Pair; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import it.unimi.dsi.fastutil.objects.ObjectList; -import net.minecraft.Util; -import net.minecraft.core.Holder; -import net.minecraft.core.HolderSet; -import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -class NamespacedHolderHelper -{ - private static final Logger LOGGER = LogManager.getLogger(); - private final ForgeRegistry owner; - private final Registry self; - @Nullable - private final ResourceLocation defaultKey; - @Nullable - private final Function> holderLookup; - private final Multimap, Supplier> optionalTags = Multimaps.newSetMultimap(new IdentityHashMap<>(), HashSet::new); - - private boolean frozen = false; // Frozen is vanilla's variant of locked, but it can be unfrozen - private List> holdersSorted; - private ObjectList> holdersById = new ObjectArrayList<>(256); - private Map> holdersByName = new HashMap<>(); - private Map> holders = new IdentityHashMap<>(); - private volatile Map, HolderSet.Named> tags = new IdentityHashMap<>(); - private Holder.Reference defaultHolder; - - NamespacedHolderHelper(ForgeRegistry owner, Registry self, @Nullable ResourceLocation defaultKey, @Nullable Function> holderLookup) - { - this.owner = owner; - this.self = self; - this.defaultKey = defaultKey; - this.holderLookup = holderLookup; - } - - - Optional> getHolder(int id) - { - return id >= 0 && id < this.holdersById.size() ? Optional.ofNullable(this.holdersById.get(id)) : Optional.empty(); - } - - Optional> getHolder(ResourceKey key) - { - return Optional.ofNullable(this.holdersByName.get(key.location())); - } - - Optional> getHolder(ResourceLocation location) - { - return Optional.ofNullable(this.holdersByName.get(location)); - } - - Optional> getHolder(T value) - { - return Optional.ofNullable(this.holders.get(value)); - } - - DataResult> getOrCreateHolder(ResourceKey key) - { - Holder.Reference ref = this.holdersByName.get(key.location()); - if (ref == null) - { - if (this.holderLookup != null) - return DataResult.error("This registry can't create new holders without value (requested key: " + key + ")"); - - if (this.frozen) - return DataResult.error("Registry is already frozen (trying to add key " + key + ")"); - - ref = Holder.Reference.createStandAlone(this.self, key); - this.holdersByName.put(key.location(), ref); - } - return DataResult.success(ref); - } - - Holder getOrCreateHolderOrThrow(ResourceKey key) - { - return getOrCreateHolder(key).getOrThrow(false, msg -> - { - throw new IllegalStateException(msg); - }); - } - - Optional> getRandom(RandomSource rand) - { - Optional> ret = Util.getRandomSafe(this.getSortedHolders(), rand).map(Holder::hackyErase); - if (this.defaultKey != null) - ret = ret.or(() -> Optional.of(this.defaultHolder)); - return ret; - } - - Stream> holders() - { - return this.getSortedHolders().stream(); - } - - boolean isKnownTagName(TagKey name) - { - return this.tags.containsKey(name); - } - - Stream, HolderSet.Named>> getTags() - { - return this.tags.entrySet().stream().map(e -> Pair.of(e.getKey(), e.getValue())); - } - - HolderSet.Named getOrCreateTag(TagKey name) - { - HolderSet.Named named = this.tags.get(name); - if (named == null) - { - named = createTag(name); - // They use volatile and set it this way to not have the performance penalties of synced read access. But this makes a lot of new maps.. We need to look into performance alternatives. - Map, HolderSet.Named> map = new IdentityHashMap<>(this.tags); - map.put(name, named); - this.tags = map; - } - - return named; - } - - void addOptionalTag(TagKey name, @NotNull Set> defaults) - { - this.optionalTags.putAll(name, defaults); - } - - Stream> getTagNames() - { - return this.tags.keySet().stream(); - } - - //TODO: Move this to ValidateCallback? - Registry freeze() - { - this.frozen = true; - List unregisterd = this.holdersByName.entrySet().stream() - .filter(e -> !e.getValue().isBound()) - .map(e -> e.getKey()).sorted().toList(); - - if (!unregisterd.isEmpty()) - throw new IllegalStateException("Unbound values in registry " + this.self.key() + ": " + unregisterd.stream().map(ResourceLocation::toString).collect(Collectors.joining(", \n\t"))); - - if (this.holderLookup != null) - { - List> intrusive = this.holders.values().stream().filter(h -> h.getType() == Holder.Reference.Type.INTRUSIVE && !h.isBound()).toList(); - if (!intrusive.isEmpty()) - throw new IllegalStateException("Some intrusive holders were not added to registry: " + intrusive); - } - return this.self; - } - - @SuppressWarnings("deprecation") - Holder.Reference createIntrusiveHolder(T value) - { - if (this.holderLookup == null) - throw new IllegalStateException("This registry can't create intrusive holders"); - if (this.frozen) - throw new IllegalStateException("Registry is already frozen"); - - return this.holders.computeIfAbsent(value, k -> Holder.Reference.createIntrusive(this.self, value)); - } - - Optional> getTag(TagKey name) - { - return Optional.ofNullable(this.tags.get(name)); - } - - void bindTags(Map, List>> newTags) - { - Map, List>> holderToTag = new IdentityHashMap<>(); - this.holdersByName.values().forEach(v -> holderToTag.put(v, new ArrayList<>())); - newTags.forEach((name, values) -> values.forEach(holder -> addTagToHolder(holderToTag, name, holder))); - - Set> set = Sets.difference(this.tags.keySet(), newTags.keySet()); - if (!set.isEmpty()) - LOGGER.warn("Not all defined tags for registry {} are present in data pack: {}", this.self.key(), set.stream().map(k -> k.location().toString()).sorted().collect(Collectors.joining(", \n\t"))); - - Map, HolderSet.Named> tmpTags = new IdentityHashMap<>(this.tags); - newTags.forEach((k, v) -> tmpTags.computeIfAbsent(k, this::createTag).bind(v)); - - Set> defaultedTags = Sets.difference(this.optionalTags.keySet(), newTags.keySet()); - defaultedTags.forEach(name -> { - List> defaults = this.optionalTags.get(name).stream() - .map(valueSupplier -> getHolder(valueSupplier.get()).orElse(null)) - .filter(Objects::nonNull) - .distinct() - .toList(); - defaults.forEach(holder -> addTagToHolder(holderToTag, name, holder)); - tmpTags.computeIfAbsent(name, this::createTag).bind(defaults); - }); - - holderToTag.forEach(Holder.Reference::bindTags); - this.tags = tmpTags; - - this.owner.onBindTags(this.tags, defaultedTags); - } - - private void addTagToHolder(Map, List>> holderToTag, TagKey name, Holder holder) - { - if (!holder.isValidInRegistry(this.self)) - throw new IllegalStateException("Can't create named set " + name + " containing value " + holder + " from outside registry " + this); - - if (!(holder instanceof Holder.Reference)) - throw new IllegalStateException("Found direct holder " + holder + " value in tag " + name); - - holderToTag.get((Holder.Reference) holder).add(name); - } - - void resetTags() - { - this.tags.values().forEach(t -> t.bind(List.of())); - this.holders.values().forEach(v -> v.bindTags(Set.of())); - } - - void unfreeze() - { - this.frozen = false; - } - - boolean isFrozen() - { - return this.frozen; - } - - boolean isIntrusive() - { - return this.holderLookup != null; - } - - @Nullable - Holder onAdded(RegistryManager stage, int id, ResourceKey key, T newValue, T oldValue) - { - if (stage != RegistryManager.ACTIVE && (this.holderLookup == null || !stage.isStaging())) // Intrusive handlers need updating in staging. - return null; // Only do holder shit on the active registries, not pending or snapshots. - - //Holder.Reference oldHolder = oldValue == null ? null : getHolder(key, oldValue); - // Do we need to do anything with the old holder? We cant update its pointer unless its non-intrusive... - // And if thats the case, then we *should* get its reference in newHolder - - Holder.Reference newHolder = getHolder(key, newValue); - - this.holdersById.size(Math.max(this.holdersById.size(), id + 1)); - this.holdersById.set(id, newHolder); - this.holdersByName.put(key.location(), newHolder); - this.holders.put(newValue, newHolder); - newHolder.bind(key, newValue); - this.holdersSorted = null; - - - if (this.defaultKey != null && this.defaultKey.equals(key.location())) - this.defaultHolder = newHolder; - - return newHolder; - } - - private HolderSet.Named createTag(TagKey name) - { - return new HolderSet.Named<>(this.self, name); - } - - - private Holder.Reference getHolder(ResourceKey key, T value) - { - if (this.holderLookup != null) - return this.holderLookup.apply(value); - - return this.holdersByName.computeIfAbsent(key.location(), k -> Holder.Reference.createStandAlone(this.self, key)); - } - - private List> getSortedHolders() - { - if (this.holdersSorted == null) - this.holdersSorted = this.holdersById.stream().filter(Objects::nonNull).toList(); - - return this.holdersSorted; - } - -} diff --git a/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java b/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java index f9ce3227d9..44c68e19ce 100644 --- a/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java +++ b/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java @@ -5,82 +5,92 @@ package net.minecraftforge.registries; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.OptionalInt; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.Stream; - -import com.mojang.serialization.DataResult; +import com.google.common.collect.Multimap; +import com.google.common.collect.Multimaps; +import com.google.common.collect.Sets; +import com.mojang.datafixers.util.Pair; +import com.mojang.logging.LogUtils; +import com.mojang.serialization.Lifecycle; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import it.unimi.dsi.fastutil.objects.ObjectList; +import net.minecraft.Util; import net.minecraft.core.Holder; +import net.minecraft.core.HolderGetter; import net.minecraft.core.HolderSet; +import net.minecraft.core.MappedRegistry; +import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; -import net.minecraft.core.MappedRegistry; -import net.minecraft.core.Registry; - import net.minecraft.util.RandomSource; import org.apache.commons.lang3.Validate; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.mojang.datafixers.util.Pair; -import com.mojang.serialization.Lifecycle; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.IdentityHashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Collectors; +import java.util.stream.Stream; -class NamespacedWrapper extends MappedRegistry implements ILockableRegistry, IHolderHelperHolder +class NamespacedWrapper extends MappedRegistry implements ILockableRegistry { - private static final Logger LOGGER = LogManager.getLogger(); + static final Logger LOGGER = LogUtils.getLogger(); private final ForgeRegistry delegate; - private final NamespacedHolderHelper holders; + @Nullable + private final Function> intrusiveHolderCallback; + private final Multimap, Supplier> optionalTags = Multimaps.newSetMultimap(new IdentityHashMap<>(), HashSet::new); - private boolean locked = false; - private Lifecycle elementsLifecycle = Lifecycle.experimental(); + boolean locked = false; + Lifecycle registryLifecycle = Lifecycle.experimental(); + private boolean frozen = false; // Frozen is vanilla's variant of locked, but it can be unfrozen + private List> holdersSorted; + private ObjectList> holdersById = new ObjectArrayList<>(256); + private Map> holdersByName = new HashMap<>(); + private Map> holders = new IdentityHashMap<>(); + private RegistryManager stage; + private volatile Map, HolderSet.Named> tags = new IdentityHashMap<>(); - public NamespacedWrapper(ForgeRegistry owner, Function> holderLookup) + NamespacedWrapper(ForgeRegistry fowner, Function> intrusiveHolderCallback, RegistryManager stage) { - super(owner.getRegistryKey(), Lifecycle.experimental(), holderLookup); - this.delegate = owner; - this.holders = new NamespacedHolderHelper<>(owner, this, null, holderLookup); + super(fowner.getRegistryKey(), Lifecycle.experimental(), intrusiveHolderCallback != null); + this.delegate = fowner; + this.intrusiveHolderCallback = intrusiveHolderCallback; + this.stage = stage; } @Override - public Holder registerMapping(int id, ResourceKey key, T value, Lifecycle lifecycle) + public Holder.Reference registerMapping(int id, ResourceKey key, T value, Lifecycle lifecycle) { if (locked) throw new IllegalStateException("Can not register to a locked registry. Modder should use Forge Register methods."); Validate.notNull(value); markKnown(); - this.elementsLifecycle = this.elementsLifecycle.add(lifecycle); - - T oldValue = get(key); + this.registryLifecycle = this.registryLifecycle.add(lifecycle); int realId = this.delegate.add(id, key.location(), value); if (realId != id && id != -1) LOGGER.warn("Registered object did not get ID it asked for. Name: {} Expected: {} Got: {}", key, id, realId); - return this.holders.onAdded(RegistryManager.ACTIVE, realId, key, value, oldValue); + return getHolder(key, value); } @Override - public Holder register(ResourceKey key, T value, Lifecycle lifecycle) + public Holder.Reference register(ResourceKey key, T value, Lifecycle lifecycle) { return registerMapping(-1, key, value, lifecycle); } - @Override - public Holder registerOrOverride(OptionalInt id, ResourceKey key, T value, Lifecycle lifecycle) { - int wanted = -1; - if (id.isPresent() && byId(id.getAsInt()) != null) - wanted = id.getAsInt(); - return registerMapping(wanted, key, value, lifecycle); - } - // Reading Functions @Override @Nullable @@ -92,7 +102,7 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr @Override public Optional getOptional(@Nullable ResourceLocation name) { - return Optional.ofNullable( this.delegate.getRaw(name)); //get without default + return Optional.ofNullable(this.delegate.getRaw(name)); //get without default } @Override @@ -124,7 +134,7 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr @Override public boolean containsKey(ResourceKey key) { - return this.delegate.getRegistryName().equals(key.registry()) && containsKey(key.location()); + return this.delegate.getRegistryName().equals(key.registry()) && containsKey(key.location()); } @Override @@ -147,9 +157,9 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr } @Override - public Lifecycle elementsLifecycle() + public Lifecycle registryLifecycle() { - return this.elementsLifecycle; + return this.registryLifecycle; } @Override @@ -188,32 +198,289 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr return this.delegate.size(); } + /** + * @deprecated Forge: For internal use only. Use the Register events when registering values. + */ + @Deprecated @Override - public NamespacedHolderHelper getHolderHelper() + public void lock() { - return this.holders; + this.locked = true; } - @Override public Optional> getHolder(int id) { return this.holders.getHolder(id); } - @Override public Optional> getHolder(ResourceKey key) { return this.holders.getHolder(key); } - @Override public DataResult> getOrCreateHolder(ResourceKey key) { return this.holders.getOrCreateHolder(key); } - @Override public Holder getOrCreateHolderOrThrow(ResourceKey key) { return this.holders.getOrCreateHolderOrThrow(key); } - @Override public Optional> getRandom(RandomSource rand) { return this.holders.getRandom(rand); } - @Override public Stream> holders() { return this.holders.holders(); } - @Override public boolean isKnownTagName(TagKey name) { return this.holders.isKnownTagName(name); } - @Override public Stream, HolderSet.Named>> getTags() { return this.holders.getTags(); } - @Override public HolderSet.Named getOrCreateTag(TagKey name) { return this.holders.getOrCreateTag(name); } - @Override public Stream> getTagNames() { return this.holders.getTagNames(); } - @Override public Registry freeze() { return this.holders.freeze(); } - @Override public Holder.Reference createIntrusiveHolder(T value) { return this.holders.createIntrusiveHolder(value); } - @Override public Optional> getTag(TagKey name) { return this.holders.getTag(name); } - @Override public void bindTags(Map, List>> newTags) { this.holders.bindTags(newTags); } - @Override public void resetTags() { this.holders.resetTags(); } - @Deprecated @Override public void unfreeze() { this.holders.unfreeze(); } + @Override + public Optional> getHolder(int id) + { + return id >= 0 && id < this.holdersById.size() ? Optional.ofNullable(this.holdersById.get(id)) : Optional.empty(); + } - /** @deprecated Forge: For internal use only. Use the Register events when registering values. */ - @Deprecated @Override public void lock(){ this.locked = true; } + @Override + public Optional> getHolder(ResourceKey key) + { + return Optional.ofNullable(this.holdersByName.get(key.location())); + } + Optional> getHolder(ResourceLocation location) + { + return Optional.ofNullable(this.holdersByName.get(location)); + } + + Optional> getHolder(T value) + { + return Optional.ofNullable(this.holders.get(value)); + } + + @Override + public HolderGetter createRegistrationLookup() + { + this.validateWrite(); + return new HolderGetter() + { + public Optional> get(ResourceKey p_259097_) + { + return Optional.of(this.getOrThrow(p_259097_)); + } + + public Holder.Reference getOrThrow(ResourceKey p_259750_) + { + return NamespacedWrapper.this.getOrCreateHolderOrThrow(p_259750_); + } + + public Optional> get(TagKey p_259486_) + { + return Optional.of(this.getOrThrow(p_259486_)); + } + + public HolderSet.Named getOrThrow(TagKey p_260298_) + { + return NamespacedWrapper.this.getOrCreateTag(p_260298_); + } + }; + } + + void validateWrite() + { + if (this.frozen) + throw new IllegalStateException("Registry is already frozen"); + } + + void validateWrite(ResourceKey key) + { + if (this.frozen) + throw new IllegalStateException("Registry is already frozen (trying to add key " + key + ")"); + } + + Holder.Reference getOrCreateHolderOrThrow(ResourceKey key) + { + return this.holdersByName.computeIfAbsent(key.location(), k -> { + if (this.intrusiveHolderCallback != null) + { + throw new IllegalStateException("This registry can't create new holders without value"); + } + else + { + this.validateWrite(key); + return Holder.Reference.createStandAlone(this.holderOwner(), key); + } + }); + } + + @Override + public Optional> getRandom(RandomSource rand) + { + return Util.getRandomSafe(this.getSortedHolders(), rand); + } + + @Override + public Stream> holders() + { + return this.getSortedHolders().stream(); + } + + @Override + public Stream, HolderSet.Named>> getTags() + { + return this.tags.entrySet().stream().map(e -> Pair.of(e.getKey(), e.getValue())); + } + + @Override + public HolderSet.Named getOrCreateTag(TagKey name) + { + HolderSet.Named named = this.tags.get(name); + if (named == null) + { + named = createTag(name); + // They use volatile and set it this way to not have the performance penalties of synced read access. But this makes a lot of new maps.. We need to look into performance alternatives. + Map, HolderSet.Named> map = new IdentityHashMap<>(this.tags); + map.put(name, named); + this.tags = map; + } + + return named; + } + + void addOptionalTag(TagKey name, @NotNull Set> defaults) + { + this.optionalTags.putAll(name, defaults); + } + + @Override + public Stream> getTagNames() + { + return this.tags.keySet().stream(); + } + + //TODO: Move this to ValidateCallback? + @Override + public Registry freeze() + { + this.frozen = true; + List unregistered = this.holdersByName.entrySet().stream() + .filter(e -> !e.getValue().isBound()) + .map(Map.Entry::getKey).sorted().toList(); + + if (!unregistered.isEmpty()) + throw new IllegalStateException("Unbound values in registry " + this.key() + ": " + unregistered.stream().map(ResourceLocation::toString).collect(Collectors.joining(", \n\t"))); + + if (this.unregisteredIntrusiveHolders != null && this.unregisteredIntrusiveHolders.values().stream().anyMatch(r -> !r.isBound() && r.getType() == Holder.Reference.Type.INTRUSIVE)) { + throw new IllegalStateException("Some intrusive holders were not registered: " + this.unregisteredIntrusiveHolders.values() + " Hint: Did you register all your registry objects? Registry stage: " + stage.getName()); + } + + return this; + } + + @Override + public Holder.Reference createIntrusiveHolder(T value) + { + if (this.intrusiveHolderCallback == null) + throw new IllegalStateException("This registry can't create intrusive holders"); + + this.validateWrite(); + + return super.createIntrusiveHolder(value); + } + + @Override + public Optional> getTag(TagKey name) + { + return Optional.ofNullable(this.tags.get(name)); + } + + @Override + public void bindTags(Map, List>> newTags) + { + Map, List>> holderToTag = new IdentityHashMap<>(); + this.holdersByName.values().forEach(v -> holderToTag.put(v, new ArrayList<>())); + newTags.forEach((name, values) -> values.forEach(holder -> addTagToHolder(holderToTag, name, holder))); + + Set> set = new HashSet<>(Sets.difference(this.tags.keySet(), newTags.keySet())); + set.removeAll(this.optionalTags.keySet()); + if (!set.isEmpty()) + LOGGER.warn("Not all defined tags for registry {} are present in data pack: {}", this.key(), set.stream().map(k -> k.location().toString()).sorted() + .collect(Collectors.joining(", \n\t"))); + + Map, HolderSet.Named> tmpTags = new IdentityHashMap<>(this.tags); + newTags.forEach((k, v) -> tmpTags.computeIfAbsent(k, this::createTag).bind(v)); + + Set> defaultedTags = Sets.difference(this.optionalTags.keySet(), newTags.keySet()); + defaultedTags.forEach(name -> { + List> defaults = this.optionalTags.get(name).stream() + .map(valueSupplier -> getHolder(valueSupplier.get()).orElse(null)) + .filter(Objects::nonNull) + .distinct() + .toList(); + defaults.forEach(holder -> addTagToHolder(holderToTag, name, holder)); + tmpTags.computeIfAbsent(name, this::createTag).bind(defaults); + }); + + holderToTag.forEach(Holder.Reference::bindTags); + this.tags = tmpTags; + + this.delegate.onBindTags(this.tags, defaultedTags); + } + + private void addTagToHolder(Map, List>> holderToTag, TagKey name, Holder holder) + { + if (!holder.canSerializeIn(this.holderOwner())) + throw new IllegalStateException("Can't create named set " + name + " containing value " + holder + " from outside registry " + this); + + if (!(holder instanceof Holder.Reference)) + throw new IllegalStateException("Found direct holder " + holder + " value in tag " + name); + + holderToTag.get((Holder.Reference) holder).add(name); + } + + @Override + public void resetTags() + { + this.tags.values().forEach(t -> t.bind(List.of())); + this.holders.values().forEach(v -> v.bindTags(Set.of())); + } + + @Override + public void unfreeze() + { + this.frozen = false; + } + + boolean isFrozen() + { + return this.frozen; + } + + boolean isIntrusive() + { + return this.intrusiveHolderCallback != null; + } + + @Nullable + Holder.Reference onAdded(RegistryManager stage, int id, ResourceKey key, T newValue, T oldValue) + { + if (stage != RegistryManager.ACTIVE && (this.intrusiveHolderCallback == null || !stage.isStaging())) // Intrusive handlers need updating in staging. + return null; // Only do holder shit on the active registries, not pending or snapshots. + + //Holder.Reference oldHolder = oldValue == null ? null : getHolder(key, oldValue); + // Do we need to do anything with the old holder? We cant update its pointer unless its non-intrusive... + // And if thats the case, then we *should* get its reference in newHolder + + Holder.Reference newHolder = getHolder(key, newValue); + + this.holdersById.size(Math.max(this.holdersById.size(), id + 1)); + this.holdersById.set(id, newHolder); + this.holdersByName.put(key.location(), newHolder); + this.holders.put(newValue, newHolder); + if (this.unregisteredIntrusiveHolders != null) + { + this.unregisteredIntrusiveHolders.remove(newValue); + newHolder.bindKey(key); + } + newHolder.bindValue(newValue); + this.holdersSorted = null; + + return newHolder; + } + + @SuppressWarnings("deprecation") + private HolderSet.Named createTag(TagKey name) + { + return HolderSet.emptyNamed(this.holderOwner(), name); + } + + private Holder.Reference getHolder(ResourceKey key, T value) + { + if (this.intrusiveHolderCallback != null) + return this.intrusiveHolderCallback.apply(value); + + return this.holdersByName.computeIfAbsent(key.location(), k -> Holder.Reference.createStandAlone(this.holderOwner(), key)); + } + + private List> getSortedHolders() + { + if (this.holdersSorted == null) + this.holdersSorted = this.holdersById.stream().filter(Objects::nonNull).toList(); + + return this.holdersSorted; + } public static class Factory implements IForgeRegistry.CreateCallback, IForgeRegistry.AddCallback { @@ -222,15 +489,15 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr @Override public void onCreate(IForgeRegistryInternal owner, RegistryManager stage) { - ForgeRegistry fowner = (ForgeRegistry)owner; - owner.setSlaveMap(ID, new NamespacedWrapper(fowner, fowner.getBuilder().getVanillaHolder())); + ForgeRegistry fowner = (ForgeRegistry) owner; + owner.setSlaveMap(ID, new NamespacedWrapper(fowner, fowner.getBuilder().getIntrusiveHolderCallback(), stage)); } @Override @SuppressWarnings("unchecked") public void onAdd(IForgeRegistryInternal owner, RegistryManager stage, int id, ResourceKey key, V value, V oldValue) { - owner.getSlaveMap(ID, NamespacedWrapper.class).holders.onAdded(stage, id, key, value, oldValue); + owner.getSlaveMap(ID, NamespacedWrapper.class).onAdded(stage, id, key, value, oldValue); } } } diff --git a/src/main/java/net/minecraftforge/registries/NewRegistryEvent.java b/src/main/java/net/minecraftforge/registries/NewRegistryEvent.java index 680d10f1d1..e958149dc4 100644 --- a/src/main/java/net/minecraftforge/registries/NewRegistryEvent.java +++ b/src/main/java/net/minecraftforge/registries/NewRegistryEvent.java @@ -6,20 +6,18 @@ package net.minecraftforge.registries; import com.mojang.logging.LogUtils; -import net.minecraft.core.Registry; -import net.minecraft.core.RegistryAccess; -import net.minecraft.data.BuiltinRegistries; -import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fml.event.IModBusEvent; -import org.jetbrains.annotations.Nullable; -import org.slf4j.Logger; - import java.util.ArrayList; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; import java.util.function.Consumer; import java.util.function.Supplier; +import net.minecraft.core.MappedRegistry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.fml.event.IModBusEvent; +import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; /** * Register new registries when you receive this event through {@link RegistryBuilder} and {@link #create(RegistryBuilder)}. @@ -58,11 +56,15 @@ public class NewRegistryEvent extends Event implements IModBusEvent return registryHolder; } + @SuppressWarnings("deprecation") void fill() { RuntimeException aggregate = new RuntimeException(); Map, IForgeRegistry> builtRegistries = new IdentityHashMap<>(); + if (BuiltInRegistries.REGISTRY instanceof MappedRegistry rootRegistry) + rootRegistry.unfreeze(); + for (RegistryData data : this.registries) { try { @@ -74,6 +76,9 @@ public class NewRegistryEvent extends Event implements IModBusEvent } } + if (BuiltInRegistries.REGISTRY instanceof MappedRegistry rootRegistry) + rootRegistry.freeze(); + if (aggregate.getSuppressed().length > 0) LOGGER.error(LogUtils.FATAL_MARKER, "Failed to create some forge registries, see suppressed exceptions for details", aggregate); } @@ -85,16 +90,7 @@ public class NewRegistryEvent extends Event implements IModBusEvent builtRegistries.put(builder, registry); - RegistryAccess.RegistryData dataPackRegistryData = builder.getDataPackRegistryData(); - if (dataPackRegistryData != null) // if this is a datapack registry - { - if (!BuiltinRegistries.REGISTRY.containsKey(registry.getRegistryName())) - { - DataPackRegistriesHooks.addRegistryCodec(dataPackRegistryData); - RegistryManager.registerToBuiltinRegistry((ForgeRegistry) registry); - } - } - else if (builder.getHasWrapper() && !Registry.REGISTRY.containsKey(registry.getRegistryName())) + if (builder.getHasWrapper() && !BuiltInRegistries.REGISTRY.containsKey(registry.getRegistryName())) RegistryManager.registerToRootRegistry((ForgeRegistry) registry); data.registryHolder.registry = registry; diff --git a/src/main/java/net/minecraftforge/registries/RegistryBuilder.java b/src/main/java/net/minecraftforge/registries/RegistryBuilder.java index e35e4bcfdb..9f571446c1 100644 --- a/src/main/java/net/minecraftforge/registries/RegistryBuilder.java +++ b/src/main/java/net/minecraftforge/registries/RegistryBuilder.java @@ -5,24 +5,21 @@ package net.minecraftforge.registries; +import com.google.common.collect.Lists; +import net.minecraft.core.Holder; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.registries.IForgeRegistry.AddCallback; +import net.minecraftforge.registries.IForgeRegistry.BakeCallback; +import net.minecraftforge.registries.IForgeRegistry.ClearCallback; +import net.minecraftforge.registries.IForgeRegistry.CreateCallback; +import net.minecraftforge.registries.IForgeRegistry.DummyFactory; +import net.minecraftforge.registries.IForgeRegistry.MissingFactory; +import net.minecraftforge.registries.IForgeRegistry.ValidateCallback; +import org.jetbrains.annotations.Nullable; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.function.Function; -import java.util.function.Supplier; - -import com.google.common.base.Suppliers; -import com.google.common.collect.Lists; -import com.mojang.serialization.Codec; - -import net.minecraft.client.multiplayer.ClientPacketListener; -import net.minecraft.core.Holder; -import net.minecraft.core.Registry; -import net.minecraft.core.RegistryAccess; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.registries.IForgeRegistry.*; -import org.jetbrains.annotations.Nullable; public class RegistryBuilder { @@ -37,16 +34,16 @@ public class RegistryBuilder private List> createCallback = Lists.newArrayList(); private List> validateCallback = Lists.newArrayList(); private List> bakeCallback = Lists.newArrayList(); - private Function> vanillaHolder; private boolean saveToDisc = true; private boolean sync = true; private boolean allowOverrides = true; private boolean allowModifications = false; private boolean hasWrapper = false; - private Supplier> dataPackRegistryData = () -> null; // If present, implies this is a datapack registry. private DummyFactory dummyFactory; private MissingFactory missingFactory; private Set legacyNames = new HashSet<>(); + @Nullable + private Function> intrusiveHolderCallback = null; public RegistryBuilder setName(ResourceLocation name) { @@ -176,8 +173,8 @@ public class RegistryBuilder } /** - * Prevents the registry from being synced to clients. Does *not* affect datapack registries, datapack registries are unsynced by default - * unless a non-null network codec is registered via {@link #dataPackRegistry(Codec, Codec)} + * Prevents the registry from being synced to clients. + * * @return this */ public RegistryBuilder disableSync() @@ -215,9 +212,9 @@ public class RegistryBuilder return this; } - RegistryBuilder vanillaHolder(Function> func) + RegistryBuilder intrusiveHolderCallback(Function> intrusiveHolderCallback) { - this.vanillaHolder = func; + this.intrusiveHolderCallback = intrusiveHolderCallback; return this; } @@ -235,66 +232,6 @@ public class RegistryBuilder return this; } - /** - *

Register this registry as an unsynced datapack registry, which will cause data to be loaded from - * a datapack folder based on the registry's name. The mod that registers this registry does not need to exist - * on the client to connect to servers with the mod/registry.

- *

Data JSONs will be loaded from {@code data//modid/registryname/}, where modid is the mod that registered this registry.

- * - * @param codec the codec to be used for loading data from datapacks on servers - * @return this builder - * - * @see #dataPackRegistry(Codec, Codec) - */ - public RegistryBuilder dataPackRegistry(Codec codec) - { - return this.dataPackRegistry(codec, null); - } - - /** - *

Register this registry as a datapack registry, which will cause data to be loaded from - * a datapack folder based on the registry's name.

- *

Data JSONs will be loaded from {@code data//modid/registryname/}, where modid is the mod that registered this registry.

- * - * @param codec the codec to be used for loading data from datapacks on servers - * @param networkCodec the codec to be used for syncing loaded data to clients.
- * If networkCodec is null, data will not be synced, and clients without the mod that registered this registry can - * connect to servers with the mod.
- * If networkCodec is not null, then data will be synced (accessible via {@link ClientPacketListener#registryAccess()}), - * and the mod must be present on a client to connect to servers with the mod. - * @return this builder - * - * @see #dataPackRegistry(Codec) - */ - public RegistryBuilder dataPackRegistry(Codec codec, @Nullable Codec networkCodec) - { - this.hasWrapper(); // A wrapper is required for data pack registries. - this.disableSync(); // Datapack registries are synced using a different system than static registries. - // Supplier averts having to set the registry name before calling this. - this.dataPackRegistryData = Suppliers.memoize(() -> { - // Validate registry key. - if (this.registryName == null) - throw new IllegalStateException("Registry builder cannot build a datapack registry: registry name not set"); - - ResourceKey> registryKey = ResourceKey.createRegistryKey(this.registryName); - return new RegistryAccess.RegistryData<>(registryKey, codec, networkCodec); - }); - return this; - } - - /** - * Retrieves datapack registry information, if any. - * - * @return RegistryData containing the registry's key and codec(s). If returned data is null, this has not been marked as a datapack registry. - * - * @throws IllegalStateException if this has been marked as a datapack registry, but registry name has not been set. - */ - @Nullable - RegistryAccess.RegistryData getDataPackRegistryData() - { - return this.dataPackRegistryData.get(); - } - /** * Modders: Use {@link NewRegistryEvent#create(RegistryBuilder)} instead */ @@ -438,9 +375,9 @@ public class RegistryBuilder return legacyNames; } - Function> getVanillaHolder() + Function> getIntrusiveHolderCallback() { - return this.vanillaHolder; + return this.intrusiveHolderCallback; } boolean getHasWrapper() diff --git a/src/main/java/net/minecraftforge/registries/RegistryManager.java b/src/main/java/net/minecraftforge/registries/RegistryManager.java index a65eb10467..594105b2d9 100644 --- a/src/main/java/net/minecraftforge/registries/RegistryManager.java +++ b/src/main/java/net/minecraftforge/registries/RegistryManager.java @@ -19,7 +19,7 @@ import com.google.common.collect.Sets; import com.mojang.serialization.Lifecycle; import net.minecraft.core.WritableRegistry; -import net.minecraft.data.BuiltinRegistries; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.core.Registry; @@ -131,12 +131,7 @@ public class RegistryManager static void registerToRootRegistry(ForgeRegistry forgeReg) { - injectForgeRegistry(forgeReg, Registry.REGISTRY); - } - - static void registerToBuiltinRegistry(ForgeRegistry forgeReg) - { - injectForgeRegistry(forgeReg, BuiltinRegistries.REGISTRY); + injectForgeRegistry(forgeReg, BuiltInRegistries.REGISTRY); } @SuppressWarnings("unchecked") @@ -151,11 +146,14 @@ public class RegistryManager public static void postNewRegistryEvent() { NewRegistryEvent event = new NewRegistryEvent(); - vanillaRegistryKeys = Set.copyOf(Registry.REGISTRY.keySet()); + DataPackRegistryEvent.NewRegistry dataPackEvent = new DataPackRegistryEvent.NewRegistry(); + vanillaRegistryKeys = Set.copyOf(BuiltInRegistries.REGISTRY.keySet()); ModLoader.get().postEventWithWrapInModOrder(event, (mc, e) -> ModLoadingContext.get().setActiveContainer(mc), (mc, e) -> ModLoadingContext.get().setActiveContainer(null)); + ModLoader.get().postEventWithWrapInModOrder(dataPackEvent, (mc, e) -> ModLoadingContext.get().setActiveContainer(mc), (mc, e) -> ModLoadingContext.get().setActiveContainer(null)); event.fill(); + dataPackEvent.process(); } private void addLegacyName(ResourceLocation legacyName, ResourceLocation name) diff --git a/src/main/java/net/minecraftforge/registries/RegistryObject.java b/src/main/java/net/minecraftforge/registries/RegistryObject.java index 9f0edb532d..c82013e9c9 100644 --- a/src/main/java/net/minecraftforge/registries/RegistryObject.java +++ b/src/main/java/net/minecraftforge/registries/RegistryObject.java @@ -7,7 +7,7 @@ package net.minecraftforge.registries; import net.minecraft.core.Holder; import net.minecraft.core.Registry; -import net.minecraft.data.BuiltinRegistries; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; @@ -52,7 +52,7 @@ public final class RegistryObject implements Supplier * Use {@link #createOptional(ResourceLocation, ResourceKey, String)} for RegistryObjects of optional registries. * * @param name the name of the object to look up in a registry - * @param registryKey the key of the registry. Supports lookups on {@link BuiltinRegistries}, {@link Registry}, and {@link RegistryManager#ACTIVE}. + * @param registryKey the key of the registry. Supports lookups on {@link BuiltInRegistries} and {@link RegistryManager#ACTIVE}. * @param modid the mod id calling context * @return a {@link RegistryObject} that stores the value of an object from a registry once it is ready * @see #createOptional(ResourceLocation, ResourceKey, String) @@ -72,7 +72,7 @@ public final class RegistryObject implements Supplier * Use {@link #create(ResourceLocation, ResourceKey, String)} for RegistryObjects that should throw exceptions on missing registry. * * @param name the name of the object to look up in a registry - * @param registryKey the key of the registry. Supports lookups on {@link BuiltinRegistries}, {@link Registry}, and {@link RegistryManager#ACTIVE}. + * @param registryKey the key of the registry. Supports lookups on {@link BuiltInRegistries} and {@link RegistryManager#ACTIVE}. * @param modid the mod id calling context * @return a {@link RegistryObject} that stores the value of an object from a registry once it is ready * @see #create(ResourceLocation, ResourceKey, String) @@ -92,7 +92,7 @@ public final class RegistryObject implements Supplier * Use {@link #createOptional(ResourceLocation, ResourceLocation, String)} for RegistryObjects of optional registries. * * @param name the name of the object to look up in a registry - * @param registryName the name of the registry. Supports lookups on {@link BuiltinRegistries}, {@link Registry}, and {@link RegistryManager#ACTIVE}. + * @param registryName the name of the registry. Supports lookups on {@link BuiltInRegistries} and {@link RegistryManager#ACTIVE}. * @param modid the mod id calling context * @return a {@link RegistryObject} that stores the value of an object from a registry once it is ready * @see #createOptional(ResourceLocation, ResourceLocation, String) @@ -112,7 +112,7 @@ public final class RegistryObject implements Supplier * Use {@link #create(ResourceLocation, ResourceLocation, String)} for RegistryObjects that should throw exceptions on missing registry. * * @param name the name of the object to look up in a registry - * @param registryName the name of the registry. Supports lookups on {@link BuiltinRegistries}, {@link Registry}, and {@link RegistryManager#ACTIVE}. + * @param registryName the name of the registry. Supports lookups on {@link BuiltInRegistries} and {@link RegistryManager#ACTIVE}. * @param modid the mod id calling context * @return a {@link RegistryObject} that stores the value of an object from a registry once it is ready * @see #create(ResourceLocation, ResourceLocation, String) @@ -251,20 +251,13 @@ public final class RegistryObject implements Supplier return; } - Registry vanillaRegistry = (Registry) Registry.REGISTRY.get(registryName); + Registry vanillaRegistry = (Registry) BuiltInRegistries.REGISTRY.get(registryName); if (vanillaRegistry != null) { updateReference(vanillaRegistry); return; } - Registry builtinRegistry = (Registry) BuiltinRegistries.REGISTRY.get(registryName); - if (builtinRegistry != null) - { - updateReference(builtinRegistry); - return; - } - this.value = null; this.holder = null; } @@ -288,8 +281,7 @@ public final class RegistryObject implements Supplier private static boolean registryExists(ResourceLocation registryName) { return RegistryManager.ACTIVE.getRegistry(registryName) != null - || Registry.REGISTRY.containsKey(registryName) - || BuiltinRegistries.REGISTRY.containsKey(registryName); + || BuiltInRegistries.REGISTRY.containsKey(registryName); } public ResourceLocation getId() @@ -479,26 +471,13 @@ public final class RegistryObject implements Supplier * This should only be used in cases where vanilla code requires passing in a Holder. * Mod-written code should rely on RegistryObjects or Suppliers instead. *

- * The returned optional will be empty if the registry does not exist. - * Otherwise, the optional Holder will be present even if {@link #isPresent()} returns false. + * The returned optional will be empty if the registry does not exist or if {@link #isPresent() returns false}. * * @return an optional {@link Holder} instance pointing to this RegistryObject's name and value */ - @SuppressWarnings("unchecked") @NotNull public Optional> getHolder() { - if (this.holder == null && this.key != null && registryExists(this.key.registry())) - { - ResourceLocation registryName = this.key.registry(); - Registry registry = (Registry) Registry.REGISTRY.get(registryName); - if (registry == null) - registry = (Registry) BuiltinRegistries.REGISTRY.get(registryName); - - if (registry != null) - this.holder = registry.getOrCreateHolder(this.key).result().get(); - } - return Optional.ofNullable(this.holder); } diff --git a/src/main/java/net/minecraftforge/registries/holdersets/AnyHolderSet.java b/src/main/java/net/minecraftforge/registries/holdersets/AnyHolderSet.java index 614d3613e2..1689264d7e 100644 --- a/src/main/java/net/minecraftforge/registries/holdersets/AnyHolderSet.java +++ b/src/main/java/net/minecraftforge/registries/holdersets/AnyHolderSet.java @@ -15,7 +15,10 @@ import java.util.stream.Stream; import com.mojang.datafixers.util.Either; import com.mojang.serialization.Codec; +import net.minecraft.Util; import net.minecraft.core.Holder; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.HolderOwner; import net.minecraft.core.Registry; import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceKey; @@ -31,12 +34,12 @@ import net.minecraftforge.common.ForgeMod; * } * */ -public record AnyHolderSet(Registry registry) implements ICustomHolderSet +public record AnyHolderSet(HolderLookup.RegistryLookup registryLookup) implements ICustomHolderSet { public static Codec> codec(ResourceKey> registryKey, Codec> holderCodec, boolean forceList) { - return RegistryOps.retrieveRegistry(registryKey) - .xmap(AnyHolderSet::new, AnyHolderSet::registry) + return RegistryOps.retrieveRegistryLookup(registryKey) + .xmap(AnyHolderSet::new, AnyHolderSet::registryLookup) .codec(); } @@ -45,7 +48,7 @@ public record AnyHolderSet(Registry registry) implements ICustomHolderSet< { return ForgeMod.ANY_HOLDER_SET.get(); } - + @Override public Iterator> iterator() { @@ -55,13 +58,13 @@ public record AnyHolderSet(Registry registry) implements ICustomHolderSet< @Override public Stream> stream() { - return registry.holders().map(Function.identity()); + return this.registryLookup.listElements().map(Function.identity()); } @Override public int size() { - return this.registry.size(); + return (int) this.stream().count(); } @Override @@ -73,30 +76,41 @@ public record AnyHolderSet(Registry registry) implements ICustomHolderSet< @Override public Optional> getRandomElement(RandomSource random) { - return this.registry.getRandom(random); + return Util.getRandomSafe(this.stream().toList(), random); } @Override public Holder get(int i) { - return this.registry.getHolder(i).orElseThrow(() -> new NoSuchElementException("No element " + i + " in registry " + this.registry.key())); + List> holders = this.stream().toList(); + Holder holder = i >= holders.size() ? null : holders.get(i); + if (holder == null) + throw new NoSuchElementException("No element " + i + " in registry " + this.registryLookup.key()); + + return holder; } @Override public boolean contains(Holder holder) { - return holder.unwrapKey().map(this.registry::containsKey).orElse(false); + return holder.unwrapKey().map(key -> this.registryLookup.listElementIds().anyMatch(key::equals)).orElse(false); } @Override - public boolean isValidInRegistry(Registry registry) + public boolean canSerializeIn(HolderOwner holderOwner) { - return this.registry == registry; + return this.registryLookup.canSerializeIn(holderOwner); + } + + @Override + public Optional> unwrapKey() + { + return Optional.empty(); } @Override public String toString() { - return "AnySet(" + this.registry.key() + ")"; + return "AnySet(" + this.registryLookup.key() + ")"; } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/registries/holdersets/CompositeHolderSet.java b/src/main/java/net/minecraftforge/registries/holdersets/CompositeHolderSet.java index 1f356317d7..b513e30450 100644 --- a/src/main/java/net/minecraftforge/registries/holdersets/CompositeHolderSet.java +++ b/src/main/java/net/minecraftforge/registries/holdersets/CompositeHolderSet.java @@ -12,6 +12,7 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Stream; +import net.minecraft.core.HolderOwner; import org.jetbrains.annotations.Nullable; import com.mojang.datafixers.util.Either; @@ -37,7 +38,7 @@ public abstract class CompositeHolderSet implements ICustomHolderSet private Set> set = null; @Nullable private List> list = null; - + public CompositeHolderSet(List> components) { this.components = components; @@ -46,17 +47,17 @@ public abstract class CompositeHolderSet implements ICustomHolderSet holderset.addInvalidationListener(this::invalidate); } } - + /** * {@return immutable Set of Holders given this composite holderset's component holdersets} */ protected abstract Set> createSet(); - + public List> getComponents() { return this.components; } - + public Set> getSet() { Set> thisSet = this.set; @@ -71,7 +72,7 @@ public abstract class CompositeHolderSet implements ICustomHolderSet return thisSet; } } - + public List> getList() { List> thisList = this.list; @@ -86,13 +87,13 @@ public abstract class CompositeHolderSet implements ICustomHolderSet return thisList; } } - + @Override public void addInvalidationListener(Runnable runnable) { this.owners.add(runnable); } - + private void invalidate() { this.set = null; @@ -144,11 +145,11 @@ public abstract class CompositeHolderSet implements ICustomHolderSet } @Override - public boolean isValidInRegistry(Registry registry) + public boolean canSerializeIn(HolderOwner holderOwner) { for (HolderSet component : this.components) { - if (!component.isValidInRegistry(registry)) + if (!component.canSerializeIn(holderOwner)) { return false; } @@ -156,6 +157,12 @@ public abstract class CompositeHolderSet implements ICustomHolderSet return true; } + @Override + public Optional> unwrapKey() + { + return Optional.empty(); + } + @Override public Iterator> iterator() { diff --git a/src/main/java/net/minecraftforge/registries/holdersets/NotHolderSet.java b/src/main/java/net/minecraftforge/registries/holdersets/NotHolderSet.java index 0b3f2db8e0..fe810a1e2a 100644 --- a/src/main/java/net/minecraftforge/registries/holdersets/NotHolderSet.java +++ b/src/main/java/net/minecraftforge/registries/holdersets/NotHolderSet.java @@ -11,6 +11,9 @@ import java.util.List; import java.util.Optional; import java.util.stream.Stream; +import net.minecraft.core.HolderGetter; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.HolderOwner; import org.jetbrains.annotations.Nullable; import com.mojang.datafixers.util.Either; @@ -44,23 +47,23 @@ public class NotHolderSet implements ICustomHolderSet public static Codec> codec(ResourceKey> registryKey, Codec> holderCodec, boolean forceList) { return RecordCodecBuilder.>create(builder -> builder.group( - RegistryOps.retrieveRegistry(registryKey).forGetter(NotHolderSet::registry), + RegistryOps.retrieveRegistryLookup(registryKey).forGetter(NotHolderSet::registryLookup), HolderSetCodec.create(registryKey, holderCodec, forceList).fieldOf("value").forGetter(NotHolderSet::value) ).apply(builder, NotHolderSet::new)); } private final List owners = new ArrayList<>(); - private final Registry registry; + private final HolderLookup.RegistryLookup registryLookup; private final HolderSet value; @Nullable private List> list = null; - - public Registry registry() { return this.registry; } + + public HolderLookup.RegistryLookup registryLookup() { return this.registryLookup; } public HolderSet value() { return this.value; } - - public NotHolderSet(Registry registry, HolderSet value) + + public NotHolderSet(HolderLookup.RegistryLookup registryLookup, HolderSet value) { - this.registry = registry; + this.registryLookup = registryLookup; this.value = value; this.value.addInvalidationListener(this::invalidate); } @@ -70,13 +73,13 @@ public class NotHolderSet implements ICustomHolderSet { return ForgeMod.NOT_HOLDER_SET.get(); } - + @Override public void addInvalidationListener(Runnable runnable) { this.owners.add(runnable); } - + @Override public Iterator> iterator() { @@ -124,9 +127,15 @@ public class NotHolderSet implements ICustomHolderSet } @Override - public boolean isValidInRegistry(Registry registry) + public boolean canSerializeIn(HolderOwner holderOwner) { - return this.registry == registry; + return this.registryLookup.canSerializeIn(holderOwner); + } + + @Override + public Optional> unwrapKey() + { + return Optional.empty(); } @Override @@ -134,13 +143,13 @@ public class NotHolderSet implements ICustomHolderSet { return "NotSet(" + this.value + ")"; } - + private List> getList() { List> thisList = this.list; if (thisList == null) { - List> list = this.registry.holders() + List> list = this.registryLookup.listElements() .filter(holder -> !this.value.contains(holder)) .map(holder -> (Holder)holder) .toList(); @@ -152,7 +161,7 @@ public class NotHolderSet implements ICustomHolderSet return thisList; } } - + private void invalidate() { this.list = null; diff --git a/src/main/java/net/minecraftforge/registries/holdersets/OrHolderSet.java b/src/main/java/net/minecraftforge/registries/holdersets/OrHolderSet.java index ede452f1f0..b178e92708 100644 --- a/src/main/java/net/minecraftforge/registries/holdersets/OrHolderSet.java +++ b/src/main/java/net/minecraftforge/registries/holdersets/OrHolderSet.java @@ -12,6 +12,7 @@ import java.util.stream.Collectors; import com.mojang.serialization.Codec; import net.minecraft.core.Holder; +import net.minecraft.core.HolderOwner; import net.minecraft.core.HolderSet; import net.minecraft.core.Registry; import net.minecraft.resources.HolderSetCodec; @@ -40,7 +41,7 @@ public class OrHolderSet extends CompositeHolderSet .fieldOf("values") .codec(); } - + public OrHolderSet(List> values) { super(values); diff --git a/src/main/java/net/minecraftforge/resource/DelegatingPackResources.java b/src/main/java/net/minecraftforge/resource/DelegatingPackResources.java index e528a30915..57d8e1e2c9 100644 --- a/src/main/java/net/minecraftforge/resource/DelegatingPackResources.java +++ b/src/main/java/net/minecraftforge/resource/DelegatingPackResources.java @@ -5,37 +5,36 @@ package net.minecraftforge.resource; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.*; -import java.util.function.Predicate; -import java.util.stream.Collectors; - import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import net.minecraft.server.packs.PackResources; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.AbstractPackResources; -import net.minecraft.server.packs.ResourcePackFileNotFoundException; +import net.minecraft.server.packs.PackResources; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.metadata.MetadataSectionSerializer; import net.minecraft.server.packs.metadata.pack.PackMetadataSection; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.resources.IoSupplier; +import org.jetbrains.annotations.Nullable; public class DelegatingPackResources extends AbstractPackResources { + private final PackMetadataSection packMeta; private final List delegates; private Map> namespacesAssets; private Map> namespacesData; - private final String name; - private final PackMetadataSection packInfo; - - public DelegatingPackResources(String id, String name, PackMetadataSection packInfo, List packs) + public DelegatingPackResources(String packId, boolean isBuiltin, PackMetadataSection packMeta, List packs) { - super(new File(id)); - this.name = name; - this.packInfo = packInfo; + super(packId, isBuiltin); + this.packMeta = packMeta; this.delegates = ImmutableList.copyOf(packs); this.namespacesAssets = this.buildNamespaceMap(PackType.CLIENT_RESOURCES, delegates); this.namespacesData = this.buildNamespaceMap(PackType.SERVER_DATA, delegates); @@ -70,29 +69,21 @@ public class DelegatingPackResources extends AbstractPackResources return ImmutableMap.copyOf(map); } - @Override - public String getName() - { - return name; - } - @SuppressWarnings("unchecked") + @Nullable @Override public T getMetadataSection(MetadataSectionSerializer deserializer) throws IOException { - if (deserializer.getMetadataSectionName().equals("pack")) - { - return (T) packInfo; - } - return null; + return deserializer.getMetadataSectionName().equals("pack") ? (T) this.packMeta : null; } @Override - public Collection getResources(PackType type, String pathIn, String pathIn2, Predicate filter) + public void listResources(PackType type, String resourceNamespace, String paths, ResourceOutput resourceOutput) { - return delegates.stream() - .flatMap(r -> r.getResources(type, pathIn, pathIn2, filter).stream()) - .collect(Collectors.toList()); + for (PackResources delegate : this.delegates) + { + delegate.listResources(type, resourceNamespace, paths, resourceOutput); + } } @Override @@ -110,51 +101,26 @@ public class DelegatingPackResources extends AbstractPackResources } } + @Nullable @Override - public InputStream getRootResource(String fileName) throws IOException + public IoSupplier getRootResource(String... paths) { - // root resources do not make sense here - throw new ResourcePackFileNotFoundException(this.file, fileName); + // Root resources do not make sense here + throw null; } + @Nullable @Override - protected InputStream getResource(String resourcePath) throws IOException - { - // never called, we override all methods that call this - throw new ResourcePackFileNotFoundException(this.file, resourcePath); - } - - @Override - protected boolean hasResource(String resourcePath) - { - // never called, we override all methods that call this - return false; - } - - @Override - public InputStream getResource(PackType type, ResourceLocation location) throws IOException + public IoSupplier getResource(PackType type, ResourceLocation location) { for (PackResources pack : getCandidatePacks(type, location)) { - if (pack.hasResource(type, location)) - { + IoSupplier ioSupplier = pack.getResource(type, location); + if (ioSupplier != null) return pack.getResource(type, location); - } } - throw new ResourcePackFileNotFoundException(this.file, getFullPath(type, location)); - } - @Override - public boolean hasResource(PackType type, ResourceLocation location) - { - for (PackResources pack : getCandidatePacks(type, location)) - { - if (pack.hasResource(type, location)) - { - return true; - } - } - return false; + return null; } private List getCandidatePacks(PackType type, ResourceLocation location) @@ -163,11 +129,4 @@ public class DelegatingPackResources extends AbstractPackResources List packsWithNamespace = map.get(location.getNamespace()); return packsWithNamespace == null ? Collections.emptyList() : packsWithNamespace; } - - private static String getFullPath(PackType type, ResourceLocation location) - { - // stolen from ResourcePack - return String.format(Locale.ROOT, "%s/%s/%s", type.getDirectory(), location.getNamespace(), location.getPath()); - } - } diff --git a/src/main/java/net/minecraftforge/resource/PathPackResources.java b/src/main/java/net/minecraftforge/resource/PathPackResources.java index 2817ef2efb..c0948b11aa 100644 --- a/src/main/java/net/minecraftforge/resource/PathPackResources.java +++ b/src/main/java/net/minecraftforge/resource/PathPackResources.java @@ -6,24 +6,25 @@ package net.minecraftforge.resource; import com.google.common.base.Joiner; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.AbstractPackResources; -import net.minecraft.server.packs.PackType; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.io.FileNotFoundException; +import com.mojang.logging.LogUtils; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.StandardOpenOption; -import java.util.Collection; import java.util.Collections; +import java.util.List; import java.util.Locale; import java.util.Set; -import java.util.function.Predicate; import java.util.stream.Collectors; +import java.util.stream.Stream; +import net.minecraft.FileUtil; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.AbstractPackResources; +import net.minecraft.server.packs.PackType; +import net.minecraft.server.packs.resources.IoSupplier; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; /** * Defines a resource pack from an arbitrary Path. @@ -34,23 +35,23 @@ import java.util.stream.Collectors; */ public class PathPackResources extends AbstractPackResources { + private static final Logger LOGGER = LogUtils.getLogger(); private final Path source; - private final String packName; - - private final ResourceCacheManager cacheManager = new ResourceCacheManager(true, "indexModPackCachesOnThread", (packType, namespace) -> resolve(packType.getDirectory(), namespace).toAbsolutePath()); + private final ResourceCacheManager cacheManager = new ResourceCacheManager(true, "indexModPackCachesOnThread", + (packType, namespace) -> List.of(resolve(packType.getDirectory(), namespace).toAbsolutePath())); /** * Constructs a java.nio.Path-based resource pack. * - * @param packName the identifying name of the pack. - * This name should be unique within the pack finder, preferably the name of the file or folder containing the resources. - * @param source the root path of the pack. This needs to point to the folder that contains "assets" and/or "data", not the asset folder itself! + * @param packId the identifier of the pack. + * This identifier should be unique within the pack finder, preferably the name of the file or folder containing the resources. + * @param isBuiltin whether this pack resources should be considered builtin + * @param source the root path of the pack. This needs to point to the folder that contains "assets" and/or "data", not the asset folder itself! */ - public PathPackResources(String packName, final Path source) + public PathPackResources(String packId, boolean isBuiltin, final Path source) { - super(new File("dummy")); + super(packId, isBuiltin); this.source = source; - this.packName = packName; } @Override @@ -79,17 +80,6 @@ public class PathPackResources extends AbstractPackResources return this.source; } - /** - * Returns the identifying name for the pack. - * - * @return the identifier of the pack. - */ - @Override - public String getName() - { - return packName; - } - /** * Implement to return a file or folder path for the given set of path components. * @@ -104,48 +94,23 @@ public class PathPackResources extends AbstractPackResources return path; } + @Nullable @Override - protected InputStream getResource(String name) throws IOException + public IoSupplier getRootResource(String... paths) { - final Path path = resolve(name); + final Path path = resolve(paths); if (!Files.exists(path)) - throw new FileNotFoundException("Can't find resource " + name + " at " + getSource()); - return Files.newInputStream(path, StandardOpenOption.READ); + return null; + + return IoSupplier.create(path); } @Override - protected boolean hasResource(String name) + public void listResources(PackType type, String namespace, String path, ResourceOutput resourceOutput) { - final Path path = resolve(name); - return Files.exists(path); - } - - @Override - public Collection getResources(PackType type, String resourceNamespace, String pathIn, Predicate filter) - { - try - { - Path root = resolve(type.getDirectory(), resourceNamespace).toAbsolutePath(); - Path inputPath = root.getFileSystem().getPath(pathIn); - - if (ResourceCacheManager.shouldUseCache() && this.cacheManager.hasCached(type, resourceNamespace)) - { - return this.cacheManager.getResources(type, resourceNamespace, inputPath, filter); - } - - return Files.walk(root) - .map(root::relativize) - .filter(path -> !path.toString().endsWith(".mcmeta") && path.startsWith(inputPath)) - // It is VERY IMPORTANT that we do not rely on Path.toString as this is inconsistent between operating systems - // Join the path names ourselves to force forward slashes #8813 - .filter(path -> ResourceLocation.isValidPath(Joiner.on('/').join(path))) // Only process valid paths Fixes the case where people put invalid resources in their jar. - .map(path -> new ResourceLocation(resourceNamespace, Joiner.on('/').join(path))) - .filter(filter) - .collect(Collectors.toList()); - } catch (IOException e) - { - return Collections.emptyList(); - } + FileUtil.decomposePath(path).get() + .ifLeft(parts -> net.minecraft.server.packs.PathPackResources.listPath(namespace, resolve(type.getDirectory(), namespace).toAbsolutePath(), parts, resourceOutput)) + .ifRight(dataResult -> LOGGER.error("Invalid path {}: {}", path, dataResult.message())); } @Override @@ -165,19 +130,24 @@ public class PathPackResources extends AbstractPackResources try { Path root = resolve(type.getDirectory()); - return Files.walk(root, 1) - .filter(Files::isDirectory) - .map(path -> root.relativize(path)) - .filter(path -> path.getNameCount() > 0) // skip the root entry - .map(p -> p.toString().replaceAll("/$", "")) // remove the trailing slash, if present - .filter(s -> !s.isEmpty()) //filter empty strings, otherwise empty strings default to minecraft in ResourceLocations - .collect(Collectors.toSet()); - } catch (IOException e) + try (Stream walker = Files.walk(root, 1)) + { + return walker + .filter(Files::isDirectory) + .map(root::relativize) + .filter(p -> p.getNameCount() > 0) // Skip the root entry + .map(p -> p.toString().replaceAll("/$", "")) // Remove the trailing slash, if present + .filter(s -> !s.isEmpty()) // Filter empty strings, otherwise empty strings default to minecraft namespace in ResourceLocations + .collect(Collectors.toSet()); + } + } + catch (IOException e) { - if (type == PackType.SERVER_DATA) //We still have to add the resource namespace if client resources exist, as we load langs (which are in assets) on server + if (type == PackType.SERVER_DATA) // We still have to add the resource namespace if client resources exist, as we load langs (which are in assets) on server { return this.getNamespaces(PackType.CLIENT_RESOURCES); - } else + } + else { return Collections.emptySet(); } @@ -185,38 +155,29 @@ public class PathPackResources extends AbstractPackResources } @Override - public InputStream getResource(PackType type, ResourceLocation location) throws IOException + public IoSupplier getResource(PackType type, ResourceLocation location) { - if (location.getPath().startsWith("lang/")) - { - return super.getResource(PackType.CLIENT_RESOURCES, location); - } else - { - return super.getResource(type, location); - } + return this.getRootResource(getPathFromLocation(location.getPath().startsWith("lang/") ? PackType.CLIENT_RESOURCES : type, location)); } - @Override - public boolean hasResource(PackType type, ResourceLocation location) + private static String[] getPathFromLocation(PackType type, ResourceLocation location) { - if (location.getPath().startsWith("lang/")) - { - return super.hasResource(PackType.CLIENT_RESOURCES, location); - } else - { - return super.hasResource(type, location); - } + String[] parts = location.getPath().split("/"); + String[] result = new String[parts.length + 2]; + result[0] = type.getDirectory(); + result[1] = location.getNamespace(); + System.arraycopy(parts, 0, result, 2, parts.length); + return result; } @Override public void close() { - } @Override public String toString() { - return String.format(Locale.ROOT, "%s: %s", getClass().getName(), getSource()); + return String.format(Locale.ROOT, "%s: %s (%s)", getClass().getName(), this.packId(), getSource()); } } diff --git a/src/main/java/net/minecraftforge/resource/ResourceCacheManager.java b/src/main/java/net/minecraftforge/resource/ResourceCacheManager.java index 5d4d70f38e..a19024780b 100644 --- a/src/main/java/net/minecraftforge/resource/ResourceCacheManager.java +++ b/src/main/java/net/minecraftforge/resource/ResourceCacheManager.java @@ -15,25 +15,12 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterators; import com.google.common.collect.Maps; import com.mojang.logging.LogUtils; -import net.minecraft.Util; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.PackType; -import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.fml.loading.FMLPaths; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import org.slf4j.Logger; -import org.slf4j.Marker; -import org.slf4j.MarkerFactory; - import java.io.IOException; +import java.io.InputStream; import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.StandardOpenOption; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; @@ -41,9 +28,22 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.BiFunction; +import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; +import net.minecraft.Util; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.PackResources; +import net.minecraft.server.packs.PackType; +import net.minecraft.server.packs.resources.IoSupplier; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.fml.loading.FMLPaths; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; +import org.slf4j.Marker; +import org.slf4j.MarkerFactory; /** * Cache manager for resources. @@ -57,6 +57,7 @@ public class ResourceCacheManager * Logging marker to handle the hiding of the entries from the debug file. */ private static final Marker RESOURCE_CACHE = MarkerFactory.getMarker("RESOURCE-CACHE"); + private static final Joiner SLASH_JOINER = Joiner.on('/'); /** * Indicates if the underlying namespaced managers need to support reloading. @@ -72,7 +73,7 @@ public class ResourceCacheManager /** * The path builder (different users have different requirements for how they want to handle this) */ - private final BiFunction pathBuilder; + private final BiFunction> pathBuilder; /** * The individual sub managers by pack type and namespace @@ -87,14 +88,14 @@ public class ResourceCacheManager * @param pathBuilder The path builder to use. */ @Deprecated(since = "1.19.2", forRemoval = true) - public ResourceCacheManager(final boolean supportsReloading, final ForgeConfigSpec.BooleanValue indexOffThreadConfig, final BiFunction pathBuilder) + public ResourceCacheManager(final boolean supportsReloading, final ForgeConfigSpec.BooleanValue indexOffThreadConfig, final BiFunction> pathBuilder) { this.supportsReloading = supportsReloading; this.indexOnThreadConfigurationKey = Iterators.getLast(indexOffThreadConfig.getPath().iterator()); this.pathBuilder = pathBuilder; } - public ResourceCacheManager(final boolean supportsReloading, final String indexOnThreadConfigurationKey, final BiFunction pathBuilder) + public ResourceCacheManager(final boolean supportsReloading, final String indexOnThreadConfigurationKey, final BiFunction> pathBuilder) { this.supportsReloading = supportsReloading; this.indexOnThreadConfigurationKey = indexOnThreadConfigurationKey; @@ -108,7 +109,8 @@ public class ResourceCacheManager */ public static boolean shouldUseCache() { - return ResourceManagerBootCacheConfigurationHandler.getInstance().getConfigValue("cachePackAccess", true); + // TODO 1.19.3: Fix resource listing cache -SS + return false; // ResourceManagerBootCacheConfigurationHandler.getInstance().getConfigValue("cachePackAccess", true); } /** @@ -173,15 +175,16 @@ public class ResourceCacheManager } /** - * Returns the cached resources for the given pack type, namespace, path prefix and filter. + * Lists the cached resources for the given pack type, namespace, path prefix and filter. * * @param type The type of pack to look up in (data or resource) * @param resourceNamespace The namespace of the resources to look up. * @param inputPath The input path prefix to check for. - * @param filter The ternary filter to apply. - * @return A collection of resource locations which match the given filter, have the input path as prefix, are in the right pack type and have the given namespace as namespace. + * @param resourceFunction The function that turns a resource location into an input stream supplier. + * @param resourceOutput The resource output to accept resources. */ - public Collection getResources(final PackType type, final String resourceNamespace, final Path inputPath, final Predicate filter) + public void listResources(final PackType type, final String resourceNamespace, final Path inputPath, final BiFunction> resourceFunction, + final PackResources.ResourceOutput resourceOutput) { final PackTypeAndNamespace key = new PackTypeAndNamespace(type, resourceNamespace); final NamespacedResourceCacheManager manager = managersByNamespace.get(key); @@ -189,11 +192,11 @@ public class ResourceCacheManager // Check if we even have a cached manager with the given namespace, else return an empty collection. if (manager == null) { - return Collections.emptyList(); + return; } // Request the data from the manager. - return manager.getResources(inputPath, filter); + manager.listResources(inputPath, loc -> resourceFunction.apply(type, loc), resourceOutput); } /** @@ -271,7 +274,7 @@ public class ResourceCacheManager /** * The path builder to use. */ - private final BiFunction pathBuilder; + private final BiFunction> pathBuilder; /** * The path walker stream factory to use. */ @@ -295,7 +298,7 @@ public class ResourceCacheManager * @param pathBuilder The path builder to use. * @param pathFinder The path walker stream factory to use. */ - private NamespacedResourceCacheManager(final PackType packType, final String namespace, final boolean indexOnThread, BiFunction pathBuilder, final PathWalkerFactory pathFinder) + private NamespacedResourceCacheManager(final PackType packType, final String namespace, final boolean indexOnThread, BiFunction> pathBuilder, final PathWalkerFactory pathFinder) { this.packType = packType; this.namespace = namespace; @@ -332,9 +335,14 @@ public class ResourceCacheManager { LOGGER.debug(RESOURCE_CACHE, "Indexing resources for pack type {} and namespace {}, on thread: {}", packType, namespace, Thread.currentThread().getName()); - // Get the path to the root of the namespace in the current pack. - final Path rootPath = pathBuilder.apply(packType, namespace); + // Get the path(s) to the root of the namespace in the current pack. + final List rootPaths = pathBuilder.apply(packType, namespace); + rootPaths.forEach(this::doIndex); + } + + private void doIndex(Path rootPath) + { // Stream element resource that combines a normalized path and a joined path using the "/" as separator. record PathWithLocationPath(Path path, String locationPath) { @@ -344,8 +352,9 @@ public class ResourceCacheManager try (final Stream paths = pathFinder.createWalkingStream(rootPath)) { paths.parallel() // Run the stream in parallel + .filter(Predicate.not(rootPath::equals)) .map(rootPath::relativize) // Relative to the given root. - .map(path -> new PathWithLocationPath(path, Joiner.on('/').join(path))) // Create a common hierarchy. + .map(path -> new PathWithLocationPath(path, SLASH_JOINER.join(path))) // Create a common hierarchy. .filter(path -> ResourceLocation.isValidPath(path.locationPath())) // Only process valid paths .map(path -> new ResourceCacheEntry(packType, namespace, path.path(), new ResourceLocation(namespace, path.locationPath()))) // Create a cache entry. .forEach(this::injectIntoCache); // Inject the entry into the cache. @@ -410,30 +419,30 @@ public class ResourceCacheManager } /** - * Looks up resources in the given input path prefix as well as those that match the filter. + * Looks up resources in the given input path prefix. * * @param inputPath The input path prefix to look in. - * @param filter The filter which the resources must match. - * @return A collection of resource location which match the given path prefix and who match the filter. + * @param resourceFunction The function that turns a resource location into an input stream supplier. + * @param resourceOutput The resource output to accept resources. */ - public Collection getResources(final Path inputPath, final Predicate filter) + public void listResources(final Path inputPath, Function> resourceFunction, final PackResources.ResourceOutput resourceOutput) { // We only have a cache once the atomic flag has been set. if (!cacheLoaded()) { - // We need to return a mutable object here because the callers actually mutate the collection. - return new ArrayList<>(); + return; } // Use the input path prefix, we can not depend on a toString call here, since we need the / as separator. - final String pathEntry = Joiner.on('/').join(inputPath); + final String pathEntry = SLASH_JOINER.join(inputPath); // Since we inject into the cache recursively we can now just grab the map entry that is the prefix and loop over its values. // We use getOrDefault with a stream combination since the returned list needs to be mutable. - return entriesByPathPrefix.getOrDefault(pathEntry, Collections.emptyList()).stream() - .map(ResourceCacheEntry::resourceLocation) - .filter(filter) - .collect(Collectors.toList()); + List entries = this.entriesByPathPrefix.get(pathEntry); + if (entries == null) + return; + + entries.forEach(cacheEntry -> resourceOutput.accept(cacheEntry.resourceLocation(), resourceFunction.apply(cacheEntry.resourceLocation()))); } /** diff --git a/src/main/java/net/minecraftforge/resource/ResourcePackLoader.java b/src/main/java/net/minecraftforge/resource/ResourcePackLoader.java index 2133492c42..437999e66b 100644 --- a/src/main/java/net/minecraftforge/resource/ResourcePackLoader.java +++ b/src/main/java/net/minecraftforge/resource/ResourcePackLoader.java @@ -53,7 +53,7 @@ public class ResourcePackLoader { @NotNull public static PathPackResources createPackForMod(IModFileInfo mf) { - return new PathPackResources(mf.getFile().getFileName(), mf.getFile().getFilePath()){ + return new PathPackResources(mf.getFile().getFileName(), false, mf.getFile().getFilePath()){ final IModFile modFile = mf.getFile(); @NotNull @Override diff --git a/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java b/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java index 0f279628c6..ef5f7f6765 100644 --- a/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java +++ b/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java @@ -17,11 +17,12 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; import net.minecraft.core.Holder; -import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.Registries; import net.minecraft.gametest.framework.GameTestServer; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; +import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.repository.PackSource; import net.minecraft.server.packs.repository.RepositorySource; import net.minecraft.world.level.storage.LevelResource; @@ -65,6 +66,7 @@ import net.minecraftforge.fml.loading.FileUtils; import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.GameData; +import org.jetbrains.annotations.ApiStatus; public class ServerLifecycleHooks { @@ -188,25 +190,25 @@ public class ServerLifecycleHooks System.exit(retVal); } - //INTERNAL MODDERS DO NOT USE + @ApiStatus.Internal public static RepositorySource buildPackFinder(Map modResourcePacks) { - return (packList, factory) -> serverPackFinder(modResourcePacks, packList, factory); + return packAcceptor -> serverPackFinder(modResourcePacks, packAcceptor); } - private static void serverPackFinder(Map modResourcePacks, Consumer consumer, Pack.PackConstructor factory) { + private static void serverPackFinder(Map modResourcePacks, Consumer packAcceptor) { for (Entry e : modResourcePacks.entrySet()) { IModInfo mod = e.getKey().getModInfos().get(0); if (Objects.equals(mod.getModId(), "minecraft")) continue; // skip the minecraft "mod" final String name = "mod:" + mod.getModId(); - final Pack packInfo = Pack.create(name, false, e::getValue, factory, Pack.Position.BOTTOM, PackSource.DEFAULT); - if (packInfo == null) { + final Pack modPack = Pack.readMetaAndCreate(name, Component.literal(e.getValue().packId()), false, id -> e.getValue(), PackType.SERVER_DATA, Pack.Position.BOTTOM, PackSource.DEFAULT); + if (modPack == null) { // Vanilla only logs an error, instead of propagating, so handle null and warn that something went wrong ModLoader.get().addWarning(new ModLoadingWarning(mod, ModLoadingStage.ERROR, "fml.modloading.brokenresources", e.getKey())); continue; } LOGGER.debug(CORE, "Generating PackInfo named {} for mod file {}", name, e.getKey().getFilePath()); - consumer.accept(packInfo); + packAcceptor.accept(modPack); } } @@ -225,12 +227,12 @@ public class ServerLifecycleHooks .toList(); // Apply sorted biome modifiers to each biome. - registries.registryOrThrow(Registry.BIOME_REGISTRY).holders().forEach(biomeHolder -> + registries.registryOrThrow(Registries.BIOME).holders().forEach(biomeHolder -> { biomeHolder.value().modifiableBiomeInfo().applyBiomeModifiers(biomeHolder, biomeModifiers); }); // Apply sorted structure modifiers to each structure. - registries.registryOrThrow(Registry.STRUCTURE_REGISTRY).holders().forEach(structureHolder -> + registries.registryOrThrow(Registries.STRUCTURE).holders().forEach(structureHolder -> { structureHolder.value().modifiableStructureInfo().applyStructureModifiers(structureHolder, structureModifiers); }); diff --git a/src/main/java/net/minecraftforge/server/command/DimensionsCommand.java b/src/main/java/net/minecraftforge/server/command/DimensionsCommand.java index 3c5b11b425..b89f1d24e8 100644 --- a/src/main/java/net/minecraftforge/server/command/DimensionsCommand.java +++ b/src/main/java/net/minecraftforge/server/command/DimensionsCommand.java @@ -7,6 +7,7 @@ package net.minecraftforge.server.command; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; +import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.core.Registry; @@ -29,7 +30,7 @@ class DimensionsCommand .requires(cs->cs.hasPermission(0)) //permission .executes(ctx -> { ctx.getSource().sendSuccess(Component.translatable("commands.forge.dimensions.list"), true); - final Registry reg = ctx.getSource().registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY); + final Registry reg = ctx.getSource().registryAccess().registryOrThrow(Registries.DIMENSION_TYPE); Map> types = new HashMap<>(); for (ServerLevel dim : ctx.getSource().getServer().getAllLevels()) { diff --git a/src/main/java/net/minecraftforge/server/command/TPSCommand.java b/src/main/java/net/minecraftforge/server/command/TPSCommand.java index ab388a004f..8a8d90080a 100644 --- a/src/main/java/net/minecraftforge/server/command/TPSCommand.java +++ b/src/main/java/net/minecraftforge/server/command/TPSCommand.java @@ -12,6 +12,7 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.commands.arguments.DimensionArgument; import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.server.level.ServerLevel; @@ -46,10 +47,10 @@ class TPSCommand { long[] times = cs.getServer().getTickTime(dim.dimension()); - if (times == null) // Null means the world is unloaded. Not invalid. That's taken car of by DimensionArgument itself. + if (times == null) // Null means the world is unloaded. Not invalid. That's taken care of by DimensionArgument itself. times = UNLOADED; - final Registry reg = cs.registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY); + final Registry reg = cs.registryAccess().registryOrThrow(Registries.DIMENSION_TYPE); double worldTickTime = mean(times) * 1.0E-6D; double worldTPS = Math.min(1000.0 / worldTickTime, 20); cs.sendSuccess(Component.translatable("commands.forge.tps.summary.named", dim.dimension().location().toString(), reg.getKey(dim.dimensionType()), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), false); diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 16b38d08bf..3bccadf2f1 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -109,7 +109,7 @@ public net.minecraft.client.renderer.block.model.BlockModel f_111417_ # textureM public net.minecraft.client.renderer.block.model.BlockModel f_111418_ # parent public net.minecraft.client.renderer.block.model.BlockModel f_111424_ # hasAmbientOcclusion public net.minecraft.client.renderer.block.model.BlockModel m_111437_(Lnet/minecraft/client/renderer/block/model/BlockElement;Lnet/minecraft/client/renderer/block/model/BlockElementFace;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/minecraft/core/Direction;Lnet/minecraft/client/resources/model/ModelState;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/renderer/block/model/BakedQuad; # bakeFace -public net.minecraft.client.renderer.block.model.ItemModelGenerator m_111638_(ILjava/lang/String;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;)Ljava/util/List; # processFrames +public net.minecraft.client.renderer.block.model.ItemModelGenerator m_111638_(ILjava/lang/String;Lnet/minecraft/client/renderer/texture/SpriteContents;)Ljava/util/List; # processFrames public net.minecraft.client.renderer.block.model.ItemOverride$Deserializer public net.minecraft.client.renderer.block.model.ItemOverride$Deserializer ()V # constructor protected net.minecraft.client.renderer.block.model.ItemOverrides ()V # constructor @@ -131,11 +131,10 @@ protected net.minecraft.client.renderer.entity.ItemEntityRenderer m_115042_(Lnet public net.minecraft.client.renderer.entity.ItemRenderer m_115162_(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Ljava/util/List;Lnet/minecraft/world/item/ItemStack;II)V # renderQuadList public net.minecraft.client.renderer.entity.ItemRenderer m_115189_(Lnet/minecraft/client/resources/model/BakedModel;Lnet/minecraft/world/item/ItemStack;IILcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;)V # renderModelLists public net.minecraft.client.renderer.entity.LivingEntityRenderer m_115326_(Lnet/minecraft/client/renderer/entity/layers/RenderLayer;)Z # addLayer -public net.minecraft.client.renderer.texture.TextureAtlasSprite m_118415_()I # getFrameCount -public net.minecraft.client.resources.ClientPackSource f_174791_ # BUILT_IN -private-f net.minecraft.client.resources.model.ModelBakery f_119216_ # atlasPreparations - need to un-finalize so that we can delay initialization to after calling super() in ModelLoader -protected net.minecraft.client.resources.model.ModelBakery f_119234_ # UNREFERENCED_TEXTURES -protected net.minecraft.client.resources.model.ModelBakery f_119243_ # resourceManager +public net.minecraft.client.renderer.texture.SpriteContents f_243731_ # byMipLevel +default net.minecraft.client.renderer.texture.SpriteContents f_244575_ # animatedTexture +default net.minecraft.client.renderer.texture.SpriteContents m_245088_()I # getFrameCount +public net.minecraft.client.resources.ClientPackSource m_246691_(Ljava/nio/file/Path;)Lnet/minecraft/server/packs/VanillaPackResources; # createVanillaPackSource protected net.minecraft.client.resources.model.ModelBakery m_119364_(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/renderer/block/model/BlockModel; # loadBlockModel public net.minecraft.client.resources.model.SimpleBakedModel$Builder (ZZZLnet/minecraft/client/renderer/block/model/ItemTransforms;Lnet/minecraft/client/renderer/block/model/ItemOverrides;)V # constructor public net.minecraft.client.sounds.SoundEngine f_120217_ # soundManager @@ -144,133 +143,54 @@ public net.minecraft.commands.arguments.selector.EntitySelectorParser m_121229_( public net.minecraft.commands.arguments.selector.EntitySelectorParser m_121317_()V # parseOptions public net.minecraft.commands.arguments.selector.options.EntitySelectorOptions m_121453_(Ljava/lang/String;Lnet/minecraft/commands/arguments/selector/options/EntitySelectorOptions$Modifier;Ljava/util/function/Predicate;Lnet/minecraft/network/chat/Component;)V # register public net.minecraft.core.Holder$Reference m_205769_(Ljava/util/Collection;)V # bindTags -public net.minecraft.core.Holder$Reference m_205775_(Lnet/minecraft/resources/ResourceKey;Ljava/lang/Object;)V # bind +public net.minecraft.core.Holder$Reference m_246870_(Lnet/minecraft/resources/ResourceKey;)V # bindKey +public net.minecraft.core.Holder$Reference m_247654_(Ljava/lang/Object;)V # bindValue public net.minecraft.core.Holder$Reference$Type -public net.minecraft.core.HolderSet$Named (Lnet/minecraft/core/Registry;Lnet/minecraft/tags/TagKey;)V # constructor public net.minecraft.core.HolderSet$Named m_205835_(Ljava/util/List;)V # bind protected net.minecraft.core.IdMapper f_122653_ # nextId protected net.minecraft.core.IdMapper f_122654_ # tToId - internal map protected net.minecraft.core.IdMapper f_122655_ # idToT - internal index list +protected net.minecraft.core.MappedRegistry f_244282_ # unregisteredIntrusiveHolders public net.minecraft.core.particles.ParticleType (ZLnet/minecraft/core/particles/ParticleOptions$Deserializer;)V # constructor public net.minecraft.core.particles.SimpleParticleType (Z)V # constructor -protected net.minecraft.data.loot.BlockLoot m_124126_(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSingleItemTable -protected net.minecraft.data.loot.BlockLoot m_124139_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/Item;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createOreDrop -protected net.minecraft.data.loot.BlockLoot m_124142_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/Item;Lnet/minecraft/world/item/Item;Lnet/minecraft/world/level/storage/loot/predicates/LootItemCondition$Builder;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createCropDrops -protected net.minecraft.data.loot.BlockLoot m_124157_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;[F)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createLeavesDrops -protected net.minecraft.data.loot.BlockLoot m_124161_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/properties/Property;Ljava/lang/Comparable;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSinglePropConditionTable -protected net.minecraft.data.loot.BlockLoot m_124165_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/storage/loot/LootTable$Builder;)V # add -protected net.minecraft.data.loot.BlockLoot m_124168_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer$Builder;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSilkTouchDispatchTable -protected net.minecraft.data.loot.BlockLoot m_124171_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/storage/loot/predicates/LootItemCondition$Builder;Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer$Builder;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSelfDropDispatchTable -protected net.minecraft.data.loot.BlockLoot m_124175_(Lnet/minecraft/world/level/block/Block;Ljava/util/function/Function;)V # add -protected net.minecraft.data.loot.BlockLoot m_124250_(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSilkTouchOnlyTable -protected net.minecraft.data.loot.BlockLoot m_124254_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/Item;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createStemDrops -protected net.minecraft.data.loot.BlockLoot m_124257_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSingleItemTableWithSilkTouch -protected net.minecraft.data.loot.BlockLoot m_124260_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createDoublePlantWithSeedDrops -protected net.minecraft.data.loot.BlockLoot m_124263_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;[F)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createOakLeavesDrops -protected net.minecraft.data.loot.BlockLoot m_124267_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer$Builder;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createShearsDispatchTable -protected net.minecraft.data.loot.BlockLoot m_124270_(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createPotFlowerItemTable -protected net.minecraft.data.loot.BlockLoot m_124274_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/Item;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createAttachedStemDrops -protected net.minecraft.data.loot.BlockLoot m_124277_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createMushroomBlockDrop -protected net.minecraft.data.loot.BlockLoot m_124283_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer$Builder;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSilkTouchOrShearsDispatchTable -protected net.minecraft.data.loot.BlockLoot m_124286_(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createShearsOnlyDrop -protected net.minecraft.data.loot.BlockLoot m_124290_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSlabItemTable -protected net.minecraft.data.loot.BlockLoot m_124292_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createNameableBlockEntityTable -protected net.minecraft.data.loot.BlockLoot m_124294_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createShulkerBoxDrop -protected net.minecraft.data.loot.BlockLoot m_124296_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createBannerDrop -protected net.minecraft.data.loot.BlockLoot m_124298_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createBeeNestDrop -protected net.minecraft.data.loot.BlockLoot m_124300_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createBeeHiveDrop -protected net.minecraft.data.loot.BlockLoot m_124302_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createGrassDrops -protected net.minecraft.data.loot.BlockLoot m_124304_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createDoublePlantShearsDrop -protected net.minecraft.data.loot.BlockLoot m_176039_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSingleItemTable -protected net.minecraft.data.loot.BlockLoot m_176042_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSingleItemTableWithSilkTouch -protected net.minecraft.data.loot.BlockLoot m_176046_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createCopperOreDrops -protected net.minecraft.data.loot.BlockLoot m_176048_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createLapisOreDrops -protected net.minecraft.data.loot.BlockLoot m_176050_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createRedstoneOreDrops -protected net.minecraft.data.loot.BlockLoot m_176052_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createCaveVinesDrop -protected net.minecraft.data.loot.BlockLoot m_176056_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createCandleDrops -protected net.minecraft.data.loot.BlockLoot m_176058_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createCandleCakeDrops -protected net.minecraft.data.loot.BlockLoot m_236221_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/storage/loot/functions/FunctionUserBuilder;)Lnet/minecraft/world/level/storage/loot/functions/FunctionUserBuilder; # applyExplosionDecay -protected net.minecraft.data.loot.BlockLoot m_236224_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/storage/loot/predicates/ConditionUserBuilder;)Lnet/minecraft/world/level/storage/loot/predicates/ConditionUserBuilder; # applyExplosionCondition -protected net.minecraft.data.loot.BlockLoot m_236227_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/storage/loot/predicates/LootItemCondition$Builder;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createMultifaceBlockDrops -protected net.minecraft.data.loot.BlockLoot m_236248_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createMangroveLeavesDrops -protected net.minecraft.data.loot.EntityLoot f_124366_ # ENTITY_ON_FIRE -protected net.minecraft.data.loot.EntityLoot m_124371_(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/storage/loot/LootTable$Builder;)V # add -protected net.minecraft.data.loot.EntityLoot m_124380_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/world/level/storage/loot/LootTable$Builder;)V # add -protected net.minecraft.data.recipes.RecipeProvider f_176505_ # COAL_SMELTABLES -protected net.minecraft.data.recipes.RecipeProvider f_176506_ # IRON_SMELTABLES -protected net.minecraft.data.recipes.RecipeProvider f_176507_ # COPPER_SMELTABLES -protected net.minecraft.data.recipes.RecipeProvider f_176508_ # GOLD_SMELTABLES -protected net.minecraft.data.recipes.RecipeProvider f_176509_ # DIAMOND_SMELTABLES -protected net.minecraft.data.recipes.RecipeProvider f_176510_ # LAPIS_SMELTABLES -protected net.minecraft.data.recipes.RecipeProvider f_176511_ # REDSTONE_SMELTABLES -protected net.minecraft.data.recipes.RecipeProvider f_176512_ # EMERALD_SMELTABLES -protected net.minecraft.data.recipes.RecipeProvider f_176513_ # shapeBuilders +protected net.minecraft.data.loot.BlockLootSubProvider m_245335_(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSilkTouchOnlyTable +protected net.minecraft.data.loot.BlockLootSubProvider m_245602_(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createPotFlowerItemTable +protected net.minecraft.data.loot.BlockLootSubProvider m_246900_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/storage/loot/predicates/LootItemCondition$Builder;Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer$Builder;)Lnet/minecraft/world/level/storage/loot/LootTable$Builder; # createSelfDropDispatchTable +protected net.minecraft.data.loot.EntityLootSubProvider m_245552_(Lnet/minecraft/world/entity/EntityType;)Z # canHaveLootTable protected net.minecraft.data.recipes.RecipeProvider f_236355_ # recipePathProvider protected net.minecraft.data.recipes.RecipeProvider f_236356_ # advancementPathProvider -protected net.minecraft.data.recipes.RecipeProvider m_125977_(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/advancements/critereon/InventoryChangeTrigger$TriggerInstance; # has protected net.minecraft.data.recipes.RecipeProvider m_125979_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/advancements/critereon/EnterBlockTrigger$TriggerInstance; # insideOf -protected net.minecraft.data.recipes.RecipeProvider m_125994_(Ljava/util/function/Consumer;Lnet/minecraft/world/item/Item;Lnet/minecraft/world/item/Item;)V # netheriteSmithing -protected net.minecraft.data.recipes.RecipeProvider m_126002_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # woodFromLogs -protected net.minecraft.data.recipes.RecipeProvider m_126006_(Ljava/util/function/Consumer;Ljava/lang/String;Lnet/minecraft/world/item/crafting/SimpleCookingSerializer;I)V # cookRecipes protected net.minecraft.data.recipes.RecipeProvider m_126011_([Lnet/minecraft/advancements/critereon/ItemPredicate;)Lnet/minecraft/advancements/critereon/InventoryChangeTrigger$TriggerInstance; # inventoryTrigger -protected net.minecraft.data.recipes.RecipeProvider m_126021_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # woodenBoat -protected net.minecraft.data.recipes.RecipeProvider m_126061_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # coloredWoolFromWhiteWoolAndDye -protected net.minecraft.data.recipes.RecipeProvider m_126069_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # coloredCarpetFromWhiteCarpetAndDye -protected net.minecraft.data.recipes.RecipeProvider m_126073_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # bedFromPlanksAndWool -protected net.minecraft.data.recipes.RecipeProvider m_126077_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # bedFromWhiteBedAndDye -protected net.minecraft.data.recipes.RecipeProvider m_126081_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # banner -protected net.minecraft.data.recipes.RecipeProvider m_126085_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # stainedGlassFromGlassAndDye -protected net.minecraft.data.recipes.RecipeProvider m_126089_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # stainedGlassPaneFromStainedGlass -protected net.minecraft.data.recipes.RecipeProvider m_126093_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # stainedGlassPaneFromGlassPaneAndDye -protected net.minecraft.data.recipes.RecipeProvider m_126097_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # coloredTerracottaFromTerracottaAndDye -protected net.minecraft.data.recipes.RecipeProvider m_126101_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # concretePowder -protected net.minecraft.data.recipes.RecipeProvider m_176517_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)Ljava/lang/String; # getConversionRecipeName protected net.minecraft.data.recipes.RecipeProvider m_176520_(Lnet/minecraft/advancements/critereon/MinMaxBounds$Ints;Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/advancements/critereon/InventoryChangeTrigger$TriggerInstance; # has protected net.minecraft.data.recipes.RecipeProvider m_176523_(Lnet/minecraft/data/BlockFamily;Lnet/minecraft/data/BlockFamily$Variant;)Lnet/minecraft/world/level/block/Block; # getBaseBlock -protected net.minecraft.data.recipes.RecipeProvider m_176531_(Ljava/util/function/Consumer;)V # buildCraftingRecipes -protected net.minecraft.data.recipes.RecipeProvider m_176533_(Ljava/util/function/Consumer;Lnet/minecraft/world/item/crafting/SimpleCookingSerializer;Ljava/util/List;Lnet/minecraft/world/level/ItemLike;FILjava/lang/String;Ljava/lang/String;)V # oreCooking -protected net.minecraft.data.recipes.RecipeProvider m_176546_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;I)V # stonecutterResultFromBase -protected net.minecraft.data.recipes.RecipeProvider m_176551_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;Ljava/lang/String;)V # oneToOneConversionRecipe -protected net.minecraft.data.recipes.RecipeProvider m_176556_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;Ljava/lang/String;I)V # oneToOneConversionRecipe -protected net.minecraft.data.recipes.RecipeProvider m_176562_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;Ljava/lang/String;Ljava/lang/String;)V # nineBlockStorageRecipesWithCustomPacking -protected net.minecraft.data.recipes.RecipeProvider m_176568_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V # nineBlockStorageRecipes -protected net.minecraft.data.recipes.RecipeProvider m_176580_(Ljava/util/function/Consumer;Lnet/minecraft/data/BlockFamily;)V # generateRecipes -protected net.minecraft.data.recipes.RecipeProvider m_176583_(Ljava/util/function/Consumer;Ljava/lang/String;Lnet/minecraft/world/item/crafting/SimpleCookingSerializer;ILnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;F)V # simpleCookingRecipe -protected net.minecraft.data.recipes.RecipeProvider m_176591_(Ljava/util/function/Consumer;Ljava/util/List;Lnet/minecraft/world/level/ItemLike;FILjava/lang/String;)V # oreSmelting -protected net.minecraft.data.recipes.RecipeProvider m_176602_(Lnet/minecraft/world/level/ItemLike;)Ljava/lang/String; # getHasName -protected net.minecraft.data.recipes.RecipeProvider m_176610_(Ljava/util/function/Consumer;)V # waxRecipes -protected net.minecraft.data.recipes.RecipeProvider m_176616_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;Ljava/lang/String;Ljava/lang/String;)V # nineBlockStorageRecipesRecipesWithCustomUnpacking -protected net.minecraft.data.recipes.RecipeProvider m_176625_(Ljava/util/function/Consumer;Ljava/util/List;Lnet/minecraft/world/level/ItemLike;FILjava/lang/String;)V # oreBlasting -protected net.minecraft.data.recipes.RecipeProvider m_176632_(Lnet/minecraft/world/level/ItemLike;)Ljava/lang/String; # getItemName -protected net.minecraft.data.recipes.RecipeProvider m_176644_(Lnet/minecraft/world/level/ItemLike;)Ljava/lang/String; # getSimpleRecipeName -protected net.minecraft.data.recipes.RecipeProvider m_176656_(Lnet/minecraft/world/level/ItemLike;)Ljava/lang/String; # getSmeltingRecipeName protected net.minecraft.data.recipes.RecipeProvider m_176658_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # buttonBuilder -protected net.minecraft.data.recipes.RecipeProvider m_176668_(Lnet/minecraft/world/level/ItemLike;)Ljava/lang/String; # getBlastingRecipeName -protected net.minecraft.data.recipes.RecipeProvider m_176670_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # doorBuilder protected net.minecraft.data.recipes.RecipeProvider m_176678_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # fenceBuilder protected net.minecraft.data.recipes.RecipeProvider m_176684_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # fenceGateBuilder -protected net.minecraft.data.recipes.RecipeProvider m_176690_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # pressurePlate -protected net.minecraft.data.recipes.RecipeProvider m_176694_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # pressurePlateBuilder -protected net.minecraft.data.recipes.RecipeProvider m_176700_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # slab -protected net.minecraft.data.recipes.RecipeProvider m_176704_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # slabBuilder -protected net.minecraft.data.recipes.RecipeProvider m_176710_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # stairBuilder -protected net.minecraft.data.recipes.RecipeProvider m_176716_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # carpet protected net.minecraft.data.recipes.RecipeProvider m_176720_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # trapdoorBuilder protected net.minecraft.data.recipes.RecipeProvider m_176726_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # signBuilder -protected net.minecraft.data.recipes.RecipeProvider m_176735_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # stonecutterResultFromBase protected net.minecraft.data.recipes.RecipeProvider m_176739_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # smeltingResultFromBase -protected net.minecraft.data.recipes.RecipeProvider m_176743_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # nineBlockStorageRecipes -protected net.minecraft.data.recipes.RecipeProvider m_206406_(Lnet/minecraft/tags/TagKey;)Lnet/minecraft/advancements/critereon/InventoryChangeTrigger$TriggerInstance; # has -protected net.minecraft.data.recipes.RecipeProvider m_206408_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/tags/TagKey;)V # planksFromLog -protected net.minecraft.data.recipes.RecipeProvider m_206412_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/tags/TagKey;)V # planksFromLogs -protected net.minecraft.data.recipes.RecipeProvider m_236367_(Lnet/minecraft/data/CachedOutput;Lcom/google/gson/JsonObject;Ljava/nio/file/Path;)V # saveAdvancement +protected net.minecraft.data.recipes.RecipeProvider m_245792_(Lnet/minecraft/data/recipes/RecipeCategory;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/ShapedRecipeBuilder; # cutBuilder +protected net.minecraft.data.recipes.RecipeProvider m_245809_(Ljava/util/function/Consumer;Lnet/minecraft/world/item/crafting/RecipeSerializer;Ljava/util/List;Lnet/minecraft/data/recipes/RecipeCategory;Lnet/minecraft/world/level/ItemLike;FILjava/lang/String;Ljava/lang/String;)V # oreCooking +protected net.minecraft.data.recipes.RecipeProvider m_245864_(Lnet/minecraft/data/recipes/RecipeCategory;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # wallBuilder +protected net.minecraft.data.recipes.RecipeProvider m_247174_(Lnet/minecraft/data/recipes/RecipeCategory;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # polishedBuilder +protected net.minecraft.data.recipes.RecipeProvider m_247347_(Lnet/minecraft/data/recipes/RecipeCategory;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # pressurePlateBuilder +protected net.minecraft.data.recipes.RecipeProvider m_247368_(Ljava/util/function/Consumer;Lnet/minecraft/data/recipes/RecipeCategory;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/data/recipes/RecipeCategory;Lnet/minecraft/world/level/ItemLike;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V # nineBlockStorageRecipes +protected net.minecraft.data.recipes.RecipeProvider m_247434_(Ljava/util/function/Consumer;Ljava/lang/String;Lnet/minecraft/world/item/crafting/RecipeSerializer;ILnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;F)V # simpleCookingRecipe public net.minecraft.data.recipes.ShapedRecipeBuilder$Result +public net.minecraft.data.recipes.packs.VanillaRecipeProvider f_243671_ # COAL_SMELTABLES +public net.minecraft.data.recipes.packs.VanillaRecipeProvider f_243779_ # IRON_SMELTABLES +public net.minecraft.data.recipes.packs.VanillaRecipeProvider f_243908_ # COPPER_SMELTABLES +public net.minecraft.data.recipes.packs.VanillaRecipeProvider f_243974_ # DIAMOND_SMELTABLES +public net.minecraft.data.recipes.packs.VanillaRecipeProvider f_244369_ # GOLD_SMELTABLES +public net.minecraft.data.recipes.packs.VanillaRecipeProvider f_244430_ # EMERALD_SMELTABLES +public net.minecraft.data.recipes.packs.VanillaRecipeProvider f_244565_ # REDSTONE_SMELTABLES +public net.minecraft.data.recipes.packs.VanillaRecipeProvider f_244628_ # LAPIS_SMELTABLES +public net.minecraft.data.tags.IntrinsicHolderTagsProvider$IntrinsicTagAppender +public net.minecraft.data.tags.TagsProvider$TagAppender protected net.minecraft.data.tags.TagsProvider f_126543_ # builders public-f net.minecraft.data.tags.TagsProvider m_6055_()Ljava/lang/String; # getName -public net.minecraft.data.tags.TagsProvider$TagAppender f_126569_ # registry public net.minecraft.gametest.framework.GameTestServer (Ljava/lang/Thread;Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;Lnet/minecraft/server/packs/repository/PackRepository;Lnet/minecraft/server/WorldStem;Ljava/util/Collection;Lnet/minecraft/core/BlockPos;)V # constructor public net.minecraft.network.protocol.status.ClientboundStatusResponsePacket f_134885_ # GSON -public net.minecraft.resources.RegistryOps f_206806_ # registryAccess public net.minecraft.resources.ResourceLocation m_135835_(C)Z # validNamespaceChar public net.minecraft.resources.ResourceLocation m_135841_(Ljava/lang/String;)Z # isValidPath public net.minecraft.resources.ResourceLocation m_135843_(Ljava/lang/String;)Z # isValidNamespace @@ -283,8 +203,8 @@ public net.minecraft.server.level.ServerPlayer f_8940_ # containerCounter public net.minecraft.server.level.ServerPlayer m_143399_(Lnet/minecraft/world/inventory/AbstractContainerMenu;)V # initMenu public net.minecraft.server.level.ServerPlayer m_9217_()V # nextContainerCounter public net.minecraft.server.network.ServerLoginPacketListenerImpl f_10021_ # gameProfile -public net.minecraft.server.packs.AbstractPackResources f_10203_ # file public net.minecraft.server.packs.PackType f_143750_ # bridgeType +public net.minecraft.server.packs.repository.ServerPacksSource m_246173_()Lnet/minecraft/server/packs/VanillaPackResources; # createVanillaPackSource public net.minecraft.server.packs.resources.FallbackResourceManager f_10599_ # fallbacks public net.minecraft.util.ExtraCodecs$EitherCodec public net.minecraft.util.datafix.fixes.StructuresBecomeConfiguredFix$Conversion @@ -320,7 +240,22 @@ protected net.minecraft.world.entity.vehicle.AbstractMinecart m_213728_()Lnet/mi public net.minecraft.world.inventory.AnvilMenu f_39000_ # repairItemCountCost public net.minecraft.world.inventory.MenuType (Lnet/minecraft/world/inventory/MenuType$MenuSupplier;)V # constructor public net.minecraft.world.inventory.MenuType$MenuSupplier -public-f net.minecraft.world.item.CreativeModeTab f_40748_ # TABS - group array +public net.minecraft.world.item.CreativeModeTab$Output +public net.minecraft.world.item.CreativeModeTab$TabVisibility +public net.minecraft.world.item.CreativeModeTabs f_256725_ # COLORED_BLOCKS +public net.minecraft.world.item.CreativeModeTabs f_256731_ # SPAWN_EGGS +public net.minecraft.world.item.CreativeModeTabs f_256750_ # SEARCH +public net.minecraft.world.item.CreativeModeTabs f_256776_ # NATURAL_BLOCKS +public net.minecraft.world.item.CreativeModeTabs f_256788_ # BUILDING_BLOCKS +public net.minecraft.world.item.CreativeModeTabs f_256791_ # FUNCTIONAL_BLOCKS +public net.minecraft.world.item.CreativeModeTabs f_256797_ # COMBAT +public net.minecraft.world.item.CreativeModeTabs f_256837_ # OP_BLOCKS +public net.minecraft.world.item.CreativeModeTabs f_256839_ # FOOD_AND_DRINKS +public net.minecraft.world.item.CreativeModeTabs f_256869_ # TOOLS_AND_UTILITIES +public net.minecraft.world.item.CreativeModeTabs f_256917_ # HOTBAR +public net.minecraft.world.item.CreativeModeTabs f_256968_ # INGREDIENTS +public net.minecraft.world.item.CreativeModeTabs f_257028_ # REDSTONE_BLOCKS +public net.minecraft.world.item.CreativeModeTabs f_257039_ # INVENTORY #group public net.minecraft.world.item.Item public net.minecraft.world.item.AxeItem (Lnet/minecraft/world/item/Tier;FFLnet/minecraft/world/item/Item$Properties;)V # constructor public net.minecraft.world.item.DiggerItem (FFLnet/minecraft/world/item/Tier;Lnet/minecraft/tags/TagKey;Lnet/minecraft/world/item/Item$Properties;)V # constructor @@ -328,6 +263,7 @@ public net.minecraft.world.item.HoeItem (Lnet/minecraft/world/item/Tier;IF public net.minecraft.world.item.PickaxeItem (Lnet/minecraft/world/item/Tier;IFLnet/minecraft/world/item/Item$Properties;)V # constructor public net.minecraft.world.item.RecordItem (ILnet/minecraft/sounds/SoundEvent;Lnet/minecraft/world/item/Item$Properties;I)V # constructor #endgroup +public net.minecraft.world.item.ItemStackLinkedSet f_260558_ # TYPE_AND_TAG public net.minecraft.world.item.alchemy.PotionBrewing$Mix public net.minecraft.world.item.alchemy.PotionBrewing$Mix f_43533_ # ingredient public net.minecraft.world.item.context.BlockPlaceContext (Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/phys/BlockHitResult;)V # constructor @@ -348,9 +284,9 @@ public net.minecraft.world.level.Level f_46438_ # rainLevel public net.minecraft.world.level.Level f_46439_ # oThunderLevel public net.minecraft.world.level.Level f_46440_ # thunderLevel public net.minecraft.world.level.biome.Biome$ClimateSettings -protected net.minecraft.world.level.biome.BiomeGenerationSettings$Builder f_47827_ # carvers -protected net.minecraft.world.level.biome.BiomeGenerationSettings$Builder f_47828_ # features -protected net.minecraft.world.level.biome.BiomeGenerationSettings$Builder m_47832_(I)V # addFeatureStepsUpTo +protected net.minecraft.world.level.biome.BiomeGenerationSettings$PlainBuilder f_254648_ # features +protected net.minecraft.world.level.biome.BiomeGenerationSettings$PlainBuilder f_254678_ # carvers +protected net.minecraft.world.level.biome.BiomeGenerationSettings$PlainBuilder m_255276_(I)V # addFeatureStepsUpTo #group protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder * protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48005_ # fogColor protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48006_ # waterColor @@ -381,6 +317,7 @@ public net.minecraft.world.level.block.BigDripleafBlock (Lnet/minecraft/wo public net.minecraft.world.level.block.BigDripleafStemBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.BlastFurnaceBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.BushBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.ButtonBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;IZLnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundEvent;)V # constructor public net.minecraft.world.level.block.CactusBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.CakeBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.CandleCakeBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor @@ -398,7 +335,7 @@ public net.minecraft.world.level.block.CrossCollisionBlock (FFFFFLnet/mine public net.minecraft.world.level.block.DeadBushBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.DirtPathBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.DispenserBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor -public net.minecraft.world.level.block.DoorBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.DoorBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;Lnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundEvent;)V # constructor public net.minecraft.world.level.block.EnchantmentTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.EndGatewayBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.EndPortalBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor @@ -407,7 +344,7 @@ public net.minecraft.world.level.block.EnderChestBlock (Lnet/minecraft/wor public net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.FarmBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.FletchingTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor -public net.minecraft.world.level.block.FungusBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;Ljava/util/function/Supplier;)V # constructor +public net.minecraft.world.level.block.FungusBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/block/Block;)V # constructor public net.minecraft.world.level.block.FurnaceBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.GrindstoneBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.HalfTransparentBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor @@ -430,7 +367,7 @@ public net.minecraft.world.level.block.PipeBlock (FLnet/minecraft/world/le public net.minecraft.world.level.block.PlayerHeadBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.PlayerWallHeadBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.PoweredRailBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor -public net.minecraft.world.level.block.PressurePlateBlock (Lnet/minecraft/world/level/block/PressurePlateBlock$Sensitivity;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.PressurePlateBlock (Lnet/minecraft/world/level/block/PressurePlateBlock$Sensitivity;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;Lnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundEvent;)V # constructor public net.minecraft.world.level.block.PumpkinBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.RailBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.RedstoneTorchBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor @@ -451,21 +388,19 @@ public net.minecraft.world.level.block.SpawnerBlock (Lnet/minecraft/world/ public net.minecraft.world.level.block.SpongeBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.StairBlock (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.StemBlock (Lnet/minecraft/world/level/block/StemGrownBlock;Ljava/util/function/Supplier;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor -public net.minecraft.world.level.block.StoneButtonBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.StructureBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.StructureVoidBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.SugarCaneBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.TallGrassBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.TorchBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;Lnet/minecraft/core/particles/ParticleOptions;)V # constructor -public net.minecraft.world.level.block.TrapDoorBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.TrapDoorBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;Lnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundEvent;)V # constructor public net.minecraft.world.level.block.WallSkullBlock (Lnet/minecraft/world/level/block/SkullBlock$Type;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.WallTorchBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;Lnet/minecraft/core/particles/ParticleOptions;)V # constructor public net.minecraft.world.level.block.WaterlilyBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor -public net.minecraft.world.level.block.WeightedPressurePlateBlock (ILnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.WeightedPressurePlateBlock (ILnet/minecraft/world/level/block/state/BlockBehaviour$Properties;Lnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundEvent;)V # constructor public net.minecraft.world.level.block.WetSpongeBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.WitherSkullBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.WitherWallSkullBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor -public net.minecraft.world.level.block.WoodButtonBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.WoolCarpetBlock (Lnet/minecraft/world/item/DyeColor;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor #endgroup public net.minecraft.world.level.block.Block m_49805_(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;I)V # popExperience @@ -501,16 +436,13 @@ private-f net.minecraft.world.level.levelgen.DebugLevelSource f_64116_ # GRID_HE public-f net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator m_224239_(Lnet/minecraft/world/level/LevelHeightAccessor;Lnet/minecraft/world/level/levelgen/RandomState;IILorg/apache/commons/lang3/mutable/MutableObject;Ljava/util/function/Predicate;)Ljava/util/OptionalInt; # iterateNoiseColumn #group public net.minecraft.world.level.levelgen.NoiseGeneratorSettings *() -public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_198265_(ZZ)Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # overworld -public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_198268_()Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # end -public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_198269_()Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # nether -public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_198270_()Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # caves -public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_198271_()Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # floatingIslands -public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_224385_(Lnet/minecraft/core/Registry;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings;)Lnet/minecraft/core/Holder; # register +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_255038_(Lnet/minecraft/data/worldgen/BootstapContext;)Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # caves +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_255186_(Lnet/minecraft/data/worldgen/BootstapContext;)Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # end +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_255226_(Lnet/minecraft/data/worldgen/BootstapContext;ZZ)Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # overworld +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_255230_(Lnet/minecraft/data/worldgen/BootstapContext;)Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # floatingIslands +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_255410_(Lnet/minecraft/data/worldgen/BootstapContext;)Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # nether public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_64474_(Lcom/mojang/serialization/codecs/RecordCodecBuilder$Instance;)Lcom/mojang/datafixers/kinds/App; # lambda$static$0 #endgroup -public net.minecraft.world.level.levelgen.WorldGenSettings (JZZLnet/minecraft/core/Registry;Ljava/util/Optional;)V # constructor -public net.minecraft.world.level.levelgen.WorldGenSettings f_64606_ # legacyCustomOptions public net.minecraft.world.level.levelgen.feature.featuresize.FeatureSizeType (Lcom/mojang/serialization/Codec;)V # constructor public net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType (Lcom/mojang/serialization/Codec;)V # constructor public net.minecraft.world.level.levelgen.feature.rootplacers.RootPlacerType (Lcom/mojang/serialization/Codec;)V # constructor diff --git a/src/main/resources/forge.exc b/src/main/resources/forge.exc index a580f8a6b4..be53fa5712 100644 --- a/src/main/resources/forge.exc +++ b/src/main/resources/forge.exc @@ -19,32 +19,36 @@ net/minecraft/client/renderer/block/ModelBlockRenderer.tesselateWithAO(Lnet/mine net/minecraft/client/renderer/block/ModelBlockRenderer.tesselateWithoutAO(Lnet/minecraft/world/level/BlockAndTintGetter;Lnet/minecraft/client/resources/model/BakedModel;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;ZLnet/minecraft/util/RandomSource;JILnet/minecraftforge/client/model/data/ModelData;Lnet/minecraft/client/renderer/RenderType;)V=|p_111091_,p_111092_,p_111093_,p_111094_,p_111095_,p_111096_,p_111097_,p_111098_,p_111099_,p_111100_,modelData,renderType net/minecraft/client/renderer/block/model/BakedQuad.([IILnet/minecraft/core/Direction;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;ZZ)V=|p_111298_,p_111299_,p_111300_,p_111301_,p_111302_,hasAmbientOcclusion net/minecraft/client/renderer/block/model/BlockElementFace.(Lnet/minecraft/core/Direction;ILjava/lang/String;Lnet/minecraft/client/renderer/block/model/BlockFaceUV;IZ)V=|p_111359_,p_111360_,p_111361_,p_111362_,emissivity,hasAmbientOcclusion -net/minecraft/client/renderer/block/model/BlockModel.bakeVanilla(Lnet/minecraft/client/resources/model/ModelBakery;Lnet/minecraft/client/renderer/block/model/BlockModel;Ljava/util/function/Function;Lnet/minecraft/client/resources/model/ModelState;Lnet/minecraft/resources/ResourceLocation;ZLnet/minecraftforge/client/RenderTypeGroup;)Lnet/minecraft/client/resources/model/BakedModel;=|p_111450_,p_111451_,p_111452_,p_111453_,p_111454_,p_111455_,renderTypes -net/minecraft/client/renderer/block/model/ItemTransform.(Lcom/mojang/math/Vector3f;Lcom/mojang/math/Vector3f;Lcom/mojang/math/Vector3f;Lcom/mojang/math/Vector3f;)V=|p_111760_,p_111761_,p_111762_,rightRotation +net/minecraft/client/renderer/block/model/BlockModel.bakeVanilla(Lnet/minecraft/client/resources/model/ModelBaker;Lnet/minecraft/client/renderer/block/model/BlockModel;Ljava/util/function/Function;Lnet/minecraft/client/resources/model/ModelState;Lnet/minecraft/resources/ResourceLocation;ZLnet/minecraftforge/client/RenderTypeGroup;)Lnet/minecraft/client/resources/model/BakedModel;=|p_249720_,p_111451_,p_111452_,p_111453_,p_111454_,p_111455_,renderTypes +net/minecraft/client/renderer/block/model/ItemTransform.(Lorg/joml/Vector3f;Lorg/joml/Vector3f;Lorg/joml/Vector3f;Lorg/joml/Vector3f;)V=|p_254427_,p_254496_,p_254022_,rightRotation net/minecraft/client/renderer/block/model/ItemTransforms.(Lnet/minecraft/client/renderer/block/model/ItemTransform;Lnet/minecraft/client/renderer/block/model/ItemTransform;Lnet/minecraft/client/renderer/block/model/ItemTransform;Lnet/minecraft/client/renderer/block/model/ItemTransform;Lnet/minecraft/client/renderer/block/model/ItemTransform;Lnet/minecraft/client/renderer/block/model/ItemTransform;Lnet/minecraft/client/renderer/block/model/ItemTransform;Lnet/minecraft/client/renderer/block/model/ItemTransform;Lcom/google/common/collect/ImmutableMap;)V=|p_111798_,p_111799_,p_111800_,p_111801_,p_111802_,p_111803_,p_111804_,p_111805_,moddedTransforms net/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk$ChunkCompileTask.(Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;Lnet/minecraft/world/level/ChunkPos;DZ)V=|p_194422_,pos,p_194423_,p_194424_ net/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk$RebuildTask.(Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;Lnet/minecraft/world/level/ChunkPos;DLnet/minecraft/client/renderer/chunk/RenderChunkRegion;Z)V=|p_194426_,pos,p_194427_,p_194428_,p_194429_ net/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk$ResortTransparencyTask.(Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;Lnet/minecraft/world/level/ChunkPos;DLnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$CompiledChunk;)V=|p_112888_,pos,p_112889_,p_112890_ net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.(Lnet/minecraft/client/multiplayer/ClientLevel;Lnet/minecraft/client/renderer/LevelRenderer;Ljava/util/concurrent/Executor;ZLnet/minecraft/client/renderer/ChunkBufferBuilderPack;I)V=|p_194405_,p_194406_,p_194407_,p_194408_,p_194409_,countRenderBuilders +net/minecraft/client/renderer/texture/SpriteContents.(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/resources/metadata/animation/FrameSize;Lcom/mojang/blaze3d/platform/NativeImage;Lnet/minecraft/client/resources/metadata/animation/AnimationMetadataSection;Lnet/minecraftforge/client/textures/ForgeTextureMetadata;)V=|p_249787_,p_251031_,p_252131_,p_250432_,forgeMeta net/minecraft/client/resources/model/MultiPartBakedModel.getQuads(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/Direction;Lnet/minecraft/util/RandomSource;Lnet/minecraftforge/client/model/data/ModelData;Lnet/minecraft/client/renderer/RenderType;)Ljava/util/List;=|p_235050_,p_235051_,p_235052_,modelData,renderType net/minecraft/client/resources/model/SimpleBakedModel$Builder.build(Lnet/minecraftforge/client/RenderTypeGroup;)Lnet/minecraft/client/resources/model/BakedModel;=|renderTypes net/minecraft/client/resources/model/SimpleBakedModel.(Ljava/util/List;Ljava/util/Map;ZZZLnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/minecraft/client/renderer/block/model/ItemTransforms;Lnet/minecraft/client/renderer/block/model/ItemOverrides;Lnet/minecraftforge/client/RenderTypeGroup;)V=|p_119489_,p_119490_,p_119491_,p_119492_,p_119493_,p_119494_,p_119495_,p_119496_,renderTypes net/minecraft/client/resources/model/WeightedBakedModel.getQuads(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/Direction;Lnet/minecraft/util/RandomSource;Lnet/minecraftforge/client/model/data/ModelData;Lnet/minecraft/client/renderer/RenderType;)Ljava/util/List;=|p_235058_,p_235059_,p_235060_,modelData,renderType -net/minecraft/data/tags/BannerPatternTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_236411_,modId,existingFileHelper -net/minecraft/data/tags/BiomeTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_211094_,modId,existingFileHelper -net/minecraft/data/tags/BlockTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_126511_,modId,existingFileHelper -net/minecraft/data/tags/CatVariantTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_236420_,modId,existingFileHelper -net/minecraft/data/tags/EntityTypeTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_126517_,modId,existingFileHelper -net/minecraft/data/tags/FlatLevelGeneratorPresetTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_236423_,modId,existingFileHelper -net/minecraft/data/tags/FluidTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_126523_,modId,existingFileHelper -net/minecraft/data/tags/GameEventTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_176826_,modId,existingFileHelper -net/minecraft/data/tags/InstrumentTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_236428_,modId,existingFileHelper -net/minecraft/data/tags/ItemTagsProvider.(Lnet/minecraft/data/DataGenerator;Lnet/minecraft/data/tags/BlockTagsProvider;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_126530_,p_126531_,modId,existingFileHelper -net/minecraft/data/tags/PaintingVariantTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_236431_,modId,existingFileHelper -net/minecraft/data/tags/PoiTypeTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_236434_,modId,existingFileHelper -net/minecraft/data/tags/StructureTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_236437_,modId,existingFileHelper -net/minecraft/data/tags/TagsProvider.(Lnet/minecraft/data/DataGenerator;Lnet/minecraft/core/Registry;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_126546_,p_126547_,modId,existingFileHelper -net/minecraft/data/tags/WorldPresetTagsProvider.(Lnet/minecraft/data/DataGenerator;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_236457_,modId,existingFileHelper +net/minecraft/data/advancements/AdvancementProvider.(Lnet/minecraft/data/PackOutput;Ljava/util/concurrent/CompletableFuture;Ljava/util/List;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_256529_,p_255722_,p_255883_,existingFileHelper +net/minecraft/data/tags/BannerPatternTagsProvider.(Lnet/minecraft/data/PackOutput;Ljava/util/concurrent/CompletableFuture;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_256451_,p_256420_,modId,existingFileHelper +net/minecraft/data/tags/BiomeTagsProvider.(Lnet/minecraft/data/PackOutput;Ljava/util/concurrent/CompletableFuture;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_255800_,p_256205_,modId,existingFileHelper +net/minecraft/data/tags/CatVariantTagsProvider.(Lnet/minecraft/data/PackOutput;Ljava/util/concurrent/CompletableFuture;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_256547_,p_256090_,modId,existingFileHelper +net/minecraft/data/tags/EntityTypeTagsProvider.(Lnet/minecraft/data/PackOutput;Ljava/util/concurrent/CompletableFuture;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_256095_,p_256572_,modId,existingFileHelper +net/minecraft/data/tags/FlatLevelGeneratorPresetTagsProvider.(Lnet/minecraft/data/PackOutput;Ljava/util/concurrent/CompletableFuture;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_256604_,p_255962_,modId,existingFileHelper +net/minecraft/data/tags/FluidTagsProvider.(Lnet/minecraft/data/PackOutput;Ljava/util/concurrent/CompletableFuture;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_255941_,p_256600_,modId,existingFileHelper +net/minecraft/data/tags/GameEventTagsProvider.(Lnet/minecraft/data/PackOutput;Ljava/util/concurrent/CompletableFuture;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_256060_,p_255621_,modId,existingFileHelper +net/minecraft/data/tags/InstrumentTagsProvider.(Lnet/minecraft/data/PackOutput;Ljava/util/concurrent/CompletableFuture;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_256418_,p_256038_,modId,existingFileHelper +net/minecraft/data/tags/IntrinsicHolderTagsProvider$IntrinsicTagAppender.(Lnet/minecraft/tags/TagBuilder;Ljava/util/function/Function;Ljava/lang/String;)V=|p_256108_,p_256433_,modId +net/minecraft/data/tags/IntrinsicHolderTagsProvider.(Lnet/minecraft/data/PackOutput;Lnet/minecraft/resources/ResourceKey;Ljava/util/concurrent/CompletableFuture;Ljava/util/function/Function;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_256164_,p_256155_,p_256488_,p_256168_,modId,existingFileHelper +net/minecraft/data/tags/ItemTagsProvider.(Lnet/minecraft/data/PackOutput;Ljava/util/concurrent/CompletableFuture;Lnet/minecraft/data/tags/TagsProvider;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_255871_,p_256035_,p_256467_,modId,existingFileHelper +net/minecraft/data/tags/PaintingVariantTagsProvider.(Lnet/minecraft/data/PackOutput;Ljava/util/concurrent/CompletableFuture;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_255750_,p_256184_,modId,existingFileHelper +net/minecraft/data/tags/PoiTypeTagsProvider.(Lnet/minecraft/data/PackOutput;Ljava/util/concurrent/CompletableFuture;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_256012_,p_256617_,modId,existingFileHelper +net/minecraft/data/tags/StructureTagsProvider.(Lnet/minecraft/data/PackOutput;Ljava/util/concurrent/CompletableFuture;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_256522_,p_256661_,modId,existingFileHelper +net/minecraft/data/tags/TagsProvider$TagAppender.(Lnet/minecraft/tags/TagBuilder;Ljava/lang/String;)V=|p_236454_,modId +net/minecraft/data/tags/TagsProvider.(Lnet/minecraft/data/PackOutput;Lnet/minecraft/resources/ResourceKey;Ljava/util/concurrent/CompletableFuture;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_256596_,p_255886_,p_256513_,modId,existingFileHelper +net/minecraft/data/tags/WorldPresetTagsProvider.(Lnet/minecraft/data/PackOutput;Ljava/util/concurrent/CompletableFuture;Ljava/lang/String;Lnet/minecraftforge/common/data/ExistingFileHelper;)V=|p_255701_,p_255974_,modId,existingFileHelper net/minecraft/gametest/framework/GameTestRegistry.register(Ljava/lang/reflect/Method;Ljava/util/Set;)V=|p_177504_,allowedNamespaces net/minecraft/network/FriendlyByteBuf.writeItemStack(Lnet/minecraft/world/item/ItemStack;Z)Lnet/minecraft/network/FriendlyByteBuf;=|p_130056_,limitedTag net/minecraft/server/ServerAdvancementManager.(Lnet/minecraft/world/level/storage/loot/PredicateManager;Lnet/minecraftforge/common/crafting/conditions/ICondition$IContext;)V=|p_136027_,context @@ -56,9 +60,8 @@ net/minecraft/server/level/ServerPlayer.changeDimension(Lnet/minecraft/server/le net/minecraft/server/level/ServerPlayerGameMode.removeBlock(Lnet/minecraft/core/BlockPos;Z)Z=|p_180235_1_,canHarvest net/minecraft/server/level/Ticket.(Lnet/minecraft/server/level/TicketType;ILjava/lang/Object;Z)V=|p_9425_,p_9426_,p_9427_,forceTicks net/minecraft/server/packs/metadata/pack/PackMetadataSection.(Lnet/minecraft/network/chat/Component;ILjava/util/Map;)V=|p_10371_,p_10372_,packTypeVersions -net/minecraft/server/packs/repository/Pack.(Ljava/lang/String;ZLjava/util/function/Supplier;Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/Component;Lnet/minecraft/server/packs/repository/PackCompatibility;Lnet/minecraft/server/packs/repository/Pack$Position;ZLnet/minecraft/server/packs/repository/PackSource;Z)V=|p_10420_,p_10421_,p_10422_,p_10423_,p_10424_,p_10425_,p_10426_,p_10427_,p_10428_,hidden net/minecraft/world/entity/Entity.changeDimension(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/world/entity/Entity;=|p_20118_,teleporter -net/minecraft/world/entity/EntityType.(Lnet/minecraft/world/entity/EntityType$EntityFactory;Lnet/minecraft/world/entity/MobCategory;ZZZZLcom/google/common/collect/ImmutableSet;Lnet/minecraft/world/entity/EntityDimensions;IILjava/util/function/Predicate;Ljava/util/function/ToIntFunction;Ljava/util/function/ToIntFunction;Ljava/util/function/BiFunction;)V=|p_20574_,p_20575_,p_20576_,p_20577_,p_20578_,p_20579_,p_20580_,p_20581_,p_20582_,p_20583_,velocityUpdateSupplier,trackingRangeSupplier,updateIntervalSupplier,customClientFactory +net/minecraft/world/entity/EntityType.(Lnet/minecraft/world/entity/EntityType$EntityFactory;Lnet/minecraft/world/entity/MobCategory;ZZZZLcom/google/common/collect/ImmutableSet;Lnet/minecraft/world/entity/EntityDimensions;IILnet/minecraft/world/flag/FeatureFlagSet;Ljava/util/function/Predicate;Ljava/util/function/ToIntFunction;Ljava/util/function/ToIntFunction;Ljava/util/function/BiFunction;)V=|p_251402_,p_251431_,p_251439_,p_251973_,p_252007_,p_250908_,p_250201_,p_251742_,p_250479_,p_249249_,p_250427_,velocityUpdateSupplier,trackingRangeSupplier,updateIntervalSupplier,customClientFactory net/minecraft/world/entity/item/ItemEntity.changeDimension(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/world/entity/Entity;=|p_32042_,teleporter net/minecraft/world/entity/npc/AbstractVillager.changeDimension(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/world/entity/Entity;=|p_35295_,teleporter net/minecraft/world/entity/player/Player.getDigSpeed(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;)F=|p_36282_,pos @@ -76,7 +79,7 @@ net/minecraft/world/item/crafting/RecipeManager.(Lnet/minecraftforge/commo net/minecraft/world/item/crafting/RecipeManager.fromJson(Lnet/minecraft/resources/ResourceLocation;Lcom/google/gson/JsonObject;Lnet/minecraftforge/common/crafting/conditions/ICondition$IContext;)Lnet/minecraft/world/item/crafting/Recipe;=|p_44046_,p_44047_,context net/minecraft/world/item/enchantment/EnchantmentHelper.getTagEnchantmentLevel(Lnet/minecraft/world/item/enchantment/Enchantment;Lnet/minecraft/world/item/ItemStack;)I=|p_44844_,p_44845_ net/minecraft/world/level/Level.markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V=|p_46605_,levelchunk,blockstate,p_46606_,p_46607_,p_46608_ -net/minecraft/world/level/LevelSettings.(Ljava/lang/String;Lnet/minecraft/world/level/GameType;ZLnet/minecraft/world/Difficulty;ZLnet/minecraft/world/level/GameRules;Lnet/minecraft/world/level/DataPackConfig;Lcom/mojang/serialization/Lifecycle;)V=|p_46910_,p_46911_,p_46912_,p_46913_,p_46914_,p_46915_,p_46916_,lifecycle +net/minecraft/world/level/LevelSettings.(Ljava/lang/String;Lnet/minecraft/world/level/GameType;ZLnet/minecraft/world/Difficulty;ZLnet/minecraft/world/level/GameRules;Lnet/minecraft/world/level/WorldDataConfiguration;Lcom/mojang/serialization/Lifecycle;)V=|p_250485_,p_250207_,p_251631_,p_252122_,p_248961_,p_248536_,p_249797_,lifecycle net/minecraft/world/level/block/ConcretePowderBlock.touchesLiquid(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Z=|p_52065_,p_52066_,state net/minecraft/world/level/block/FireBlock.tryCatchFire(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;ILnet/minecraft/util/RandomSource;ILnet/minecraft/core/Direction;)V=|p_53432_,p_53433_,p_53434_,p_53435_,p_53436_,face net/minecraft/world/level/block/FlowerBlock.(Ljava/util/function/Supplier;ILnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V=|effectSupplier,p_53513_,p_53514_ diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index f24cb68574..03abe95b24 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,8 +1,8 @@ { "pack": { - "pack_format": 8, + "pack_format": 12, "description": "Forge resource pack", - "forge:resource_pack_format": 9, + "forge:resource_pack_format": 12, "forge:data_pack_format": 10 } } diff --git a/src/test/java/net/minecraftforge/debug/AddPackFinderEventTest.java b/src/test/java/net/minecraftforge/debug/AddPackFinderEventTest.java index 512b4c3316..90734b8489 100644 --- a/src/test/java/net/minecraftforge/debug/AddPackFinderEventTest.java +++ b/src/test/java/net/minecraftforge/debug/AddPackFinderEventTest.java @@ -7,6 +7,7 @@ package net.minecraftforge.debug; import net.minecraft.network.chat.Component; import net.minecraft.server.packs.PackType; +import net.minecraft.server.packs.PathPackResources; import net.minecraft.server.packs.metadata.pack.PackMetadataSection; import net.minecraft.server.packs.repository.Pack; import net.minecraft.server.packs.repository.PackSource; @@ -14,38 +15,32 @@ import net.minecraftforge.event.AddPackFindersEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.resource.PathPackResources; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import java.io.IOException; @Mod(AddPackFinderEventTest.MODID) -@Mod.EventBusSubscriber(modid=AddPackFinderEventTest.MODID, bus= Mod.EventBusSubscriber.Bus.MOD) public class AddPackFinderEventTest { + private static final boolean ENABLE = false; public static final String MODID = "add_pack_finders_test"; + public AddPackFinderEventTest() { + if (!ENABLE) + return; + + FMLJavaModLoadingContext.get().getModEventBus().register(this); + } + @SubscribeEvent - public static void addPackFinders(AddPackFindersEvent event) + public void addPackFinders(AddPackFindersEvent event) { - try + if (event.getPackType() == PackType.CLIENT_RESOURCES) { - if (event.getPackType() == PackType.CLIENT_RESOURCES) - { - var resourcePath = ModList.get().getModFileById(MODID).getFile().findResource("test_nested_resource_pack"); - var pack = new PathPackResources(ModList.get().getModFileById(MODID).getFile().getFileName() + ":" + resourcePath, resourcePath); - var metadataSection = pack.getMetadataSection(PackMetadataSection.SERIALIZER); - if (metadataSection != null) - { - event.addRepositorySource((packConsumer, packConstructor) -> - packConsumer.accept(packConstructor.create( - "builtin/add_pack_finders_test", Component.literal("display name"), false, - () -> pack, metadataSection, Pack.Position.BOTTOM, PackSource.BUILT_IN, false))); - } - } - } - catch(IOException ex) - { - throw new RuntimeException(ex); + var resourcePath = ModList.get().getModFileById(MODID).getFile().findResource("test_nested_resource_pack"); + var pack = Pack.readMetaAndCreate("builtin/add_pack_finders_test", Component.literal("display name"), false, + (path) -> new PathPackResources(path, resourcePath, false), PackType.CLIENT_RESOURCES, Pack.Position.BOTTOM, PackSource.BUILT_IN); + event.addRepositorySource((packConsumer) -> packConsumer.accept(pack)); } } } diff --git a/src/test/java/net/minecraftforge/debug/CreativeModeTabTest.java b/src/test/java/net/minecraftforge/debug/CreativeModeTabTest.java new file mode 100644 index 0000000000..a0e8f9e706 --- /dev/null +++ b/src/test/java/net/minecraftforge/debug/CreativeModeTabTest.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) Forge Development LLC and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.minecraftforge.debug; + +import java.util.List; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.Blocks; +import net.minecraftforge.event.CreativeModeTabEvent; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; + +@Mod(CreativeModeTabTest.MOD_ID) +public class CreativeModeTabTest +{ + public static final String MOD_ID = "creative_mode_tab_test"; + private static final boolean ENABLED = true; + + private static CreativeModeTab LOGS; + private static CreativeModeTab STONE; + + public CreativeModeTabTest() + { + if (!ENABLED) + return; + + IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + + modEventBus.addListener(CreativeModeTabTest::onCreativeModeTabRegister); + modEventBus.addListener(CreativeModeTabTest::onCreativeModeTabBuildContents); + } + + private static void onCreativeModeTabRegister(CreativeModeTabEvent.Register event) + { + LOGS = event.registerCreativeModeTab(new ResourceLocation(MOD_ID, "logs"), builder -> builder.icon(() -> new ItemStack(Blocks.ACACIA_LOG)) + .title(Component.literal("Logs")) + .withLabelColor(0x00FF00) + .displayItems((features, output, hasPermissions) -> { + output.accept(new ItemStack(Blocks.ACACIA_LOG)); + output.accept(new ItemStack(Blocks.BIRCH_LOG)); + output.accept(new ItemStack(Blocks.DARK_OAK_LOG)); + output.accept(new ItemStack(Blocks.JUNGLE_LOG)); + output.accept(new ItemStack(Blocks.OAK_LOG)); + output.accept(new ItemStack(Blocks.SPRUCE_LOG)); + })); + + STONE = event.registerCreativeModeTab(new ResourceLocation(MOD_ID, "stone"), List.of(CreativeModeTabs.BUILDING_BLOCKS), List.of(), builder -> builder.icon(() -> new ItemStack(Blocks.STONE)) + .title(Component.literal("Stone")) + .withLabelColor(0x0000FF) + .displayItems((features, output, hasPermissions) -> { + output.accept(new ItemStack(Blocks.STONE)); + output.accept(new ItemStack(Blocks.GRANITE)); + output.accept(new ItemStack(Blocks.DIORITE)); + output.accept(new ItemStack(Blocks.ANDESITE)); + })); + } + + private static void onCreativeModeTabBuildContents(CreativeModeTabEvent.BuildContents event) + { + if (event.getTab() == LOGS) + { + event.register((flags, builder, hasPermissions) -> { + builder.accept(new ItemStack(Blocks.STRIPPED_ACACIA_LOG), ItemStack.EMPTY, new ItemStack(Blocks.ACACIA_LOG)); + builder.accept(new ItemStack(Blocks.STRIPPED_BIRCH_LOG), ItemStack.EMPTY, new ItemStack(Blocks.BIRCH_LOG)); + builder.accept(new ItemStack(Blocks.STRIPPED_DARK_OAK_LOG), ItemStack.EMPTY, new ItemStack(Blocks.DARK_OAK_LOG)); + builder.accept(new ItemStack(Blocks.STRIPPED_JUNGLE_LOG), ItemStack.EMPTY, new ItemStack(Blocks.JUNGLE_LOG)); + builder.accept(new ItemStack(Blocks.STRIPPED_OAK_LOG), ItemStack.EMPTY, new ItemStack(Blocks.OAK_LOG)); + builder.accept(new ItemStack(Blocks.STRIPPED_SPRUCE_LOG), ItemStack.EMPTY, new ItemStack(Blocks.SPRUCE_LOG)); + }); + } + + if (event.getTab() == STONE) + { + event.register((flags, builder, hasPermissions) -> { + builder.accept(new ItemStack(Blocks.SMOOTH_STONE), new ItemStack(Blocks.GRANITE), new ItemStack(Blocks.STONE)); + builder.accept(new ItemStack(Blocks.POLISHED_GRANITE), new ItemStack(Blocks.DIORITE), new ItemStack(Blocks.GRANITE)); + builder.accept(new ItemStack(Blocks.POLISHED_DIORITE), new ItemStack(Blocks.ANDESITE), new ItemStack(Blocks.DIORITE)); + builder.accept(new ItemStack(Blocks.POLISHED_ANDESITE), ItemStack.EMPTY, new ItemStack(Blocks.ANDESITE)); + }); + } + } +} diff --git a/src/test/java/net/minecraftforge/debug/CustomSoundTypeTest.java b/src/test/java/net/minecraftforge/debug/CustomSoundTypeTest.java index dfd7a40480..b88db23f7f 100644 --- a/src/test/java/net/minecraftforge/debug/CustomSoundTypeTest.java +++ b/src/test/java/net/minecraftforge/debug/CustomSoundTypeTest.java @@ -5,16 +5,17 @@ package net.minecraftforge.debug; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.material.Material; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; import net.minecraftforge.common.util.ForgeSoundType; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; @@ -22,6 +23,9 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import java.util.Optional; +import java.util.function.Consumer; + @Mod(CustomSoundTypeTest.MODID) public class CustomSoundTypeTest { @@ -32,14 +36,14 @@ public class CustomSoundTypeTest private static final DeferredRegister SOUND_EVENTS = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, MODID); private static final RegistryObject TEST_STEP_EVENT = SOUND_EVENTS.register("test_step", - () -> new SoundEvent(new ResourceLocation(MODID, "block.sound_type_test.step"))); + () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(MODID, "block.sound_type_test.step"))); private static final SoundType TEST_SOUND_TYPE = new ForgeSoundType(1.0F, 1.0F, TEST_STEP_EVENT, TEST_STEP_EVENT, TEST_STEP_EVENT, TEST_STEP_EVENT, TEST_STEP_EVENT); private static final RegistryObject TEST_STEP_BLOCK = BLOCKS.register("test_block", () -> new Block(BlockBehaviour.Properties.of(Material.WOOD).sound(TEST_SOUND_TYPE))); private static final RegistryObject TEST_STEP_BLOCK_ITEM = ITEMS.register("test_block", - () -> new BlockItem(TEST_STEP_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC))); + () -> new BlockItem(TEST_STEP_BLOCK.get(), new Item.Properties())); public CustomSoundTypeTest() { @@ -47,5 +51,7 @@ public class CustomSoundTypeTest BLOCKS.register(modEventBus); ITEMS.register(modEventBus); SOUND_EVENTS.register(modEventBus); + + modEventBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.INGREDIENTS, TEST_STEP_BLOCK_ITEM.get())); } } diff --git a/src/test/java/net/minecraftforge/debug/DataGeneratorTest.java b/src/test/java/net/minecraftforge/debug/DataGeneratorTest.java index 1c849e70db..8c72f4cc3c 100644 --- a/src/test/java/net/minecraftforge/debug/DataGeneratorTest.java +++ b/src/test/java/net/minecraftforge/debug/DataGeneratorTest.java @@ -20,6 +20,7 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; +import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -29,9 +30,12 @@ import com.google.gson.JsonNull; import com.google.gson.JsonPrimitive; import net.minecraft.Util; import net.minecraft.advancements.critereon.InventoryChangeTrigger; +import net.minecraft.core.HolderLookup; import net.minecraft.data.CachedOutput; +import net.minecraft.data.PackOutput; import net.minecraft.data.advancements.AdvancementProvider; -import net.minecraft.data.recipes.ShapelessRecipeBuilder; +import net.minecraft.data.advancements.AdvancementSubProvider; +import net.minecraft.data.recipes.*; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.sounds.SoundEvents; @@ -48,8 +52,7 @@ import net.minecraftforge.common.crafting.PartialNBTIngredient; import net.minecraftforge.common.crafting.DifferenceIngredient; import net.minecraftforge.common.crafting.IntersectionIngredient; import net.minecraftforge.common.crafting.StrictNBTIngredient; -import net.minecraftforge.common.data.SoundDefinition; -import net.minecraftforge.common.data.SoundDefinitionsProvider; +import net.minecraftforge.common.data.*; import net.minecraftforge.registries.ForgeRegistries; import org.apache.commons.lang3.tuple.Triple; import org.apache.logging.log4j.LogManager; @@ -74,11 +77,7 @@ import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.block.model.ItemTransform; import net.minecraft.client.renderer.block.model.Variant; import net.minecraft.client.renderer.block.model.BlockModel.GuiLight; -import net.minecraft.data.tags.BlockTagsProvider; import net.minecraft.data.DataGenerator; -import net.minecraft.data.recipes.FinishedRecipe; -import net.minecraft.data.recipes.RecipeProvider; -import net.minecraft.data.recipes.ShapedRecipeBuilder; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.Items; @@ -99,8 +98,6 @@ import net.minecraftforge.client.model.generators.VariantBlockStateBuilder; import net.minecraftforge.common.crafting.ConditionalAdvancement; import net.minecraftforge.common.crafting.ConditionalRecipe; import net.minecraftforge.common.crafting.conditions.IConditionBuilder; -import net.minecraftforge.common.data.ExistingFileHelper; -import net.minecraftforge.common.data.LanguageProvider; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; @@ -136,6 +133,8 @@ public class DataGeneratorTest .create(); DataGenerator gen = event.getGenerator(); + PackOutput packOutput = gen.getPackOutput(); + CompletableFuture lookupProvider = event.getLookupProvider(); gen.addProvider(event.includeClient(), new Lang(gen)); // Let blockstate provider see generated item models by passing its existing file helper @@ -144,20 +143,20 @@ public class DataGeneratorTest gen.addProvider(event.includeClient(), new BlockStates(gen, itemModels.existingFileHelper)); gen.addProvider(event.includeClient(), new SoundDefinitions(gen, event.getExistingFileHelper())); - gen.addProvider(event.includeServer(), new Recipes(gen)); - gen.addProvider(event.includeServer(), new Tags(gen, event.getExistingFileHelper())); - gen.addProvider(event.includeServer(), new Advancements(gen, event.getExistingFileHelper())); + gen.addProvider(event.includeServer(), new Recipes(packOutput)); + gen.addProvider(event.includeServer(), new Tags(packOutput, lookupProvider, event.getExistingFileHelper())); + gen.addProvider(event.includeServer(), new Advancements(packOutput, lookupProvider, event.getExistingFileHelper())); } public static class Recipes extends RecipeProvider implements IConditionBuilder { - public Recipes(DataGenerator gen) + public Recipes(PackOutput gen) { super(gen); } @Override - protected void buildCraftingRecipes(Consumer consumer) + protected void buildRecipes(Consumer consumer) { // conditional recipe ResourceLocation ID = new ResourceLocation("data_gen_test", "conditional"); @@ -171,7 +170,7 @@ public class DataGeneratorTest ) ) .addRecipe( - ShapedRecipeBuilder.shaped(Blocks.DIAMOND_BLOCK, 64) + ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, Blocks.DIAMOND_BLOCK, 64) .pattern("XXX") .pattern("XXX") .pattern("XXX") @@ -214,7 +213,7 @@ public class DataGeneratorTest ) ) .addRecipe( - ShapedRecipeBuilder.shaped(Blocks.DIAMOND_BLOCK, 64) + ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, Blocks.DIAMOND_BLOCK, 64) .pattern("XXX") .pattern("XXX") .pattern("XXX") @@ -231,7 +230,7 @@ public class DataGeneratorTest tagEmpty(ItemTags.PLANKS) ) .addRecipe( - ShapedRecipeBuilder.shaped(Blocks.NETHERITE_BLOCK, 1) + ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, Blocks.NETHERITE_BLOCK, 1) .pattern("XX") .pattern("XX") .define('X', Blocks.DIAMOND_BLOCK) @@ -245,7 +244,7 @@ public class DataGeneratorTest ) ) .addRecipe( - ShapedRecipeBuilder.shaped(Blocks.NETHERITE_BLOCK, 9) + ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, Blocks.NETHERITE_BLOCK, 9) .pattern("XX") .pattern("XX") .define('X', Blocks.DIAMOND_BLOCK) @@ -264,14 +263,14 @@ public class DataGeneratorTest stack.setDamageValue(3); return stack; })); - ShapelessRecipeBuilder.shapeless(Items.GOLDEN_PICKAXE) + ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS, Items.GOLDEN_PICKAXE) .requires(nbtIngredient) .unlockedBy("has_pickaxe", has(Items.IRON_PICKAXE)) .save(consumer, new ResourceLocation("data_gen_test", "exact_nbt_ingredient")); // ingredient tests // contains NBT match - should match a stone pickaxe that lost 3 durability, regardless of setting its name - ShapelessRecipeBuilder.shapeless(Items.IRON_PICKAXE) + ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS, Items.IRON_PICKAXE) .requires(PartialNBTIngredient.of(Items.STONE_PICKAXE, Util.make(() -> { CompoundTag nbt = new CompoundTag(); @@ -282,7 +281,7 @@ public class DataGeneratorTest .save(consumer, new ResourceLocation("data_gen_test", "contains_nbt_ingredient_single_item")); // contains NBT match - should match a wood, stone, or iron pickaxe that was named "Diamond Pickaxe", regardless of damage - ShapelessRecipeBuilder.shapeless(Items.DIAMOND_PICKAXE) + ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS, Items.DIAMOND_PICKAXE) .requires(PartialNBTIngredient.of(Util.make(() -> { CompoundTag nbt = new CompoundTag(); @@ -295,7 +294,7 @@ public class DataGeneratorTest .save(consumer, new ResourceLocation("data_gen_test", "contains_nbt_ingredient_item_set")); // intersection - should match all non-flammable planks - ShapedRecipeBuilder.shaped(Blocks.NETHERRACK) + ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, Blocks.NETHERRACK) .pattern("###") .pattern("###") .pattern(" # ") @@ -304,7 +303,7 @@ public class DataGeneratorTest .save(consumer, new ResourceLocation("data_gen_test", "intersection_ingredient")); // difference - should match all flammable fences - ShapedRecipeBuilder.shaped(Items.FLINT_AND_STEEL) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, Items.FLINT_AND_STEEL) .pattern(" # ") .pattern("###") .pattern(" # ") @@ -313,7 +312,7 @@ public class DataGeneratorTest .save(consumer, new ResourceLocation("data_gen_test", "difference_ingredient")); // compound - should match planks, logs, or bedrock - ShapedRecipeBuilder.shaped(Blocks.DIRT) + ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, Blocks.DIRT) .pattern("###") .pattern(" # ") .define('#', CompoundIngredient.of(Ingredient.of(ItemTags.PLANKS), Ingredient.of(ItemTags.LOGS), Ingredient.of(Blocks.BEDROCK))) @@ -321,7 +320,7 @@ public class DataGeneratorTest .save(consumer, new ResourceLocation("data_gen_test", "compound_ingredient_only_vanilla")); // compound - should match planks, logs, or a stone pickaxe with 3 damage - ShapedRecipeBuilder.shaped(Blocks.GOLD_BLOCK) + ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, Blocks.GOLD_BLOCK) .pattern("#") .pattern("#") .define('#', CompoundIngredient.of(Ingredient.of(ItemTags.PLANKS), Ingredient.of(ItemTags.LOGS), nbtIngredient)) @@ -405,13 +404,13 @@ public class DataGeneratorTest } @Override - public void run(CachedOutput cache) throws IOException + public CompletableFuture run(CachedOutput cache) { super.run(cache); - test(); + return CompletableFuture.runAsync(this::test); } - private void test() throws IOException + private void test() { final JsonObject generated; try @@ -422,10 +421,15 @@ public class DataGeneratorTest { throw new RuntimeException("Unable to test for errors due to reflection error", e); } - final JsonObject actual = GSON.fromJson( - this.helper.getResource(new ResourceLocation("sounds.json"), PackType.CLIENT_RESOURCES).openAsReader(), - JsonObject.class - ); + final JsonObject actual; + try { + actual = GSON.fromJson( + this.helper.getResource(new ResourceLocation("sounds.json"), PackType.CLIENT_RESOURCES).openAsReader(), + JsonObject.class + ); + } catch (IOException e) { + throw new RuntimeException("Unable to test for errors due to missing sounds.json", e); + } final JsonObject filtered = new JsonObject(); generated.entrySet().forEach(it -> filtered.add(it.getKey(), Optional.ofNullable(actual.get(it.getKey())).orElseGet(JsonNull::new))); @@ -553,13 +557,13 @@ public class DataGeneratorTest public static class Tags extends BlockTagsProvider { - public Tags(DataGenerator gen, ExistingFileHelper existingFileHelper) + public Tags(PackOutput output, CompletableFuture lookupProvider, @Nullable ExistingFileHelper existingFileHelper) { - super(gen, MODID, existingFileHelper); + super(output, lookupProvider, MODID, existingFileHelper); } @Override - protected void addTags() + protected void addTags(HolderLookup.Provider provider) { tag(BlockTags.create(new ResourceLocation(MODID, "test"))) .add(Blocks.DIAMOND_BLOCK) @@ -651,7 +655,7 @@ public class DataGeneratorTest ); @Override - public void run(CachedOutput cache) throws IOException + public CompletableFuture run(CachedOutput cache) { super.run(cache); List errors = testModelResults(this.generatedModels, existingFileHelper, IGNORED_MODELS.stream().map(s -> new ResourceLocation(MODID, folder + "/" + s)).collect(Collectors.toSet())); @@ -662,6 +666,8 @@ public class DataGeneratorTest } throw new AssertionError("Generated item models differed from vanilla equivalents, check above errors."); } + + return CompletableFuture.allOf(); } @Override @@ -831,7 +837,7 @@ public class DataGeneratorTest private List errors = new ArrayList<>(); @Override - public void run(CachedOutput cache) throws IOException + public CompletableFuture run(CachedOutput cache) { super.run(cache); this.errors.addAll(testModelResults(models().generatedModels, models().existingFileHelper, Sets.union(IGNORED_MODELS, CUSTOM_MODELS))); @@ -860,6 +866,8 @@ public class DataGeneratorTest } throw new AssertionError("Generated blockstates/models differed from vanilla equivalents, check above errors."); } + + return CompletableFuture.allOf(); } private void compareVariantBlockstates(Block block, JsonObject generated, JsonObject vanilla) { @@ -1011,49 +1019,57 @@ public class DataGeneratorTest public static class Advancements extends AdvancementProvider { - public Advancements(DataGenerator generatorIn, ExistingFileHelper fileHelper) + + public Advancements(PackOutput output, CompletableFuture providerCompletableFuture, ExistingFileHelper existingFileHelper) { - super(generatorIn, fileHelper); + super(output, providerCompletableFuture, List.of(new Provider(existingFileHelper))); } - @Override - protected void registerAdvancements(Consumer consumer, ExistingFileHelper fileHelper) - { - Advancement.Builder.advancement().display(Items.DIRT, - Component.translatable(Items.DIRT.getDescriptionId()), - Component.translatable("dirt_description"), - new ResourceLocation("textures/gui/advancements/backgrounds/stone.png"), - FrameType.TASK, - true, - true, - false) - .addCriterion("has_dirt", InventoryChangeTrigger.TriggerInstance.hasItems(Items.DIRT)) - .save(consumer, new ResourceLocation(MODID, "obtain_dirt"), fileHelper); + private static class Provider implements AdvancementSubProvider { - Advancement.Builder.advancement().display(Items.DIAMOND_BLOCK, - Component.translatable(Items.DIAMOND_BLOCK.getDescriptionId()), - Component.literal("You obtained a DiamondBlock"), - new ResourceLocation("textures/gui/advancements/backgrounds/stone.png"), - FrameType.CHALLENGE, - true, - true, - false) - .addCriterion("obtained_diamond_block", InventoryChangeTrigger.TriggerInstance.hasItems(Items.DIAMOND_BLOCK)) - .save(consumer, new ResourceLocation("obtain_diamond_block"), fileHelper); + private final ExistingFileHelper fileHelper; - Advancement.Builder.advancement() - .display(Blocks.GRASS_BLOCK, - Component.translatable("advancements.story.root.title"), - Component.literal("Changed Description"), - new ResourceLocation("textures/gui/advancements/backgrounds/stone.png"), - FrameType.TASK, - false, - false, - false) - .addCriterion("crafting_table", InventoryChangeTrigger.TriggerInstance.hasItems(Blocks.CRAFTING_TABLE)) - .save(consumer, new ResourceLocation("story/root"), fileHelper); + private Provider(ExistingFileHelper fileHelper) { + this.fileHelper = fileHelper; + } - // This should cause an error because of the parent not existing + @Override + public void generate(HolderLookup.Provider registries, Consumer consumer) { + Advancement.Builder.advancement().display(Items.DIRT, + Component.translatable(Items.DIRT.getDescriptionId()), + Component.translatable("dirt_description"), + new ResourceLocation("textures/gui/advancements/backgrounds/stone.png"), + FrameType.TASK, + true, + true, + false) + .addCriterion("has_dirt", InventoryChangeTrigger.TriggerInstance.hasItems(Items.DIRT)) + .save(consumer, new ResourceLocation(MODID, "obtain_dirt"), fileHelper); + + Advancement.Builder.advancement().display(Items.DIAMOND_BLOCK, + Component.translatable(Items.DIAMOND_BLOCK.getDescriptionId()), + Component.literal("You obtained a DiamondBlock"), + new ResourceLocation("textures/gui/advancements/backgrounds/stone.png"), + FrameType.CHALLENGE, + true, + true, + false) + .addCriterion("obtained_diamond_block", InventoryChangeTrigger.TriggerInstance.hasItems(Items.DIAMOND_BLOCK)) + .save(consumer, new ResourceLocation("obtain_diamond_block"), fileHelper); + + Advancement.Builder.advancement() + .display(Blocks.GRASS_BLOCK, + Component.translatable("advancements.story.root.title"), + Component.literal("Changed Description"), + new ResourceLocation("textures/gui/advancements/backgrounds/stone.png"), + FrameType.TASK, + false, + false, + false) + .addCriterion("crafting_table", InventoryChangeTrigger.TriggerInstance.hasItems(Blocks.CRAFTING_TABLE)) + .save(consumer, new ResourceLocation("story/root"), fileHelper); + + // This should cause an error because of the parent not existing /* Advancement.Builder.advancement().display(Blocks.COBBLESTONE, new TranslationTextComponent(Items.COBBLESTONE.getDescriptionId()), new StringTextComponent("You got cobblestone"), @@ -1066,17 +1082,18 @@ public class DataGeneratorTest .parent(new ResourceLocation("not_there/not_here")) .save(consumer, new ResourceLocation("illegal_parent"), fileHelper);*/ - Advancement.Builder.advancement().display(Blocks.COBBLESTONE, - Component.translatable(Items.COBBLESTONE.getDescriptionId()), - Component.literal("You got cobblestone"), - new ResourceLocation("textures/gui/advancements/backgrounds/stone.png"), - FrameType.TASK, - false, - false, - false) - .addCriterion("get_cobbleStone", InventoryChangeTrigger.TriggerInstance.hasItems(Items.COBBLESTONE)) - .parent(new ResourceLocation("forge", "dummy_parent")) - .save(consumer, new ResourceLocation("good_parent"), fileHelper); + Advancement.Builder.advancement().display(Blocks.COBBLESTONE, + Component.translatable(Items.COBBLESTONE.getDescriptionId()), + Component.literal("You got cobblestone"), + new ResourceLocation("textures/gui/advancements/backgrounds/stone.png"), + FrameType.TASK, + false, + false, + false) + .addCriterion("get_cobbleStone", InventoryChangeTrigger.TriggerInstance.hasItems(Items.COBBLESTONE)) + .parent(new ResourceLocation("forge", "dummy_parent")) + .save(consumer, new ResourceLocation("good_parent"), fileHelper); + } } } diff --git a/src/test/java/net/minecraftforge/debug/DeferredRegistryTest.java b/src/test/java/net/minecraftforge/debug/DeferredRegistryTest.java index 8a59d3b586..d8cfb8f452 100644 --- a/src/test/java/net/minecraftforge/debug/DeferredRegistryTest.java +++ b/src/test/java/net/minecraftforge/debug/DeferredRegistryTest.java @@ -5,19 +5,16 @@ package net.minecraftforge.debug; -import java.util.List; import java.util.Set; +import java.util.function.Consumer; import java.util.function.Supplier; -import net.minecraft.core.Holder; -import net.minecraft.core.Registry; -import net.minecraft.data.worldgen.features.OreFeatures; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.crafting.RecipeType; -import net.minecraft.world.level.levelgen.placement.PlacedFeature; -import net.minecraft.world.level.levelgen.structure.templatesystem.PosRuleTestType; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.event.server.ServerStartedEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -27,7 +24,6 @@ import net.minecraft.world.level.material.Material; import net.minecraft.data.DataGenerator; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; -import net.minecraft.world.item.CreativeModeTab; import net.minecraftforge.client.model.generators.BlockStateProvider; import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.eventbus.api.IEventBus; @@ -52,18 +48,18 @@ public class DeferredRegistryTest { private static final DeferredRegister DOESNT_EXIST_REG = DeferredRegister.createOptional(new ResourceLocation(MODID, "doesnt_exist"), MODID); private static final DeferredRegister> RECIPE_TYPES = DeferredRegister.create(ForgeRegistries.RECIPE_TYPES, MODID); // Vanilla Registry - filled directly after all RegistryEvent.Register events are fired - private static final DeferredRegister> POS_RULE_TEST_TYPES = DeferredRegister.create(Registry.POS_RULE_TEST_REGISTRY, MODID); + //private static final DeferredRegister> POS_RULE_TEST_TYPES = DeferredRegister.create(Registry.POS_RULE_TEST_REGISTRY, MODID); // Vanilla Builtin Registry - filled directly after all RegistryEvent.Register events are fired - private static final DeferredRegister PLACED_FEATURES = DeferredRegister.create(Registry.PLACED_FEATURE_REGISTRY, MODID); + //private static final DeferredRegister PLACED_FEATURES = DeferredRegister.create(Registry.PLACED_FEATURE_REGISTRY, MODID); private static final RegistryObject BLOCK = BLOCKS.register("test", () -> new Block(Block.Properties.of(Material.STONE))); - private static final RegistryObject ITEM = ITEMS .register("test", () -> new BlockItem(BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_BUILDING_BLOCKS))); + private static final RegistryObject ITEM = ITEMS .register("test", () -> new BlockItem(BLOCK.get(), new Item.Properties())); private static final RegistryObject CUSTOM = CUSTOMS.register("test", () -> new Custom(){}); // Should never be created as the registry doesn't exist - this should silently fail and remain empty private static final RegistryObject DOESNT_EXIST = DOESNT_EXIST_REG.register("test", Object::new); private static final RegistryObject> RECIPE_TYPE = RECIPE_TYPES.register("test", () -> new RecipeType<>() {}); - private static final RegistryObject> POS_RULE_TEST_TYPE = POS_RULE_TEST_TYPES.register("test", () -> () -> null); - private static final RegistryObject PLACED_FEATURE = PLACED_FEATURES.register("test", () -> new PlacedFeature(Holder.hackyErase(OreFeatures.ORE_DIORITE), List.of())); + //private static final RegistryObject> POS_RULE_TEST_TYPE = POS_RULE_TEST_TYPES.register("test", () -> () -> null); + //private static final RegistryObject PLACED_FEATURE = PLACED_FEATURES.register("test", () -> new PlacedFeature(Holder.hackyErase(OreFeatures.ORE_DIORITE), List.of())); private static final TagKey CUSTOM_TAG_KEY = CUSTOMS.createOptionalTagKey("test_tag", Set.of(CUSTOM)); private static final Supplier> CUSTOM_REG = CUSTOMS.makeRegistry(() -> @@ -77,11 +73,13 @@ public class DeferredRegistryTest { ITEMS.register(modBus); CUSTOMS.register(modBus); RECIPE_TYPES.register(modBus); - POS_RULE_TEST_TYPES.register(modBus); - PLACED_FEATURES.register(modBus); + //POS_RULE_TEST_TYPES.register(modBus); + //PLACED_FEATURES.register(modBus); modBus.addListener(this::gatherData); MinecraftForge.EVENT_BUS.addListener(this::serverStarted); + + modBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.INGREDIENTS, ITEM.get())); } public void serverStarted(ServerStartedEvent event) @@ -93,8 +91,8 @@ public class DeferredRegistryTest { if (DOESNT_EXIST.isPresent()) throw new IllegalStateException("DeferredRegistryTest#DOESNT_EXIST should not be present!"); RECIPE_TYPE.get(); - POS_RULE_TEST_TYPE.get(); - PLACED_FEATURE.get(); + //POS_RULE_TEST_TYPE.get(); + //PLACED_FEATURE.get(); } public void gatherData(GatherDataEvent event) { diff --git a/src/test/java/net/minecraftforge/debug/ManyMobEffectsTest.java b/src/test/java/net/minecraftforge/debug/ManyMobEffectsTest.java index 42988a7979..98c6126757 100644 --- a/src/test/java/net/minecraftforge/debug/ManyMobEffectsTest.java +++ b/src/test/java/net/minecraftforge/debug/ManyMobEffectsTest.java @@ -7,6 +7,7 @@ package net.minecraftforge.debug; import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectCategory; import net.minecraft.world.effect.MobEffectInstance; @@ -18,7 +19,9 @@ import net.minecraft.world.item.Items; import net.minecraft.world.item.SuspiciousStewItem; import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -30,6 +33,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.util.List; +import java.util.function.Consumer; /** * Registers 255 mob effects that log every tick on the client. @@ -51,28 +55,6 @@ public class ManyMobEffectsTest private static final Logger LOGGER = LogManager.getLogger(); - private static final CreativeModeTab CREATIVE_TAB = new CreativeModeTab(MODID) - { - @Override - public ItemStack makeIcon() - { - return new ItemStack(Items.POTION); - } - - @Override - public void fillItemList(NonNullList stacks) - { - super.fillItemList(stacks); - var stack = new ItemStack(Items.POTION); - PotionUtils.setCustomEffects(stack, List.of(new MobEffectInstance(LAST_EFFECT.get(), 1000))); - stacks.add(stack); - - stack = new ItemStack(Items.SUSPICIOUS_STEW); - SuspiciousStewItem.saveMobEffect(stack, LAST_EFFECT.get(), 1000); - stacks.add(stack); - } - }; - private static final DeferredRegister MOB_EFFECTS = DeferredRegister.create(ForgeRegistries.MOB_EFFECTS, MODID); private static final RegistryObject LAST_EFFECT; @@ -109,6 +91,17 @@ public class ManyMobEffectsTest IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus(); MOB_EFFECTS.register(modBus); MinecraftForge.EVENT_BUS.addListener(ManyMobEffectsTest::mobInteract); + modBus.addListener((CreativeModeTabEvent.Register event) -> event.registerCreativeModeTab(new ResourceLocation(MODID, "many_mob_effects_test"), builder -> builder.withSearchBar() + .icon(() -> new ItemStack(Items.POTION)) + .displayItems((flags, output, isOperator) -> { + var stack = new ItemStack(Items.POTION); + PotionUtils.setCustomEffects(stack, List.of(new MobEffectInstance(LAST_EFFECT.get(), 1000))); + output.accept(stack); + + stack = new ItemStack(Items.SUSPICIOUS_STEW); + SuspiciousStewItem.saveMobEffect(stack, LAST_EFFECT.get(), 1000); + output.accept(stack); + }))); } private static void mobInteract(PlayerInteractEvent.EntityInteract event) diff --git a/src/test/java/net/minecraftforge/debug/RemoveTagDatagenTest.java b/src/test/java/net/minecraftforge/debug/RemoveTagDatagenTest.java index 02a58b0eea..908a4860bd 100644 --- a/src/test/java/net/minecraftforge/debug/RemoveTagDatagenTest.java +++ b/src/test/java/net/minecraftforge/debug/RemoveTagDatagenTest.java @@ -5,13 +5,14 @@ package net.minecraftforge.debug; +import net.minecraft.core.HolderLookup; import net.minecraft.data.DataGenerator; -import net.minecraft.data.tags.BlockTagsProvider; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; import net.minecraft.tags.TagKey; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; +import net.minecraftforge.common.data.BlockTagsProvider; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; @@ -36,17 +37,17 @@ public class RemoveTagDatagenTest DataGenerator generator = event.getGenerator(); ExistingFileHelper helper = event.getExistingFileHelper(); - generator.addProvider(true, new BlockTagsProvider(generator, MODID, helper) + generator.addProvider(true, new BlockTagsProvider(generator.getPackOutput(), event.getLookupProvider(), MODID, helper) { @SuppressWarnings("unchecked") @Override - protected void addTags() + protected void addTags(HolderLookup.Provider provider) { this.tag(TEST_TAG) .remove(ForgeRegistries.BLOCKS.getKey(Blocks.DIRT)) .remove(ForgeRegistries.BLOCKS.getKey(Blocks.OAK_DOOR), ForgeRegistries.BLOCKS.getKey(Blocks.DARK_OAK_DOOR)) - .remove(Blocks.ANVIL) - .remove(Blocks.BASALT, Blocks.POLISHED_BASALT) + .remove(ForgeRegistries.BLOCKS.getKey(Blocks.ANVIL)) + .remove(ForgeRegistries.BLOCKS.getKey(Blocks.BASALT), ForgeRegistries.BLOCKS.getKey(Blocks.POLISHED_ANDESITE)) .remove(BlockTags.BEEHIVES) .remove(BlockTags.BANNERS, BlockTags.BEDS); } diff --git a/src/test/java/net/minecraftforge/debug/block/BlockEntityOnLoadTest.java b/src/test/java/net/minecraftforge/debug/block/BlockEntityOnLoadTest.java index 01d83bf061..0a737e39cf 100644 --- a/src/test/java/net/minecraftforge/debug/block/BlockEntityOnLoadTest.java +++ b/src/test/java/net/minecraftforge/debug/block/BlockEntityOnLoadTest.java @@ -19,6 +19,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.phys.BlockHitResult; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -29,6 +30,7 @@ import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import java.util.Locale; +import java.util.function.Consumer; @Mod("be_onload_test") public class BlockEntityOnLoadTest @@ -41,7 +43,7 @@ public class BlockEntityOnLoadTest private static final DeferredRegister> BE_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, "be_onload_test"); private static final RegistryObject TEST_BLOCK = BLOCKS.register("be_onload_testblock", () -> new TestBlock(Properties.of(Material.DECORATION, MaterialColor.SAND))); - private static final RegistryObject TEST_BLOCK_ITEM = ITEMS.register("be_onload_testblock", () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS))); + private static final RegistryObject TEST_BLOCK_ITEM = ITEMS.register("be_onload_testblock", () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties())); private static final RegistryObject> TEST_BE_TYPE = BE_TYPES.register("be_onload_testbe", () -> BlockEntityType.Builder.of(TestBlockEntity::new, TEST_BLOCK.get()).build(null)); public BlockEntityOnLoadTest() @@ -52,6 +54,8 @@ public class BlockEntityOnLoadTest BLOCKS.register(modBus); ITEMS.register(modBus); BE_TYPES.register(modBus); + + modBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS, TEST_BLOCK_ITEM.get())); } } diff --git a/src/test/java/net/minecraftforge/debug/block/CustomHeadTest.java b/src/test/java/net/minecraftforge/debug/block/CustomHeadTest.java index 96f0ab8b90..1ddc00cf63 100644 --- a/src/test/java/net/minecraftforge/debug/block/CustomHeadTest.java +++ b/src/test/java/net/minecraftforge/debug/block/CustomHeadTest.java @@ -7,15 +7,11 @@ package net.minecraftforge.debug.block; import net.minecraft.client.model.SkullModel; import net.minecraft.client.model.geom.ModelLayerLocation; -import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; -import net.minecraft.client.renderer.blockentity.SignRenderer; import net.minecraft.client.renderer.blockentity.SkullBlockRenderer; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Rarity; -import net.minecraft.world.item.StandingAndWallBlockItem; +import net.minecraft.world.item.*; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SkullBlock; import net.minecraft.world.level.block.WallSkullBlock; @@ -26,12 +22,9 @@ import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.event.EntityRenderersEvent; -import net.minecraftforge.common.ForgeConfig.Client; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.Lazy; -import net.minecraftforge.debug.block.CustomSignsTest.CustomSignBlockEntity; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -42,6 +35,8 @@ import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; +import java.util.function.Consumer; + /** * Adds a blaze head block and item to test the event for registering a custom skull model and to demonstrate the proper way to register a custom mob skull. * @@ -57,7 +52,7 @@ public class CustomHeadTest private static final DeferredRegister> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, MODID); private static final RegistryObject BLAZE_HEAD = BLOCKS.register("blaze_head", () -> new CustomSkullBlock(SkullType.BLAZE, BlockBehaviour.Properties.of(Material.DECORATION).strength(1.0F))); private static final RegistryObject BLAZE_HEAD_WALL = BLOCKS.register("blaze_wall_head", () -> new CustomWallSkullBlock(SkullType.BLAZE, BlockBehaviour.Properties.of(Material.DECORATION).strength(1.0F).lootFrom(BLAZE_HEAD))); - private static final RegistryObject BLAZE_HEAD_ITEM = ITEMS.register("blaze_head", () -> new StandingAndWallBlockItem(BLAZE_HEAD.get(), BLAZE_HEAD_WALL.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS).rarity(Rarity.UNCOMMON))); + private static final RegistryObject BLAZE_HEAD_ITEM = ITEMS.register("blaze_head", () -> new StandingAndWallBlockItem(BLAZE_HEAD.get(), BLAZE_HEAD_WALL.get(), new Item.Properties().rarity(Rarity.UNCOMMON), Direction.DOWN)); private static final RegistryObject> CUSTOM_SKULL = BLOCK_ENTITIES.register("custom_skull", () -> BlockEntityType.Builder.of(CustomSkullBlockEntity::new, BLAZE_HEAD.get(), BLAZE_HEAD_WALL.get()).build(null)); public CustomHeadTest() @@ -66,6 +61,8 @@ public class CustomHeadTest BLOCKS.register(modBus); ITEMS.register(modBus); BLOCK_ENTITIES.register(modBus); + + modBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS, BLAZE_HEAD_ITEM.get())); } private static class CustomSkullBlock extends SkullBlock diff --git a/src/test/java/net/minecraftforge/debug/block/CustomSignsTest.java b/src/test/java/net/minecraftforge/debug/block/CustomSignsTest.java index dc27e5589d..9edbfc88b6 100644 --- a/src/test/java/net/minecraftforge/debug/block/CustomSignsTest.java +++ b/src/test/java/net/minecraftforge/debug/block/CustomSignsTest.java @@ -7,16 +7,17 @@ package net.minecraftforge.debug.block; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.core.BlockPos; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.level.material.Material; import net.minecraft.client.renderer.Sheets; import net.minecraft.client.renderer.blockentity.SignRenderer; import net.minecraft.world.item.Item; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.SignItem; import net.minecraft.world.level.block.entity.SignBlockEntity; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; @@ -34,6 +35,8 @@ import net.minecraft.world.level.block.state.BlockBehaviour.Properties; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.WoodType; +import java.util.function.Consumer; + @Mod(CustomSignsTest.MODID) public class CustomSignsTest { @@ -47,7 +50,7 @@ public class CustomSignsTest public static final RegistryObject TEST_WALL_SIGN = BLOCKS.register("test_wall_sign", () -> new CustomWallSignBlock(Properties.of(Material.WOOD).noCollission().strength(1.0F).sound(SoundType.WOOD), CustomSignsTest.TEST_WOOD_TYPE)); private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); - public static final RegistryObject TEST_SIGN = ITEMS.register("test_sign", () -> new SignItem((new Item.Properties()).stacksTo(16).tab(CreativeModeTab.TAB_DECORATIONS), TEST_STANDING_SIGN.get(), TEST_WALL_SIGN.get())); + public static final RegistryObject TEST_SIGN = ITEMS.register("test_sign", () -> new SignItem((new Item.Properties()).stacksTo(16), TEST_STANDING_SIGN.get(), TEST_WALL_SIGN.get())); private static final DeferredRegister> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, MODID); public static final RegistryObject> CUSTOM_SIGN = BLOCK_ENTITIES.register("custom_sign", () -> BlockEntityType.Builder.of(CustomSignBlockEntity::new, TEST_WALL_SIGN.get(), TEST_STANDING_SIGN.get()).build(null)); @@ -63,6 +66,8 @@ public class CustomSignsTest eventBus.addListener(this::clientSetup); eventBus.addListener(this::commonSetup); + + eventBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS, TEST_SIGN.get())); } } diff --git a/src/test/java/net/minecraftforge/debug/block/FullPotsAccessorDemo.java b/src/test/java/net/minecraftforge/debug/block/FullPotsAccessorDemo.java index e62415d362..07f7ede0e3 100644 --- a/src/test/java/net/minecraftforge/debug/block/FullPotsAccessorDemo.java +++ b/src/test/java/net/minecraftforge/debug/block/FullPotsAccessorDemo.java @@ -7,7 +7,6 @@ package net.minecraftforge.debug.block; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; -import com.mojang.datafixers.util.Pair; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.*; @@ -45,6 +44,7 @@ import net.minecraftforge.client.model.geometry.IGeometryBakingContext; import net.minecraftforge.client.model.geometry.IGeometryLoader; import net.minecraftforge.client.model.geometry.IUnbakedGeometry; import net.minecraftforge.common.util.ConcatenatedListView; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -56,6 +56,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; +import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; @@ -72,7 +73,7 @@ public class FullPotsAccessorDemo private static final RegistryObject DIORITE_POT = BLOCKS.register("diorite_pot", DioriteFlowerPotBlock::new); private static final RegistryObject DIORITE_POT_ITEM = ITEMS.register( "diorite_pot", - () -> new BlockItem(DIORITE_POT.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)) + () -> new BlockItem(DIORITE_POT.get(), new Item.Properties()) ); private static final RegistryObject> DIORITE_POT_BLOCK_ENTITY = BLOCK_ENTITIES.register( "diorite_pot", @@ -87,6 +88,8 @@ public class FullPotsAccessorDemo BLOCKS.register(bus); ITEMS.register(bus); BLOCK_ENTITIES.register(bus); + + bus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.INGREDIENTS, DIORITE_POT_ITEM.get())); } } @@ -256,15 +259,8 @@ public class FullPotsAccessorDemo private record DioritePotModelGeometry(UnbakedModel wrappedModel) implements IUnbakedGeometry { @Override - public BakedModel bake(IGeometryBakingContext context, ModelBakery bakery, Function spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) - { - return new DioritePotModel(wrappedModel.bake(bakery, spriteGetter, modelState, modelLocation)); - } - - @Override - public Collection getMaterials(IGeometryBakingContext context, Function modelGetter, Set> missingTextureErrors) - { - return wrappedModel.getMaterials(modelGetter, missingTextureErrors); + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) { + return new DioritePotModel(wrappedModel.bake(baker, spriteGetter, modelState, modelLocation)); } } @@ -299,8 +295,8 @@ public class FullPotsAccessorDemo return potModel.getQuads(potState, face, rand, ModelData.EMPTY, renderType) .stream() - .filter(q -> !q.getSprite().getName().equals(POT_TEXTURE)) - .filter(q -> !q.getSprite().getName().equals(DIRT_TEXTURE)) + .filter(q -> !q.getSprite().contents().name().equals(POT_TEXTURE)) + .filter(q -> !q.getSprite().contents().name().equals(DIRT_TEXTURE)) .collect(Collectors.toList()); } diff --git a/src/test/java/net/minecraftforge/debug/block/PistonEventTest.java b/src/test/java/net/minecraftforge/debug/block/PistonEventTest.java index e3857b0c0a..c29250a3db 100644 --- a/src/test/java/net/minecraftforge/debug/block/PistonEventTest.java +++ b/src/test/java/net/minecraftforge/debug/block/PistonEventTest.java @@ -7,8 +7,10 @@ package net.minecraftforge.debug.block; import java.util.List; import java.util.Locale; +import java.util.function.Consumer; import net.minecraft.network.chat.Component; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.Blocks; @@ -20,7 +22,6 @@ import net.minecraft.data.DataGenerator; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.core.Direction; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; @@ -28,6 +29,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.model.generators.BlockStateProvider; import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.event.level.PistonEvent; import net.minecraftforge.event.level.PistonEvent.PistonMoveType; import net.minecraftforge.eventbus.api.IEventBus; @@ -55,10 +57,8 @@ public class PistonEventTest private static DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID); private static DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); - private static RegistryObject shiftOnMove = BLOCKS.register(blockName, () -> new Block(Block.Properties.of(Material.STONE))); - static { - ITEMS.register(blockName, () -> new BlockItem(shiftOnMove.get(), new Item.Properties().tab(CreativeModeTab.TAB_BUILDING_BLOCKS))); - } + private static RegistryObject SHIFT_ON_MOVE = BLOCKS.register(blockName, () -> new Block(Block.Properties.of(Material.STONE))); + private static RegistryObject SHIFT_ON_MOVE_ITEM = ITEMS.register(blockName, () -> new BlockItem(SHIFT_ON_MOVE.get(), new Item.Properties())); public PistonEventTest() { @@ -66,6 +66,8 @@ public class PistonEventTest BLOCKS.register(modBus); ITEMS.register(modBus); modBus.addListener(this::gatherData); + + modBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS, SHIFT_ON_MOVE_ITEM.get())); } @SubscribeEvent @@ -104,10 +106,10 @@ public class PistonEventTest // Make the block move up and out of the way so long as it won't replace the piston BlockPos pushedBlockPos = event.getFaceOffsetPos(); - if (world.getBlockState(pushedBlockPos).getBlock() == shiftOnMove.get() && event.getDirection() != Direction.DOWN) + if (world.getBlockState(pushedBlockPos).getBlock() == SHIFT_ON_MOVE.get() && event.getDirection() != Direction.DOWN) { world.setBlockAndUpdate(pushedBlockPos, Blocks.AIR.defaultBlockState()); - world.setBlockAndUpdate(pushedBlockPos.above(), shiftOnMove.get().defaultBlockState()); + world.setBlockAndUpdate(pushedBlockPos.above(), SHIFT_ON_MOVE.get().defaultBlockState()); } // Block pushing cobblestone (directly, indirectly works) @@ -154,9 +156,9 @@ public class PistonEventTest @Override protected void registerStatesAndModels() { - ModelFile model = models().cubeAll(shiftOnMove.getId().getPath(), mcLoc("block/furnace_top")); - simpleBlock(shiftOnMove.get(), model); - simpleBlockItem(shiftOnMove.get(), model); + ModelFile model = models().cubeAll(SHIFT_ON_MOVE.getId().getPath(), mcLoc("block/furnace_top")); + simpleBlock(SHIFT_ON_MOVE.get(), model); + simpleBlockItem(SHIFT_ON_MOVE.get(), model); } } diff --git a/src/test/java/net/minecraftforge/debug/block/RedstoneSidedConnectivityTest.java b/src/test/java/net/minecraftforge/debug/block/RedstoneSidedConnectivityTest.java index 957c2862f4..ecaab208be 100644 --- a/src/test/java/net/minecraftforge/debug/block/RedstoneSidedConnectivityTest.java +++ b/src/test/java/net/minecraftforge/debug/block/RedstoneSidedConnectivityTest.java @@ -8,7 +8,7 @@ package net.minecraftforge.debug.block; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; @@ -16,6 +16,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.FurnaceBlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -24,6 +25,8 @@ import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import org.jetbrains.annotations.Nullable; +import java.util.function.Consumer; + @Mod(RedstoneSidedConnectivityTest.MODID) public class RedstoneSidedConnectivityTest { @@ -35,7 +38,7 @@ public class RedstoneSidedConnectivityTest private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); private static final RegistryObject TEST_REDSTONE_BLOCK = BLOCKS.register(BLOCK_ID, EastRedstoneBlock::new); - private static final RegistryObject TEST_REDSTONE_BLOCKITEM = ITEMS.register(BLOCK_ID, () -> new BlockItem(TEST_REDSTONE_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_BUILDING_BLOCKS))); + private static final RegistryObject TEST_REDSTONE_BLOCKITEM = ITEMS.register(BLOCK_ID, () -> new BlockItem(TEST_REDSTONE_BLOCK.get(), new Item.Properties())); public RedstoneSidedConnectivityTest() { @@ -45,6 +48,8 @@ public class RedstoneSidedConnectivityTest IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus(); BLOCKS.register(modBus); ITEMS.register(modBus); + + modBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS, TEST_REDSTONE_BLOCKITEM.get())); } private static class EastRedstoneBlock extends Block diff --git a/src/test/java/net/minecraftforge/debug/client/AmbientOcclusionElementsTest.java b/src/test/java/net/minecraftforge/debug/client/AmbientOcclusionElementsTest.java index 1c1ec981e3..ed509f4318 100644 --- a/src/test/java/net/minecraftforge/debug/client/AmbientOcclusionElementsTest.java +++ b/src/test/java/net/minecraftforge/debug/client/AmbientOcclusionElementsTest.java @@ -6,11 +6,12 @@ package net.minecraftforge.debug.client; import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.material.Material; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -18,12 +19,16 @@ import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; +import java.util.function.Consumer; + /** * Test mod that demos disabling ambient occlusion on specific faces of "elements" models. */ @Mod(AmbientOcclusionElementsTest.MOD_ID) public class AmbientOcclusionElementsTest { + private static final boolean ENABLED = false; + public static final String MOD_ID = "ambient_occlusion_elements_test"; private static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID); private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); @@ -32,15 +37,21 @@ public class AmbientOcclusionElementsTest public static final RegistryObject AO_BLOCK_NO_SHADE = BLOCKS.register("ambient_occlusion_no_shade", () -> new Block(BlockBehaviour.Properties.of(Material.STONE))); public static final RegistryObject NO_AO_BLOCK_SHADE = BLOCKS.register("no_ambient_occlusion_shade", () -> new Block(BlockBehaviour.Properties.of(Material.STONE))); public static final RegistryObject NO_AO_BLOCK_NO_SHADE = BLOCKS.register("no_ambient_occlusion_no_shade", () -> new Block(BlockBehaviour.Properties.of(Material.STONE))); - public static final RegistryObject AO_BLOCK_SHADE_ITEM = ITEMS.register("ambient_occlusion_shade", () -> new BlockItem(AO_BLOCK_SHADE.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS))); - public static final RegistryObject AO_BLOCK_NO_SHADE_ITEM = ITEMS.register("ambient_occlusion_no_shade", () -> new BlockItem(AO_BLOCK_NO_SHADE.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS))); - public static final RegistryObject NO_AO_BLOCK_SHADE_ITEM = ITEMS.register("no_ambient_occlusion_shade", () -> new BlockItem(NO_AO_BLOCK_SHADE.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS))); - public static final RegistryObject NO_AO_BLOCK_NO_SHADE_ITEM = ITEMS.register("no_ambient_occlusion_no_shade", () -> new BlockItem(NO_AO_BLOCK_NO_SHADE.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS))); + public static final RegistryObject AO_BLOCK_SHADE_ITEM = ITEMS.register("ambient_occlusion_shade", () -> new BlockItem(AO_BLOCK_SHADE.get(), new Item.Properties())); + public static final RegistryObject AO_BLOCK_NO_SHADE_ITEM = ITEMS.register("ambient_occlusion_no_shade", () -> new BlockItem(AO_BLOCK_NO_SHADE.get(), new Item.Properties())); + public static final RegistryObject NO_AO_BLOCK_SHADE_ITEM = ITEMS.register("no_ambient_occlusion_shade", () -> new BlockItem(NO_AO_BLOCK_SHADE.get(), new Item.Properties())); + public static final RegistryObject NO_AO_BLOCK_NO_SHADE_ITEM = ITEMS.register("no_ambient_occlusion_no_shade", () -> new BlockItem(NO_AO_BLOCK_NO_SHADE.get(), new Item.Properties())); public AmbientOcclusionElementsTest() { + if (!ENABLED) + return; + IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); BLOCKS.register(modEventBus); ITEMS.register(modEventBus); + + modEventBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS, + AO_BLOCK_SHADE_ITEM.get(), AO_BLOCK_NO_SHADE_ITEM.get(), NO_AO_BLOCK_SHADE_ITEM.get(), NO_AO_BLOCK_NO_SHADE_ITEM.get())); } } diff --git a/src/test/java/net/minecraftforge/debug/client/AudioStreamTest.java b/src/test/java/net/minecraftforge/debug/client/AudioStreamTest.java index 86f2fc58a8..c9d9666e50 100644 --- a/src/test/java/net/minecraftforge/debug/client/AudioStreamTest.java +++ b/src/test/java/net/minecraftforge/debug/client/AudioStreamTest.java @@ -5,7 +5,6 @@ package net.minecraftforge.debug.client; -import com.mojang.math.Vector3d; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.sounds.AbstractSoundInstance; import net.minecraft.client.resources.sounds.Sound; diff --git a/src/test/java/net/minecraftforge/debug/client/CustomArmorModelTest.java b/src/test/java/net/minecraftforge/debug/client/CustomArmorModelTest.java index 59c157c883..144741fb60 100644 --- a/src/test/java/net/minecraftforge/debug/client/CustomArmorModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/CustomArmorModelTest.java @@ -16,15 +16,11 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ArmorItem; -import net.minecraft.world.item.ArmorMaterial; -import net.minecraft.world.item.ArmorMaterials; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; +import net.minecraft.world.item.*; import net.minecraft.world.item.Item.Properties; -import net.minecraft.world.item.ItemStack; import net.minecraftforge.client.extensions.common.IClientItemExtensions; import net.minecraftforge.common.util.Lazy; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -43,15 +39,18 @@ public class CustomArmorModelTest static final String MOD_ID = "custom_armor_model_test"; private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); // demonstrates custom non-humanoid model - private static final RegistryObject RED_LEGGINGS = ITEMS.register("red_leggings", () -> new TintedArmorItem(ArmorMaterials.DIAMOND, EquipmentSlot.LEGS, new Properties().stacksTo(1).tab(CreativeModeTab.TAB_MISC))); + private static final RegistryObject RED_LEGGINGS = ITEMS.register("red_leggings", () -> new TintedArmorItem(ArmorMaterials.DIAMOND, EquipmentSlot.LEGS, new Properties().stacksTo(1))); // demonstrates the properties are copied from the vanilla model - private static final RegistryObject ENDERMAN_CHESTPLATE = ITEMS.register("enderman_chestplate", () -> new EndermanArmorItem(ArmorMaterials.GOLD, EquipmentSlot.CHEST, new Properties().stacksTo(1).tab(CreativeModeTab.TAB_MISC))); - private static final RegistryObject ENDERMAN_BOOTS = ITEMS.register("enderman_boots", () -> new EndermanArmorItem(ArmorMaterials.GOLD, EquipmentSlot.FEET, new Properties().stacksTo(1).tab(CreativeModeTab.TAB_MISC))); + private static final RegistryObject ENDERMAN_CHESTPLATE = ITEMS.register("enderman_chestplate", () -> new EndermanArmorItem(ArmorMaterials.GOLD, EquipmentSlot.CHEST, new Properties().stacksTo(1))); + private static final RegistryObject ENDERMAN_BOOTS = ITEMS.register("enderman_boots", () -> new EndermanArmorItem(ArmorMaterials.GOLD, EquipmentSlot.FEET, new Properties().stacksTo(1))); public CustomArmorModelTest() { final IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus(); ITEMS.register(modBus); + + modBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.INGREDIENTS, + RED_LEGGINGS.get(), ENDERMAN_CHESTPLATE.get(), ENDERMAN_BOOTS.get())); } private static class TintedArmorItem extends ArmorItem diff --git a/src/test/java/net/minecraftforge/debug/client/CustomTASTest.java b/src/test/java/net/minecraftforge/debug/client/CustomTASTest.java index 44343ca5ef..62745711d8 100644 --- a/src/test/java/net/minecraftforge/debug/client/CustomTASTest.java +++ b/src/test/java/net/minecraftforge/debug/client/CustomTASTest.java @@ -8,13 +8,15 @@ package net.minecraftforge.debug.client; import java.util.Random; import com.mojang.blaze3d.platform.NativeImage; -import net.minecraft.client.renderer.texture.TextureAtlas; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.texture.Tickable; +import net.minecraft.client.renderer.texture.*; +import net.minecraft.client.resources.metadata.animation.AnimationMetadataSection; +import net.minecraft.client.resources.metadata.animation.FrameSize; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.Resource; import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.world.item.Item; import net.minecraftforge.client.event.RegisterTextureAtlasSpriteLoadersEvent; +import net.minecraftforge.client.textures.ForgeTextureMetadata; import net.minecraftforge.client.textures.ITextureAtlasSpriteLoader; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -23,6 +25,7 @@ import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; @Mod(CustomTASTest.MOD_ID) public class CustomTASTest @@ -52,27 +55,48 @@ public class CustomTASTest private static class TasLoader implements ITextureAtlasSpriteLoader { @Override - @NotNull - public TextureAtlasSprite load(TextureAtlas atlas, ResourceManager resourceManager, TextureAtlasSprite.Info textureInfo, Resource resource, int atlasWidth, int atlasHeight, int spriteX, int spriteY, int mipmapLevel, NativeImage image) - { - return new TextureAtlasSprite( - atlas, textureInfo, mipmapLevel, atlasWidth, atlasHeight, spriteX, spriteY, image - ) - { - private final Random random = new Random(); + public SpriteContents loadContents(ResourceLocation name, Resource resource, FrameSize frameSize, NativeImage image, AnimationMetadataSection animationMeta, ForgeTextureMetadata forgeMeta) { + final class TASSpriteContents extends SpriteContents { + + public TASSpriteContents(ResourceLocation p_249787_, FrameSize p_251031_, NativeImage p_252131_, AnimationMetadataSection p_250432_, @Nullable ForgeTextureMetadata forgeMeta) { + super(p_249787_, p_251031_, p_252131_, p_250432_, forgeMeta); + } @Override - public Tickable getAnimationTicker() - { - return this::tick; + public @NotNull SpriteTicker createTicker() { + return new Ticker(); } - private void tick() - { - this.mainImage[0].fillRect(0, 0, 16, 16, 0xFF000000 | random.nextInt(0xFFFFFF)); - this.uploadFirstFrame(); + class Ticker implements SpriteTicker { + + final Random random = new Random(); + + @Override + public void tickAndUpload(int p_248847_, int p_250486_) { + TASSpriteContents.this.byMipLevel[0].fillRect(0, 0, 16, 16, 0xFF000000 | random.nextInt(0xFFFFFF)); + TASSpriteContents.this.uploadFirstFrame(p_248847_, p_250486_); + } + + @Override + public void close() { + + } } - }; + } + + return new TASSpriteContents(name, frameSize, image, animationMeta, forgeMeta); + } + + @Override + public @NotNull TextureAtlasSprite makeSprite(ResourceLocation atlasName, SpriteContents contents, int atlasWidth, int atlasHeight, int spriteX, int spriteY, int mipmapLevel) { + final class TASSprite extends TextureAtlasSprite { + + public TASSprite(ResourceLocation p_250211_, SpriteContents p_248526_, int p_248950_, int p_249741_, int p_248672_, int p_248637_) { + super(p_250211_, p_248526_, p_248950_, p_249741_, p_248672_, p_248637_); + } + } + + return new TASSprite(atlasName, contents, atlasWidth, atlasHeight, spriteX, spriteY); } } diff --git a/src/test/java/net/minecraftforge/debug/client/CustomTooltipTest.java b/src/test/java/net/minecraftforge/debug/client/CustomTooltipTest.java index c9b3458981..4c27e1adde 100644 --- a/src/test/java/net/minecraftforge/debug/client/CustomTooltipTest.java +++ b/src/test/java/net/minecraftforge/debug/client/CustomTooltipTest.java @@ -12,9 +12,7 @@ import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiComponent; -import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.font.FontManager; -import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.network.chat.Component; @@ -23,18 +21,14 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.tooltip.TooltipComponent; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Items; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.item.*; import net.minecraft.world.level.Level; -import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RegisterClientTooltipComponentFactoriesEvent; import net.minecraftforge.client.event.RenderTooltipEvent; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.CreativeModeTabEvent; +import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -44,10 +38,9 @@ import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import org.jetbrains.annotations.Nullable; -import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.Optional; +import java.util.function.Consumer; @Mod(CustomTooltipTest.ID) public class CustomTooltipTest @@ -59,18 +52,20 @@ public class CustomTooltipTest private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ID); static final RegistryObject CUSTOM_ITEM = ITEMS.register( "test_item", - () -> new CustomItemWithTooltip(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) + () -> new CustomItemWithTooltip(new Item.Properties()) ); public CustomTooltipTest() { if (ENABLED) { + IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); if (FMLEnvironment.dist.isClient()) { MinecraftForge.EVENT_BUS.register(ClientEventHandler.class); - FMLJavaModLoadingContext.get().getModEventBus().register(ClientModBusEventHandler.class); + modEventBus.register(ClientModBusEventHandler.class); } - ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); + ITEMS.register(modEventBus); + modEventBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.INGREDIENTS, CUSTOM_ITEM.get())); } } @@ -117,10 +112,10 @@ public class CustomTooltipTest @Override public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { - if (level.isClientSide) +/* if (level.isClientSide) Update to 1.19.3: Disable screen tests since logic for tooltips on buttons has changed massively! { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> TooltipTestScreen::show); - } + }*/ return InteractionResultHolder.success(player.getItemInHand(hand)); } @@ -187,7 +182,9 @@ public class CustomTooltipTest } - static class TooltipTestScreen extends Screen +/* Disabled on update to 1.19.3: Tooltips have changed massively, and mojang now handles them differently + +static class TooltipTestScreen extends Screen { private ItemStack testStack = ItemStack.EMPTY; @@ -213,19 +210,20 @@ public class CustomTooltipTest @Override protected void init() { - addRenderableWidget(new Button(10, 10, 200, 20, Component.literal("Toggle Stack: EMPTY"), button -> { + addRenderableWidget(Button.builder(Component.literal("Toggle Stack: EMPTY"), button -> { this.testStack = this.testStack.isEmpty() ? new ItemStack(Items.APPLE) : ItemStack.EMPTY; button.setMessage(Component.literal("Toggle Stack: " + (testStack.isEmpty() ? "EMPTY" : "Apple"))); - })); - - addRenderableWidget(new Button(220, 10, 200, 20, Component.literal("Toggle Font: null"), button -> { + }).pos(10, 10).size(200,20).build()); + addRenderableWidget(Button.builder(Component.literal("Toggle Font: null"), button -> { this.testFont = this.testFont == null ? ClientModBusEventHandler.customFont : null; button.setMessage(Component.literal("Toggle Font: " + (testFont == null ? "null" : "customFont"))); - })); + }).pos(220, 10).size(200,20).build()); + + // * must have stack context // # must have custom font - List> tooltipTests = Arrays.asList( + List> tooltipTests = Arrays.asList( Map.entry(" 1 * ", this::test1), Map.entry(" 2 * ", this::test2), Map.entry(" 3 #", this::test3), @@ -330,6 +328,6 @@ public class CustomTooltipTest { renderComponentTooltip(poseStack, List.of(Component.literal("test")), mouseX, mouseY, this.testFont, ItemStack.EMPTY); } - } + }*/ } diff --git a/src/test/java/net/minecraftforge/debug/client/EmissiveElementsTest.java b/src/test/java/net/minecraftforge/debug/client/EmissiveElementsTest.java index 252ac461df..78df4077de 100644 --- a/src/test/java/net/minecraftforge/debug/client/EmissiveElementsTest.java +++ b/src/test/java/net/minecraftforge/debug/client/EmissiveElementsTest.java @@ -6,11 +6,12 @@ package net.minecraftforge.debug.client; import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.material.Material; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -29,12 +30,14 @@ public class EmissiveElementsTest private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); public static final RegistryObject TEST_BLOCK = BLOCKS.register("emissive", () -> new Block(BlockBehaviour.Properties.of(Material.STONE))); - public static final RegistryObject TEST_BLOCK_ITEM = ITEMS.register("emissive", () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS))); + public static final RegistryObject TEST_BLOCK_ITEM = ITEMS.register("emissive", () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties())); public EmissiveElementsTest() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); BLOCKS.register(modEventBus); ITEMS.register(modEventBus); + + modEventBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS, TEST_BLOCK_ITEM.get())); } } diff --git a/src/test/java/net/minecraftforge/debug/client/GuiLayeringTest.java b/src/test/java/net/minecraftforge/debug/client/GuiLayeringTest.java index 8d3023be30..7abccd1d6b 100644 --- a/src/test/java/net/minecraftforge/debug/client/GuiLayeringTest.java +++ b/src/test/java/net/minecraftforge/debug/client/GuiLayeringTest.java @@ -21,6 +21,8 @@ import java.util.Random; @Mod(GuiLayeringTest.MODID) public class GuiLayeringTest { + private static final boolean ENABLED = false; + private static final Random RANDOM = new Random(); public static final String MODID = "gui_layer_test"; @@ -30,14 +32,15 @@ public class GuiLayeringTest @SubscribeEvent public static void guiOpen(ScreenEvent.Init event) { - if (event.getScreen() instanceof AbstractContainerScreen) + if (event.getScreen() instanceof AbstractContainerScreen && ENABLED) { - event.addListener(new Button(2, 2, 150, 20, Component.literal("Test Gui Layering"), btn -> { + event.addListener(Button.builder(Component.literal("Test Gui Layering"), btn -> { Minecraft.getInstance().pushGuiLayer(new TestLayer(Component.literal("LayerScreen"))); - })); - event.addListener(new Button(2, 25, 150, 20, Component.literal("Test Gui Normal"), btn -> { + }).pos(2,2).size(150, 20).build()); + + event.addListener(Button.builder(Component.literal("Test Gui Normal"), btn -> { Minecraft.getInstance().setScreen(new TestLayer(Component.literal("LayerScreen"))); - })); + }).pos(2, 25).size(150, 20).build()); } } @@ -72,9 +75,9 @@ public class GuiLayeringTest xoff = RANDOM.nextInt(xoff); yoff = RANDOM.nextInt(yoff); - this.addRenderableWidget(new Button(xoff, yoff + buttonSpacing * (cnt++), buttonWidth, buttonHeight, Component.literal("Push New Layer"), this::pushLayerButton)); - this.addRenderableWidget(new Button(xoff, yoff + buttonSpacing * (cnt++), buttonWidth, buttonHeight, Component.literal("Pop Current Layer"), this::popLayerButton)); - this.addRenderableWidget(new Button(xoff, yoff + buttonSpacing * (cnt++), buttonWidth, buttonHeight, Component.literal("Close entire stack"), this::closeStack)); + this.addRenderableWidget(Button.builder(Component.literal("Push New Layer"), this::pushLayerButton).pos(xoff, yoff + buttonSpacing * (cnt++)).size(buttonWidth, buttonHeight).build()); + this.addRenderableWidget(Button.builder(Component.literal("Pop Current Layer"), this::popLayerButton).pos(xoff, yoff + buttonSpacing * (cnt++)).size(buttonWidth, buttonHeight).build()); + this.addRenderableWidget(Button.builder(Component.literal("Close entire stack"), this::closeStack).pos(xoff, yoff + buttonSpacing * (cnt++)).size(buttonWidth, buttonHeight).build()); } private void closeStack(Button button) diff --git a/src/test/java/net/minecraftforge/debug/client/model/CompositeModelTest.java b/src/test/java/net/minecraftforge/debug/client/model/CompositeModelTest.java index a832adb927..68984e9e23 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/CompositeModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/CompositeModelTest.java @@ -5,16 +5,13 @@ package net.minecraftforge.debug.client.model; +import net.minecraft.world.item.*; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.core.BlockPos; @@ -22,6 +19,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.level.BlockGetter; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; @@ -30,6 +28,8 @@ import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import org.jetbrains.annotations.Nullable; +import java.util.function.Consumer; + @Mod(CompositeModelTest.MODID) public class CompositeModelTest { @@ -72,7 +72,7 @@ public class CompositeModelTest ); public static RegistryObject composite_item = ITEMS.register("composite_block", () -> - new BlockItem(composite_block.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)) { + new BlockItem(composite_block.get(), new Item.Properties()) { @Override public boolean canEquip(ItemStack stack, EquipmentSlot armorType, Entity entity) { @@ -87,5 +87,7 @@ public class CompositeModelTest BLOCKS.register(modEventBus); ITEMS.register(modEventBus); + + modEventBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.INGREDIENTS, composite_item.get())); } } diff --git a/src/test/java/net/minecraftforge/debug/client/model/CustomTransformTypeTest.java b/src/test/java/net/minecraftforge/debug/client/model/CustomTransformTypeTest.java index 5a7a8426fc..89adb08313 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/CustomTransformTypeTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/CustomTransformTypeTest.java @@ -40,6 +40,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.EntityRenderersEvent; import net.minecraftforge.client.model.generators.*; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -49,6 +50,8 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import org.jetbrains.annotations.Nullable; +import java.util.function.Consumer; + /* * Test mod for the custom transform types feature. * This test mod adds an item that should be held in the main hand, while another item is in the offhand. @@ -117,7 +120,7 @@ public class CustomTransformTypeTest public static final RegistryObject> ITEM_HANGER_BE = BLOCK_ENTITY_TYPES.register("item_hanger", () -> BlockEntityType.Builder.of(ItemHangerBlockEntity::new, ITEM_HANGER_BLOCK.get()).build(null)); public static final RegistryObject - ITEM_HANGER_ITEM = ITEMS.register("item_hanger", () -> new ItemHangerItem(ITEM_HANGER_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC))); + ITEM_HANGER_ITEM = ITEMS.register("item_hanger", () -> new ItemHangerItem(ITEM_HANGER_BLOCK.get(), new Item.Properties())); public CustomTransformTypeTest() { @@ -126,6 +129,13 @@ public class CustomTransformTypeTest BLOCKS.register(modBus); BLOCK_ENTITY_TYPES.register(modBus); ITEMS.register(modBus); + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(ITEM_HANGER_ITEM.get()); + }); + } + }); } public void gatherData(GatherDataEvent event) diff --git a/src/test/java/net/minecraftforge/debug/client/model/DynBucketModelTest.java b/src/test/java/net/minecraftforge/debug/client/model/DynBucketModelTest.java index 366044c432..1e18ce7f13 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/DynBucketModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/DynBucketModelTest.java @@ -5,8 +5,9 @@ package net.minecraftforge.debug.client.model; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; -import net.minecraft.world.item.CreativeModeTab; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; @@ -14,22 +15,32 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import java.util.function.Consumer; + @Mod(DynBucketModelTest.MODID) public class DynBucketModelTest { public static final boolean ENABLE = false; // TODO fix public static final String MODID = "dyn_bucket_model_test"; public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); - - public static final RegistryObject DRIP_BUCKET = ITEMS.register("drip_bucket", () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC))); - public static final RegistryObject LAVA_OBSIDIAN = ITEMS.register("lava_obsidian", () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC))); - + + public static final RegistryObject DRIP_BUCKET = ITEMS.register("drip_bucket", () -> new Item(new Item.Properties())); + public static final RegistryObject LAVA_OBSIDIAN = ITEMS.register("lava_obsidian", () -> new Item(new Item.Properties())); + public DynBucketModelTest() { if (ENABLE) { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); ITEMS.register(modEventBus); + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(DRIP_BUCKET.get()); + output.accept(LAVA_OBSIDIAN.get()); + }); + } + }); } } } diff --git a/src/test/java/net/minecraftforge/debug/client/model/MegaModelTest.java b/src/test/java/net/minecraftforge/debug/client/model/MegaModelTest.java index a73eceeb23..939eb6d045 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/MegaModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/MegaModelTest.java @@ -5,9 +5,7 @@ package net.minecraftforge.debug.client.model; -import com.mojang.math.Quaternion; import com.mojang.math.Transformation; -import com.mojang.math.Vector3f; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.resources.model.BakedModel; @@ -20,7 +18,7 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -36,6 +34,7 @@ import net.minecraftforge.client.model.BakedModelWrapper; import net.minecraftforge.client.model.IQuadTransformer; import net.minecraftforge.client.model.data.ModelData; import net.minecraftforge.client.model.data.ModelProperty; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -45,9 +44,12 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.joml.Quaternionf; +import org.joml.Vector3f; import java.util.List; import java.util.Set; +import java.util.function.Consumer; /** * Test mod that demos most Forge-provided model loaders in a single block + item, as well as in-JSON render states @@ -75,7 +77,7 @@ public class MegaModelTest private static final String REG_NAME = "test_block"; public static final RegistryObject TEST_BLOCK = BLOCKS.register(REG_NAME, TestBlock::new); - public static final RegistryObject TEST_BLOCK_ITEM = ITEMS.register(REG_NAME, () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS))); + public static final RegistryObject TEST_BLOCK_ITEM = ITEMS.register(REG_NAME, () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties())); public static final RegistryObject> TEST_BLOCK_ENTITY = BLOCK_ENTITIES.register(REG_NAME, () -> new BlockEntityType<>( TestBlock.Entity::new, Set.of(TEST_BLOCK.get()), null )); @@ -86,6 +88,12 @@ public class MegaModelTest BLOCKS.register(modEventBus); ITEMS.register(modEventBus); BLOCK_ENTITIES.register(modEventBus); + + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.BUILDING_BLOCKS) { + onBuildContents.register((p_259204_, p_259752_, p_260123_) -> p_259752_.accept(TEST_BLOCK_ITEM.get())); + } + }); } @Mod.EventBusSubscriber(value = Dist.CLIENT, modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) @@ -143,9 +151,9 @@ public class MegaModelTest { return ModelData.builder().with(TestData.PROPERTY, new TestData(new Transformation( new Vector3f(0, y * 0.2f, 0), - Quaternion.ONE, + new Quaternionf(1f, 1f, 1f, 1f), Transformation.identity().getScale(), - Quaternion.ONE + new Quaternionf(1f, 1f, 1f, 1f) ))).build(); } } diff --git a/src/test/java/net/minecraftforge/debug/client/model/MultiLayerModelTest.java b/src/test/java/net/minecraftforge/debug/client/model/MultiLayerModelTest.java index d487ddae58..0c1eacd4ac 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/MultiLayerModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/MultiLayerModelTest.java @@ -5,21 +5,25 @@ package net.minecraftforge.debug.client.model; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.material.Material; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ObjectHolder; import net.minecraftforge.registries.RegisterEvent; +import java.util.function.Consumer; + @Mod(MultiLayerModelTest.MODID) public class MultiLayerModelTest { @@ -48,7 +52,14 @@ public class MultiLayerModelTest { if (!ENABLED || !event.getRegistryKey().equals(ForgeRegistries.Keys.ITEMS)) return; - event.register(ForgeRegistries.Keys.ITEMS, blockId, () -> new BlockItem(TEST_BLOCK, new Item.Properties().tab(CreativeModeTab.TAB_MISC))); + event.register(ForgeRegistries.Keys.ITEMS, blockId, () -> new BlockItem(TEST_BLOCK, new Item.Properties())); + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(TEST_BLOCK.asItem()); + }); + } + }); } @SubscribeEvent diff --git a/src/test/java/net/minecraftforge/debug/client/model/NewModelLoaderTest.java b/src/test/java/net/minecraftforge/debug/client/model/NewModelLoaderTest.java index f911938756..dd23998c14 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/NewModelLoaderTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/NewModelLoaderTest.java @@ -7,8 +7,9 @@ package net.minecraftforge.debug.client.model; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; -import com.mojang.datafixers.util.Pair; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.resources.model.ModelBaker; +import net.minecraft.world.item.*; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; @@ -38,6 +39,7 @@ import net.minecraftforge.client.model.generators.loaders.SeparateTransformsMode import net.minecraftforge.client.model.geometry.SimpleUnbakedGeometry; import net.minecraftforge.client.model.pipeline.QuadBakingVertexConsumer; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; @@ -46,19 +48,11 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; -import java.util.Collection; -import java.util.Collections; -import java.util.Set; +import java.util.function.Consumer; import java.util.function.Function; import net.minecraft.client.renderer.block.model.ItemTransforms; -import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelState; -import net.minecraft.client.resources.model.UnbakedModel; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.BlockPlaceContext; import org.jetbrains.annotations.Nullable; @@ -95,7 +89,7 @@ public class NewModelLoaderTest ); public static RegistryObject obj_item = ITEMS.register("obj_block", () -> - new BlockItem(obj_block.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)) { + new BlockItem(obj_block.get(), new Item.Properties()) { @Override public boolean canEquip(ItemStack stack, EquipmentSlot armorType, Entity entity) { @@ -105,23 +99,23 @@ public class NewModelLoaderTest ); public static RegistryObject custom_transforms = ITEMS.register("custom_transforms", () -> - new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) + new Item(new Item.Properties()) ); public static RegistryObject custom_vanilla_loader = ITEMS.register("custom_vanilla_loader", () -> - new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) + new Item(new Item.Properties()) ); public static RegistryObject custom_loader = ITEMS.register("custom_loader", () -> - new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) + new Item(new Item.Properties()) ); public static RegistryObject item_layers = ITEMS.register("item_layers", () -> - new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) + new Item(new Item.Properties()) ); public static RegistryObject separate_perspective = ITEMS.register("separate_perspective", () -> - new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) + new Item(new Item.Properties()) ); public NewModelLoaderTest() @@ -133,6 +127,20 @@ public class NewModelLoaderTest modEventBus.addListener(this::modelRegistry); modEventBus.addListener(this::datagen); + + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(obj_item.get()); + output.accept(custom_transforms.get()); + output.accept(custom_vanilla_loader.get()); + output.accept(custom_loader.get()); + output.accept(item_layers.get()); + output.accept(separate_perspective.get()); + + }); + } + }); } public void modelRegistry(ModelEvent.RegisterGeometryLoaders event) @@ -152,8 +160,7 @@ public class NewModelLoaderTest static class TestModel extends SimpleUnbakedGeometry { @Override - protected void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBakery bakery, Function< net.minecraft.client.resources.model.Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) - { + protected void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBaker baker, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) { TextureAtlasSprite texture = spriteGetter.apply(owner.getMaterial("particle")); var quadBaker = new QuadBakingVertexConsumer.Buffered(); @@ -168,12 +175,6 @@ public class NewModelLoaderTest modelBuilder.addUnculledFace(quadBaker.getQuad()); } - - @Override - public Collection< net.minecraft.client.resources.model.Material> getMaterials(IGeometryBakingContext context, Function modelGetter, Set> missingTextureErrors) - { - return Collections.singleton(context.getMaterial("particle")); - } } private void datagen(GatherDataEvent event) diff --git a/src/test/java/net/minecraftforge/debug/client/model/TRSRTransformerTest.java b/src/test/java/net/minecraftforge/debug/client/model/TRSRTransformerTest.java index 372519cdce..15426f82a0 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/TRSRTransformerTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/TRSRTransformerTest.java @@ -6,9 +6,11 @@ package net.minecraftforge.debug.client.model; import java.util.List; +import java.util.function.Consumer; import net.minecraft.client.renderer.RenderType; import net.minecraft.util.RandomSource; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; @@ -18,18 +20,16 @@ import net.minecraft.client.renderer.block.model.ItemOverrides; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; -import com.mojang.math.Quaternion; import com.mojang.math.Transformation; -import com.mojang.math.Vector3f; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.ModelEvent; import net.minecraftforge.client.model.IQuadTransformer; import net.minecraftforge.client.model.IDynamicBakedModel; import net.minecraftforge.client.model.data.ModelData; import net.minecraftforge.common.util.TransformationHelper; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.registries.RegistryObject; @@ -38,6 +38,8 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import org.jetbrains.annotations.Nullable; +import org.joml.Quaternionf; +import org.joml.Vector3f; @Mod(TRSRTransformerTest.MODID) public class TRSRTransformerTest { @@ -47,13 +49,19 @@ public class TRSRTransformerTest { private static final RegistryObject TEST_BLOCK = BLOCKS.register("test", () -> new Block(Block.Properties.of(Material.STONE))); @SuppressWarnings("unused") - private static final RegistryObject TEST_ITEM = ITEMS.register("test", () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC))); + private static final RegistryObject TEST_ITEM = ITEMS.register("test", () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties())); public TRSRTransformerTest() { final IEventBus mod = FMLJavaModLoadingContext.get().getModEventBus(); DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> mod.addListener(this::onModelBake)); BLOCKS.register(mod); ITEMS.register(mod); + + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.BUILDING_BLOCKS) { + onBuildContents.register((p_259204_, p_259752_, p_260123_) -> p_259752_.accept(TEST_ITEM.get())); + } + }); } public void onModelBake(ModelEvent.BakingCompleted e) { @@ -73,7 +81,7 @@ public class TRSRTransformerTest { @Override public List getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand, ModelData data, @Nullable RenderType renderType) { - Quaternion rot = TransformationHelper.quatFromXYZ(new Vector3f(0, 45, 0), true); + Quaternionf rot = TransformationHelper.quatFromXYZ(new Vector3f(0, 45, 0), true); Vector3f translation = new Vector3f(0, 0.33f, 0); Transformation trans = new Transformation(translation, rot, null, null).blockCenterToCorner(); diff --git a/src/test/java/net/minecraftforge/debug/client/rendering/RenderableTest.java b/src/test/java/net/minecraftforge/debug/client/rendering/RenderableTest.java index 8c336fd64e..3367267cbd 100644 --- a/src/test/java/net/minecraftforge/debug/client/rendering/RenderableTest.java +++ b/src/test/java/net/minecraftforge/debug/client/rendering/RenderableTest.java @@ -7,13 +7,13 @@ package net.minecraftforge.debug.client.rendering; import java.util.Map; +import com.mojang.math.Transformation; +import net.minecraftforge.common.util.TransformationHelper; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.google.common.collect.ImmutableMap; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; -import com.mojang.math.Quaternion; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.LightTexture; @@ -43,6 +43,8 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLEnvironment; +import org.joml.Matrix4f; +import org.joml.Quaternionf; /** * This mod is testing the use of {@link RenderLevelStageEvent} and is a modifaction of a pre-existing test mod that used the old @@ -185,13 +187,11 @@ public class RenderableTest var map = ImmutableMap.builder(); var left = new Matrix4f(); - left.setIdentity(); - left.multiply(Quaternion.fromYXZ(0, 0, (float)Math.sin(time * 0.4) * 0.1f)); + left.rotation((float)Math.sin(time * 0.4) * 0.1f, 0, 0, 1); map.put("object_1", left); var right = new Matrix4f(); - right.setIdentity(); - right.multiply(Quaternion.fromYXZ(0, 0, -(float)Math.sin(time * 0.4) * 0.1f)); + right.rotation(-(float)Math.sin(time * 0.4) * 0.1f, 0, 0, 1); map.put("object_9", right); var transforms = CompositeRenderable.Transforms.of(map.build()); diff --git a/src/test/java/net/minecraftforge/debug/client/rendering/ShaderResourcesTest.java b/src/test/java/net/minecraftforge/debug/client/rendering/ShaderResourcesTest.java index 832f3e66b3..8ab3bced25 100644 --- a/src/test/java/net/minecraftforge/debug/client/rendering/ShaderResourcesTest.java +++ b/src/test/java/net/minecraftforge/debug/client/rendering/ShaderResourcesTest.java @@ -48,24 +48,24 @@ public class ShaderResourcesTest modEventBus.addListener(ClientInit::registerShaders); } - + public static void registerShaders(final RegisterShadersEvent event) { if (!ENABLE) return; - + try { event.registerShader( new ShaderInstance( - event.getResourceManager(), + event.getResourceProvider(), new ResourceLocation(MODID, "vertex_cubemap"), DefaultVertexFormat.POSITION), shader -> { LOGGER.info("Completely loaded shader {} with no issues", shader.getName()); }); - + LOGGER.info("Loaded registered shaders with no exceptions"); } catch (IOException e) diff --git a/src/test/java/net/minecraftforge/debug/entity/GravityAttributeTest.java b/src/test/java/net/minecraftforge/debug/entity/GravityAttributeTest.java index e4ff4e7f2e..d83f1b4d94 100644 --- a/src/test/java/net/minecraftforge/debug/entity/GravityAttributeTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/GravityAttributeTest.java @@ -8,14 +8,17 @@ package net.minecraftforge.debug.entity; import java.util.ArrayList; import java.util.List; import java.util.UUID; +import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; +import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BiomeTags; import net.minecraft.world.entity.ai.attributes.AttributeInstance; -import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraftforge.common.ForgeMod; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegisterEvent; import org.apache.logging.log4j.LogManager; @@ -31,7 +34,6 @@ import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.Item; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Rarity; import net.minecraft.world.level.Level; import net.minecraft.server.level.ServerLevel; @@ -117,7 +119,15 @@ public class GravityAttributeTest public void registerItems(RegisterEvent event) { event.register(ForgeRegistries.Keys.ITEMS, helper -> helper.register("gravity_stick", - new ItemGravityStick(new Properties().tab(CreativeModeTab.TAB_TOOLS).rarity(Rarity.RARE)))); + new ItemGravityStick(new Properties().rarity(Rarity.RARE)))); + + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.TOOLS_AND_UTILITIES) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(ForgeRegistries.ITEMS.getValue(new ResourceLocation("gravity_attribute_test", "gravity_stick"))); + }); + } + }); } public static class ItemGravityStick extends Item diff --git a/src/test/java/net/minecraftforge/debug/entity/PartEntityTest.java b/src/test/java/net/minecraftforge/debug/entity/PartEntityTest.java index 48f8e227d3..ff84d1c88e 100644 --- a/src/test/java/net/minecraftforge/debug/entity/PartEntityTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/PartEntityTest.java @@ -8,6 +8,7 @@ package net.minecraftforge.debug.entity; import net.minecraft.client.renderer.entity.PigRenderer; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; @@ -178,7 +179,7 @@ public class PartEntityTest return this == entity || this.parent == entity; } - public Packet getAddEntityPacket() + public Packet getAddEntityPacket() { throw new UnsupportedOperationException(); } diff --git a/src/test/java/net/minecraftforge/debug/entity/player/ItemUseAnimationTest.java b/src/test/java/net/minecraftforge/debug/entity/player/ItemUseAnimationTest.java index b5ba19096d..bea0002277 100644 --- a/src/test/java/net/minecraftforge/debug/entity/player/ItemUseAnimationTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/player/ItemUseAnimationTest.java @@ -12,11 +12,9 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.food.FoodProperties; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.UseAnim; +import net.minecraft.world.item.*; import net.minecraftforge.client.extensions.common.IClientItemExtensions; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; @@ -39,11 +37,18 @@ public class ItemUseAnimationTest private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); - private static final RegistryObject THING = ITEMS.register("thing", () -> new ThingItem(new Item.Properties().tab(CreativeModeTab.TAB_TOOLS).food(new FoodProperties.Builder().nutrition(4).alwaysEat().build()))); + private static final RegistryObject THING = ITEMS.register("thing", () -> new ThingItem(new Item.Properties().food(new FoodProperties.Builder().nutrition(4).alwaysEat().build()))); public ItemUseAnimationTest() { ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.COMBAT) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(THING.get()); + }); + } + }); } private static class ThingItem extends Item diff --git a/src/test/java/net/minecraftforge/debug/entity/player/PlayerAttackKnockbackTest.java b/src/test/java/net/minecraftforge/debug/entity/player/PlayerAttackKnockbackTest.java index 9b6a3edf3c..48c22d92d3 100644 --- a/src/test/java/net/minecraftforge/debug/entity/player/PlayerAttackKnockbackTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/player/PlayerAttackKnockbackTest.java @@ -11,11 +11,8 @@ import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.Attributes; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.SwordItem; -import net.minecraft.world.item.Tier; -import net.minecraft.world.item.Tiers; +import net.minecraft.world.item.*; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -24,6 +21,7 @@ import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import java.util.UUID; +import java.util.function.Consumer; /** * Tests if the patch to PlayerEntity to make it utilize Attributes.ATTACK_KNOCKBACK works @@ -41,13 +39,20 @@ public class PlayerAttackKnockbackTest { static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); static RegistryObject KNOCKBACK_SWORD = ITEMS.register("knockback_sword", () -> - new KnockbackSwordItem(Tiers.IRON, 3, -2.4F, ATTACK_KNOCKBACK_VALUE, (new Item.Properties()).tab(CreativeModeTab.TAB_COMBAT)) + new KnockbackSwordItem(Tiers.IRON, 3, -2.4F, ATTACK_KNOCKBACK_VALUE, (new Item.Properties())) ); public PlayerAttackKnockbackTest() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); ITEMS.register(modEventBus); + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.COMBAT) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(KNOCKBACK_SWORD.get()); + }); + } + }); } static class KnockbackSwordItem extends SwordItem { diff --git a/src/test/java/net/minecraftforge/debug/fluid/FluidTypeTest.java b/src/test/java/net/minecraftforge/debug/fluid/FluidTypeTest.java index d9cd1310ac..04c62cf0cd 100644 --- a/src/test/java/net/minecraftforge/debug/fluid/FluidTypeTest.java +++ b/src/test/java/net/minecraftforge/debug/fluid/FluidTypeTest.java @@ -7,7 +7,6 @@ package net.minecraftforge.debug.fluid; import com.mojang.blaze3d.shaders.FogShape; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.math.Vector3f; import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; @@ -15,10 +14,7 @@ import net.minecraft.client.renderer.FogRenderer; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.BucketItem; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Items; +import net.minecraft.world.item.*; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; @@ -31,6 +27,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions; import net.minecraftforge.client.event.RegisterColorHandlersEvent; import net.minecraftforge.common.ForgeMod; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fluids.FluidInteractionRegistry; import net.minecraftforge.fluids.FluidType; @@ -46,6 +43,7 @@ import net.minecraftforge.registries.RegistryObject; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; +import org.joml.Vector3f; import java.util.function.Consumer; import java.util.stream.Stream; @@ -158,7 +156,7 @@ public class FluidTypeTest private static final RegistryObject TEST_FLUID_BLOCK = BLOCKS.register("test_fluid_block", () -> new LiquidBlock(TEST_FLUID, BlockBehaviour.Properties.of(Material.WATER).noCollission().strength(100.0F).noLootTable())); private static final RegistryObject TEST_FLUID_BUCKET = ITEMS.register("test_fluid_bucket", () -> - new BucketItem(TEST_FLUID, new Item.Properties().craftRemainder(Items.BUCKET).stacksTo(1).tab(CreativeModeTab.TAB_MISC))); + new BucketItem(TEST_FLUID, new Item.Properties().craftRemainder(Items.BUCKET).stacksTo(1))); public FluidTypeTest() { @@ -177,6 +175,17 @@ public class FluidTypeTest modEventBus.addListener(this::commonSetup); DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> new FluidTypeTestClient(modEventBus)); + + FMLJavaModLoadingContext.get().getModEventBus().addListener(new Consumer() { + @Override + public void accept(CreativeModeTabEvent.BuildContents onBuildContents) { + if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) { + onBuildContents.register((flags, output, permission) -> { + output.accept(new ItemStack(TEST_FLUID_BUCKET.get())); + }); + } + } + }); } } diff --git a/src/test/java/net/minecraftforge/debug/fluid/NewFluidTest.java b/src/test/java/net/minecraftforge/debug/fluid/NewFluidTest.java index 1fadede73b..84ca69fc4d 100644 --- a/src/test/java/net/minecraftforge/debug/fluid/NewFluidTest.java +++ b/src/test/java/net/minecraftforge/debug/fluid/NewFluidTest.java @@ -5,6 +5,7 @@ package net.minecraftforge.debug.fluid; +import net.minecraft.world.item.*; import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.block.state.properties.BooleanProperty; @@ -13,6 +14,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.LevelAccessor; import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.fluids.DispenseFluidContainer; import net.minecraftforge.fluids.FluidType; import org.apache.commons.lang3.Validate; @@ -33,12 +35,6 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraft.world.level.block.state.BlockBehaviour.Properties; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.BucketItem; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.DispenserBlock; @@ -116,7 +112,7 @@ public class NewFluidTest new LiquidBlock(test_fluid, Properties.of(Material.WATER).noCollission().strength(100.0F).noLootTable()) ); public static RegistryObject test_fluid_bucket = ITEMS.register("test_fluid_bucket", () -> - new BucketItem(test_fluid, new Item.Properties().craftRemainder(Items.BUCKET).stacksTo(1).tab(CreativeModeTab.TAB_MISC)) + new BucketItem(test_fluid, new Item.Properties().craftRemainder(Items.BUCKET).stacksTo(1)) ); // WARNING: this doesn't allow "any fluid", only the fluid from this test mod! @@ -124,7 +120,7 @@ public class NewFluidTest new FluidloggableBlock(Properties.of(Material.WOOD).noCollission().strength(100.0F).noLootTable()) ); public static RegistryObject fluidloggable_blockitem = ITEMS.register("fluidloggable_block", () -> - new BlockItem(fluidloggable_block.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)) + new BlockItem(fluidloggable_block.get(), new Item.Properties()) ); public NewFluidTest() @@ -139,6 +135,15 @@ public class NewFluidTest ITEMS.register(modEventBus); FLUID_TYPES.register(modEventBus); FLUIDS.register(modEventBus); + + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(fluidloggable_blockitem.get()); + output.accept(test_fluid_bucket.get()); + }); + } + }); } } diff --git a/src/test/java/net/minecraftforge/debug/item/CustomElytraTest.java b/src/test/java/net/minecraftforge/debug/item/CustomElytraTest.java index 185d20b69a..429c47566b 100644 --- a/src/test/java/net/minecraftforge/debug/item/CustomElytraTest.java +++ b/src/test/java/net/minecraftforge/debug/item/CustomElytraTest.java @@ -7,6 +7,7 @@ package net.minecraftforge.debug.item; import net.minecraft.client.model.geom.EntityModelSet; import net.minecraft.client.renderer.entity.LivingEntityRenderer; +import net.minecraft.world.item.*; import net.minecraft.world.level.block.DispenserBlock; import net.minecraft.client.Minecraft; import net.minecraft.client.player.AbstractClientPlayer; @@ -19,6 +20,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; @@ -29,25 +31,30 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraft.world.item.Item.Properties; -import net.minecraft.world.item.ArmorItem; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.function.Consumer; + @Mod(CustomElytraTest.MOD_ID) @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = CustomElytraTest.MOD_ID) public class CustomElytraTest { public static final String MOD_ID = "custom_elytra_test"; private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); - private static final RegistryObject TEST_ELYTRA = ITEMS.register("test_elytra",() -> new CustomElytra(new Properties().durability(100).tab(CreativeModeTab.TAB_MISC))); + private static final RegistryObject TEST_ELYTRA = ITEMS.register("test_elytra",() -> new CustomElytra(new Properties().durability(100))); public CustomElytraTest() { final IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus(); ITEMS.register(modBus); modBus.addListener(this::onClientSetup); + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(TEST_ELYTRA.get()); + }); + } + }); } private void onClientSetup(FMLClientSetupEvent event) diff --git a/src/test/java/net/minecraftforge/debug/item/CustomMobBucketTest.java b/src/test/java/net/minecraftforge/debug/item/CustomMobBucketTest.java index 93c3b943a3..02b94f90b2 100644 --- a/src/test/java/net/minecraftforge/debug/item/CustomMobBucketTest.java +++ b/src/test/java/net/minecraftforge/debug/item/CustomMobBucketTest.java @@ -7,10 +7,11 @@ package net.minecraftforge.debug.item; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; import net.minecraft.world.item.MobBucketItem; import net.minecraft.world.level.material.Fluids; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -18,6 +19,8 @@ import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; +import java.util.function.Consumer; + @Mod(CustomMobBucketTest.MODID) public class CustomMobBucketTest { @@ -30,7 +33,7 @@ public class CustomMobBucketTest () -> EntityType.COW, () -> Fluids.WATER, () -> SoundEvents.BUCKET_EMPTY_FISH, - (new Item.Properties()).stacksTo(1).tab(CreativeModeTab.TAB_MISC))); + (new Item.Properties()).stacksTo(1))); public CustomMobBucketTest() { @@ -38,6 +41,13 @@ public class CustomMobBucketTest { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); ITEMS.register(modEventBus); + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(COW_BUCKET.get()); + }); + } + }); } } } diff --git a/src/test/java/net/minecraftforge/debug/item/CustomShieldTest.java b/src/test/java/net/minecraftforge/debug/item/CustomShieldTest.java index ca59d3acb2..4c0c97559c 100644 --- a/src/test/java/net/minecraftforge/debug/item/CustomShieldTest.java +++ b/src/test/java/net/minecraftforge/debug/item/CustomShieldTest.java @@ -8,30 +8,37 @@ package net.minecraftforge.debug.item; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.UseAnim; +import net.minecraft.world.item.*; import net.minecraft.world.level.Level; import net.minecraftforge.common.ToolAction; import net.minecraftforge.common.ToolActions; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.DeferredRegister; +import java.util.function.Consumer; + @Mod("custom_shield_test") public class CustomShieldTest { private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, "custom_shield_test"); private static final RegistryObject CUSTOM_SHIELD_ITEM = ITEMS.register("custom_shield", - () -> new CustomShieldItem((new Item.Properties()).durability(336).tab(CreativeModeTab.TAB_COMBAT))); + () -> new CustomShieldItem((new Item.Properties()).durability(336))); public CustomShieldTest() { ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.COMBAT) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(CUSTOM_SHIELD_ITEM.get()); + }); + } + }); } private static class CustomShieldItem extends Item diff --git a/src/test/java/net/minecraftforge/debug/item/EnderMaskTest.java b/src/test/java/net/minecraftforge/debug/item/EnderMaskTest.java index 35b7faac0b..5f34612f4f 100644 --- a/src/test/java/net/minecraftforge/debug/item/EnderMaskTest.java +++ b/src/test/java/net/minecraftforge/debug/item/EnderMaskTest.java @@ -8,6 +8,8 @@ package net.minecraftforge.debug.item; import net.minecraft.world.entity.monster.EnderMan; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.*; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; @@ -15,11 +17,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; -import net.minecraft.world.item.ArmorItem; -import net.minecraft.world.item.ArmorMaterials; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; +import java.util.function.Consumer; @Mod(EnderMaskTest.MODID) public class EnderMaskTest @@ -28,7 +26,7 @@ public class EnderMaskTest public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); public static RegistryObject ender_mask = ITEMS.register("ender_mask", () -> - new ArmorItem(ArmorMaterials.LEATHER, EquipmentSlot.HEAD, (new Item.Properties().tab(CreativeModeTab.TAB_MISC))) + new ArmorItem(ArmorMaterials.LEATHER, EquipmentSlot.HEAD, (new Item.Properties())) { @Override public boolean isEnderMask(ItemStack stack, Player player, EnderMan endermanEntity) @@ -42,5 +40,12 @@ public class EnderMaskTest { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); ITEMS.register(modEventBus); + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(ender_mask.get()); + }); + } + }); } } diff --git a/src/test/java/net/minecraftforge/debug/item/ForgeSpawnEggItemTest.java b/src/test/java/net/minecraftforge/debug/item/ForgeSpawnEggItemTest.java index 06c6bd3b84..d9b901303b 100644 --- a/src/test/java/net/minecraftforge/debug/item/ForgeSpawnEggItemTest.java +++ b/src/test/java/net/minecraftforge/debug/item/ForgeSpawnEggItemTest.java @@ -6,6 +6,8 @@ package net.minecraftforge.debug.item; import java.util.Map; +import java.util.function.Consumer; + import net.minecraft.client.renderer.entity.PigRenderer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; @@ -13,12 +15,13 @@ import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.AttributeInstance; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.animal.Pig; -import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.EntityRenderersEvent; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.common.ForgeSpawnEggItem; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.event.entity.EntityAttributeCreationEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -41,7 +44,7 @@ public class ForgeSpawnEggItemTest private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); private static final RegistryObject EGG = ITEMS.register("test_spawn_egg", () -> - new ForgeSpawnEggItem(ENTITY, 0x0000FF, 0xFF0000, new Item.Properties().tab(CreativeModeTab.TAB_MISC)) + new ForgeSpawnEggItem(ENTITY, 0x0000FF, 0xFF0000, new Item.Properties()) ); public ForgeSpawnEggItemTest() @@ -52,6 +55,13 @@ public class ForgeSpawnEggItemTest ENTITIES.register(FMLJavaModLoadingContext.get().getModEventBus()); FMLJavaModLoadingContext.get().getModEventBus().register(this); + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(EGG.get()); + }); + } + }); } } diff --git a/src/test/java/net/minecraftforge/debug/item/HiddenTooltipPartsTest.java b/src/test/java/net/minecraftforge/debug/item/HiddenTooltipPartsTest.java index fc1ebb3b90..e2f73743d9 100644 --- a/src/test/java/net/minecraftforge/debug/item/HiddenTooltipPartsTest.java +++ b/src/test/java/net/minecraftforge/debug/item/HiddenTooltipPartsTest.java @@ -12,9 +12,10 @@ import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation; import net.minecraft.world.entity.ai.attributes.Attributes; -import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; @@ -22,7 +23,7 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import org.jetbrains.annotations.NotNull; -import java.util.Set; +import java.util.function.Consumer; @Mod(HiddenTooltipPartsTest.MOD_ID) @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, modid = HiddenTooltipPartsTest.MOD_ID) @@ -32,11 +33,18 @@ public class HiddenTooltipPartsTest public static final boolean ENABLED = true; private static final AttributeModifier MODIFIER = new AttributeModifier(MOD_ID, 10f, Operation.ADDITION); private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); - private static final RegistryObject TEST_ITEM = ITEMS.register("test_item", () -> new TestItem(new Item.Properties().tab(CreativeModeTab.TAB_MISC))); + private static final RegistryObject TEST_ITEM = ITEMS.register("test_item", () -> new TestItem(new Item.Properties())); public HiddenTooltipPartsTest() { ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(TEST_ITEM.get()); + }); + } + }); } static class TestItem extends Item diff --git a/src/test/java/net/minecraftforge/debug/item/MusicDiscTest.java b/src/test/java/net/minecraftforge/debug/item/MusicDiscTest.java index acd7cb5228..c00a60741e 100644 --- a/src/test/java/net/minecraftforge/debug/item/MusicDiscTest.java +++ b/src/test/java/net/minecraftforge/debug/item/MusicDiscTest.java @@ -27,7 +27,7 @@ public class MusicDiscTest private static final DeferredRegister SOUND_EVENTS = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, MOD_ID); private static final RegistryObject TEST_SOUND_EVENT = SOUND_EVENTS.register("test_sound_event", - () -> new SoundEvent(new ResourceLocation(MOD_ID, "test_sound_event"))); + () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(MOD_ID, "test_sound_event"))); private static final RegistryObject TEST_MUSIC_DISC = ITEMS.register("test_music_disc", () -> new RecordItem(1, TEST_SOUND_EVENT, new Item.Properties().stacksTo(1).rarity(Rarity.EPIC), 20)); diff --git a/src/test/java/net/minecraftforge/debug/item/RangedMobsUseModdedWeaponsTest.java b/src/test/java/net/minecraftforge/debug/item/RangedMobsUseModdedWeaponsTest.java index 0bcf1e851b..71a317f90b 100644 --- a/src/test/java/net/minecraftforge/debug/item/RangedMobsUseModdedWeaponsTest.java +++ b/src/test/java/net/minecraftforge/debug/item/RangedMobsUseModdedWeaponsTest.java @@ -7,11 +7,8 @@ package net.minecraftforge.debug.item; import net.minecraft.client.renderer.item.ItemProperties; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.BowItem; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.CrossbowItem; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Items; +import net.minecraft.world.item.*; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; @@ -20,6 +17,8 @@ import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import java.util.function.Consumer; + @Mod(RangedMobsUseModdedWeaponsTest.MOD_ID) public class RangedMobsUseModdedWeaponsTest { @@ -34,10 +33,10 @@ public class RangedMobsUseModdedWeaponsTest { private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); private static final RegistryObject MODDED_BOW = ITEMS.register("modded_bow", () -> - new BowItem(new Item.Properties().tab(CreativeModeTab.TAB_COMBAT).defaultDurability(384)) + new BowItem(new Item.Properties().defaultDurability(384)) ); private static final RegistryObject MODDED_CROSSBOW = ITEMS.register("modded_crossbow", () -> - new CrossbowItem(new Item.Properties().tab(CreativeModeTab.TAB_COMBAT).defaultDurability(326)) + new CrossbowItem(new Item.Properties().defaultDurability(326)) ); public RangedMobsUseModdedWeaponsTest() @@ -46,6 +45,14 @@ public class RangedMobsUseModdedWeaponsTest { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); ITEMS.register(modEventBus); modEventBus.addListener(this::onClientSetup); + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.COMBAT) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(MODDED_BOW.get()); + output.accept(MODDED_CROSSBOW.get()); + }); + } + }); } } diff --git a/src/test/java/net/minecraftforge/debug/item/SnowBootsTest.java b/src/test/java/net/minecraftforge/debug/item/SnowBootsTest.java index 8b490c5493..23195b82fc 100644 --- a/src/test/java/net/minecraftforge/debug/item/SnowBootsTest.java +++ b/src/test/java/net/minecraftforge/debug/item/SnowBootsTest.java @@ -7,13 +7,8 @@ package net.minecraftforge.debug.item; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.monster.EnderMan; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ArmorItem; -import net.minecraft.world.item.ArmorMaterials; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.*; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -21,6 +16,8 @@ import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; +import java.util.function.Consumer; + @Mod(SnowBootsTest.MODID) public class SnowBootsTest { @@ -28,7 +25,7 @@ public class SnowBootsTest public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); public static RegistryObject snow_boots = ITEMS.register("snow_boots", () -> - new ArmorItem(ArmorMaterials.DIAMOND, EquipmentSlot.FEET, (new Item.Properties().tab(CreativeModeTab.TAB_MISC))) + new ArmorItem(ArmorMaterials.DIAMOND, EquipmentSlot.FEET, (new Item.Properties())) { @Override public boolean canWalkOnPowderedSnow(ItemStack stack, LivingEntity wearer) { @@ -41,5 +38,12 @@ public class SnowBootsTest { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); ITEMS.register(modEventBus); + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.COMBAT) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(snow_boots.get()); + }); + } + }); } } diff --git a/src/test/java/net/minecraftforge/debug/item/TagBasedToolTypesTest.java b/src/test/java/net/minecraftforge/debug/item/TagBasedToolTypesTest.java index 70070d6071..dd545077f9 100644 --- a/src/test/java/net/minecraftforge/debug/item/TagBasedToolTypesTest.java +++ b/src/test/java/net/minecraftforge/debug/item/TagBasedToolTypesTest.java @@ -5,13 +5,14 @@ package net.minecraftforge.debug.item; +import net.minecraft.core.HolderLookup; import net.minecraft.data.DataGenerator; -import net.minecraft.data.loot.BlockLoot; +import net.minecraft.data.loot.BlockLootSubProvider; import net.minecraft.data.loot.LootTableProvider; -import net.minecraft.data.tags.BlockTagsProvider; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; import net.minecraft.tags.TagKey; +import net.minecraft.world.flag.FeatureFlags; import net.minecraft.world.item.*; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.block.Block; @@ -19,10 +20,6 @@ import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.MaterialColor; -import net.minecraft.world.level.storage.loot.LootTable; -import net.minecraft.world.level.storage.loot.LootTables; -import net.minecraft.world.level.storage.loot.ValidationContext; -import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import net.minecraftforge.client.model.generators.BlockStateProvider; import net.minecraftforge.client.model.generators.ItemModelProvider; @@ -30,7 +27,9 @@ import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.client.model.generators.ModelFile.UncheckedModelFile; import net.minecraftforge.common.ForgeTier; import net.minecraftforge.common.TierSortingRegistry; +import net.minecraftforge.common.data.BlockTagsProvider; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -41,15 +40,11 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import java.util.List; -import java.util.Map; -import java.util.function.BiConsumer; +import java.util.Set; import java.util.function.Consumer; import java.util.function.Supplier; import java.util.stream.Collectors; -import com.google.common.collect.ImmutableList; -import com.mojang.datafixers.util.Pair; - @Mod(TagBasedToolTypesTest.MODID) public class TagBasedToolTypesTest { @@ -69,10 +64,10 @@ public class TagBasedToolTypesTest private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); @SuppressWarnings("unused") - private static final RegistryObject ORE_ITEM = ITEMS.register(STONE.getId().getPath(), () -> new BlockItem(STONE.get(), (new Item.Properties()).tab(CreativeModeTab.TAB_BUILDING_BLOCKS))); + private static final RegistryObject ORE_ITEM = ITEMS.register(STONE.getId().getPath(), () -> new BlockItem(STONE.get(), (new Item.Properties()))); private static final RegistryObject TOOL = ITEMS.register("test_tool", () -> { - return new DiggerItem(1, 1, MY_TIER, MINEABLE_TAG, new Item.Properties().tab(CreativeModeTab.TAB_TOOLS)) + return new DiggerItem(1, 1, MY_TIER, MINEABLE_TAG, new Item.Properties()) { @Override public float getDestroySpeed(ItemStack stack, BlockState state) @@ -102,6 +97,22 @@ public class TagBasedToolTypesTest BLOCKS.register(modEventBus); ITEMS.register(modEventBus); modEventBus.addListener(this::gatherData); + + FMLJavaModLoadingContext.get().getModEventBus().addListener(new Consumer() { + @Override + public void accept(CreativeModeTabEvent.BuildContents onBuildContents) { + if (onBuildContents.getTab() == CreativeModeTabs.TOOLS_AND_UTILITIES) { + onBuildContents.register((flags, output, permission) -> { + output.accept(TOOL.get()); + }); + } else if (onBuildContents.getTab() == CreativeModeTabs.BUILDING_BLOCKS) { + onBuildContents.register((flags, output, permission) -> { + output.accept(ORE_ITEM.get()); + }); + } + } + + }); } @SubscribeEvent @@ -110,47 +121,35 @@ public class TagBasedToolTypesTest DataGenerator gen = event.getGenerator(); ExistingFileHelper existing = event.getExistingFileHelper(); - gen.addProvider(event.includeServer(), new BlockTagsProvider(gen, MODID, existing) + gen.addProvider(event.includeServer(), new BlockTagsProvider(gen.getPackOutput(), event.getLookupProvider(), MODID, existing) { @Override - protected void addTags() - { + protected void addTags(HolderLookup.Provider registry) { this.tag(MINEABLE_TAG).add(STONE.get()); this.tag(REQUIRES_TAG).add(STONE.get()); } }); - gen.addProvider(event.includeServer(), new LootTableProvider(gen) - { - @Override - protected void validate(Map map, ValidationContext validationtracker) + final class TestBlockLootProvider extends BlockLootSubProvider { + public TestBlockLootProvider() { - map.forEach((name, table) -> LootTables.validate(validationtracker, name, table)); + super(Set.of(), FeatureFlags.REGISTRY.allFlags()); } @Override - protected List>>, LootContextParamSet>> getTables() + protected Iterable getKnownBlocks() { - return ImmutableList.of(Pair.of(() -> - { - return new BlockLoot() - { - - @Override - protected Iterable getKnownBlocks() - { - return BLOCKS.getEntries().stream().map(Supplier::get).collect(Collectors.toList()); - } - - @Override - protected void addTables() - { - this.dropSelf(STONE.get()); - } - }; - }, LootContextParamSets.BLOCK)); + return BLOCKS.getEntries().stream().map(Supplier::get).collect(Collectors.toList()); } - }); + + @Override + protected void generate() + { + this.dropSelf(STONE.get()); + } + } + + gen.addProvider(event.includeServer(), new LootTableProvider(event.getGenerator().getPackOutput(), Set.of(), List.of(new LootTableProvider.SubProviderEntry(TestBlockLootProvider::new, LootContextParamSets.BLOCK)))); gen.addProvider(event.includeClient(), new BlockStateProvider(gen, MODID, existing) { diff --git a/src/test/java/net/minecraftforge/debug/misc/DataPackRegistriesTest.java b/src/test/java/net/minecraftforge/debug/misc/DataPackRegistriesTest.java index 331269fa66..42a482d749 100644 --- a/src/test/java/net/minecraftforge/debug/misc/DataPackRegistriesTest.java +++ b/src/test/java/net/minecraftforge/debug/misc/DataPackRegistriesTest.java @@ -5,28 +5,24 @@ package net.minecraftforge.debug.misc; -import java.io.IOException; -import java.nio.file.Path; -import java.util.Locale; - -import net.minecraft.data.CachedOutput; -import org.slf4j.Logger; - import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import com.mojang.logging.LogUtils; import com.mojang.serialization.Codec; import com.mojang.serialization.JsonOps; - +import java.nio.file.Path; +import java.util.Locale; +import java.util.concurrent.CompletableFuture; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.core.Holder; +import net.minecraft.core.HolderLookup; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; +import net.minecraft.data.CachedOutput; import net.minecraft.data.DataGenerator; import net.minecraft.data.DataProvider; -import net.minecraft.data.HashCache; import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; @@ -34,17 +30,16 @@ import net.minecraft.server.packs.PackType; import net.minecraft.tags.TagKey; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.event.TagsUpdatedEvent; import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLEnvironment; import net.minecraftforge.fml.util.thread.EffectiveSide; -import net.minecraftforge.data.event.GatherDataEvent; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.RegistryBuilder; +import net.minecraftforge.registries.DataPackRegistryEvent; import net.minecraftforge.registries.RegistryObject; +import org.slf4j.Logger; /** *

This test class shows an example of how to register unsynced and synced datapack registries, @@ -58,7 +53,7 @@ import net.minecraftforge.registries.RegistryObject; *

  • data/data_pack_registries_test/tags/data_pack_registries_test/syncable/test.json
  • * */ -@Mod(DataPackRegistriesTest.MODID) +//@Mod(DataPackRegistriesTest.MODID) public class DataPackRegistriesTest { private static final boolean ENABLED = true; @@ -66,7 +61,8 @@ public class DataPackRegistriesTest private static final Logger LOGGER = LogUtils.getLogger(); private static final ResourceLocation TEST_RL = new ResourceLocation(MODID, "test"); - private final RegistryObject datagenTestObject; + //TODO: Fix datapack generation for it. + private final RegistryObject datagenTestObject = null; public DataPackRegistriesTest() { @@ -76,23 +72,10 @@ public class DataPackRegistriesTest final IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus(); final IEventBus forgeBus = MinecraftForge.EVENT_BUS; - // Deferred Registers can be created for datapack registries in static init or mod constructor. - // (We'll do it in mod constructor, as when doing the ENABLED check it's less verbose than static init.) - // As with static registries, any mod can make a Deferred Register for a given datapack registry, - // but only one mod can register the internal registry with makeRegistry. - final DeferredRegister unsyncables = DeferredRegister.create(Unsyncable.REGISTRY_KEY, MODID); - final DeferredRegister syncables = DeferredRegister.create(Syncable.REGISTRY_KEY, MODID); - - // RegistryBuilder#dataPackRegistry marks the registry as a datapack registry rather than a static registry. - unsyncables.makeRegistry(() -> new RegistryBuilder().disableSaving().dataPackRegistry(Unsyncable.DIRECT_CODEC)); - // The overload of #dataPackRegistry that takes a second codec marks the datapack registry as syncable. - syncables.makeRegistry(() -> new RegistryBuilder().disableSaving().dataPackRegistry(Syncable.DIRECT_CODEC, Syncable.DIRECT_CODEC)); - - // Datapack registry elements can be datagenerated, but they must be registered as builtin objects first. - this.datagenTestObject = unsyncables.register("datagen_test", () -> new Unsyncable("Datagen Success")); - - unsyncables.register(modBus); - syncables.register(modBus); + modBus.addListener((DataPackRegistryEvent.NewRegistry event) -> { + event.dataPackRegistry(ResourceKey.createRegistryKey(new ResourceLocation(MODID, "unsyncable")), Unsyncable.DIRECT_CODEC); + event.dataPackRegistry(ResourceKey.createRegistryKey(new ResourceLocation(MODID, "syncable")), Syncable.DIRECT_CODEC, Syncable.DIRECT_CODEC); + }); modBus.addListener(this::onGatherData); forgeBus.addListener(this::onServerStarting); @@ -109,33 +92,32 @@ public class DataPackRegistriesTest // Objects to be datagenerated must be registered (e.g. via DeferredRegister above). // This outputs to data/data_pack_registries_test/data_pack_registries_test/unsyncable/datagen_test.json final DataGenerator generator = event.getGenerator(); - final Path outputFolder = generator.getOutputFolder(); - final RegistryOps ops = RegistryOps.create(JsonOps.INSTANCE, RegistryAccess.BUILTIN.get()); + final Path outputFolder = generator.getPackOutput().getOutputFolder(); + final CompletableFuture providerCompletableFuture = event.getLookupProvider(); final Gson gson = new GsonBuilder().setPrettyPrinting().create(); final ResourceLocation registryId = Unsyncable.REGISTRY_KEY.location(); final ResourceLocation id = this.datagenTestObject.getId(); - final Unsyncable element = this.datagenTestObject.get(); + final Unsyncable element = new Unsyncable("Datagen Success"); final String pathString = String.join("/", PackType.SERVER_DATA.getDirectory(), id.getNamespace(), registryId.getNamespace(), registryId.getPath(), id.getPath()+".json"); final Path path = outputFolder.resolve(pathString); generator.addProvider(event.includeServer(), new DataProvider() { @Override - public void run(final CachedOutput cache) throws IOException + public CompletableFuture run(final CachedOutput cache) { - Unsyncable.DIRECT_CODEC.encodeStart(ops, element) - .resultOrPartial(msg -> LOGGER.error("Failed to encode {}: {}", path, msg)) // Log error on encode failure. - .ifPresent(json -> // Output to file on encode success. - { - try - { - DataProvider.saveStable(cache, json, path); - } - catch (IOException e) // The throws can't deal with this exception, because we're inside the ifPresent. - { - LOGGER.error("Failed to save " + pathString, e); - } - }); + return providerCompletableFuture.thenCompose(provider -> { + final RegistryOps ops = RegistryOps.create(JsonOps.INSTANCE, provider); + + Unsyncable.DIRECT_CODEC.encodeStart(ops, element) + .resultOrPartial(msg -> LOGGER.error("Failed to encode {}: {}", path, msg)) // Log error on encode failure. + .ifPresent(json -> // Output to file on encode success. + { + DataProvider.saveStable(cache, json, path); + }); + + return CompletableFuture.allOf(); + }); } @Override diff --git a/src/test/java/net/minecraftforge/debug/misc/GameTestTest.java b/src/test/java/net/minecraftforge/debug/misc/GameTestTest.java index e6126d1734..51fc12018a 100644 --- a/src/test/java/net/minecraftforge/debug/misc/GameTestTest.java +++ b/src/test/java/net/minecraftforge/debug/misc/GameTestTest.java @@ -12,10 +12,7 @@ import net.minecraft.gametest.framework.GameTestGenerator; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.gametest.framework.TestFunction; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Items; +import net.minecraft.world.item.*; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.EntityBlock; @@ -31,6 +28,7 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.EnergyStorage; import net.minecraftforge.energy.IEnergyStorage; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.event.RegisterGameTestsEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -44,6 +42,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; +import java.util.function.Consumer; @Mod(GameTestTest.MODID) public class GameTestTest @@ -57,7 +56,7 @@ public class GameTestTest () -> new EnergyBlock(Properties.of(Material.STONE, MaterialColor.STONE))); @SuppressWarnings("unused") private static final RegistryObject ENERGY_BLOCK_ITEM = ITEMS.register("energy_block", - () -> new BlockItem(ENERGY_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC))); + () -> new BlockItem(ENERGY_BLOCK.get(), new Item.Properties())); private static final RegistryObject> ENERGY_BLOCK_ENTITY = BLOCK_ENTITIES.register("energy", () -> BlockEntityType.Builder.of(EnergyBlockEntity::new, ENERGY_BLOCK.get()).build(null)); @@ -71,6 +70,14 @@ public class GameTestTest BLOCKS.register(modBus); ITEMS.register(modBus); BLOCK_ENTITIES.register(modBus); + + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(ENERGY_BLOCK_ITEM.get()); + }); + } + }); } } diff --git a/src/test/java/net/minecraftforge/debug/misc/ModMismatchTest.java b/src/test/java/net/minecraftforge/debug/misc/ModMismatchTest.java index 8016a53b1f..ede181f52c 100644 --- a/src/test/java/net/minecraftforge/debug/misc/ModMismatchTest.java +++ b/src/test/java/net/minecraftforge/debug/misc/ModMismatchTest.java @@ -55,7 +55,7 @@ public class ModMismatchTest if (REGISTER_REGISTRY_ENTRY && FMLEnvironment.dist == Dist.DEDICATED_SERVER) { IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus(); - SOUND_EVENTS.register("mismatching_sound_event", () -> new SoundEvent(new ResourceLocation(MOD_ID, "server.connect.fail"))); + SOUND_EVENTS.register("mismatching_sound_event", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(MOD_ID, "server.connect.fail"))); SOUND_EVENTS.register(eventBus); } } diff --git a/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestScreen.java b/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestScreen.java index 8f17115562..50c0e17f21 100644 --- a/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestScreen.java +++ b/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestScreen.java @@ -131,13 +131,6 @@ public class RecipeBookTestScreen extends AbstractContainerScreenThis tests the following features and requirements of biome modifier jsons::

    *
      @@ -62,7 +68,8 @@ import net.minecraftforge.registries.RegistryObject; *

      If the biome modifiers are applied correctly, then badlands biomes should generate large basalt columns, * spawn magma cubes, have red-colored water, and be snowy. Additionally, biomes in the is_forest tag are missing * oak trees, pine trees, and skeletons.

      - */ + *//* + @Mod(BiomeModifierTest.MODID) public class BiomeModifierTest { @@ -195,3 +202,4 @@ public class BiomeModifierTest } } } +*/ diff --git a/src/test/java/net/minecraftforge/debug/world/DimensionSettingsTest.java b/src/test/java/net/minecraftforge/debug/world/DimensionSettingsTest.java index 97b7bf678a..f6762c31cf 100644 --- a/src/test/java/net/minecraftforge/debug/world/DimensionSettingsTest.java +++ b/src/test/java/net/minecraftforge/debug/world/DimensionSettingsTest.java @@ -5,19 +5,7 @@ package net.minecraftforge.debug.world; -import com.sun.jna.Structure; -import net.minecraft.data.BuiltinRegistries; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.HashMap; -import java.util.Optional; /** * To see the effects of this test mod you must create a new world then teleport to the custom diff --git a/src/test/java/net/minecraftforge/debug/world/ForgeChunkManagerTest.java b/src/test/java/net/minecraftforge/debug/world/ForgeChunkManagerTest.java index 35ca6da51d..a49c62979a 100644 --- a/src/test/java/net/minecraftforge/debug/world/ForgeChunkManagerTest.java +++ b/src/test/java/net/minecraftforge/debug/world/ForgeChunkManagerTest.java @@ -9,18 +9,20 @@ import com.mojang.datafixers.util.Pair; import it.unimi.dsi.fastutil.longs.LongSet; import java.util.Map; import java.util.UUID; +import java.util.function.Consumer; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.core.BlockPos; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.world.ForgeChunkManager; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; @@ -41,7 +43,7 @@ public class ForgeChunkManagerTest private static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID); private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); private static final RegistryObject CHUNK_LOADER_BLOCK = BLOCKS.register("chunk_loader", () -> new ChunkLoaderBlock(Properties.of(Material.STONE))); - private static final RegistryObject CHUNK_LOADER_ITEM = ITEMS.register("chunk_loader", () -> new BlockItem(CHUNK_LOADER_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC))); + private static final RegistryObject CHUNK_LOADER_ITEM = ITEMS.register("chunk_loader", () -> new BlockItem(CHUNK_LOADER_BLOCK.get(), new Item.Properties())); public ForgeChunkManagerTest() { @@ -49,6 +51,13 @@ public class ForgeChunkManagerTest modEventBus.addListener(this::commonSetup); BLOCKS.register(modEventBus); ITEMS.register(modEventBus); + FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer) onBuildContents -> { + if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) { + onBuildContents.register((flags, output, permissions) -> { + output.accept(CHUNK_LOADER_ITEM.get()); + }); + } + }); } private void commonSetup(FMLCommonSetupEvent event) diff --git a/src/test/java/net/minecraftforge/debug/world/StructureModifierTest.java b/src/test/java/net/minecraftforge/debug/world/StructureModifierTest.java index 094cf9bf70..66bb3d942e 100644 --- a/src/test/java/net/minecraftforge/debug/world/StructureModifierTest.java +++ b/src/test/java/net/minecraftforge/debug/world/StructureModifierTest.java @@ -15,6 +15,7 @@ import net.minecraft.core.HolderSet; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryCodecs; +import net.minecraft.core.registries.Registries; import net.minecraft.data.DataGenerator; import net.minecraft.data.DataProvider; import net.minecraft.resources.RegistryOps; @@ -49,7 +50,7 @@ import org.apache.logging.log4j.Logger; @Mod(StructureModifierTest.MODID) public class StructureModifierTest { - private static final Codec> STRUCTURE_LIST_CODEC = RegistryCodecs.homogeneousList(Registry.STRUCTURE_REGISTRY, Structure.DIRECT_CODEC); + private static final Codec> STRUCTURE_LIST_CODEC = RegistryCodecs.homogeneousList(Registries.STRUCTURE, Structure.DIRECT_CODEC); public static final Logger LOGGER = LogManager.getLogger(); public static final String MODID = "structure_modifiers_test"; public static final boolean ENABLED = true; @@ -77,7 +78,9 @@ public class StructureModifierTest private void onGatherData(GatherDataEvent event) { - // Example of how to datagen datapack registry objects. +/* TODO: During the update to 1.19.3 data providers got partially turned into async executions. Creating a registry ops requires this. + + // Example of how to datagen datapack registry objects. DataGenerator generator = event.getGenerator(); final RegistryOps ops = RegistryOps.create(JsonOps.INSTANCE, RegistryAccess.BUILTIN.get()); @@ -91,7 +94,7 @@ public class StructureModifierTest DataProvider structureModifierProvider = JsonCodecProvider.forDatapackRegistry(generator, event.getExistingFileHelper(), MODID, ops, ForgeRegistries.Keys.STRUCTURE_MODIFIERS, Map.of(MODIFY_STRONGHOLD_RL, structureModifier)); - generator.addProvider(event.includeServer(), structureModifierProvider); + generator.addProvider(event.includeServer(), structureModifierProvider);*/ } public record TestModifier(HolderSet structures, MobCategory category, MobSpawnSettings.SpawnerData spawn) diff --git a/src/test/resources/META-INF/jarjar/metadata.json b/src/test/resources/META-INF/jarjar/metadata-broken.json similarity index 100% rename from src/test/resources/META-INF/jarjar/metadata.json rename to src/test/resources/META-INF/jarjar/metadata-broken.json diff --git a/src/test/resources/META-INF/mods.toml b/src/test/resources/META-INF/mods.toml index 5d5bfe507a..71dd1e7a86 100644 --- a/src/test/resources/META-INF/mods.toml +++ b/src/test/resources/META-INF/mods.toml @@ -6,8 +6,6 @@ license="LGPL v2.1" modId="eventtests" [[mods]] modId="client_command_test" -[[mods]] - modId="biome_modifiers_test" [[mods]] modId="structure_modifiers_test" [[mods]] @@ -244,7 +242,7 @@ modId="valid_railshape_test" modId="player_negotiation_event_test" [[mods]] modId="custom_rarity_test" -[[mods]] +[[modsDisabled]] modId="data_pack_registries_test" [[mods]] modId="mod_mismatch_test" @@ -270,6 +268,8 @@ modId="item_stacked_on_other_test" modId="ambient_occlusion_elements_test" [[mods]] modId="grindstone_event_test" +[[mods]] +modId="creative_mode_tab_test" # ADD ABOVE THIS LINE diff --git a/src/test/resources/assets/forgedebugitemlayermodel/blockstates/test_item.json b/src/test/resources/assets/forgedebugitemlayermodel/blockstates/test_item.json index 4fcba2edd9..c79a15e161 100644 --- a/src/test/resources/assets/forgedebugitemlayermodel/blockstates/test_item.json +++ b/src/test/resources/assets/forgedebugitemlayermodel/blockstates/test_item.json @@ -4,18 +4,6 @@ "inventory": { "model": "forge:item-layer", "transform": "forge:default-tool", - /*"transform": { - "thirdperson": { - "translation": [ 0, 0.078125, -0.21875 ], - "rotation": [ {"y": -90}, {"z": -35} ], - "scale": 0.85 - }, - "firstperson": { - "translation": [ 0, 0.25, 0.125 ], - "rotation": [ {"y": 135}, {"z": 25} ], - "scale": 1.7 - } - },*/ "textures": { "layer0": "items/diamond_pickaxe" } diff --git a/src/test/resources/assets/forgedebugmodelanimation/blockstates/test_animation_block.json b/src/test/resources/assets/forgedebugmodelanimation/blockstates/test_animation_block.json index 26dc74ed9d..40a0adfe61 100644 --- a/src/test/resources/assets/forgedebugmodelanimation/blockstates/test_animation_block.json +++ b/src/test/resources/assets/forgedebugmodelanimation/blockstates/test_animation_block.json @@ -7,11 +7,7 @@ "front": "blocks/log_oak", "chamber": "blocks/redstone_block", "trunk": "blocks/end_stone" - }/*, - "model": "forgedebugmodelloaderregistry:chest.b3d", - "custom": { - "mesh": ["Base", "Lid"] - }*/ + } }, "variants": { "normal": [{}], @@ -32,15 +28,9 @@ }, "static": { "true": { - /*"custom": { - "mesh": ["Base"] - }*/ "model": "forgedebugmodelanimation:engine" }, "false": { - /*"custom": { - "mesh": ["Lid"] - }*/ "model": "forgedebugmodelanimation:engine_ring" } }, diff --git a/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/custom_model_block.json b/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/custom_model_block.json index ee9d41488e..6c9db8588e 100644 --- a/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/custom_model_block.json +++ b/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/custom_model_block.json @@ -2,7 +2,6 @@ "forge_marker": 1, "defaults": { "textures": { - //"#texture": "forgedebugmodelloaderregistry:texture", "#chest": "entity/chest/normal" }, "model": "forgedebugmodelloaderregistry:chest.b3d", diff --git a/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/obj_custom_data_block.json b/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/obj_custom_data_block.json index e6af6f30ae..9aaaae5817 100644 --- a/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/obj_custom_data_block.json +++ b/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/obj_custom_data_block.json @@ -3,34 +3,29 @@ "defaults": { "textures": {}, "model": "forgedebugmodelloaderregistry:fancy_fence.obj" - //"custom": {"show": ["post"]} }, "variants": { "north": { "true": { "model": "forgedebugmodelloaderregistry:fancy_fence.obj" - //"custom": {"show": ["north"]} }, "false": {} }, "south": { "true": { "model": "forgedebugmodelloaderregistry:fancy_fence.obj" - //"custom": {"show": ["south"]} }, "false": {} }, "west": { "true": { "model": "forgedebugmodelloaderregistry:fancy_fence.obj" - //"custom": {"show": ["west"]} }, "false": {} }, "east": { "true": { "model": "forgedebugmodelloaderregistry:fancy_fence.obj" - //"custom": {"show": ["east"]} }, "false": {} } diff --git a/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/obj_tesseract_block.json b/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/obj_tesseract_block.json index 8b0446b987..44f5e142c0 100644 --- a/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/obj_tesseract_block.json +++ b/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/obj_tesseract_block.json @@ -2,7 +2,6 @@ "forge_marker": 1, "defaults": { "textures": { -// "#lambert7SG": "forgedebugmodelloaderregistry:texture" //the identifier must be a name of a material defined by the "model" obj's .mtl file }, "model": "forgedebugmodelloaderregistry:tesseract.obj" }, diff --git a/src/test/resources/assets/forgedebugmultilayermodel/blockstates/test_layer_block.json b/src/test/resources/assets/forgedebugmultilayermodel/disabled/blockstates/test_layer_block.json similarity index 100% rename from src/test/resources/assets/forgedebugmultilayermodel/blockstates/test_layer_block.json rename to src/test/resources/assets/forgedebugmultilayermodel/disabled/blockstates/test_layer_block.json diff --git a/src/test/resources/assets/forgedebugmultilayermodel/models/block/test_layer_block.json b/src/test/resources/assets/forgedebugmultilayermodel/disabled/models/block/test_layer_block.json similarity index 100% rename from src/test/resources/assets/forgedebugmultilayermodel/models/block/test_layer_block.json rename to src/test/resources/assets/forgedebugmultilayermodel/disabled/models/block/test_layer_block.json diff --git a/src/test/resources/assets/forgedebugmultilayermodel/models/item/test_layer_block.json b/src/test/resources/assets/forgedebugmultilayermodel/disabled/models/item/test_layer_block.json similarity index 100% rename from src/test/resources/assets/forgedebugmultilayermodel/models/item/test_layer_block.json rename to src/test/resources/assets/forgedebugmultilayermodel/disabled/models/item/test_layer_block.json diff --git a/src/test/resources/assets/new_model_loader_test/models/item/custom_transforms.json b/src/test/resources/assets/new_model_loader_test/models/item/custom_transforms.json index 4d8af77c4b..c0f8bba948 100644 --- a/src/test/resources/assets/new_model_loader_test/models/item/custom_transforms.json +++ b/src/test/resources/assets/new_model_loader_test/models/item/custom_transforms.json @@ -5,9 +5,9 @@ "textures": { "particle": "block/oak_planks" }, - "transform": { + "display": { "firstperson_righthand": { - "scale": 3.0 + "scale": [3.0, 3.0, 3.0] } } } diff --git a/src/test/resources/pack.mcmeta b/src/test/resources/pack.mcmeta index 54840e39b6..d4e620cc97 100644 --- a/src/test/resources/pack.mcmeta +++ b/src/test/resources/pack.mcmeta @@ -1,8 +1,8 @@ { "pack": { - "pack_format": 8, + "pack_format": 12, "description": "Forge tests resource pack", - "forge:resource_pack_format": 9, + "forge:resource_pack_format": 12, "forge:data_pack_format": 10 } } diff --git a/src/test/resources/test_nested_resource_pack/pack.mcmeta b/src/test/resources/test_nested_resource_pack/pack.mcmeta index 79454ac7a1..b54513bd63 100644 --- a/src/test/resources/test_nested_resource_pack/pack.mcmeta +++ b/src/test/resources/test_nested_resource_pack/pack.mcmeta @@ -1,8 +1,8 @@ { "pack": { - "pack_format": 8, + "pack_format": 12, "description": "Nested resource pack", - "forge:resource_pack_format": 9, + "forge:resource_pack_format": 12, "forge:data_pack_format": 10 } }