diff --git a/.gitignore b/.gitignore index 17132052f1..137ed073ba 100644 --- a/.gitignore +++ b/.gitignore @@ -26,7 +26,6 @@ /projects/mcp/ /projects/clean/ /projects/forge/ -#/patches/* #occupational hazards /projects/**/build/ @@ -35,20 +34,10 @@ /projects/**/*.launch /repo/ src/*/generated/**/.cache/ + # Generated by gradle every import **/src/main/resources/META-INF/MANIFEST.MF /fmlloader/src/main/resources/forge_version.json -#Patch rejects -#/patches-/ -#*.patch.rej -#/projects/*/rejects/ - -# FML changelog -changelog.txt -*.py -*.7z -/logs/ - /ForgeRoot.ipr /ForgeRoot.iws diff --git a/build_forge.gradle b/build_forge.gradle index 6d32a41e9a..96e1e6e949 100644 --- a/build_forge.gradle +++ b/build_forge.gradle @@ -47,6 +47,7 @@ jarSigner.autoDetect('forge') applyPatches { level 'WARNING' failOnError = UPDATING != 'true' + rejects = rootProject.layout.projectDirectory.dir('rejects').asFile } sourceSets { @@ -387,7 +388,7 @@ tasks.register("findFinalizeSpawnTargets", BytecodePredicateFinder) { return 'net/minecraft/world/level/BaseSpawner' != parent.name // Ignore this class as we special case it. && insn.getOpcode().equals(Opcodes.INVOKEVIRTUAL) && insn.name == 'm_6518_' - && insn.desc == '(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/MobSpawnType;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;'; + && insn.desc == '(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/EntitySpawnReason;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;'; } } tasks.register('validateDeprecations', ValidateDeprecations) { diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/ModList.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModList.java index e2ffdfa997..c091d78a9d 100644 --- a/fmlcore/src/main/java/net/minecraftforge/fml/ModList.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ModList.java @@ -15,12 +15,8 @@ import net.minecraftforge.fml.loading.moddiscovery.ModFile; import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo; import net.minecraftforge.fml.loading.moddiscovery.ModInfo; import net.minecraftforge.forgespi.locating.IModFile; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - import java.util.AbstractMap; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.List; @@ -32,8 +28,6 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; import java.util.concurrent.CompletionStage; import java.util.concurrent.Executor; -import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.ForkJoinWorkerThread; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.Consumer; @@ -45,9 +39,7 @@ import java.util.stream.Stream; * Master list of all mods - game-side version. This is classloaded in the game scope and * can dispatch game level events as a result. */ -public class ModList -{ - //private static final Logger LOGGER = LogManager.getLogger(); +public class ModList { private static ModList INSTANCE; private final List modFiles; private final List sortedList; @@ -57,8 +49,7 @@ public class ModList private List modFileScanData; private List sortedContainers; - private ModList(final List modFiles, final List sortedList) - { + private ModList(final List modFiles, final List sortedList) { this.modFiles = modFiles.stream().map(ModFile::getModFileInfo).map(ModFileInfo.class::cast).collect(Collectors.toList()); this.sortedList = sortedList.stream(). map(ModInfo.class::cast). @@ -82,12 +73,12 @@ public class ModList getModContainerState(mainMod.getModId()), ((ModFileInfo)mf.getModFileInfo()).getCodeSigningFingerprint().orElse("NOSIGNATURE")); } + private String crashReport() { return "\n"+applyForEachModFile(this::fileToLine).collect(Collectors.joining("\n\t\t", "\t\t", "")); } - public static ModList of(List modFiles, List sortedList) - { + public static ModList of(List modFiles, List sortedList) { INSTANCE = new ModList(modFiles, sortedList); return INSTANCE; } @@ -96,13 +87,11 @@ public class ModList return INSTANCE; } - public List getModFiles() - { + public List getModFiles() { return modFiles; } - public IModFileInfo getModFileById(String modid) - { + public IModFileInfo getModFileById(String modid) { return this.fileById.get(modid); } @@ -151,48 +140,39 @@ public class ModList return CompletableFuture.allOf(results).handle((r, th)->null).thenApply(res -> list); } - void setLoadedMods(final List modContainers) - { + void setLoadedMods(final List modContainers) { this.mods = modContainers; this.sortedContainers = modContainers.stream().sorted(Comparator.comparingInt(c->sortedList.indexOf(c.getModInfo()))).toList(); this.indexedMods = modContainers.stream().collect(Collectors.toMap(ModContainer::getModId, Function.identity())); } @SuppressWarnings("unchecked") - public Optional getModObjectById(String modId) - { + public Optional getModObjectById(String modId) { return getModContainerById(modId).map(ModContainer::getMod).map(o -> (T) o); } - public Optional getModContainerById(String modId) - { + public Optional getModContainerById(String modId) { return Optional.ofNullable(this.indexedMods.get(modId)); } - public Optional getModContainerByObject(Object obj) - { + public Optional getModContainerByObject(Object obj) { return mods.stream().filter(mc -> mc.getMod() == obj).findFirst(); } - public List getMods() - { + public List getMods() { return this.sortedList; } - public boolean isLoaded(String modTarget) - { + public boolean isLoaded(String modTarget) { return this.indexedMods.containsKey(modTarget); } - public int size() - { + public int size() { return mods.size(); } - public List getAllScanData() - { - if (modFileScanData == null) - { + public List getAllScanData() { + if (modFileScanData == null) { modFileScanData = this.sortedList.stream(). map(IModInfo::getOwningFile). filter(Objects::nonNull). @@ -205,8 +185,7 @@ public class ModList } - public void forEachModFile(Consumer fileConsumer) - { + public void forEachModFile(Consumer fileConsumer) { modFiles.stream().map(IModFileInfo::getFile).forEach(fileConsumer); } @@ -225,10 +204,4 @@ public class ModList public Stream applyForEachModContainer(Function function) { return indexedMods.values().stream().map(function); } - - private static class UncaughtModLoadingException extends ModLoadingException { - public UncaughtModLoadingException(ModLoadingStage stage, Throwable originalException) { - super(null, stage, "fml.modloading.uncaughterror", originalException); - } - } } diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingContext.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingContext.java index 30cba0f1c2..980c7c43a3 100644 --- a/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingContext.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingContext.java @@ -8,20 +8,15 @@ package net.minecraftforge.fml; import com.mojang.logging.LogUtils; import net.minecraftforge.fml.config.IConfigSpec; import net.minecraftforge.fml.config.ModConfig; -import net.minecraftforge.fml.loading.FMLLoader; import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.function.BiPredicate; import java.util.function.Supplier; -public class ModLoadingContext -{ +public class ModLoadingContext { private static final Logger LOGGER = LogUtils.getLogger(); private static final ThreadLocal context = ThreadLocal.withInitial(ModLoadingContext::new); private ModContainer activeContainer; private Object languageExtension; - private ModLoadingStage stage; /** * @deprecated Use the context provided by your language loader in your mod's constructor diff --git a/fmlearlydisplay/src/main/java/net/minecraftforge/fml/earlydisplay/DisplayWindow.java b/fmlearlydisplay/src/main/java/net/minecraftforge/fml/earlydisplay/DisplayWindow.java index 06d33b6d3c..81a2673d87 100644 --- a/fmlearlydisplay/src/main/java/net/minecraftforge/fml/earlydisplay/DisplayWindow.java +++ b/fmlearlydisplay/src/main/java/net/minecraftforge/fml/earlydisplay/DisplayWindow.java @@ -22,9 +22,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.awt.Desktop; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.URI; @@ -87,6 +85,7 @@ public class DisplayWindow implements ImmediateWindowProvider { private ScheduledFuture initializationFuture; private PerformanceInfo performanceInfo; + @SuppressWarnings("unused") private ScheduledFuture performanceTick; // The GL ID of the window. Used for all operations private long window; @@ -259,7 +258,11 @@ public class DisplayWindow implements ImmediateWindowProvider { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - this.elements.removeIf(element -> !element.render(context, framecount)); + for (var itr = this.elements.iterator(); itr.hasNext(); ) { + var element = itr.next(); + if (!element.render(context, framecount)) + itr.remove(); + } if (animationTimerTrigger.compareAndSet(true, false)) // we only increment the framecount on a periodic basis framecount++; } @@ -302,13 +305,6 @@ public class DisplayWindow implements ImmediateWindowProvider { } private void crashElegantly(String errorDetails) { - String qrText; - try (var is = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/glfailure.txt")))) { - qrText = is.lines().collect(Collectors.joining("\n")); - } catch (IOException ioe) { - qrText = ""; - } - StringBuilder msgBuilder = new StringBuilder(2000); msgBuilder.append("Failed to initialize graphics window with current settings.\n"); msgBuilder.append("\n\n"); @@ -407,13 +403,13 @@ public class DisplayWindow implements ImmediateWindowProvider { if (showHelpLog && versidx == 0) { LOGGER.info(""" If this message is the only thing at the bottom of your log before a crash, you probably have a driver issue. - + Possible solutions: A) Make sure Minecraft is set to prefer high performance graphics in the OS and/or driver control panel B) Check for driver updates on the graphics brand's website C) Try reinstalling your graphics drivers D) If still not working after trying all of the above, ask for further help on the Forge forums or Discord - + You can safely ignore this message if the game starts up successfully."""); } glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, GL_VERSIONS[versidx][0]); // we try our versions one at a time @@ -497,10 +493,6 @@ public class DisplayWindow implements ImmediateWindowProvider { glfwPollEvents(); } - private void badWindowHandler(final int code, final long desc) { - LOGGER.error("Got error from GLFW window init: "+code+ " "+MemoryUtil.memUTF8(desc)); - } - private void winResize(long window, int width, int height) { if (window == this.window && width != 0 && height != 0) { this.winWidth = width; @@ -634,7 +626,6 @@ public class DisplayWindow implements ImmediateWindowProvider { public void addMojangTexture(final int textureId) { this.elements.add(0, RenderElement.mojang(textureId, framecount)); -// this.elements.get(0).retire(framecount + 1); } public void close() { diff --git a/fmlearlydisplay/src/main/java/net/minecraftforge/fml/earlydisplay/SimpleFont.java b/fmlearlydisplay/src/main/java/net/minecraftforge/fml/earlydisplay/SimpleFont.java index 2482c5a0ab..d02c22f1dc 100644 --- a/fmlearlydisplay/src/main/java/net/minecraftforge/fml/earlydisplay/SimpleFont.java +++ b/fmlearlydisplay/src/main/java/net/minecraftforge/fml/earlydisplay/SimpleFont.java @@ -11,8 +11,6 @@ import org.lwjgl.stb.STBTTFontinfo; import org.lwjgl.stb.STBTTPackContext; import org.lwjgl.stb.STBTTPackRange; import org.lwjgl.stb.STBTTPackedchar; -import org.lwjgl.system.MemoryStack; - import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; diff --git a/gradle.properties b/gradle.properties index e1e07d657b..f59ff44519 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,11 +5,11 @@ org.gradle.daemon=false org.gradle.parallel=true JAVA_VERSION=21 -MC_VERSION=1.21.1 +MC_VERSION=1.21.3 MC_NEXT_VERSION=1.22 -MCP_VERSION=20240808.132146 +MCP_VERSION=20241025.112443 MAPPING_CHANNEL=official -MAPPING_VERSION=1.21.1 +MAPPING_VERSION=1.21.3 // Set to true before the first build of a new MC version, so we don't do compatibility checks CHECK_COMPATIBILITY=false diff --git a/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch b/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch index debc4de3a3..bcd842bc68 100644 --- a/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/pipeline/RenderTarget.java +++ b/com/mojang/blaze3d/pipeline/RenderTarget.java -@@ -104,7 +_,10 @@ +@@ -96,7 +_,10 @@ GlStateManager._texParameter(3553, 34892, 0); GlStateManager._texParameter(3553, 10242, 33071); GlStateManager._texParameter(3553, 10243, 33071); @@ -11,7 +11,7 @@ } this.setFilterMode(9728, true); -@@ -114,8 +_,13 @@ +@@ -106,8 +_,13 @@ GlStateManager._texImage2D(3553, 0, 32856, this.width, this.height, 0, 6408, 5121, null); GlStateManager._glBindFramebuffer(36160, this.frameBufferId); GlStateManager._glFramebufferTexture2D(36160, 36064, 3553, this.colorTextureId, 0); @@ -26,7 +26,7 @@ } this.checkStatus(); -@@ -257,5 +_,26 @@ +@@ -229,5 +_,26 @@ public int getDepthTextureId() { return this.depthBufferId; @@ -42,7 +42,7 @@ + public void enableStencil() { + if (stencilEnabled) return; + stencilEnabled = true; -+ this.resize(viewWidth, viewHeight, net.minecraft.client.Minecraft.ON_OSX); ++ this.resize(viewWidth, viewHeight); + } + + /** diff --git a/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch b/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch index c260d9bbe0..aa078314f5 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 -@@ -493,9 +_,17 @@ +@@ -519,9 +_,17 @@ } } diff --git a/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch b/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch index d9d1e8ebfa..9a2213c1b8 100644 --- a/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/platform/Window.java +++ b/com/mojang/blaze3d/platform/Window.java -@@ -84,7 +_,8 @@ +@@ -88,7 +_,8 @@ GLFW.glfwWindowHint(139267, 2); GLFW.glfwWindowHint(139272, 204801); GLFW.glfwWindowHint(139270, 1); @@ -10,7 +10,7 @@ if (monitor != null) { VideoMode videomode = monitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty()); this.windowedX = this.x = monitor.getX() + videomode.getWidth() / 2 - this.width / 2; -@@ -96,6 +_,7 @@ +@@ -100,6 +_,7 @@ this.windowedX = this.x = aint1[0]; this.windowedY = this.y = aint[0]; } @@ -18,7 +18,7 @@ GLFW.glfwMakeContextCurrent(this.window); GL.createCapabilities(); -@@ -254,6 +_,9 @@ +@@ -267,6 +_,9 @@ GLFW.glfwGetFramebufferSize(this.window, aint, aint1); this.framebufferWidth = aint[0] > 0 ? aint[0] : 1; this.framebufferHeight = aint1[0] > 0 ? aint1[0] : 1; diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/PoseStack.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/PoseStack.java.patch index d7121ee657..a28f85f1ad 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/PoseStack.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/PoseStack.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/vertex/PoseStack.java +++ b/com/mojang/blaze3d/vertex/PoseStack.java -@@ -13,7 +_,7 @@ +@@ -14,7 +_,7 @@ import org.joml.Vector3f; @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/SheetedDecalTextureGenerator.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/SheetedDecalTextureGenerator.java.patch deleted file mode 100644 index bf5aa5876e..0000000000 --- a/patches/minecraft/com/mojang/blaze3d/vertex/SheetedDecalTextureGenerator.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/com/mojang/blaze3d/vertex/SheetedDecalTextureGenerator.java -+++ b/com/mojang/blaze3d/vertex/SheetedDecalTextureGenerator.java -@@ -62,7 +_,7 @@ - public VertexConsumer setNormal(float p_344306_, float p_342091_, float p_344579_) { - this.delegate.setNormal(p_344306_, p_342091_, p_344579_); - Vector3f vector3f = this.normalInversePose.transform(p_344306_, p_342091_, p_344579_, this.normal); -- Direction direction = Direction.getNearest(vector3f.x(), vector3f.y(), vector3f.z()); -+ Direction direction = net.minecraftforge.client.ForgeHooksClient.getNearestStable(vector3f.x(), vector3f.y(), vector3f.z()); - Vector3f vector3f1 = this.cameraInversePose.transformPosition(this.x, this.y, this.z, this.worldPos); - vector3f1.rotateY((float) Math.PI); - vector3f1.rotateX((float) (-Math.PI / 2)); diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch index 51ed6b49c0..bc4e67cede 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/vertex/VertexConsumer.java +++ b/com/mojang/blaze3d/vertex/VertexConsumer.java -@@ -12,7 +_,7 @@ +@@ -13,7 +_,7 @@ import org.lwjgl.system.MemoryStack; @OnlyIn(Dist.CLIENT) @@ -9,16 +9,15 @@ VertexConsumer addVertex(float p_344294_, float p_342213_, float p_344859_); VertexConsumer setColor(int p_342749_, int p_344324_, int p_343336_, int p_342831_); -@@ -135,10 +_,11 @@ - } +@@ -133,9 +_,11 @@ - int i1 = FastColor.ARGB32.color(k, (int)f3, (int)f4, (int)f5); -- int j1 = p_331444_[l]; -+ int j1 = applyBakedLighting(p_331444_[l], bytebuffer); + int j1 = ARGB.color(k, (int)f3, (int)f4, (int)f5); + int k1 = LightTexture.lightCoordsWithEmission(p_331444_[i1], l); ++ k1 = applyBakedLighting(k1, bytebuffer); float f10 = bytebuffer.getFloat(16); float f9 = bytebuffer.getFloat(20); Vector3f vector3f1 = matrix4f.transformPosition(f, f1, f2, new Vector3f()); + applyBakedNormals(vector3f, bytebuffer, p_85988_.normal()); - this.addVertex(vector3f1.x(), vector3f1.y(), vector3f1.z(), i1, f10, f9, p_85993_, j1, vector3f.x(), vector3f.y(), vector3f.z()); + this.addVertex(vector3f1.x(), vector3f1.y(), vector3f1.z(), j1, f10, f9, p_85993_, k1, vector3f.x(), vector3f.y(), vector3f.z()); } } diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch index a4d471cdb2..cc32c45123 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/vertex/VertexFormat.java +++ b/com/mojang/blaze3d/vertex/VertexFormat.java -@@ -13,7 +_,7 @@ +@@ -14,7 +_,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) @@ -9,7 +9,7 @@ public static final int UNKNOWN_ELEMENT = -1; private final List elements; private final List names; -@@ -22,6 +_,7 @@ +@@ -23,6 +_,7 @@ private final int[] offsetsByElement = new int[32]; @Nullable private VertexBuffer immediateDrawVertexBuffer; @@ -17,7 +17,7 @@ VertexFormat(List p_343616_, List p_345241_, IntList p_345522_, int p_344162_) { this.elements = p_343616_; -@@ -34,6 +_,11 @@ +@@ -35,6 +_,11 @@ int j = vertexformatelement != null ? p_343616_.indexOf(vertexformatelement) : -1; this.offsetsByElement[i] = j != -1 ? p_345522_.getInt(j) : -1; } @@ -29,7 +29,7 @@ } public static VertexFormat.Builder builder() { -@@ -158,6 +_,9 @@ +@@ -141,6 +_,9 @@ return vertexbuffer; } diff --git a/patches/minecraft/net/minecraft/SharedConstants.java.patch b/patches/minecraft/net/minecraft/SharedConstants.java.patch index 224810a1bc..6202c3fe8a 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 -@@ -171,6 +_,7 @@ +@@ -170,6 +_,7 @@ } static { diff --git a/patches/minecraft/net/minecraft/Util.java.patch b/patches/minecraft/net/minecraft/Util.java.patch index 52a00eeaec..259ca88d92 100644 --- a/patches/minecraft/net/minecraft/Util.java.patch +++ b/patches/minecraft/net/minecraft/Util.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/Util.java +++ b/net/minecraft/Util.java -@@ -267,7 +_,7 @@ +@@ -264,7 +_,7 @@ .getSchema(DataFixUtils.makeKey(SharedConstants.getCurrentVersion().getDataVersion().getVersion())) .getChoiceType(p_137552_, p_137553_); } catch (IllegalArgumentException illegalargumentexception) { diff --git a/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch b/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch index 55fdf25a68..b8110f15fe 100644 --- a/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch +++ b/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/advancements/AdvancementRewards.java +++ b/net/minecraft/advancements/AdvancementRewards.java -@@ -40,6 +_,7 @@ +@@ -41,6 +_,7 @@ LootParams lootparams = new LootParams.Builder(p_9990_.serverLevel()) .withParameter(LootContextParams.THIS_ENTITY, p_9990_) .withParameter(LootContextParams.ORIGIN, p_9990_.position()) diff --git a/patches/minecraft/net/minecraft/client/Camera.java.patch b/patches/minecraft/net/minecraft/client/Camera.java.patch index 41fb46d237..93a5d1ebe2 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 -@@ -105,9 +_,13 @@ +@@ -120,9 +_,13 @@ } protected void setRotation(float p_90573_, float p_90574_) { @@ -15,7 +15,7 @@ FORWARDS.rotate(this.rotation, this.forwards); UP.rotate(this.rotation, this.up); LEFT.rotate(this.rotation, this.left); -@@ -223,6 +_,13 @@ +@@ -238,6 +_,13 @@ public float getPartialTickTime() { return this.partialTickTime; diff --git a/patches/minecraft/net/minecraft/client/ClientRecipeBook.java.patch b/patches/minecraft/net/minecraft/client/ClientRecipeBook.java.patch deleted file mode 100644 index 264d3465e3..0000000000 --- a/patches/minecraft/net/minecraft/client/ClientRecipeBook.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/client/ClientRecipeBook.java -+++ b/net/minecraft/client/ClientRecipeBook.java -@@ -65,7 +_,7 @@ - Recipe recipe = recipeholder.value(); - if (!recipe.isSpecial() && !recipe.isIncomplete()) { - RecipeBookCategories recipebookcategories = getCategory(recipeholder); -- String s = recipe.getGroup(); -+ String s = recipe.getGroup().isEmpty() ? recipeholder.id().toString() : recipe.getGroup(); // FORGE: Group value defaults to the recipe's ID if the recipe's explicit group is empty. - if (s.isEmpty()) { - map.computeIfAbsent(recipebookcategories, p_90645_ -> Lists.newArrayList()).add(ImmutableList.of(recipeholder)); - } else { -@@ -125,6 +_,8 @@ - } else if (recipetype == RecipeType.SMITHING) { - return RecipeBookCategories.SMITHING; - } else { -+ var categories = net.minecraftforge.client.RecipeBookManager.findCategories((RecipeType)recipetype, p_299041_); -+ if (categories != null) return categories; - LOGGER.warn( - "Unknown recipe category: {}/{}", - LogUtils.defer(() -> BuiltInRegistries.RECIPE_TYPE.getKey(recipe.getType())), diff --git a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch index 418774aa87..b975627132 100644 --- a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch +++ b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch @@ -1,18 +1,21 @@ --- a/net/minecraft/client/KeyboardHandler.java +++ b/net/minecraft/client/KeyboardHandler.java -@@ -405,9 +_,9 @@ - Screen.wrapScreenError(() -> { - if (p_90897_ == 1 || p_90897_ == 2) { +@@ -424,12 +_,12 @@ + if (screen != null) { + try { + if (p_90897_ != 1 && p_90897_ != 2) { +- if (p_90897_ == 0 && screen.keyReleased(p_90895_, p_90896_, p_90898_)) { ++ if (p_90897_ == 0 && net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleased(screen, p_90895_, p_90896_, p_90898_)) { + return; + } + } else { screen.afterKeyboardAction(); -- aboolean[0] = screen.keyPressed(p_90895_, p_90896_, p_90898_); -+ net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressed(aboolean, screen, p_90895_, p_90896_, p_90898_); - } else if (p_90897_ == 0) { -- aboolean[0] = screen.keyReleased(p_90895_, p_90896_, p_90898_); -+ net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleased(aboolean, screen, p_90895_, p_90896_, p_90898_); +- if (screen.keyPressed(p_90895_, p_90896_, p_90898_)) { ++ if (net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressed(screen, p_90895_, p_90896_, p_90898_)) { + return; + } } - }, "keyPressed event handler", screen.getClass().getCanonicalName()); - if (aboolean[0]) { -@@ -476,20 +_,21 @@ +@@ -505,6 +_,7 @@ } } } @@ -20,20 +23,17 @@ } } - private void charTyped(long p_90890_, int p_90891_, int p_90892_) { - if (p_90890_ == this.minecraft.getWindow().getWindow()) { -- GuiEventListener guieventlistener = this.minecraft.screen; -+ Screen guieventlistener = this.minecraft.screen; - if (guieventlistener != null && this.minecraft.getOverlay() == null) { - if (Character.charCount(p_90891_) == 1) { - Screen.wrapScreenError( -- () -> guieventlistener.charTyped((char)p_90891_, p_90892_), "charTyped event handler", guieventlistener.getClass().getCanonicalName() -+ () -> net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(guieventlistener, (char)p_90891_, p_90892_), "charTyped event handler", guieventlistener.getClass().getCanonicalName() - ); - } else { - for (char c0 : Character.toChars(p_90891_)) { -- Screen.wrapScreenError(() -> guieventlistener.charTyped(c0, p_90892_), "charTyped event handler", guieventlistener.getClass().getCanonicalName()); -+ Screen.wrapScreenError(() -> net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(guieventlistener, c0, p_90892_), "charTyped event handler", guieventlistener.getClass().getCanonicalName()); +@@ -514,10 +_,10 @@ + if (screen != null && this.minecraft.getOverlay() == null) { + try { + if (Character.isBmpCodePoint(p_90891_)) { +- screen.charTyped((char)p_90891_, p_90892_); ++ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, (char)p_90891_, p_90892_); + } else if (Character.isValidCodePoint(p_90891_)) { +- screen.charTyped(Character.highSurrogate(p_90891_), p_90892_); +- screen.charTyped(Character.lowSurrogate(p_90891_), p_90892_); ++ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, Character.highSurrogate(p_90891_), p_90892_); ++ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, Character.lowSurrogate(p_90891_), p_90892_); } - } - } + } catch (Throwable throwable) { + CrashReport crashreport = CrashReport.forThrowable(throwable, "charTyped event handler"); diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index c070876db2..27e4dc5379 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 -@@ -254,7 +_,7 @@ +@@ -253,7 +_,7 @@ import org.slf4j.Logger; @OnlyIn(Dist.CLIENT) @@ -9,7 +9,7 @@ static Minecraft instance; private static final Logger LOGGER = LogUtils.getLogger(); public static final boolean ON_OSX = Util.getPlatform() == Util.OS.OSX; -@@ -431,7 +_,6 @@ +@@ -433,7 +_,6 @@ } }, Util.nonCriticalIoPool()); LOGGER.info("Setting user: {}", this.user.getName()); @@ -17,10 +17,10 @@ this.demo = p_91084_.game.demo; this.allowsMultiplayer = !p_91084_.game.disableMultiplayer; this.allowsChat = !p_91084_.game.disableChat; -@@ -468,15 +_,15 @@ +@@ -480,15 +_,15 @@ + LOGGER.error("Couldn't set icon", (Throwable)ioexception); } - this.window.setFramerateLimit(this.options.framerateLimit().get()); + // FORGE: Move mouse and keyboard handler setup further below this.mouseHandler = new MouseHandler(this); - this.mouseHandler.setup(this.window.getWindow()); @@ -29,27 +29,21 @@ RenderSystem.initRenderer(this.options.glDebugVerbosity, false); this.mainRenderTarget = new MainTarget(this.window.getWidth(), this.window.getHeight()); this.mainRenderTarget.setClearColor(0.0F, 0.0F, 0.0F, 0.0F); - this.mainRenderTarget.clear(ON_OSX); + this.mainRenderTarget.clear(); this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES); + net.minecraftforge.client.loading.ClientModLoader.begin(this, this.resourcePackRepository, this.resourceManager); this.resourcePackRepository.reload(); this.options.loadSelectedResourcePacks(this.resourcePackRepository); this.languageManager = new LanguageManager(this.options.languageCode, p_340763_ -> { -@@ -540,6 +_,7 @@ - this.entityRenderDispatcher = new EntityRenderDispatcher(this, this.textureManager, this.itemRenderer, this.blockRenderer, this.font, this.options, this.entityModels); +@@ -562,6 +_,7 @@ + ); this.resourceManager.registerReloadListener(this.entityRenderDispatcher); this.particleEngine = new ParticleEngine(this.level, this.textureManager); + net.minecraftforge.client.ForgeHooksClient.onRegisterParticleProviders(this.particleEngine); this.resourceManager.registerReloadListener(this.particleEngine); this.paintingTextures = new PaintingTextureManager(this.textureManager); this.resourceManager.registerReloadListener(this.paintingTextures); -@@ -552,11 +_,15 @@ - this.gameRenderer = new GameRenderer(this, this.entityRenderDispatcher.getItemInHandRenderer(), this.resourceManager, this.renderBuffers); - this.resourceManager.registerReloadListener(this.gameRenderer.createReloadListener()); - this.levelRenderer = new LevelRenderer(this, this.entityRenderDispatcher, this.blockEntityRenderDispatcher, this.renderBuffers); -+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.RenderLevelStageEvent.RegisterStageEvent()); - this.resourceManager.registerReloadListener(this.levelRenderer); - this.gpuWarnlistManager = new GpuWarnlistManager(); +@@ -577,6 +_,9 @@ this.resourceManager.registerReloadListener(this.gpuWarnlistManager); this.resourceManager.registerReloadListener(this.regionalCompliancies); this.gui = new Gui(this); @@ -59,7 +53,7 @@ this.debugRenderer = new DebugRenderer(this); RealmsClient realmsclient = RealmsClient.create(this); this.realmsDataFetcher = new RealmsDataFetcher(realmsclient); -@@ -580,6 +_,7 @@ +@@ -600,6 +_,7 @@ this.options.fullscreen().set(this.window.isFullscreen()); } @@ -67,7 +61,7 @@ this.window.updateVsync(this.options.enableVsync().get()); this.window.updateRawMouseInput(this.options.rawMouseInput().get()); this.window.setDefaultErrorCallback(); -@@ -600,16 +_,17 @@ +@@ -620,16 +_,17 @@ GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS); Minecraft.GameLoadCookie minecraft$gameloadcookie = new Minecraft.GameLoadCookie(realmsclient, p_91084_.quickPlay); this.setOverlay( @@ -87,8 +81,8 @@ + ).get() ); this.quickPlayLog = QuickPlayLog.of(p_91084_.quickPlay.path()); - } -@@ -698,6 +_,7 @@ + this.framerateLimitTracker = new FramerateLimitTracker(this.options, this); +@@ -724,6 +_,7 @@ StringBuilder stringbuilder = new StringBuilder("Minecraft"); if (checkModStatus().shouldReportAsModified()) { stringbuilder.append("*"); @@ -96,7 +90,7 @@ } stringbuilder.append(" "); -@@ -721,6 +_,8 @@ +@@ -747,6 +_,8 @@ } private UserApiService createUserApiService(YggdrasilAuthenticationService p_193586_, GameConfig p_193587_) { @@ -105,7 +99,7 @@ return p_193587_.user.user.getType() != User.Type.MSA ? UserApiService.OFFLINE : p_193586_.createUserApiService(p_193587_.user.user.getAccessToken()); -@@ -731,7 +_,7 @@ +@@ -757,7 +_,7 @@ } private void rollbackResourcePacks(Throwable p_91240_, @Nullable Minecraft.GameLoadCookie p_299515_) { @@ -114,7 +108,7 @@ this.clearResourcePacksOnError(p_91240_, null, p_299515_); } else { Util.throwAsRuntime(p_91240_); -@@ -991,12 +_,6 @@ +@@ -1043,12 +_,6 @@ LOGGER.error("setScreen called from non-game thread"); } @@ -127,7 +121,7 @@ if (p_91153_ == null && this.clientLevelTeardownInProgress) { throw new IllegalStateException("Trying to return to in-game GUI during disconnection"); } else { -@@ -1010,6 +_,23 @@ +@@ -1062,6 +_,23 @@ } } @@ -151,19 +145,19 @@ this.screen = p_91153_; if (this.screen != null) { this.screen.added(); -@@ -1155,9 +_,11 @@ +@@ -1215,9 +_,11 @@ this.mouseHandler.handleAccumulatedMovement(); - this.profiler.pop(); + profilerfiller.pop(); if (!this.noRender) { -+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickStart(this.timer); - this.profiler.popPush("gameRenderer"); - this.gameRenderer.render(this.timer, p_91384_); - this.profiler.pop(); -+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickEnd(this.timer); ++ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickStart(this.deltaTracker); + profilerfiller.popPush("gameRenderer"); + this.gameRenderer.render(this.deltaTracker, p_91384_); + profilerfiller.pop(); ++ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickEnd(this.deltaTracker); } - if (this.fpsPieResults != null) { -@@ -1283,10 +_,12 @@ + profilerfiller.push("blit"); +@@ -1339,10 +_,12 @@ this.window.setGuiScale((double)i); if (this.screen != null) { this.screen.resize(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); @@ -171,12 +165,12 @@ } RenderTarget rendertarget = this.getMainRenderTarget(); - rendertarget.resize(this.window.getWidth(), this.window.getHeight(), ON_OSX); + rendertarget.resize(this.window.getWidth(), this.window.getHeight()); + if (this.gameRenderer != null) this.gameRenderer.resize(this.window.getWidth(), this.window.getHeight()); this.mouseHandler.setIgnoreFirstMove(); } -@@ -1554,6 +_,7 @@ +@@ -1483,6 +_,7 @@ } public void stop() { @@ -184,7 +178,7 @@ this.running = false; } -@@ -1582,10 +_,18 @@ +@@ -1511,10 +_,18 @@ if (p_91387_ && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) { BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; BlockPos blockpos = blockhitresult.getBlockPos(); @@ -206,7 +200,7 @@ this.player.swing(InteractionHand.MAIN_HAND); } } -@@ -1613,6 +_,8 @@ +@@ -1542,6 +_,8 @@ return false; } else { boolean flag = false; @@ -215,7 +209,7 @@ switch (this.hitResult.getType()) { case ENTITY: this.gameMode.attack(this.player, ((EntityHitResult)this.hitResult).getEntity()); -@@ -1620,7 +_,7 @@ +@@ -1549,7 +_,7 @@ case BLOCK: BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; BlockPos blockpos = blockhitresult.getBlockPos(); @@ -224,7 +218,7 @@ this.gameMode.startDestroyBlock(blockpos, blockhitresult.getDirection()); if (this.level.getBlockState(blockpos).isAir()) { flag = true; -@@ -1633,8 +_,10 @@ +@@ -1562,8 +_,10 @@ } this.player.resetAttackStrengthTicker(); @@ -235,7 +229,7 @@ this.player.swing(InteractionHand.MAIN_HAND); return flag; } -@@ -1650,6 +_,12 @@ +@@ -1579,6 +_,12 @@ } for (InteractionHand interactionhand : InteractionHand.values()) { @@ -248,68 +242,68 @@ ItemStack itemstack = this.player.getItemInHand(interactionhand); if (!itemstack.isItemEnabled(this.level.enabledFeatures())) { return; -@@ -1670,7 +_,7 @@ +@@ -1599,7 +_,7 @@ } - if (interactionresult.consumesAction()) { -- if (interactionresult.shouldSwing()) { -+ if (interactionresult.shouldSwing() && inputEvent.shouldSwingHand()) { + if (interactionresult instanceof InteractionResult.Success interactionresult$success2) { +- if (interactionresult$success2.swingSource() == InteractionResult.SwingSource.CLIENT) { ++ if (interactionresult$success2.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) { this.player.swing(interactionhand); } -@@ -1682,7 +_,7 @@ +@@ -1611,7 +_,7 @@ int i = itemstack.getCount(); InteractionResult interactionresult1 = this.gameMode.useItemOn(this.player, interactionhand, blockhitresult); - if (interactionresult1.consumesAction()) { -- if (interactionresult1.shouldSwing()) { -+ if (interactionresult1.shouldSwing() && inputEvent.shouldSwingHand()) { + if (interactionresult1 instanceof InteractionResult.Success interactionresult$success) { +- if (interactionresult$success.swingSource() == InteractionResult.SwingSource.CLIENT) { ++ if (interactionresult$success.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) { this.player.swing(interactionhand); if (!itemstack.isEmpty() && (itemstack.getCount() != i || this.gameMode.hasInfiniteItems())) { this.gameRenderer.itemInHandRenderer.itemUsed(interactionhand); -@@ -1698,6 +_,9 @@ +@@ -1627,6 +_,9 @@ } } + if (itemstack.isEmpty() && (this.hitResult == null || this.hitResult.getType() == HitResult.Type.MISS)) + net.minecraftforge.event.ForgeEventFactory.onRightClickEmpty(this.player, interactionhand); + - if (!itemstack.isEmpty()) { - InteractionResult interactionresult2 = this.gameMode.useItem(this.player, interactionhand); - if (interactionresult2.consumesAction()) { -@@ -1728,6 +_,8 @@ - this.rightClickDelay--; + if (!itemstack.isEmpty() + && this.gameMode.useItem(this.player, interactionhand) instanceof InteractionResult.Success interactionresult$success1) { + if (interactionresult$success1.swingSource() == InteractionResult.SwingSource.CLIENT) { +@@ -1656,6 +_,8 @@ } + ProfilerFiller profilerfiller = Profiler.get(); + net.minecraftforge.event.ForgeEventFactory.onPreClientTick(); + - this.profiler.push("gui"); + profilerfiller.push("gui"); this.chatListener.tick(); this.gui.tick(this.pause); -@@ -1811,6 +_,7 @@ +@@ -1745,6 +_,7 @@ this.tutorial.tick(); + net.minecraftforge.event.ForgeEventFactory.onPreLevelTick(this.level, () -> true); try { this.level.tick(() -> true); - } catch (Throwable throwable) { -@@ -1824,6 +_,7 @@ + } catch (Throwable throwable1) { +@@ -1758,6 +_,7 @@ - throw new ReportedException(crashreport); + throw new ReportedException(crashreport1); } + net.minecraftforge.event.ForgeEventFactory.onPostLevelTick(this.level, () -> true); } - this.profiler.popPush("animateTick"); -@@ -1843,6 +_,7 @@ - this.profiler.popPush("keyboard"); + profilerfiller.popPush("animateTick"); +@@ -1782,6 +_,7 @@ + profilerfiller.popPush("keyboard"); this.keyboardHandler.tick(); - this.profiler.pop(); + profilerfiller.pop(); + net.minecraftforge.event.ForgeEventFactory.onPostClientTick(); } private boolean isLevelRunningNormally() { -@@ -2043,6 +_,7 @@ +@@ -1983,6 +_,7 @@ } public void setLevel(ClientLevel p_91157_, ReceivingLevelScreen.Reason p_335893_) { @@ -317,7 +311,7 @@ this.updateScreenAndTick(new ReceivingLevelScreen(() -> false, p_335893_)); this.level = p_91157_; this.updateLevelInEngines(p_91157_); -@@ -2080,6 +_,7 @@ +@@ -2020,6 +_,7 @@ IntegratedServer integratedserver = this.singleplayerServer; this.singleplayerServer = null; this.gameRenderer.resetData(); @@ -325,15 +319,15 @@ this.gameMode = null; this.narrator.clear(); this.clientLevelTeardownInProgress = true; -@@ -2087,6 +_,7 @@ +@@ -2027,6 +_,7 @@ try { this.updateScreenAndTick(p_335030_); if (this.level != null) { + net.minecraftforge.event.ForgeEventFactory.onLevelUnload(this.level); if (integratedserver != null) { - this.profiler.push("waitForServer"); - -@@ -2099,6 +_,7 @@ + ProfilerFiller profilerfiller = Profiler.get(); + profilerfiller.push("waitForServer"); +@@ -2040,6 +_,7 @@ this.gui.onDisconnected(); this.isLocalServer = false; @@ -341,7 +335,7 @@ } this.level = null; -@@ -2245,6 +_,7 @@ +@@ -2187,6 +_,7 @@ private void pickBlock() { if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) { @@ -349,7 +343,7 @@ boolean flag = this.player.getAbilities().instabuild; BlockEntity blockentity = null; HitResult.Type hitresult$type = this.hitResult.getType(); -@@ -2257,7 +_,7 @@ +@@ -2199,7 +_,7 @@ } Block block = blockstate.getBlock(); @@ -358,7 +352,7 @@ if (itemstack.isEmpty()) { return; } -@@ -2271,7 +_,7 @@ +@@ -2213,7 +_,7 @@ } Entity entity = ((EntityHitResult)this.hitResult).getEntity(); @@ -367,7 +361,7 @@ if (itemstack == null) { return; } -@@ -2855,6 +_,10 @@ +@@ -2818,6 +_,10 @@ @Nullable public static String getLauncherBrand() { return System.getProperty("minecraft.launcher.brand"); diff --git a/patches/minecraft/net/minecraft/client/MouseHandler.java.patch b/patches/minecraft/net/minecraft/client/MouseHandler.java.patch index e9209f6d48..a6bb21b24f 100644 --- a/patches/minecraft/net/minecraft/client/MouseHandler.java.patch +++ b/patches/minecraft/net/minecraft/client/MouseHandler.java.patch @@ -1,34 +1,40 @@ --- a/net/minecraft/client/MouseHandler.java +++ b/net/minecraft/client/MouseHandler.java -@@ -79,6 +_,7 @@ +@@ -85,6 +_,7 @@ this.activeButton = -1; } + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPre(p_91532_, p_91533_, p_91534_)) return; - boolean[] aboolean = new boolean[]{false}; if (this.minecraft.getOverlay() == null) { if (this.minecraft.screen == null) { -@@ -91,9 +_,9 @@ - Screen screen = this.minecraft.screen; - if (flag) { + if (!this.mouseGrabbed && flag) { +@@ -98,7 +_,7 @@ screen.afterMouseAction(); -- Screen.wrapScreenError(() -> aboolean[0] = screen.mouseClicked(d0, d1, i), "mouseClicked event handler", screen.getClass().getCanonicalName()); -+ Screen.wrapScreenError(() -> net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseClicked(aboolean, screen, d0, d1, i), "mouseClicked event handler", screen.getClass().getCanonicalName()); + + try { +- if (screen.mouseClicked(d0, d1, i)) { ++ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseClicked(screen, d0, d1, i)) { + return; + } + } catch (Throwable throwable1) { +@@ -112,7 +_,7 @@ + } } else { -- Screen.wrapScreenError(() -> aboolean[0] = screen.mouseReleased(d0, d1, i), "mouseReleased event handler", screen.getClass().getCanonicalName()); -+ Screen.wrapScreenError(() -> net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseReleased(aboolean, screen, d0, d1, i), "mouseReleased event handler", screen.getClass().getCanonicalName()); - } + try { +- if (screen.mouseReleased(d0, d1, i)) { ++ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseReleased(screen, d0, d1, i)) { + return; + } + } catch (Throwable throwable) { +@@ -147,6 +_,7 @@ } } -@@ -116,6 +_,7 @@ - } - } - } -+ net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPost(p_91532_, p_91533_, p_91534_); } ++ net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPost(p_91532_, p_91533_, p_91534_); } -@@ -129,7 +_,9 @@ + private void onScroll(long p_91527_, double p_91528_, double p_91529_) { +@@ -160,7 +_,9 @@ if (this.minecraft.screen != null) { double d3 = this.xpos * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getScreenWidth(); double d4 = this.ypos * (double)this.minecraft.getWindow().getGuiScaledHeight() / (double)this.minecraft.getWindow().getScreenHeight(); @@ -38,25 +44,25 @@ + net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseScrollPost(this.minecraft.screen, d3, d4, d1, d2); this.minecraft.screen.afterMouseAction(); } else if (this.minecraft.player != null) { - if (this.accumulatedScrollX != 0.0 && Math.signum(d1) != Math.signum(this.accumulatedScrollX)) { -@@ -151,6 +_,7 @@ - this.accumulatedScrollX -= (double)j; - this.accumulatedScrollY -= (double)i; - int k = i == 0 ? -j : i; + Vector2i vector2i = this.scrollWheelHandler.onMouseScroll(d1, d2); +@@ -169,6 +_,7 @@ + } + + int i = vector2i.y == 0 ? -vector2i.x : vector2i.y; + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseScroll(this, d1, d2)) return; if (this.minecraft.player.isSpectator()) { if (this.minecraft.gui.getSpectatorGui().isMenuActive()) { - this.minecraft.gui.getSpectatorGui().onMouseScrolled(-k); -@@ -236,7 +_,7 @@ - if (this.activeButton != -1 && this.mousePressedTime > 0.0) { - double d4 = this.accumulatedDX * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getScreenWidth(); + this.minecraft.gui.getSpectatorGui().onMouseScrolled(-i); +@@ -274,7 +_,7 @@ double d5 = this.accumulatedDY * (double)this.minecraft.getWindow().getGuiScaledHeight() / (double)this.minecraft.getWindow().getScreenHeight(); -- Screen.wrapScreenError(() -> screen.mouseDragged(d2, d3, this.activeButton, d4, d5), "mouseDragged event handler", screen.getClass().getCanonicalName()); -+ Screen.wrapScreenError(() -> net.minecraftforge.client.ForgeHooksClient.onScreenMouseDrag(screen, d2, d3, this.activeButton, d4, d5), "mouseDragged event handler", screen.getClass().getCanonicalName()); - } - screen.afterMouseMove(); -@@ -303,6 +_,14 @@ + try { +- screen.mouseDragged(d2, d3, this.activeButton, d4, d5); ++ net.minecraftforge.client.ForgeHooksClient.onScreenMouseDrag(screen, d2, d3, this.activeButton, d4, d5); + } catch (Throwable throwable) { + CrashReport crashreport1 = CrashReport.forThrowable(throwable, "mouseDragged event handler"); + screen.fillCrashDetails(crashreport1); +@@ -349,6 +_,14 @@ public double ypos() { return this.ypos; diff --git a/patches/minecraft/net/minecraft/client/Options.java.patch b/patches/minecraft/net/minecraft/client/Options.java.patch index 03f039ca68..9b54094b87 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 -@@ -681,7 +_,8 @@ +@@ -698,7 +_,8 @@ }, new OptionInstance.LazyEnum<>( () -> Stream.concat(Stream.of(""), Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().stream()).toList(), @@ -10,7 +10,7 @@ ? Optional.empty() : Optional.of(p_232011_), Codec.STRING -@@ -1050,6 +_,7 @@ +@@ -1079,6 +_,7 @@ } public Options(Minecraft p_92138_, File p_92139_) { @@ -18,7 +18,7 @@ this.minecraft = p_92138_; this.optionsFile = new File(p_92139_, "options.txt"); boolean flag = Runtime.getRuntime().maxMemory() >= 1000000000L; -@@ -1184,12 +_,22 @@ +@@ -1210,12 +_,22 @@ p_168428_.process("telemetryOptInExtra", this.telemetryOptInExtra); this.onboardAccessibility = p_168428_.process("onboardAccessibility", this.onboardAccessibility); p_168428_.process("menuBackgroundBlurriness", this.menuBackgroundBlurriness); @@ -42,7 +42,7 @@ } } -@@ -1207,6 +_,10 @@ +@@ -1233,6 +_,10 @@ } public void load() { @@ -53,7 +53,7 @@ try { if (!this.optionsFile.exists()) { return; -@@ -1234,7 +_,8 @@ +@@ -1260,7 +_,8 @@ } } @@ -63,15 +63,15 @@ new Options.FieldAccess() { @Nullable private String getValueOrNull(String p_168459_) { -@@ -1428,6 +_,7 @@ +@@ -1451,6 +_,7 @@ } public void broadcastOptions() { + 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. if (this.minecraft.player != null) { - this.minecraft.player.connection.send(new ServerboundClientInformationPacket(this.buildPlayerInformation())); + this.minecraft.player.connection.broadcastClientInformation(this.buildPlayerInformation()); } -@@ -1546,6 +_,23 @@ +@@ -1564,6 +_,23 @@ public static Component genericValueLabel(Component p_231901_, int p_231902_) { return genericValueLabel(p_231901_, Component.literal(Integer.toString(p_231902_))); diff --git a/patches/minecraft/net/minecraft/client/RecipeBookCategories.java.patch b/patches/minecraft/net/minecraft/client/RecipeBookCategories.java.patch deleted file mode 100644 index c329f18d54..0000000000 --- a/patches/minecraft/net/minecraft/client/RecipeBookCategories.java.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- a/net/minecraft/client/RecipeBookCategories.java -+++ b/net/minecraft/client/RecipeBookCategories.java -@@ -12,7 +_,7 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - - @OnlyIn(Dist.CLIENT) --public enum RecipeBookCategories { -+public enum RecipeBookCategories implements net.minecraftforge.common.IExtensibleEnum { - CRAFTING_SEARCH(new ItemStack(Items.COMPASS)), - CRAFTING_BUILDING_BLOCKS(new ItemStack(Blocks.BRICKS)), - CRAFTING_REDSTONE(new ItemStack(Items.REDSTONE)), -@@ -38,7 +_,7 @@ - public static final List CRAFTING_CATEGORIES = ImmutableList.of( - CRAFTING_SEARCH, CRAFTING_EQUIPMENT, CRAFTING_BUILDING_BLOCKS, CRAFTING_MISC, CRAFTING_REDSTONE - ); -- public static final Map> AGGREGATE_CATEGORIES = ImmutableMap.of( -+ public static final Map> AGGREGATE_CATEGORIES = net.minecraftforge.client.RecipeBookManager.getAggregateCategories(ImmutableMap.of( - CRAFTING_SEARCH, - ImmutableList.of(CRAFTING_EQUIPMENT, CRAFTING_BUILDING_BLOCKS, CRAFTING_MISC, CRAFTING_REDSTONE), - FURNACE_SEARCH, -@@ -47,7 +_,7 @@ - ImmutableList.of(BLAST_FURNACE_BLOCKS, BLAST_FURNACE_MISC), - SMOKER_SEARCH, - ImmutableList.of(SMOKER_FOOD) -- ); -+ )); - private final List itemIcons; - - private RecipeBookCategories(final ItemStack... p_92267_) { -@@ -60,10 +_,15 @@ - case FURNACE -> FURNACE_CATEGORIES; - case BLAST_FURNACE -> BLAST_FURNACE_CATEGORIES; - case SMOKER -> SMOKER_CATEGORIES; -+ default -> net.minecraftforge.client.RecipeBookManager.getCustomCategoriesOrEmpty(p_92270_); - }; - } - - public List getIconItems() { - return this.itemIcons; -+ } -+ -+ public static RecipeBookCategories create(String name, ItemStack... icons) { -+ throw new IllegalStateException("Enum not extended"); - } - } 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 35f507c211..ae1c04e53d 100644 --- a/patches/minecraft/net/minecraft/client/color/item/ItemColors.java.patch +++ b/patches/minecraft/net/minecraft/client/color/item/ItemColors.java.patch @@ -10,8 +10,8 @@ public static ItemColors createDefault(BlockColors p_92684_) { ItemColors itemcolors = new ItemColors(); -@@ -105,17 +_,20 @@ - : FastColor.ARGB32.opaque(p_325310_.getOrDefault(DataComponents.MAP_COLOR, MapItemColor.DEFAULT).rgb()), +@@ -101,17 +_,20 @@ + (p_357654_, p_357655_) -> p_357655_ == 0 ? -1 : ARGB.opaque(p_357654_.getOrDefault(DataComponents.MAP_COLOR, MapItemColor.DEFAULT).rgb()), Items.FILLED_MAP ); + net.minecraftforge.client.ForgeHooksClient.onItemColorsInit(itemcolors, p_92684_); diff --git a/patches/minecraft/net/minecraft/client/gui/Font.java.patch b/patches/minecraft/net/minecraft/client/gui/Font.java.patch index 1ef74b6d42..1383e43f3b 100644 --- a/patches/minecraft/net/minecraft/client/gui/Font.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/Font.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/Font.java +++ b/net/minecraft/client/gui/Font.java -@@ -31,7 +_,7 @@ +@@ -33,7 +_,7 @@ import org.joml.Vector3f; @OnlyIn(Dist.CLIENT) @@ -9,12 +9,3 @@ private static final float EFFECT_DEPTH = 0.01F; private static final Vector3f SHADOW_OFFSET = new Vector3f(0.0F, 0.0F, 0.03F); public static final int ALPHA_CUTOFF = 8; -@@ -322,6 +_,8 @@ - public StringSplitter getSplitter() { - return this.splitter; - } -+ -+ @Override public Font self() { return this; } - - @OnlyIn(Dist.CLIENT) - public static enum DisplayMode { diff --git a/patches/minecraft/net/minecraft/client/gui/Gui.java.patch b/patches/minecraft/net/minecraft/client/gui/Gui.java.patch index 39d9427de9..1687e9df6c 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 -@@ -131,7 +_,7 @@ +@@ -147,7 +_,7 @@ public float vignetteBrightness = 1.0F; private int toolHighlightTimer; private ItemStack lastToolHighlight = ItemStack.EMPTY; @@ -9,7 +9,7 @@ private final SubtitleOverlay subtitleOverlay; private final SpectatorGui spectatorGui; private final PlayerTabOverlay tabList; -@@ -318,7 +_,7 @@ +@@ -345,7 +_,7 @@ Window window = this.minecraft.getWindow(); int i = Mth.floor(this.minecraft.mouseHandler.xpos() * (double)window.getGuiScaledWidth() / (double)window.getScreenWidth()); int j = Mth.floor(this.minecraft.mouseHandler.ypos() * (double)window.getGuiScaledHeight() / (double)window.getScreenHeight()); @@ -18,24 +18,24 @@ } } -@@ -434,6 +_,8 @@ +@@ -443,6 +_,8 @@ for (MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) { Holder holder = mobeffectinstance.getEffect(); + var renderer = net.minecraftforge.client.extensions.common.IClientMobEffectExtensions.of(mobeffectinstance); + if (!renderer.isVisibleInGui(mobeffectinstance)) continue; if (mobeffectinstance.showIcon()) { - int i = p_282812_.guiWidth(); - int j = 1; -@@ -463,6 +_,7 @@ + int k = p_282812_.guiWidth(); + int l = 1; +@@ -473,6 +_,7 @@ } } -+ if (renderer.renderGuiIcon(mobeffectinstance, this, p_282812_, i, j, 0, f)) continue; ++ if (renderer.renderGuiIcon(mobeffectinstance, this, p_282812_, k, l, 0, f)) continue; TextureAtlasSprite textureatlassprite = mobeffecttexturemanager.get(holder); - int l1 = i; - int i1 = j; -@@ -625,6 +_,10 @@ + int l1 = k; + int k1 = l; +@@ -623,6 +_,10 @@ } private void renderSelectedItemName(GuiGraphics p_283501_) { @@ -43,10 +43,10 @@ + } + + public void renderSelectedItemName(GuiGraphics p_283501_, int yShift) { - this.minecraft.getProfiler().push("selectedItemName"); + Profiler.get().push("selectedItemName"); if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) { MutableComponent mutablecomponent = Component.empty().append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().color()); -@@ -632,9 +_,13 @@ +@@ -630,9 +_,13 @@ mutablecomponent.withStyle(ChatFormatting.ITALIC); } @@ -62,16 +62,16 @@ if (!this.minecraft.gameMode.canHurtPlayer()) { k += 14; } -@@ -645,7 +_,7 @@ +@@ -643,7 +_,7 @@ } if (l > 0) { -- p_283501_.drawStringWithBackdrop(this.getFont(), mutablecomponent, j, k, i, FastColor.ARGB32.color(l, -1)); -+ p_283501_.drawStringWithBackdrop(font, highlightTip, j, k, i, FastColor.ARGB32.color(l, -1)); +- p_283501_.drawStringWithBackdrop(this.getFont(), mutablecomponent, j, k, i, ARGB.color(l, -1)); ++ p_283501_.drawStringWithBackdrop(font, highlightTip, j, k, i, ARGB.color(l, -1)); } } -@@ -1146,7 +_,7 @@ +@@ -1152,7 +_,7 @@ ItemStack itemstack = this.minecraft.player.getInventory().getSelected(); if (itemstack.isEmpty()) { this.toolHighlightTimer = 0; diff --git a/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch index 3a68444ef1..3f5471e921 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/GuiGraphics.java +++ b/net/minecraft/client/gui/GuiGraphics.java -@@ -56,7 +_,7 @@ +@@ -53,7 +_,7 @@ import org.joml.Vector2ic; @OnlyIn(Dist.CLIENT) @@ -9,7 +9,7 @@ public static final float MAX_GUI_Z = 10000.0F; public static final float MIN_GUI_Z = -10000.0F; private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE = 2; -@@ -268,6 +_,11 @@ +@@ -227,6 +_,11 @@ } public int drawString(Font p_283343_, @Nullable String p_281896_, int p_283569_, int p_283418_, int p_281560_, boolean p_282130_) { @@ -18,10 +18,10 @@ + + // Forge: Add float variant for x,y coordinates + public int drawString(Font p_283343_, @Nullable String p_281896_, float p_283569_, float p_283418_, int p_281560_, boolean p_282130_) { - if (p_281896_ == null) { - return 0; - } else { -@@ -294,6 +_,11 @@ + return p_281896_ == null + ? 0 + : p_283343_.drawInBatch( +@@ -248,6 +_,11 @@ } public int drawString(Font p_282636_, FormattedCharSequence p_281596_, int p_281586_, int p_282816_, int p_281743_, boolean p_282394_) { @@ -30,10 +30,10 @@ + + // Forge: Add float variant for x,y coordinates + public int drawString(Font p_282636_, FormattedCharSequence p_281596_, float p_281586_, float p_282816_, int p_281743_, boolean p_282394_) { - int i = p_282636_.drawInBatch( + return p_282636_.drawInBatch( p_281596_, (float)p_281586_, -@@ -864,6 +_,7 @@ +@@ -872,6 +_,7 @@ CrashReport crashreport = CrashReport.forThrowable(throwable, "Rendering item"); CrashReportCategory crashreportcategory = crashreport.addCategory("Item being rendered"); crashreportcategory.setDetail("Item Type", () -> String.valueOf(p_281675_.getItem())); @@ -41,9 +41,9 @@ crashreportcategory.setDetail("Item Components", () -> String.valueOf(p_281675_.getComponents())); crashreportcategory.setDetail("Item Foil", () -> String.valueOf(p_281675_.hasFoil())); throw new ReportedException(crashreport); -@@ -904,16 +_,26 @@ - } - +@@ -892,13 +_,24 @@ + this.renderItemCount(p_282005_, p_283349_, p_282641_, p_282146_, p_282803_); + this.renderItemCooldown(p_283349_, p_282641_, p_282146_); this.pose.popPose(); + net.minecraftforge.client.ItemDecoratorHandler.of(p_283349_).render(this, p_282005_, p_283349_, p_282641_, p_282146_); } @@ -53,50 +53,56 @@ public void renderTooltip(Font p_282308_, ItemStack p_282781_, int p_282687_, int p_282292_) { + this.tooltipStack = p_282781_; - this.renderTooltip(p_282308_, Screen.getTooltipFromItem(this.minecraft, p_282781_), p_282781_.getTooltipImage(), p_282687_, p_282292_); + this.renderTooltip( + p_282308_, Screen.getTooltipFromItem(this.minecraft, p_282781_), p_282781_.getTooltipImage(), p_282687_, p_282292_, p_282781_.get(DataComponents.TOOLTIP_STYLE) + ); + this.tooltipStack = ItemStack.EMPTY; + } + + public void renderTooltip(Font font, List textComponents, Optional tooltipComponent, ItemStack stack, int mouseX, int mouseY) { + this.tooltipStack = stack; -+ this.renderTooltip(font, textComponents, tooltipComponent, mouseX, mouseY); ++ this.renderTooltip(font, textComponents, tooltipComponent, mouseX, mouseY, stack.get(DataComponents.TOOLTIP_STYLE)); + this.tooltipStack = ItemStack.EMPTY; } public void renderTooltip(Font p_283128_, List p_282716_, Optional p_281682_, int p_283678_, int p_281696_) { -- List list = p_282716_.stream().map(Component::getVisualOrderText).map(ClientTooltipComponent::create).collect(Util.toMutableList()); -- p_281682_.ifPresent(p_325321_ -> list.add(list.isEmpty() ? 0 : 1, ClientTooltipComponent.create(p_325321_))); -+ List list = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, p_282716_, p_281682_, p_283678_, guiWidth(), guiHeight(), p_283128_); - this.renderTooltipInternal(p_283128_, list, p_283678_, p_281696_, DefaultTooltipPositioner.INSTANCE); +@@ -908,8 +_,7 @@ + public void renderTooltip( + Font p_362491_, List p_368544_, Optional p_362815_, int p_366300_, int p_368952_, @Nullable ResourceLocation p_368469_ + ) { +- List list = p_368544_.stream().map(Component::getVisualOrderText).map(ClientTooltipComponent::create).collect(Util.toMutableList()); +- p_362815_.ifPresent(p_325321_ -> list.add(list.isEmpty() ? 0 : 1, ClientTooltipComponent.create(p_325321_))); ++ List list = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, p_368544_, p_362815_, p_366300_, guiWidth(), guiHeight(), p_362491_); + this.renderTooltipInternal(p_362491_, list, p_366300_, p_368952_, DefaultTooltipPositioner.INSTANCE, p_368469_); } @@ -922,7 +_,22 @@ } public void renderComponentTooltip(Font p_282739_, List p_281832_, int p_282191_, int p_282446_) { -- this.renderTooltip(p_282739_, Lists.transform(p_281832_, Component::getVisualOrderText), p_282191_, p_282446_); +- this.renderComponentTooltip(p_282739_, p_281832_, p_282191_, p_282446_, null); + List components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, p_281832_, p_282191_, guiWidth(), guiHeight(), p_282739_); -+ this.renderTooltipInternal(p_282739_, components, p_282191_, p_282446_, DefaultTooltipPositioner.INSTANCE); ++ this.renderTooltipInternal(p_282739_, components, p_282191_, p_282446_, DefaultTooltipPositioner.INSTANCE, null); + } + + public void renderComponentTooltip(Font font, List tooltips, int mouseX, int mouseY, ItemStack stack) { + this.tooltipStack = stack; + List components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(stack, tooltips, mouseX, guiWidth(), guiHeight(), font); -+ this.renderTooltipInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE); ++ this.renderTooltipInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE, null); + this.tooltipStack = ItemStack.EMPTY; + } + + public void renderComponentTooltipFromElements(Font font, List> elements, int mouseX, int mouseY, ItemStack stack) { + this.tooltipStack = stack; + List components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponentsFromElements(stack, elements, mouseX, guiWidth(), guiHeight(), font); -+ this.renderTooltipInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE); ++ this.renderTooltipInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE, null); + this.tooltipStack = ItemStack.EMPTY; } - public void renderTooltip(Font p_282192_, List p_282297_, int p_281680_, int p_283325_) { -@@ -941,11 +_,13 @@ - - private void renderTooltipInternal(Font p_282675_, List p_282615_, int p_283230_, int p_283417_, ClientTooltipPositioner p_282442_) { + public void renderComponentTooltip(Font p_369090_, List p_365405_, int p_368143_, int p_366244_, @Nullable ResourceLocation p_364763_) { +@@ -964,11 +_,13 @@ + @Nullable ResourceLocation p_368234_ + ) { if (!p_282615_.isEmpty()) { + var preEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipPre(this.tooltipStack, this, p_283230_, p_283417_, guiWidth(), guiHeight(), p_282615_, p_282675_, p_282442_); + if (preEvent.isCanceled()) return; @@ -109,21 +115,19 @@ if (k > i) { i = k; } -@@ -955,18 +_,21 @@ +@@ -978,18 +_,19 @@ int i2 = i; int j2 = j; -- Vector2ic vector2ic = p_282442_.positionTooltip(this.guiWidth(), this.guiHeight(), p_283230_, p_283417_, i2, j2); +- Vector2ic vector2ic = p_282442_.positionTooltip(this.guiWidth(), this.guiHeight(), p_283230_, p_283417_, i, j); + Vector2ic vector2ic = p_282442_.positionTooltip(this.guiWidth(), this.guiHeight(), preEvent.getX(), preEvent.getY(), i2, j2); int l = vector2ic.x(); int i1 = vector2ic.y(); this.pose.pushPose(); int j1 = 400; -- this.drawManaged(() -> TooltipRenderUtil.renderTooltipBackground(this, l, i1, i2, j2, 400)); -+ this.drawManaged(() -> { -+ var colorEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipColor(this.tooltipStack, this, l, i1, preEvent.getFont(), p_282615_); -+ TooltipRenderUtil.renderTooltipBackground(this, l, i1, i2, j2, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundEnd(), colorEvent.getBorderStart(), colorEvent.getBorderEnd()); -+ }); +- TooltipRenderUtil.renderTooltipBackground(this, l, i1, i, j, 400, p_368234_); ++ var background_event = net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTooltipBackground(this.tooltipStack, this, l, i1, preEvent.getFont(), p_282615_, p_368234_); ++ TooltipRenderUtil.renderTooltipBackground(this, l, i1, i, j, 400, background_event.getBackground()); this.pose.translate(0.0F, 0.0F, 400.0F); int k1 = i1; @@ -131,15 +135,26 @@ ClientTooltipComponent clienttooltipcomponent1 = p_282615_.get(l1); - clienttooltipcomponent1.renderText(p_282675_, l, k1, this.pose.last().pose(), this.bufferSource); + clienttooltipcomponent1.renderText(preEvent.getFont(), l, k1, this.pose.last().pose(), this.bufferSource); - k1 += clienttooltipcomponent1.getHeight() + (l1 == 0 ? 2 : 0); + k1 += clienttooltipcomponent1.getHeight(p_282675_) + (l1 == 0 ? 2 : 0); } -@@ -974,7 +_,7 @@ +@@ -997,7 +_,7 @@ for (int k2 = 0; k2 < p_282615_.size(); k2++) { ClientTooltipComponent clienttooltipcomponent2 = p_282615_.get(k2); -- clienttooltipcomponent2.renderImage(p_282675_, l, k1, this); -+ clienttooltipcomponent2.renderImage(preEvent.getFont(), l, k1, this); - k1 += clienttooltipcomponent2.getHeight() + (k2 == 0 ? 2 : 0); +- clienttooltipcomponent2.renderImage(p_282675_, l, k1, i2, j2, this); ++ clienttooltipcomponent2.renderImage(preEvent.getFont(), l, k1, i2, j2, this); + k1 += clienttooltipcomponent2.getHeight(p_282675_) + (k2 == 0 ? 2 : 0); } +@@ -1054,6 +_,10 @@ + } + } + } ++ } ++ ++ public MultiBufferSource.BufferSource getBufferSource() { ++ return this.bufferSource; + } + + public void drawSpecial(Consumer p_367429_) { diff --git a/patches/minecraft/net/minecraft/client/gui/components/AbstractButton.java.patch b/patches/minecraft/net/minecraft/client/gui/components/AbstractButton.java.patch index 5d141a2e4f..56d0a21b54 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/AbstractButton.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/AbstractButton.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/gui/components/AbstractButton.java +++ b/net/minecraft/client/gui/components/AbstractButton.java -@@ -34,7 +_,7 @@ - RenderSystem.enableDepthTest(); - p_281670_.blitSprite(SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight()); - p_281670_.setColor(1.0F, 1.0F, 1.0F, 1.0F); +@@ -39,7 +_,7 @@ + this.getHeight(), + ARGB.white(this.alpha) + ); - int i = this.active ? 16777215 : 10526880; + int i = getFGColor(); this.renderString(p_281670_, minecraft.font, i | Mth.ceil(this.alpha * 255.0F) << 24); 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 18e208cc47..0f91a10ba9 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/components/AbstractWidget.java +++ b/net/minecraft/client/gui/components/AbstractWidget.java -@@ -255,6 +_,25 @@ +@@ -259,6 +_,25 @@ this.focused = p_93693_; } diff --git a/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch index 1384ff556d..94a2ced220 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/components/BossHealthOverlay.java +++ b/net/minecraft/client/gui/components/BossHealthOverlay.java -@@ -63,13 +_,16 @@ +@@ -66,13 +_,16 @@ for (LerpingBossEvent lerpingbossevent : this.events.values()) { int k = i / 2 - 91; 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 ae5eb1459d..b9aae530d0 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/components/DebugScreenOverlay.java +++ b/net/minecraft/client/gui/components/DebugScreenOverlay.java -@@ -101,9 +_,9 @@ +@@ -105,9 +_,9 @@ @Nullable private CompletableFuture serverChunk; private boolean renderDebug; @@ -13,53 +13,54 @@ private final LocalSampleLogger frameTimeLogger = new LocalSampleLogger(1); private final LocalSampleLogger tickTimeLogger = new LocalSampleLogger(TpsDebugDimensions.values().length); private final LocalSampleLogger pingLogger = new LocalSampleLogger(1); -@@ -129,14 +_,18 @@ +@@ -135,14 +_,18 @@ this.clientChunk = null; } - public void render(GuiGraphics p_281427_) { -- this.minecraft.getProfiler().push("debug"); +- ProfilerFiller profilerfiller = Profiler.get(); +- profilerfiller.push("debug"); + protected void update() { Entity entity = this.minecraft.getCameraEntity(); this.block = entity.pick(20.0, 0.0F, false); this.liquid = entity.pick(20.0, 0.0F, true); -- p_281427_.drawManaged(() -> { + } + -+ protected void drawText(GuiGraphics p_281427_) { - this.drawGameInformation(p_281427_); - this.drawSystemInformation(p_281427_); ++ protected void drawText(ProfilerFiller profilerfiller, GuiGraphics p_281427_) { + this.drawGameInformation(p_281427_); + this.drawSystemInformation(p_281427_); + } + -+ protected void drawFPSCharts(GuiGraphics p_281427_) { - if (this.renderFpsCharts) { - int i = p_281427_.guiWidth(); - int j = i / 2; -@@ -146,7 +_,9 @@ - this.tpsChart.drawChart(p_281427_, i - k, k); - } - } ++ protected void drawFPSCharts(ProfilerFiller profilerfiller, GuiGraphics p_281427_) { + this.profilerPieChart.setBottomOffset(10); + if (this.renderFpsCharts) { + int i = p_281427_.guiWidth(); +@@ -155,7 +_,9 @@ + + this.profilerPieChart.setBottomOffset(this.tpsChart.getFullHeight()); + } + } -+ protected void drawNetworkCharts(GuiGraphics p_281427_) { - if (this.renderNetworkCharts) { - int l = p_281427_.guiWidth(); - int i1 = l / 2; -@@ -157,12 +_,21 @@ - int j1 = this.pingChart.getWidth(i1); - this.pingChart.drawChart(p_281427_, l - j1, j1); - } ++ protected void drawNetworkCharts(ProfilerFiller profilerfiller, GuiGraphics p_281427_) { + if (this.renderNetworkCharts) { + int l = p_281427_.guiWidth(); + int i1 = l / 2; +@@ -171,12 +_,22 @@ + try (Zone zone = profilerfiller.zone("profilerPie")) { + this.profilerPieChart.render(p_281427_); + } + } + + public void render(GuiGraphics p_281427_) { -+ this.minecraft.getProfiler().push("debug"); ++ ProfilerFiller profilerfiller = Profiler.get(); ++ profilerfiller.push("debug"); + this.update(); -+ p_281427_.drawManaged(() -> { -+ this.drawText(p_281427_); -+ this.drawFPSCharts(p_281427_); -+ this.drawNetworkCharts(p_281427_); - }); - this.minecraft.getProfiler().pop(); ++ ++ this.drawText(profilerfiller, p_281427_); ++ this.drawFPSCharts(profilerfiller, p_281427_); ++ this.drawNetworkCharts(profilerfiller, p_281427_); + + profilerfiller.pop(); } - protected void drawGameInformation(GuiGraphics p_281525_) { @@ -69,7 +70,7 @@ list.add(""); boolean flag = this.minecraft.getSingleplayerServer() != null; list.add( -@@ -176,11 +_,18 @@ +@@ -190,11 +_,18 @@ + (this.renderNetworkCharts ? " visible" : " hidden") ); list.add("For help: press F3 + Q"); @@ -79,17 +80,17 @@ + protected void drawGameInformation(GuiGraphics p_281525_) { + List list = this.getGameInformation(); + list.addAll(this.getOverlayHelp()); -+ net.minecraftforge.client.ForgeHooksClient.onCustomizeDebugEvent(p_281525_, minecraft.getWindow(), minecraft.getTimer().getRealtimeDeltaTicks(), list, true); ++ net.minecraftforge.client.ForgeHooksClient.onCustomizeDebugEvent(p_281525_, minecraft.getWindow(), minecraft.getDeltaTracker().getRealtimeDeltaTicks(), list, true); + this.renderLines(p_281525_, list, true); } protected void drawSystemInformation(GuiGraphics p_281261_) { List list = this.getSystemInformation(); -+ net.minecraftforge.client.ForgeHooksClient.onCustomizeDebugEvent(p_281261_, minecraft.getWindow(), minecraft.getTimer().getRealtimeDeltaTicks(), list, false); ++ net.minecraftforge.client.ForgeHooksClient.onCustomizeDebugEvent(p_281261_, minecraft.getWindow(), minecraft.getDeltaTracker().getRealtimeDeltaTicks(), list, false); this.renderLines(p_281261_, list, false); } -@@ -529,6 +_,7 @@ +@@ -543,6 +_,7 @@ list.add(""); list.add(ChatFormatting.UNDERLINE + "Targeted Entity"); list.add(String.valueOf(BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()))); diff --git a/patches/minecraft/net/minecraft/client/gui/components/toasts/ToastComponent.java.patch b/patches/minecraft/net/minecraft/client/gui/components/toasts/ToastComponent.java.patch deleted file mode 100644 index 3e682a3adc..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/components/toasts/ToastComponent.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/client/gui/components/toasts/ToastComponent.java -+++ b/net/minecraft/client/gui/components/toasts/ToastComponent.java -@@ -97,6 +_,7 @@ - } - - public void addToast(Toast p_94923_) { -+ if (net.minecraftforge.client.ForgeHooksClient.onToastAdd(p_94923_)) return; - this.queued.add(p_94923_); - } - diff --git a/patches/minecraft/net/minecraft/client/gui/components/toasts/ToastManager.java.patch b/patches/minecraft/net/minecraft/client/gui/components/toasts/ToastManager.java.patch new file mode 100644 index 0000000000..d0fa544e40 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/components/toasts/ToastManager.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/gui/components/toasts/ToastManager.java ++++ b/net/minecraft/client/gui/components/toasts/ToastManager.java +@@ -107,6 +_,7 @@ + } + + public void addToast(Toast p_360768_) { ++ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onToastAdd(p_360768_)) return; + this.queued.add(p_360768_); + } + 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 c969051b14..d91b950e22 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,30 @@ --- a/net/minecraft/client/gui/screens/LoadingOverlay.java +++ b/net/minecraft/client/gui/screens/LoadingOverlay.java -@@ -131,6 +_,7 @@ +@@ -62,6 +_,8 @@ + return p_169325_ & 16777215 | p_169326_ << 24; + } + ++ protected boolean renderContents(GuiGraphics gui, float alpha) { return true; } ++ + @Override + public void render(GuiGraphics p_281839_, int p_282704_, int p_283650_, float p_283394_) { + int i = p_281839_.guiWidth(); +@@ -100,6 +_,7 @@ + f2 = 1.0F; + } + ++ if (renderContents(p_281839_, f2)) { + int k2 = (int)((double)p_281839_.guiWidth() * 0.5); + int l2 = (int)((double)p_281839_.guiHeight() * 0.5); + double d1 = Math.min((double)p_281839_.guiWidth() * 0.75, (double)p_281839_.guiHeight()) * 0.25; +@@ -115,12 +_,14 @@ + if (f < 1.0F) { + this.drawProgressBar(p_281839_, i / 2 - j1, l1 - 5, i / 2 + j1, l1 + 5, 1.0F - Mth.clamp(f, 0.0F, 1.0F)); + } ++ } + + if (f >= 2.0F) { + this.minecraft.setOverlay(null); } if (this.fadeOutStart == -1L && this.reload.isDone() && (!this.fadeIn || f1 >= 2.0F)) { @@ -8,7 +32,7 @@ try { this.reload.checkExceptions(); this.onFinish.accept(Optional.empty()); -@@ -138,7 +_,6 @@ +@@ -128,7 +_,6 @@ this.onFinish.accept(Optional.of(throwable)); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/PauseScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/PauseScreen.java.patch index c6b9e05587..84f93468af 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/PauseScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/PauseScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/PauseScreen.java +++ b/net/minecraft/client/gui/screens/PauseScreen.java -@@ -94,6 +_,7 @@ +@@ -95,6 +_,7 @@ } else { gridlayout$rowhelper.addChild(this.openScreenButton(PLAYER_REPORTING, () -> new SocialInteractionsScreen(this))); } 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 e64ba39563..b2ffeb2dd9 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 -@@ -201,7 +_,7 @@ +@@ -200,7 +_,7 @@ } public void onClose() { @@ -9,7 +9,7 @@ } protected T addRenderableWidget(T p_169406_) { -@@ -312,8 +_,10 @@ +@@ -311,8 +_,10 @@ this.width = p_96608_; this.height = p_96609_; if (!this.initialized) { @@ -20,7 +20,7 @@ } else { this.repositionElements(); } -@@ -326,8 +_,10 @@ +@@ -325,8 +_,10 @@ protected void rebuildWidgets() { this.clearWidgets(); this.clearFocus(); @@ -31,15 +31,15 @@ } @Override -@@ -354,6 +_,7 @@ +@@ -353,6 +_,7 @@ - this.renderBlurredBackground(p_297268_); + this.renderBlurredBackground(); this.renderMenuBackground(p_283688_); + net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderScreenBackground(this, p_283688_); } - protected void renderBlurredBackground(float p_336041_) { -@@ -463,6 +_,19 @@ + protected void renderBlurredBackground() { +@@ -454,6 +_,19 @@ } public void onFilesDrop(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 0c78647e6f..0e956fe57f 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch @@ -14,26 +14,26 @@ int l = this.height / 4 + 48; + Button modButton = null; if (this.minecraft.isDemo()) { - this.createDemoMenuOptions(l, 24); + l = this.createDemoMenuOptions(l, 24); } else { - this.createNormalMenuOptions(l, 24); + l = this.createNormalMenuOptions(l, 24); + modButton = this.addRenderableWidget(Button.builder(Component.translatable("fml.menu.mods"), button -> this.minecraft.setScreen(new net.minecraftforge.client.gui.ModListScreen(this))) -+ .pos(this.width / 2 - 100, l + 24 * 2).size(98, 20).build()); ++ .pos(this.width / 2 - 100, l).size(98, 20).build()); } + modUpdateNotification = net.minecraftforge.client.gui.TitleScreenModUpdateIndicator.init(this, modButton); + l = this.createTestWorldButton(l, 24); SpriteIconButton spriteiconbutton = this.addRenderableWidget( - CommonButtons.language( -@@ -170,7 +_,7 @@ - }).bounds(this.width / 2 - 100, p_96764_ + p_96765_ * 1, 200, 20).tooltip(tooltip).build()).active = flag; +@@ -184,7 +_,7 @@ + }).bounds(this.width / 2 - 100, i = p_96764_ + p_96765_, 200, 20).tooltip(tooltip).build()).active = flag; this.addRenderableWidget( Button.builder(Component.translatable("menu.online"), p_325369_ -> this.minecraft.setScreen(new RealmsMainScreen(this))) -- .bounds(this.width / 2 - 100, p_96764_ + p_96765_ * 2, 200, 20) -+ .bounds(this.width / 2 + 2, p_96764_ + p_96765_ * 2, 98, 20) +- .bounds(this.width / 2 - 100, p_96764_ = i + p_96765_, 200, 20) ++ .bounds(this.width / 2 + 2, p_96764_ = i + p_96765_, 98, 20) .tooltip(tooltip) .build() ) -@@ -276,6 +_,7 @@ +@@ -293,6 +_,7 @@ if ((i & -67108864) != 0) { super.render(p_282860_, p_281753_, p_283539_, p_282628_); this.logoRenderer.renderLogo(p_282860_, this.width, f); @@ -41,7 +41,7 @@ if (this.splash != null && !this.minecraft.options.hideSplashTexts().get()) { this.splash.render(p_282860_, this.width, this.font, i); } -@@ -291,11 +_,19 @@ +@@ -308,10 +_,18 @@ s = s + I18n.get("menu.modded"); } @@ -55,7 +55,6 @@ + ); + if (this.realmsNotificationsEnabled() && f >= 1.0F) { - RenderSystem.enableDepthTest(); this.realmsNotificationsScreen.render(p_282860_, p_281753_, p_283539_, p_282628_); } + if (f >= 1.0f) this.modUpdateNotification.render(p_282860_, p_281753_, p_283539_, p_282628_); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch index 77a576f7dd..ddd9a85098 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementTab.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementTab.java -@@ -37,6 +_,7 @@ +@@ -38,6 +_,7 @@ private int maxY = Integer.MIN_VALUE; private float fade; private boolean centered; @@ -8,7 +8,7 @@ public AdvancementTab( Minecraft p_97145_, AdvancementsScreen p_97146_, AdvancementTabType p_97147_, int p_97148_, AdvancementNode p_297568_, DisplayInfo p_97150_ -@@ -53,6 +_,15 @@ +@@ -54,6 +_,15 @@ this.addWidget(this.root, p_297568_.holder()); } @@ -24,7 +24,7 @@ public AdvancementTabType getType() { return this.type; } -@@ -146,8 +_,8 @@ +@@ -147,8 +_,8 @@ return null; } else { for (AdvancementTabType advancementtabtype : AdvancementTabType.values()) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch index e59c5b25e0..d8eeab7d80 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java -@@ -69,6 +_,7 @@ +@@ -70,6 +_,7 @@ 5 ); 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 bcfeee7b7b..f39b9b6186 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java -@@ -49,6 +_,7 @@ +@@ -51,6 +_,7 @@ @Nullable private AdvancementTab selectedTab; private boolean isScrolling; @@ -8,7 +8,7 @@ public AdvancementsScreen(ClientAdvancements p_97340_) { this(p_97340_, null); -@@ -62,6 +_,19 @@ +@@ -64,6 +_,19 @@ @Override protected void init() { @@ -28,7 +28,7 @@ this.layout.addTitleHeader(TITLE, this.font); this.tabs.clear(); this.selectedTab = null; -@@ -106,7 +_,7 @@ +@@ -108,7 +_,7 @@ int j = (this.height - 140) / 2; for (AdvancementTab advancementtab : this.tabs.values()) { @@ -37,8 +37,8 @@ this.advancements.setSelectedTab(advancementtab.getRootNode().holder(), true); break; } -@@ -180,10 +_,12 @@ - p_283395_.blit(WINDOW_LOCATION, p_281890_, p_282532_, 0, 0, 252, 140); +@@ -181,10 +_,12 @@ + p_283395_.blit(RenderType::guiTextured, WINDOW_LOCATION, p_281890_, p_282532_, 0.0F, 0.0F, 252, 140, 256, 256); if (this.tabs.size() > 1) { for (AdvancementTab advancementtab : this.tabs.values()) { + if (advancementtab.getPage() == tabPage) @@ -50,7 +50,7 @@ advancementtab1.drawIcon(p_283395_, p_281890_, p_282532_); } } -@@ -203,6 +_,7 @@ +@@ -202,6 +_,7 @@ if (this.tabs.size() > 1) { for (AdvancementTab advancementtab : this.tabs.values()) { 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 2e2ced75b5..86593465a8 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,49 +1,32 @@ --- a/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java +++ b/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java -@@ -92,6 +_,7 @@ +@@ -108,6 +_,7 @@ int i = this.leftPos; int j = this.topPos; super.render(p_283479_, p_283661_, p_281248_, p_281886_); + net.minecraftforge.client.event.ForgeEventFactoryClient.onContainerRenderBackground(this, p_283479_, p_283661_, p_281248_); - RenderSystem.disableDepthTest(); p_283479_.pose().pushPose(); p_283479_.pose().translate((float)i, (float)j, 0.0F); -@@ -108,12 +_,13 @@ - int l = slot.x; - int i1 = slot.y; - if (this.hoveredSlot.isHighlightable()) { -- renderSlotHighlight(p_283479_, l, i1, 0); -+ renderSlotHighlight(p_283479_, l, i1, 0, getSlotColor(k)); - } - } + Slot slot = this.hoveredSlot; +@@ -119,6 +_,8 @@ + this.onStopHovering(slot); } - this.renderLabels(p_283479_, p_283661_, p_281248_); + net.minecraftforge.client.event.ForgeEventFactoryClient.onContainerRenderForeground(this, p_283479_, p_283661_, p_281248_); ++ + this.renderLabels(p_283479_, p_283661_, p_281248_); ItemStack itemstack = this.draggingItem.isEmpty() ? this.menu.getCarried() : this.draggingItem; if (!itemstack.isEmpty()) { - int l1 = 8; -@@ -156,13 +_,17 @@ - } - - public static void renderSlotHighlight(GuiGraphics p_283692_, int p_281453_, int p_281915_, int p_283504_) { -- p_283692_.fillGradient(RenderType.guiOverlay(), p_281453_, p_281915_, p_281453_ + 16, p_281915_ + 16, -2130706433, -2130706433, p_283504_); -+ renderSlotHighlight(p_283692_, p_281453_, p_281915_, p_283504_, -2130706433); -+ } -+ -+ public static void renderSlotHighlight(GuiGraphics p_283692_, int p_281453_, int p_281915_, int p_283504_, int color) { -+ p_283692_.fillGradient(RenderType.guiOverlay(), p_281453_, p_281915_, p_281453_ + 16, p_281915_ + 16, color, color, p_283504_); - } - - protected void renderTooltip(GuiGraphics p_283594_, int p_282171_, int p_281909_) { - if (this.menu.getCarried().isEmpty() && this.hoveredSlot != null && this.hoveredSlot.hasItem()) { +@@ -199,7 +_,7 @@ ItemStack itemstack = this.hoveredSlot.getItem(); -- p_283594_.renderTooltip(this.font, this.getTooltipFromContainerItem(itemstack), itemstack.getTooltipImage(), p_282171_, p_281909_); -+ p_283594_.renderTooltip(this.font, this.getTooltipFromContainerItem(itemstack), itemstack.getTooltipImage(), itemstack, p_282171_, p_281909_); + if (this.menu.getCarried().isEmpty() || this.showTooltipWithItemInHand(itemstack)) { + p_283594_.renderTooltip( +- this.font, this.getTooltipFromContainerItem(itemstack), itemstack.getTooltipImage(), p_282171_, p_281909_, itemstack.get(DataComponents.TOOLTIP_STYLE) ++ this.font, this.getTooltipFromContainerItem(itemstack), itemstack.getTooltipImage(), itemstack, p_282171_, p_281909_ + ); + } } - } - -@@ -174,7 +_,8 @@ +@@ -217,7 +_,8 @@ p_282567_.pose().pushPose(); p_282567_.pose().translate(0.0F, 0.0F, 232.0F); p_282567_.renderItem(p_281330_, p_281772_, p_281689_); @@ -53,17 +36,17 @@ p_282567_.pose().popPose(); } -@@ -282,7 +_,8 @@ +@@ -324,7 +_,8 @@ if (super.mouseClicked(p_97748_, p_97749_, p_97750_)) { return true; } else { - boolean flag = this.minecraft.options.keyPickItem.matchesMouse(p_97750_) && this.minecraft.gameMode.hasInfiniteItems(); + InputConstants.Key mouseKey = InputConstants.Type.MOUSE.getOrCreate(p_97750_); + boolean flag = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey); - Slot slot = this.findSlot(p_97748_, p_97749_); + Slot slot = this.getHoveredSlot(p_97748_, p_97749_); long i = Util.getMillis(); this.doubleclick = this.lastClickSlot == slot && i - this.lastClickTime < 250L && this.lastClickButton == p_97750_; -@@ -293,6 +_,7 @@ +@@ -335,6 +_,7 @@ int j = this.leftPos; int k = this.topPos; boolean flag1 = this.hasClickedOutside(p_97748_, p_97749_, j, k, p_97750_); @@ -71,7 +54,7 @@ int l = -1; if (slot != null) { l = slot.index; -@@ -318,7 +_,7 @@ +@@ -360,7 +_,7 @@ } } else if (!this.isQuickCrafting) { if (this.menu.getCarried().isEmpty()) { @@ -80,7 +63,7 @@ this.slotClicked(slot, l, p_97750_, ClickType.CLONE); } else { boolean flag2 = l != -999 -@@ -346,7 +_,7 @@ +@@ -388,7 +_,7 @@ this.quickCraftingType = 0; } else if (p_97750_ == 1) { this.quickCraftingType = 1; @@ -89,12 +72,12 @@ this.quickCraftingType = 2; } } -@@ -425,10 +_,13 @@ +@@ -467,10 +_,13 @@ @Override public boolean mouseReleased(double p_97812_, double p_97813_, int p_97814_) { + super.mouseReleased(p_97812_, p_97813_, p_97814_); //Forge, Call parent to release buttons - Slot slot = this.findSlot(p_97812_, p_97813_); + Slot slot = this.getHoveredSlot(p_97812_, p_97813_); int i = this.leftPos; int j = this.topPos; boolean flag = this.hasClickedOutside(p_97812_, p_97813_, i, j, p_97814_); @@ -103,7 +86,7 @@ int k = -1; if (slot != null) { k = slot.index; -@@ -445,7 +_,7 @@ +@@ -487,7 +_,7 @@ if (slot2 != null && slot2.mayPickup(this.minecraft.player) && slot2.hasItem() @@ -112,7 +95,7 @@ && AbstractContainerMenu.canItemQuickReplace(slot2, this.lastQuickMoved, true)) { this.slotClicked(slot2, slot2.index, p_97814_, ClickType.QUICK_MOVE); } -@@ -509,7 +_,7 @@ +@@ -551,7 +_,7 @@ this.slotClicked(null, -999, AbstractContainerMenu.getQuickcraftMask(2, this.quickCraftingType), ClickType.QUICK_CRAFT); } else if (!this.menu.getCarried().isEmpty()) { @@ -121,7 +104,7 @@ this.slotClicked(slot, k, p_97814_, ClickType.CLONE); } else { boolean flag1 = k != -999 -@@ -568,9 +_,10 @@ +@@ -631,9 +_,10 @@ @Override public boolean keyPressed(int p_97765_, int p_97766_, int p_97767_) { @@ -133,11 +116,10 @@ this.onClose(); return true; } else { -@@ -639,5 +_,17 @@ - public void onClose() { - this.minecraft.player.closeContainer(); +@@ -707,4 +_,11 @@ + super.onClose(); -+ } + } + + @org.jetbrains.annotations.Nullable + public Slot getSlotUnderMouse() { return this.hoveredSlot; } @@ -145,9 +127,4 @@ + public int getGuiTop() { return topPos; } + public int getXSize() { return imageWidth; } + public int getYSize() { return imageHeight; } -+ -+ protected int slotColor = -2130706433; -+ public int getSlotColor(int index) { -+ return slotColor; - } } 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 4a8347aeb6..3be90137b4 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,15 +1,15 @@ --- a/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java +++ b/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java -@@ -112,6 +_,8 @@ - private boolean hasClickedOutside; +@@ -115,6 +_,8 @@ private final Set> visibleTags = new HashSet<>(); private final boolean displayOperatorCreativeTab; + private final EffectsInInventory effects; + 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<>()); public CreativeModeInventoryScreen(LocalPlayer p_344408_, FeatureFlagSet p_260074_, boolean p_259569_) { super(new CreativeModeInventoryScreen.ItemPickerMenu(p_344408_), p_344408_.getInventory(), CommonComponents.EMPTY); -@@ -159,7 +_,7 @@ +@@ -163,7 +_,7 @@ private void refreshCurrentTabContents(Collection p_261591_) { int i = this.menu.getRowIndexForScroll(this.scrollOffs); this.menu.items.clear(); @@ -18,7 +18,7 @@ this.refreshSearchResults(); } else { this.menu.items.addAll(p_261591_); -@@ -322,6 +_,35 @@ +@@ -331,6 +_,35 @@ protected void init() { if (this.minecraft.gameMode.hasInfiniteItems()) { super.init(); @@ -54,7 +54,7 @@ this.searchBox = new EditBox(this.font, this.leftPos + 82, this.topPos + 6, 80, 9, Component.translatable("itemGroup.search")); this.searchBox.setMaxLength(50); this.searchBox.setBordered(false); -@@ -368,7 +_,7 @@ +@@ -377,7 +_,7 @@ public boolean charTyped(char p_98521_, int p_98522_) { if (this.ignoreTextInput) { return false; @@ -63,7 +63,7 @@ return false; } else { String s = this.searchBox.getValue(); -@@ -387,7 +_,7 @@ +@@ -396,7 +_,7 @@ @Override public boolean keyPressed(int p_98547_, int p_98548_, int p_98549_) { this.ignoreTextInput = false; @@ -72,7 +72,7 @@ if (this.minecraft.options.keyChat.matches(p_98547_, p_98548_)) { this.ignoreTextInput = true; this.selectTab(CreativeModeTabs.searchTab()); -@@ -423,6 +_,7 @@ +@@ -432,6 +_,7 @@ } private void refreshSearchResults() { @@ -80,7 +80,7 @@ this.menu.items.clear(); this.visibleTags.clear(); String s = this.searchBox.getValue(); -@@ -435,10 +_,10 @@ +@@ -444,10 +_,10 @@ SearchTree searchtree; if (s.startsWith("#")) { s = s.substring(1); @@ -93,7 +93,7 @@ } this.menu.items.addAll(searchtree.search(s.toLowerCase(Locale.ROOT))); -@@ -466,7 +_,8 @@ +@@ -479,7 +_,8 @@ @Override protected void renderLabels(GuiGraphics p_283168_, int p_281774_, int p_281466_) { if (selectedTab.showTitle()) { @@ -103,7 +103,7 @@ } } -@@ -476,7 +_,7 @@ +@@ -489,7 +_,7 @@ double d0 = p_98531_ - (double)this.leftPos; double d1 = p_98532_ - (double)this.topPos; @@ -112,7 +112,7 @@ if (this.checkTabClicked(creativemodetab, d0, d1)) { return true; } -@@ -498,7 +_,7 @@ +@@ -511,7 +_,7 @@ double d1 = p_98623_ - (double)this.topPos; this.scrolling = false; @@ -121,15 +121,7 @@ if (this.checkTabClicked(creativemodetab, d0, d1)) { this.selectTab(creativemodetab); return true; -@@ -516,6 +_,7 @@ - private void selectTab(CreativeModeTab p_98561_) { - CreativeModeTab creativemodetab = selectedTab; - selectedTab = p_98561_; -+ slotColor = p_98561_.getSlotColor(); - this.quickCraftSlots.clear(); - this.menu.items.clear(); - this.clearDraggingState(); -@@ -592,13 +_,15 @@ +@@ -605,13 +_,15 @@ this.originalSlots = null; } @@ -146,9 +138,9 @@ this.refreshSearchResults(); } else { -@@ -661,7 +_,15 @@ - public void render(GuiGraphics p_283000_, int p_281317_, int p_282770_, float p_281295_) { +@@ -677,7 +_,15 @@ super.render(p_283000_, p_281317_, p_282770_, p_281295_); + this.effects.render(p_283000_, p_281317_, p_282770_, p_281295_); - for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { + if (this.pages.size() != 1) { @@ -163,7 +155,7 @@ if (this.checkTabHovering(p_283000_, creativemodetab, p_281317_, p_282770_)) { break; } -@@ -673,6 +_,7 @@ +@@ -689,6 +_,7 @@ p_283000_.renderTooltip(this.font, TRASH_SLOT_TOOLTIP, p_281317_, p_282770_); } @@ -171,7 +163,7 @@ this.renderTooltip(p_283000_, p_281317_, p_282770_); } -@@ -680,7 +_,7 @@ +@@ -701,7 +_,7 @@ public List getTooltipFromContainerItem(ItemStack p_281769_) { boolean flag = this.hoveredSlot != null && this.hoveredSlot instanceof CreativeModeInventoryScreen.CustomCreativeSlot; boolean flag1 = selectedTab.getType() == CreativeModeTab.Type.CATEGORY; @@ -180,7 +172,7 @@ TooltipFlag.Default tooltipflag$default = this.minecraft.options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL; TooltipFlag tooltipflag = flag ? tooltipflag$default.asCreative() : tooltipflag$default; List list = p_281769_.getTooltipLines(Item.TooltipContext.of(this.minecraft.level), this.minecraft.player, tooltipflag); -@@ -699,7 +_,7 @@ +@@ -720,7 +_,7 @@ int i = 1; for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { @@ -189,7 +181,7 @@ list1.add(i++, creativemodetab.getDisplayName().copy().withStyle(ChatFormatting.BLUE)); } } -@@ -710,7 +_,7 @@ +@@ -731,7 +_,7 @@ @Override protected void renderBg(GuiGraphics p_282663_, float p_282504_, int p_282089_, int p_282249_) { @@ -198,15 +190,15 @@ if (creativemodetab != selectedTab) { this.renderTabButton(p_282663_, creativemodetab); } -@@ -726,6 +_,7 @@ - p_282663_.blitSprite(resourcelocation, j, k + (int)((float)(i - k - 17) * this.scrollOffs), 12, 15); +@@ -747,6 +_,7 @@ + p_282663_.blitSprite(RenderType::guiTextured, resourcelocation, j, k + (int)((float)(i - k - 17) * this.scrollOffs), 12, 15); } + if (currentPage.getVisibleTabs().contains(selectedTab)) //Forge: only display tab selection when the selected tab is on the current page this.renderTabButton(p_282663_, selectedTab); if (selectedTab.getType() == CreativeModeTab.Type.INVENTORY) { InventoryScreen.renderEntityInInventoryFollowsMouse( -@@ -744,7 +_,7 @@ +@@ -765,7 +_,7 @@ } private int getTabX(CreativeModeTab p_260136_) { @@ -215,7 +207,7 @@ int j = 27; int k = 27 * i; if (p_260136_.isAlignedRight()) { -@@ -756,7 +_,7 @@ +@@ -777,7 +_,7 @@ private int getTabY(CreativeModeTab p_260181_) { int i = 0; @@ -224,7 +216,7 @@ i -= 32; } else { i += this.imageHeight; -@@ -784,8 +_,8 @@ +@@ -805,8 +_,8 @@ protected void renderTabButton(GuiGraphics p_283590_, CreativeModeTab p_283489_) { boolean flag = p_283489_ == selectedTab; @@ -235,15 +227,15 @@ int j = this.leftPos + this.getTabX(p_283489_); int k = this.topPos - (flag1 ? 28 : -(this.imageHeight - 4)); ResourceLocation[] aresourcelocation; -@@ -795,6 +_,7 @@ +@@ -816,6 +_,7 @@ aresourcelocation = flag ? SELECTED_BOTTOM_TABS : UNSELECTED_BOTTOM_TABS; } + com.mojang.blaze3d.systems.RenderSystem.enableBlend(); //Forge: Make sure blend is enabled else tabs show a white border. - p_283590_.blitSprite(aresourcelocation[Mth.clamp(i, 0, aresourcelocation.length)], j, k, 26, 32); + p_283590_.blitSprite(RenderType::guiTextured, aresourcelocation[Mth.clamp(i, 0, aresourcelocation.length)], j, k, 26, 32); p_283590_.pose().pushPose(); p_283590_.pose().translate(0.0F, 0.0F, 100.0F); -@@ -836,6 +_,14 @@ +@@ -857,6 +_,14 @@ } } @@ -258,7 +250,7 @@ @OnlyIn(Dist.CLIENT) static class CustomCreativeSlot extends Slot { public CustomCreativeSlot(Container p_98633_, int p_98634_, int p_98635_, int p_98636_) { -@@ -1020,6 +_,22 @@ +@@ -1038,6 +_,22 @@ @Override public boolean mayPickup(Player p_98665_) { return this.target.mayPickup(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/EffectsInInventory.java.patch similarity index 56% rename from patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch rename to patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java.patch index c7c8d832b6..3834589086 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java.patch @@ -1,10 +1,10 @@ ---- a/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java -+++ b/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java -@@ -47,12 +_,16 @@ +--- a/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java ++++ b/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java +@@ -48,12 +_,16 @@ Collection collection = this.minecraft.player.getActiveEffects(); if (!collection.isEmpty() && j >= 32) { boolean flag = j >= 120; -+ var event = net.minecraftforge.client.ForgeHooksClient.onScreenPotionSize(this, j, !flag, i); ++ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenEffectSize(this.screen, j, !flag, i); + if (event.isCanceled()) return; + flag = !event.isCompact(); + i = event.getHorizontalOffset(); @@ -15,30 +15,40 @@ - Iterable iterable = Ordering.natural().sortedCopy(collection); + Iterable iterable = collection.stream().filter(net.minecraftforge.client.ForgeHooksClient::shouldRenderEffect).sorted().toList(); - this.renderBackgrounds(p_281945_, i, k, iterable, flag); - this.renderIcons(p_281945_, i, k, iterable, flag); + this.renderBackgrounds(p_362146_, i, k, iterable, flag); + this.renderIcons(p_362146_, i, k, iterable, flag); if (flag) { -@@ -98,6 +_,11 @@ - int i = this.topPos; +@@ -99,6 +_,11 @@ + int i = this.screen.topPos; - for (MobEffectInstance mobeffectinstance : p_282642_) { + for (MobEffectInstance mobeffectinstance : p_361981_) { + var renderer = net.minecraftforge.client.extensions.common.IClientMobEffectExtensions.of(mobeffectinstance); -+ if (renderer.renderInventoryIcon(mobeffectinstance, this, p_282745_, p_282521_ + (p_281536_ ? 6 : 7), i, 0)) { -+ i += p_282291_; ++ if (renderer.renderInventoryIcon(mobeffectinstance, this, p_367085_, p_367644_ + (p_368681_ ? 6 : 7), i, 0)) { ++ i += p_367522_; + continue; + } Holder holder = mobeffectinstance.getEffect(); TextureAtlasSprite textureatlassprite = mobeffecttexturemanager.get(holder); - p_282745_.blit(p_282521_ + (p_281536_ ? 6 : 7), i + 7, 0, 18, 18, textureatlassprite); -@@ -109,6 +_,11 @@ - int i = this.topPos; + p_367085_.blitSprite(RenderType::guiTextured, textureatlassprite, p_367644_ + (p_368681_ ? 6 : 7), i + 7, 18, 18); +@@ -110,6 +_,11 @@ + int i = this.screen.topPos; - for (MobEffectInstance mobeffectinstance : p_281986_) { + for (MobEffectInstance mobeffectinstance : p_365480_) { + var renderer = net.minecraftforge.client.extensions.common.IClientMobEffectExtensions.of(mobeffectinstance); -+ if (renderer.renderInventoryText(mobeffectinstance, this, p_281462_, p_283484_, i, 0)) { -+ i += p_282057_; ++ if (renderer.renderInventoryText(mobeffectinstance, this, p_361851_, p_367468_, i, 0)) { ++ i += p_365556_; + continue; + } Component component = this.getEffectName(mobeffectinstance); - p_281462_.drawString(this.font, component, p_283484_ + 10 + 18, i + 6, 16777215); + p_361851_.drawString(this.screen.getFont(), component, p_367468_ + 10 + 18, i + 6, 16777215); Component component1 = MobEffectUtil.formatDuration(mobeffectinstance, 1.0F, this.minecraft.level.tickRateManager().tickrate()); +@@ -125,5 +_,9 @@ + } + + return mutablecomponent; ++ } ++ ++ public AbstractContainerScreen getScreen() { ++ return this.screen; + } + } 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 cdbd0e4a75..8dc2658742 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,18 +1,18 @@ --- a/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java +++ b/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java -@@ -111,7 +_,7 @@ +@@ -109,7 +_,7 @@ int l1 = 86 - this.font.width(s); FormattedText formattedtext = EnchantmentNames.getInstance().getRandomName(this.font, l1); int i2 = 6839882; - if ((k < l + 1 || this.minecraft.player.experienceLevel < k1) && !this.minecraft.player.getAbilities().instabuild) { + if (((k < l + 1 || this.minecraft.player.experienceLevel < k1) && !this.minecraft.player.getAbilities().instabuild) || this.menu.enchantClue[l] == -1) { // Forge: render buttons as disabled when enchantable but enchantability not met on lower levels{ - RenderSystem.enableBlend(); - p_282430_.blitSprite(ENCHANTMENT_SLOT_DISABLED_SPRITE, i1, j + 14 + 19 * l, 108, 19); - p_282430_.blitSprite(DISABLED_LEVEL_SPRITES[l], i1 + 1, j + 15 + 19 * l, 16, 16); -@@ -177,13 +_,16 @@ + p_282430_.blitSprite(RenderType::guiTextured, ENCHANTMENT_SLOT_DISABLED_SPRITE, i1, j + 14 + 19 * l, 108, 19); + p_282430_.blitSprite(RenderType::guiTextured, DISABLED_LEVEL_SPRITES[l], i1 + 1, j + 15 + 19 * l, 16, 16); + p_282430_.drawWordWrap(this.font, formattedtext, j1, j + 16 + 19 * l, l1, (i2 & 16711422) >> 1); +@@ -175,13 +_,16 @@ .registryAccess() - .registryOrThrow(Registries.ENCHANTMENT) - .getHolder(this.menu.enchantClue[j]); + .lookupOrThrow(Registries.ENCHANTMENT) + .get(this.menu.enchantClue[j]); - if (!optional.isEmpty()) { + { int l = this.menu.levelClue[j]; diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java.patch index 74155da1f7..0b4bbf6b6e 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java +++ b/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java -@@ -15,7 +_,7 @@ +@@ -16,7 +_,7 @@ private static final Vector3f TEXT_SCALE = new Vector3f(1.0F, 1.0F, 1.0F); private static final int TEXTURE_WIDTH = 16; private static final int TEXTURE_HEIGHT = 16; 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 551b637c82..a86f0be302 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 @@ -1,16 +1,17 @@ --- a/net/minecraft/client/gui/screens/inventory/MerchantScreen.java +++ b/net/minecraft/client/gui/screens/inventory/MerchantScreen.java -@@ -234,7 +_,12 @@ - p_281357_.renderItemDecorations(this.font, p_283466_, p_282403_, p_283601_); +@@ -232,6 +_,14 @@ } else { p_281357_.renderItemDecorations(this.font, p_282046_, p_282403_, p_283601_, p_282046_.getCount() == 1 ? "1" : null); -- p_281357_.renderItemDecorations(this.font, p_283466_, p_282403_ + 14, p_283601_, p_283466_.getCount() == 1 ? "1" : null); + p_281357_.renderItemDecorations(this.font, p_283466_, p_282403_ + 14, p_283601_, p_283466_.getCount() == 1 ? "1" : null); ++ /* + // Forge: fixes Forge-8806, code for count rendering taken from GuiGraphics#renderGuiItemDecorations + p_281357_.pose().pushPose(); + p_281357_.pose().translate(0.0F, 0.0F, 200.0F); + String count = p_283466_.getCount() == 1 ? "1" : String.valueOf(p_283466_.getCount()); + font.drawInBatch(count, (float) (p_282403_ + 14) + 19 - 2 - font.width(count), (float)p_283601_ + 6 + 3, 0xFFFFFF, true, p_281357_.pose().last().pose(), p_281357_.bufferSource(), net.minecraft.client.gui.Font.DisplayMode.NORMAL, 0, 15728880, false); + p_281357_.pose().popPose(); ++ */ p_281357_.pose().pushPose(); p_281357_.pose().translate(0.0F, 0.0F, 300.0F); - p_281357_.blitSprite(DISCOUNT_STRIKETHRUOGH_SPRITE, p_282403_ + 7, p_283601_ + 12, 0, 9, 2); + p_281357_.blitSprite(RenderType::guiTextured, DISCOUNT_STRIKETHRUOGH_SPRITE, p_282403_ + 7, p_283601_ + 12, 9, 2); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch index f168e8b7e1..bbf34272e3 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java +++ b/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java -@@ -22,6 +_,8 @@ - } else if (p_169951_ instanceof ClientActivePlayersTooltip.ActivePlayersTooltip clientactiveplayerstooltip$activeplayerstooltip) { - return new ClientActivePlayersTooltip(clientactiveplayerstooltip$activeplayerstooltip); - } else { -+ ClientTooltipComponent result = net.minecraftforge.client.gui.ClientTooltipComponentManager.createClientTooltipComponent(p_169951_); -+ if (result != null) return result; - throw new IllegalArgumentException("Unknown TooltipComponent"); - } +@@ -25,7 +_,7 @@ + case ClientActivePlayersTooltip.ActivePlayersTooltip clientactiveplayerstooltip$activeplayerstooltip -> new ClientActivePlayersTooltip( + clientactiveplayerstooltip$activeplayerstooltip + ); +- default -> throw new IllegalArgumentException("Unknown TooltipComponent"); ++ default -> net.minecraftforge.client.gui.ClientTooltipComponentManager.createClientTooltipComponent(p_169951_); + }); } + diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/tooltip/TooltipRenderUtil.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/tooltip/TooltipRenderUtil.java.patch deleted file mode 100644 index 647a25f15c..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/tooltip/TooltipRenderUtil.java.patch +++ /dev/null @@ -1,40 +0,0 @@ ---- a/net/minecraft/client/gui/screens/inventory/tooltip/TooltipRenderUtil.java -+++ b/net/minecraft/client/gui/screens/inventory/tooltip/TooltipRenderUtil.java -@@ -17,16 +_,21 @@ - private static final int BORDER_COLOR_BOTTOM = 1344798847; - - public static void renderTooltipBackground(GuiGraphics p_282666_, int p_281901_, int p_281846_, int p_281559_, int p_283336_, int p_283422_) { -+ renderTooltipBackground(p_282666_, p_281901_, p_281846_, p_281559_, p_283336_, p_283422_, BACKGROUND_COLOR, BACKGROUND_COLOR, BORDER_COLOR_TOP, BORDER_COLOR_BOTTOM); -+ } -+ -+ // Forge: Allow specifying colors for the inner border gradient and a gradient instead of a single color for the background and outer border -+ public static void renderTooltipBackground(GuiGraphics p_282666_, int p_281901_, int p_281846_, int p_281559_, int p_283336_, int p_283422_, int backgroundTop, int backgroundBottom, int borderTop, int borderBottom) { - int i = p_281901_ - 3; - int j = p_281846_ - 3; - int k = p_281559_ + 3 + 3; - int l = p_283336_ + 3 + 3; -- renderHorizontalLine(p_282666_, i, j - 1, k, p_283422_, -267386864); -- renderHorizontalLine(p_282666_, i, j + l, k, p_283422_, -267386864); -- renderRectangle(p_282666_, i, j, k, l, p_283422_, -267386864); -- renderVerticalLine(p_282666_, i - 1, j, l, p_283422_, -267386864); -- renderVerticalLine(p_282666_, i + k, j, l, p_283422_, -267386864); -- renderFrameGradient(p_282666_, i, j + 1, k, l, p_283422_, 1347420415, 1344798847); -+ renderHorizontalLine(p_282666_, i, j - 1, k, p_283422_, backgroundTop); -+ renderHorizontalLine(p_282666_, i, j + l, k, p_283422_, backgroundBottom); -+ renderRectangleGradient(p_282666_, i, j, k, l, p_283422_, backgroundTop, backgroundBottom); -+ renderVerticalLineGradient(p_282666_, i - 1, j, l, p_283422_, backgroundTop, backgroundBottom); -+ renderVerticalLineGradient(p_282666_, i + k, j, l, p_283422_, backgroundTop, backgroundBottom); -+ renderFrameGradient(p_282666_, i, j + 1, k, l, p_283422_, borderTop, borderBottom); - } - - private static void renderFrameGradient( -@@ -52,5 +_,9 @@ - - private static void renderRectangle(GuiGraphics p_281392_, int p_282294_, int p_283353_, int p_282640_, int p_281964_, int p_283211_, int p_282349_) { - p_281392_.fill(p_282294_, p_283353_, p_282294_ + p_282640_, p_283353_ + p_281964_, p_283211_, p_282349_); -+ } -+ -+ private static void renderRectangleGradient(GuiGraphics p_281392_, int p_282294_, int p_283353_, int p_282640_, int p_281964_, int p_283211_, int p_282349_, int colorTo) { -+ p_281392_.fillGradient(p_282294_, p_283353_, p_282294_ + p_282640_, p_283353_ + p_281964_, p_283211_, p_282349_, colorTo); - } - } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch index 8248894167..2b240ca07b 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch @@ -24,14 +24,15 @@ .createNarration( p_342179_ -> p_343088_.isUnbound() ? Component.translatable("narrator.controls.unbound", p_343976_) -@@ -163,6 +_,7 @@ +@@ -163,7 +_,7 @@ ) .build(); - this.resetButton = Button.builder(RESET_BUTTON_TITLE, p_343650_ -> { + this.resetButton = Button.builder(RESET_BUTTON_TITLE, p_357685_ -> { +- p_343088_.setKey(p_343088_.getDefaultKey()); + this.key.setToDefault(); - KeyBindsList.this.minecraft.options.setKey(p_343088_, p_343088_.getDefaultKey()); KeyBindsList.this.resetMappingAndUpdateButtons(); }).bounds(0, 0, 50, 20).createNarration(p_344192_ -> Component.translatable("narrator.controls.reset", p_343976_)).build(); + this.refreshEntry(); @@ -215,7 +_,7 @@ MutableComponent mutablecomponent = Component.empty(); if (!this.key.isUnbound()) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java.patch index 7d8ceaacab..f670b5c7e6 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java.patch @@ -9,15 +9,15 @@ } this.keyBindsList.resetMappingAndUpdateButtons(); -@@ -73,11 +_,14 @@ +@@ -73,11 +_,12 @@ public boolean keyPressed(int p_342715_, int p_342862_, int p_345515_) { if (this.selectedKey != null) { if (p_342715_ == 256) { +- this.selectedKey.setKey(InputConstants.UNKNOWN); + this.selectedKey.setKeyModifierAndCode(null, InputConstants.UNKNOWN); - this.options.setKey(this.selectedKey, InputConstants.UNKNOWN); } else { +- this.selectedKey.setKey(InputConstants.getKey(p_342715_, p_342862_)); + this.selectedKey.setKeyModifierAndCode(null, InputConstants.getKey(p_342715_, p_342862_)); - this.options.setKey(this.selectedKey, InputConstants.getKey(p_342715_, p_342862_)); } + if (p_342715_ == 256 || !net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.selectedKey.getKey())) 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 57e4502854..427a059bb8 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 @@ -6,6 +6,6 @@ p_100014_.setSelected(null); - p_100015_.forEach( + p_100015_.filter(PackSelectionModel.Entry::notHidden).forEach( - p_340813_ -> { + p_357689_ -> { TransferableSelectionList.PackEntry transferableselectionlist$packentry1 = new TransferableSelectionList.PackEntry( - this.minecraft, p_100014_, p_340813_ + this.minecraft, p_100014_, p_357689_ 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 deleted file mode 100644 index 8ae3eb448c..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java -+++ b/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java -@@ -115,7 +_,7 @@ - this.initFilterButtonTextures(); - this.tabButtons.clear(); - -- for (RecipeBookCategories recipebookcategories : RecipeBookCategories.getCategories(this.menu.getRecipeBookType())) { -+ for (RecipeBookCategories recipebookcategories : this.menu.getRecipeBookCategories()) { - this.tabButtons.add(new RecipeBookTabButton(recipebookcategories)); - } - -@@ -293,7 +_,7 @@ - } - - if (itemstack != null && this.minecraft.screen != null) { -- p_282776_.renderComponentTooltip(this.minecraft.font, Screen.getTooltipFromItem(this.minecraft, itemstack), p_282948_, p_283050_); -+ p_282776_.renderComponentTooltip(this.minecraft.font, Screen.getTooltipFromItem(this.minecraft, itemstack), p_282948_, p_283050_, itemstack); - } - } - 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 530d7be907..f98ff819c0 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,14 +1,14 @@ --- a/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java +++ b/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java -@@ -118,6 +_,7 @@ - public static void openFresh(Minecraft p_232897_, @Nullable Screen p_232898_) { - queueLoadScreen(p_232897_, PREPARING_WORLD_DATA); - PackRepository packrepository = new PackRepository(new ServerPacksSource(p_232897_.directoryValidator())); +@@ -169,6 +_,7 @@ + ) { + queueLoadScreen(p_369292_, PREPARING_WORLD_DATA); + PackRepository packrepository = new PackRepository(new ServerPacksSource(p_369292_.directoryValidator())); + net.minecraftforge.event.ForgeEventFactory.addPackFindersServer(packrepository::addPackFinder); WorldLoader.InitConfig worldloader$initconfig = createDefaultLoadConfig(packrepository, WorldDataConfiguration.DEFAULT); CompletableFuture completablefuture = WorldLoader.load( worldloader$initconfig, -@@ -415,7 +_,7 @@ +@@ -479,7 +_,7 @@ if (p_269627_) { p_270552_.accept(this.uiState.getSettings().dataConfiguration()); } else { @@ -17,7 +17,7 @@ } }, Component.translatable("dataPack.validation.failed"), -@@ -533,6 +_,7 @@ +@@ -593,6 +_,7 @@ if (path != null) { if (this.tempDataPackRepository == null) { this.tempDataPackRepository = ServerPacksSource.createPackRepository(path, this.packValidator); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java.patch index 758bc0a72d..17da7eab79 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java.patch @@ -1,11 +1,15 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java -@@ -62,6 +_,10 @@ +@@ -75,6 +_,14 @@ ); } + public WorldCreationContext withDataConfiguration(WorldDataConfiguration dataConfiguration) { -+ return new WorldCreationContext(this.options, this.datapackDimensions, this.selectedDimensions, this.worldgenRegistries, this.dataPackResources, dataConfiguration); ++ return new WorldCreationContext(this.options, this.datapackDimensions, this.selectedDimensions, this.worldgenRegistries, this.dataPackResources, dataConfiguration, this.initialWorldCreationOptions); ++ } ++ ++ public WorldCreationContext withInitalOptions(InitialWorldCreationOptions initialWorldCreationOptions) { ++ return new WorldCreationContext(this.options, this.datapackDimensions, this.selectedDimensions, this.worldgenRegistries, this.dataPackResources, this.dataConfiguration, initialWorldCreationOptions); + } + public RegistryAccess.Frozen worldgenLoadContext() { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java.patch index bd4f8b3e64..41579607b6 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java -@@ -225,7 +_,7 @@ +@@ -234,7 +_,7 @@ @Nullable public PresetEditor getPresetEditor() { Holder holder = this.getWorldType().preset(); 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 f51edab783..d33ff54196 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 -@@ -321,6 +_,8 @@ +@@ -329,6 +_,8 @@ this.minecraft.forceSetScreen(new GenericMessageScreen(Component.translatable("selectWorld.resource_load"))); PackRepository packrepository = ServerPacksSource.createPackRepository(p_333651_); 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 8f8c4af743..8943dc5e1f 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 @@ -8,16 +8,16 @@ static final Component FROM_NEWER_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.fromNewerVersion1").withStyle(ChatFormatting.RED); static final Component FROM_NEWER_TOOLTIP_2 = Component.translatable("selectWorld.tooltip.fromNewerVersion2").withStyle(ChatFormatting.RED); static final Component SNAPSHOT_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.snapshot1").withStyle(ChatFormatting.GOLD); -@@ -402,6 +_,7 @@ - RenderSystem.enableBlend(); - p_281612_.blit(this.icon.textureLocation(), p_282820_, p_283181_, 0.0F, 0.0F, 32, 32, 32, 32); - RenderSystem.disableBlend(); +@@ -400,6 +_,7 @@ + p_281612_.drawString(this.minecraft.font, s1, p_282820_ + 32 + 3, p_283181_ + 9 + 3, -8355712, false); + p_281612_.drawString(this.minecraft.font, component, p_282820_ + 32 + 3, p_283181_ + 9 + 9 + 3, -8355712, false); + p_281612_.blit(RenderType::guiTextured, this.icon.textureLocation(), p_282820_, p_283181_, 0.0F, 0.0F, 32, 32, 32, 32); + renderExperimentalWarning(p_281612_, p_283204_, p_283025_, p_283181_, p_282820_); if (this.minecraft.options.touchscreen().get() || p_283396_) { p_281612_.fill(p_282820_, p_283181_, p_282820_ + 32, p_283181_ + 32, -1601138544); int j = p_283204_ - p_282820_; -@@ -448,6 +_,19 @@ - p_281612_.blitSprite(resourcelocation, p_282820_, p_283181_, 32, 32); +@@ -446,6 +_,19 @@ + p_281612_.blitSprite(RenderType::guiTextured, resourcelocation, p_282820_, p_283181_, 32, 32); } } + } @@ -26,7 +26,7 @@ + private void renderExperimentalWarning(GuiGraphics guiGraphics, int mouseX, int mouseY, int top, int left) { + if (this.summary.isLifecycleExperimental()) { + int leftStart = left + WorldSelectionList.this.getRowWidth(); -+ guiGraphics.blit(WorldSelectionList.FORGE_EXPERIMENTAL_WARNING_ICON, leftStart - 36, top, 0.0F, 0.0F, 32, 32, 32, 32); ++ guiGraphics.blit(RenderType::guiTextured, WorldSelectionList.FORGE_EXPERIMENTAL_WARNING_ICON, leftStart - 36, top, 0.0F, 0.0F, 32, 32, 32, 32); + if (WorldSelectionList.this.getEntryAtPosition(mouseX, mouseY) == this && mouseX > leftStart - 36 && mouseX < leftStart) { + var font = Minecraft.getInstance().font; + List tooltip = font.split(Component.translatable("forge.experimentalsettings.tooltip"), 200); diff --git a/patches/minecraft/net/minecraft/client/main/Main.java.patch b/patches/minecraft/net/minecraft/client/main/Main.java.patch index 55bf083c85..6aba45470a 100644 --- a/patches/minecraft/net/minecraft/client/main/Main.java.patch +++ b/patches/minecraft/net/minecraft/client/main/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/main/Main.java +++ b/net/minecraft/client/main/Main.java -@@ -111,8 +_,8 @@ +@@ -120,8 +_,8 @@ CrashReport.preload(); logger = LogUtils.getLogger(); s1 = "Bootstrap"; @@ -9,4 +9,4 @@ + net.minecraftforge.fml.loading.BackgroundWaiter.runAndTick(Bootstrap::bootStrap, net.minecraftforge.fml.loading.FMLLoader.progressWindowTick); Bootstrap.validate(); s1 = "Argument parsing"; - List list = optionset.valuesOf(optionspec27); + List list = optionset.valuesOf(optionspec29); diff --git a/patches/minecraft/net/minecraft/client/model/HumanoidModel.java.patch b/patches/minecraft/net/minecraft/client/model/HumanoidModel.java.patch index 54ee4894d7..7e4692ecab 100644 --- a/patches/minecraft/net/minecraft/client/model/HumanoidModel.java.patch +++ b/patches/minecraft/net/minecraft/client/model/HumanoidModel.java.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/client/model/HumanoidModel.java +++ b/net/minecraft/client/model/HumanoidModel.java -@@ -308,6 +_,8 @@ +@@ -259,6 +_,8 @@ case BRUSH: this.rightArm.xRot = this.rightArm.xRot * 0.5F - (float) (Math.PI / 5); this.rightArm.yRot = 0.0F; + default: -+ this.rightArmPose.applyTransform(this, p_102876_, net.minecraft.world.entity.HumanoidArm.RIGHT); ++ p_366231_.applyTransform(this, p_362371_, net.minecraft.world.entity.HumanoidArm.RIGHT); } } -@@ -352,6 +_,8 @@ +@@ -303,6 +_,8 @@ case BRUSH: this.leftArm.xRot = this.leftArm.xRot * 0.5F - (float) (Math.PI / 5); this.leftArm.yRot = 0.0F; + default: -+ this.leftArmPose.applyTransform(this, p_102879_, net.minecraft.world.entity.HumanoidArm.LEFT); ++ p_370002_.applyTransform(this, p_363560_, net.minecraft.world.entity.HumanoidArm.LEFT); } } -@@ -451,7 +_,7 @@ +@@ -381,7 +_,7 @@ } @OnlyIn(Dist.CLIENT) @@ -27,7 +27,7 @@ EMPTY(false), ITEM(false), BLOCK(false), -@@ -467,10 +_,28 @@ +@@ -397,10 +_,28 @@ private ArmPose(final boolean p_102896_) { this.twoHanded = p_102896_; @@ -51,8 +51,8 @@ + throw new IllegalStateException("Enum not extended"); + } + -+ public void applyTransform(HumanoidModel model, T entity, net.minecraft.world.entity.HumanoidArm arm) { -+ if (this.forgeArmPose != null) this.forgeArmPose.applyTransform(model, entity, arm); ++ public void applyTransform(HumanoidModel model, T state, net.minecraft.world.entity.HumanoidArm arm) { ++ if (this.forgeArmPose != null) this.forgeArmPose.applyTransform(model, state, arm); } } } 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 31b3e59ce8..14e14cbcc2 100644 --- a/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch +++ b/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/model/geom/LayerDefinitions.java +++ b/net/minecraft/client/model/geom/LayerDefinitions.java -@@ -329,6 +_,7 @@ - WoodType.values().forEach(p_171114_ -> builder.put(ModelLayers.createSignModelName(p_171114_), layerdefinition23)); - LayerDefinition layerdefinition24 = HangingSignRenderer.createHangingSignLayer(); - WoodType.values().forEach(p_247864_ -> builder.put(ModelLayers.createHangingSignModelName(p_247864_), layerdefinition24)); +@@ -449,6 +_,7 @@ + builder.put(ModelLayers.createWallSignModelName(p_357774_), layerdefinition54); + builder.put(ModelLayers.createHangingSignModelName(p_357774_), layerdefinition55); + }); + net.minecraftforge.client.ForgeHooksClient.loadLayerDefinitions(builder); ImmutableMap immutablemap = builder.build(); List list = ModelLayers.getKnownLocations().filter(p_171117_ -> !immutablemap.containsKey(p_171117_)).collect(Collectors.toList()); 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 15f7d2b852..d8b287cfb9 100644 --- a/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch +++ b/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch @@ -1,12 +1,18 @@ --- a/net/minecraft/client/model/geom/ModelLayers.java +++ b/net/minecraft/client/model/geom/ModelLayers.java -@@ -229,11 +_,13 @@ +@@ -301,15 +_,18 @@ } - public static ModelLayerLocation createSignModelName(WoodType p_171292_) { -- return createLocation("sign/" + p_171292_.name(), "main"); + public static ModelLayerLocation createStandingSignModelName(WoodType p_171292_) { +- return createLocation("sign/standing/" + p_171292_.name(), "main"); + ResourceLocation location = ResourceLocation.parse(p_171292_.name()); -+ return new ModelLayerLocation(ResourceLocation.fromNamespaceAndPath(location.getNamespace(), "sign/" + location.getPath()), "main"); ++ return new ModelLayerLocation(ResourceLocation.fromNamespaceAndPath(location.getNamespace(), "sign/standing/" + location.getPath()), "main"); + } + + public static ModelLayerLocation createWallSignModelName(WoodType p_363532_) { +- return createLocation("sign/wall/" + p_363532_.name(), "main"); ++ ResourceLocation location = ResourceLocation.parse(p_363532_.name()); ++ return new ModelLayerLocation(ResourceLocation.fromNamespaceAndPath(location.getNamespace(), "sign/wall/" + location.getPath()), "main"); } public static ModelLayerLocation createHangingSignModelName(WoodType p_252225_) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch index fddcd362fe..34a6e9d7d1 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/client/multiplayer/ClientChunkCache.java +++ b/net/minecraft/client/multiplayer/ClientChunkCache.java -@@ -61,6 +_,7 @@ +@@ -63,6 +_,7 @@ int i = this.storage.getIndex(p_298665_.x, p_298665_.z); LevelChunk levelchunk = this.storage.getChunk(i); if (isValidChunk(levelchunk, p_298665_.x, p_298665_.z)) { + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.level.ChunkEvent.Unload(levelchunk)); - this.storage.replace(i, levelchunk, null); + this.storage.drop(i, levelchunk); } } -@@ -121,6 +_,7 @@ +@@ -123,6 +_,7 @@ } this.level.onChunkLoaded(chunkpos); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch index f4972a4a09..03a46c905e 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java -@@ -149,6 +_,7 @@ +@@ -142,6 +_,7 @@ @Override public void handleCustomPayload(ClientboundCustomPayloadPacket p_298103_) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch index acd8e424d3..e8ef0efe00 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java -@@ -143,6 +_,7 @@ +@@ -142,6 +_,7 @@ ); this.connection.send(ServerboundFinishConfigurationPacket.INSTANCE); this.connection.setupOutboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(registryaccess$frozen))); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch index 4f1b17242d..7a283dfa4a 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java -@@ -210,6 +_,7 @@ +@@ -209,6 +_,7 @@ Component component = this.wasTransferredTo ? CommonComponents.TRANSFER_CONNECT_FAILED : CommonComponents.CONNECT_FAILED; if (this.serverData != null && this.serverData.isRealm()) { this.minecraft.setScreen(new DisconnectedRealmsScreen(this.parent, component, p_342266_.reason())); @@ -8,7 +8,7 @@ } else { this.minecraft.setScreen(new DisconnectedScreen(this.parent, component, p_342266_)); } -@@ -234,6 +_,7 @@ +@@ -233,6 +_,7 @@ @Override public void handleCustomQuery(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 6d0bbf458b..6e062759b9 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 -@@ -113,12 +_,15 @@ +@@ -118,6 +_,7 @@ p_194170_.put(BiomeColors.GRASS_COLOR_RESOLVER, new BlockTintCache(p_194181_ -> this.calculateBlockTint(p_194181_, BiomeColors.GRASS_COLOR_RESOLVER))); p_194170_.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new BlockTintCache(p_194177_ -> this.calculateBlockTint(p_194177_, BiomeColors.FOLIAGE_COLOR_RESOLVER))); p_194170_.put(BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache(p_194168_ -> this.calculateBlockTint(p_194168_, BiomeColors.WATER_COLOR_RESOLVER))); @@ -8,16 +8,17 @@ }); private final ClientChunkCache chunkSource; private final Deque lightUpdateQueue = Queues.newArrayDeque(); - private int serverSimulationDistance; - private final BlockStatePredictionHandler blockStatePredictionHandler = new BlockStatePredictionHandler(); +@@ -126,6 +_,8 @@ + private final int seaLevel; + private boolean tickDayTime; private static final Set MARKER_PARTICLE_ITEMS = Set.of(Items.BARRIER, Items.LIGHT); + private final it.unimi.dsi.fastutil.ints.Int2ObjectMap> partEntities = new it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<>(); + private final net.minecraftforge.client.model.data.ModelDataManager modelDataManager = new net.minecraftforge.client.model.data.ModelDataManager(this); public void handleBlockChangedAck(int p_233652_) { this.blockStatePredictionHandler.endPredictionsUpTo(p_233652_, this); -@@ -183,6 +_,8 @@ - this.serverSimulationDistance = p_205510_; +@@ -192,6 +_,8 @@ + this.serverSimulationDistance = p_364305_; this.updateSkyBrightness(); this.prepareWeather(); + this.gatherCapabilities(); @@ -25,15 +26,15 @@ } public void queueLightUpdate(Runnable p_194172_) { -@@ -273,6 +_,7 @@ +@@ -274,6 +_,7 @@ p_104640_.setOldPosAndRot(); p_104640_.tickCount++; - this.getProfiler().push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_104640_.getType()).toString()); + Profiler.get().push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_104640_.getType()).toString()); + if (p_104640_.canUpdate()) p_104640_.tick(); - this.getProfiler().pop(); + Profiler.get().pop(); -@@ -321,8 +_,10 @@ +@@ -326,8 +_,10 @@ } public void addEntity(Entity p_104741_) { @@ -44,7 +45,7 @@ } public void removeEntity(int p_171643_, Entity.RemovalReason p_171644_) { -@@ -493,6 +_,12 @@ +@@ -498,6 +_,12 @@ float p_263349_, long p_263408_ ) { @@ -57,7 +58,7 @@ if (p_263381_ == this.minecraft.player) { this.playSound(p_263372_, p_263404_, p_263365_, p_263335_.value(), p_263417_, p_263416_, p_263349_, false, p_263408_); } -@@ -502,6 +_,12 @@ +@@ -507,6 +_,12 @@ public void playSeededSound( @Nullable Player p_263514_, Entity p_263536_, Holder p_263518_, SoundSource p_263487_, float p_263538_, float p_263524_, long p_263509_ ) { @@ -70,8 +71,8 @@ if (p_263514_ == this.minecraft.player) { this.minecraft.getSoundManager().play(new EntityBoundSoundInstance(p_263518_.value(), p_263487_, p_263538_, p_263524_, p_263536_, p_263509_)); } -@@ -927,6 +_,24 @@ - return this.connection.potionBrewing(); +@@ -943,6 +_,24 @@ + return this.seaLevel; } + @Override @@ -95,7 +96,7 @@ @OnlyIn(Dist.CLIENT) public static class ClientLevelData implements WritableLevelData { private final boolean hardcore; -@@ -1022,6 +_,7 @@ +@@ -1031,6 +_,7 @@ } public void setDifficulty(Difficulty p_104852_) { @@ -103,7 +104,7 @@ this.difficulty = p_104852_; } -@@ -1058,11 +_,26 @@ +@@ -1067,11 +_,26 @@ if (p_171712_ instanceof AbstractClientPlayer) { ClientLevel.this.players.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 a9b4396f11..89ee62157d 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 -@@ -427,6 +_,7 @@ +@@ -451,6 +_,7 @@ this.minecraft.debugRenderer.clear(); this.minecraft.player.resetPos(); @@ -8,17 +8,16 @@ this.minecraft.player.setId(p_105030_.playerId()); this.level.addEntity(this.minecraft.player); this.minecraft.player.input = new KeyboardInput(this.minecraft.options); -@@ -1164,7 +_,9 @@ +@@ -1249,6 +_,8 @@ localplayer1.getAttributes().assignBaseValues(localplayer.getAttributes()); } + localplayer1.updateSyncFields(localplayer); // Forge: fix MC-10657 - localplayer1.resetPos(); + net.minecraftforge.client.event.ForgeEventFactoryClient.firePlayerRespawn(this.minecraft.gameMode, localplayer, localplayer1, localplayer1.connection.connection); this.level.addEntity(localplayer1); - localplayer1.setYRot(-180.0F); localplayer1.input = new KeyboardInput(this.minecraft.options); -@@ -1300,10 +_,7 @@ + this.minecraft.gameMode.adjustPlayer(localplayer1); +@@ -1393,10 +_,7 @@ PacketUtils.ensureRunningOnSameThread(p_104976_, this, this.minecraft); BlockPos blockpos = p_104976_.getPos(); this.minecraft.level.getBlockEntity(blockpos, p_104976_.getType()).ifPresent(p_325478_ -> { @@ -30,7 +29,7 @@ if (p_325478_ instanceof CommandBlockEntity && this.minecraft.screen instanceof CommandBlockEditScreen) { ((CommandBlockEditScreen)this.minecraft.screen).updateGui(); -@@ -1465,7 +_,9 @@ +@@ -1557,7 +_,9 @@ @Override public void handleCommands(ClientboundCommandsPacket p_104990_) { PacketUtils.ensureRunningOnSameThread(p_104990_, this, this.minecraft); @@ -41,24 +40,24 @@ } @Override -@@ -1487,6 +_,7 @@ - ClientRecipeBook clientrecipebook = this.minecraft.player.getRecipeBook(); - clientrecipebook.setupCollections(this.recipeManager.getOrderedRecipes(), this.minecraft.level.registryAccess()); - this.searchTrees.updateRecipes(clientrecipebook, this.registryAccess); -+ net.minecraftforge.client.ForgeHooksClient.onRecipesUpdated(this.recipeManager); +@@ -1658,6 +_,7 @@ + if (this.minecraft.screen instanceof RecipeUpdateListener recipeupdatelistener) { + recipeupdatelistener.recipesUpdated(); + } ++ net.minecraftforge.client.event.ForgeEventFactoryClient.onRecipesUpdated(p_364029_); } @Override -@@ -1585,6 +_,8 @@ - tagcollector.updateTags(this.registryAccess, this.connection.isMemoryConnection()); - List list = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems()); - this.searchTrees.updateCreativeTags(list); +@@ -1696,6 +_,8 @@ + this.fuelValues = FuelValues.vanillaBurnTimes(this.registryAccess, this.enabledFeatures); + List list1 = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems()); + this.searchTrees.updateCreativeTags(list1); + + net.minecraftforge.event.ForgeEventFactory.onTagsUpdated(this.registryAccess, true, this.connection.isMemoryConnection()); } @Override -@@ -2389,6 +_,8 @@ +@@ -2516,6 +_,8 @@ } public void sendChat(String p_249888_) { @@ -67,7 +66,7 @@ Instant instant = Instant.now(); long i = Crypt.SaltSupplier.getLong(); LastSeenMessagesTracker.Update lastseenmessagestracker$update = this.lastSeenMessages.generateAndApplyUpdate(); -@@ -2397,6 +_,7 @@ +@@ -2524,6 +_,7 @@ } public void sendCommand(String p_250092_) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch index 25fdd043a6..cfcbab4131 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/MultiPlayerGameMode.java +++ b/net/minecraft/client/multiplayer/MultiPlayerGameMode.java -@@ -105,6 +_,7 @@ +@@ -106,6 +_,7 @@ } public boolean destroyBlock(BlockPos p_105268_) { @@ -8,7 +8,7 @@ if (this.minecraft.player.blockActionRestricted(this.minecraft.level, p_105268_, this.localPlayerMode)) { return false; } else { -@@ -119,9 +_,8 @@ +@@ -120,9 +_,8 @@ } else if (blockstate.isAir()) { return false; } else { @@ -19,7 +19,7 @@ if (flag) { block.destroy(level, p_105268_, blockstate); } -@@ -142,6 +_,7 @@ +@@ -143,6 +_,7 @@ BlockState blockstate = this.minecraft.level.getBlockState(p_105270_); this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105270_, blockstate, 1.0F); this.startPrediction(this.minecraft.level, p_233757_ -> { @@ -27,7 +27,7 @@ this.destroyBlock(p_105270_); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_, p_233757_); }); -@@ -151,15 +_,18 @@ +@@ -152,15 +_,18 @@ this.connection .send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.destroyBlockPos, p_105271_)); } @@ -46,7 +46,7 @@ if (flag && blockstate1.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105270_) >= 1.0F) { this.destroyBlock(p_105270_); } else { -@@ -170,6 +_,7 @@ +@@ -171,6 +_,7 @@ this.destroyTicks = 0.0F; this.minecraft.level.destroyBlockProgress(this.minecraft.player.getId(), this.destroyBlockPos, this.getDestroyStage()); } @@ -54,7 +54,7 @@ return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_, p_233728_); }); -@@ -202,6 +_,7 @@ +@@ -203,6 +_,7 @@ BlockState blockstate1 = this.minecraft.level.getBlockState(p_105284_); this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate1, 1.0F); this.startPrediction(this.minecraft.level, p_233753_ -> { @@ -62,7 +62,7 @@ this.destroyBlock(p_105284_); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105284_, p_105285_, p_233753_); }); -@@ -214,7 +_,7 @@ +@@ -215,7 +_,7 @@ } else { this.destroyProgress = this.destroyProgress + blockstate.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105284_); if (this.destroyTicks % 4.0F == 0.0F) { @@ -71,7 +71,7 @@ this.minecraft .getSoundManager() .play( -@@ -231,6 +_,7 @@ +@@ -232,6 +_,7 @@ this.destroyTicks++; this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate, Mth.clamp(this.destroyProgress, 0.0F, 1.0F)); @@ -79,7 +79,7 @@ if (this.destroyProgress >= 1.0F) { this.isDestroying = false; this.startPrediction(this.minecraft.level, p_233739_ -> { -@@ -269,7 +_,7 @@ +@@ -270,7 +_,7 @@ private boolean sameDestroyTarget(BlockPos p_105282_) { ItemStack itemstack = this.minecraft.player.getMainHandItem(); @@ -88,7 +88,7 @@ } private void ensureHasSentCarriedItem() { -@@ -297,12 +_,23 @@ +@@ -298,12 +_,23 @@ private InteractionResult performUseItemOn(LocalPlayer p_233747_, InteractionHand p_233748_, BlockHitResult p_233749_) { BlockPos blockpos = p_233749_.getBlockPos(); ItemStack itemstack = p_233747_.getItemInHand(p_233748_); @@ -97,7 +97,7 @@ + return event.getCancellationResult(); + } if (this.localPlayerMode == GameType.SPECTATOR) { - return InteractionResult.SUCCESS; + return InteractionResult.CONSUME; } else { - boolean flag = !p_233747_.getMainHandItem().isEmpty() || !p_233747_.getOffhandItem().isEmpty(); + UseOnContext useoncontext = new UseOnContext(p_233747_, p_233748_, p_233749_); @@ -114,20 +114,20 @@ BlockState blockstate = this.minecraft.level.getBlockState(blockpos); if (!this.connection.isFeatureEnabled(blockstate.getBlock().requiredFeatures())) { return InteractionResult.FAIL; -@@ -323,8 +_,10 @@ +@@ -324,8 +_,10 @@ } } -- if (!itemstack.isEmpty() && !p_233747_.getCooldowns().isOnCooldown(itemstack.getItem())) { +- if (!itemstack.isEmpty() && !p_233747_.getCooldowns().isOnCooldown(itemstack)) { - UseOnContext useoncontext = new UseOnContext(p_233747_, p_233748_, p_233749_); + if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) { + return InteractionResult.PASS; + } -+ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (!itemstack.isEmpty() && !p_233747_.getCooldowns().isOnCooldown(itemstack.getItem()))) { - InteractionResult interactionresult1; ++ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (!itemstack.isEmpty() && !p_233747_.getCooldowns().isOnCooldown(itemstack))) { + InteractionResult interactionresult2; if (this.localPlayerMode.isCreative()) { int i = itemstack.getCount(); -@@ -358,10 +_,18 @@ +@@ -359,6 +_,11 @@ mutableobject.setValue(InteractionResult.PASS); return serverbounduseitempacket; } else { @@ -136,8 +136,11 @@ + mutableobject.setValue(event.getCancellationResult()); + return serverbounduseitempacket; + } - InteractionResultHolder interactionresultholder = itemstack.use(this.minecraft.level, p_233722_, p_233723_); - ItemStack itemstack1 = interactionresultholder.getObject(); + InteractionResult interactionresult = itemstack.use(this.minecraft.level, p_233722_, p_233723_); + ItemStack itemstack1; + if (interactionresult instanceof InteractionResult.Success interactionresult$success) { +@@ -369,6 +_,9 @@ + if (itemstack1 != itemstack) { p_233722_.setItemInHand(p_233723_, itemstack1); + if (itemstack1.isEmpty()) { @@ -145,8 +148,8 @@ + } } - mutableobject.setValue(interactionresultholder.getResult()); -@@ -393,6 +_,10 @@ + mutableobject.setValue(interactionresult); +@@ -400,6 +_,10 @@ public InteractionResult interact(Player p_105227_, Entity p_105228_, InteractionHand p_105229_) { this.ensureHasSentCarriedItem(); this.connection.send(ServerboundInteractPacket.createInteractionPacket(p_105228_, p_105227_.isShiftKeyDown(), p_105229_)); @@ -154,10 +157,10 @@ + var event = net.minecraftforge.event.ForgeEventFactory.onEntityInteract(p_105227_, p_105228_, p_105229_); + if (event.isCanceled()) return event.getCancellationResult(); + } - return this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : p_105227_.interactOn(p_105228_, p_105229_); + return (InteractionResult)(this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : p_105227_.interactOn(p_105228_, p_105229_)); } -@@ -400,6 +_,10 @@ +@@ -407,6 +_,10 @@ this.ensureHasSentCarriedItem(); Vec3 vec3 = p_105233_.getLocation().subtract(p_105232_.getX(), p_105232_.getY(), p_105232_.getZ()); this.connection.send(ServerboundInteractPacket.createInteractionPacket(p_105232_, p_105231_.isShiftKeyDown(), p_105234_, vec3)); @@ -165,6 +168,6 @@ + var event = net.minecraftforge.event.ForgeEventFactory.onEntityInteractSpecific(p_105231_, p_105232_, p_105234_, vec3); + if (event.isCanceled()) return event.getCancellationResult(); + } - return this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : p_105232_.interactAt(p_105231_, vec3, p_105234_); + return (InteractionResult)(this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : p_105232_.interactAt(p_105231_, vec3, p_105234_)); } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch index fa8302a828..5aa803aaa2 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 -@@ -85,6 +_,7 @@ +@@ -86,6 +_,7 @@ } protected void setGameMode(GameType p_105318_) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch index 88b4befe93..86400f9a3e 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/SessionSearchTrees.java +++ b/net/minecraft/client/multiplayer/SessionSearchTrees.java -@@ -31,8 +_,8 @@ +@@ -34,8 +_,8 @@ private static final SessionSearchTrees.Key RECIPE_COLLECTIONS = new SessionSearchTrees.Key(); public static final SessionSearchTrees.Key CREATIVE_NAMES = new SessionSearchTrees.Key(); public static final SessionSearchTrees.Key CREATIVE_TAGS = new SessionSearchTrees.Key(); @@ -11,7 +11,7 @@ private CompletableFuture> recipeSearch = CompletableFuture.completedFuture(SearchTree.empty()); private final Map reloaders = new IdentityHashMap<>(); -@@ -82,44 +_,52 @@ +@@ -92,44 +_,52 @@ } public void updateCreativeTags(List p_344581_) { diff --git a/patches/minecraft/net/minecraft/client/particle/BreakingItemParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/BreakingItemParticle.java.patch index a6d25a2790..8e9d7a78fc 100644 --- a/patches/minecraft/net/minecraft/client/particle/BreakingItemParticle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/BreakingItemParticle.java.patch @@ -1,12 +1,11 @@ --- a/net/minecraft/client/particle/BreakingItemParticle.java +++ b/net/minecraft/client/particle/BreakingItemParticle.java -@@ -33,7 +_,8 @@ +@@ -33,7 +_,7 @@ protected BreakingItemParticle(ClientLevel p_105665_, double p_105666_, double p_105667_, double p_105668_, ItemStack p_105669_) { super(p_105665_, p_105666_, p_105667_, p_105668_, 0.0, 0.0, 0.0); - this.setSprite(Minecraft.getInstance().getItemRenderer().getModel(p_105669_, p_105665_, null, 0).getParticleIcon()); -+ var model = Minecraft.getInstance().getItemRenderer().getModel(p_105669_, p_105665_, null, 0); -+ this.setSprite(model.getOverrides().resolve(model, p_105669_, p_105665_, null, 0).getParticleIcon(net.minecraftforge.client.model.data.ModelData.EMPTY)); ++ this.setSprite(Minecraft.getInstance().getItemRenderer().getModel(p_105669_, p_105665_, null, 0).getParticleIcon(net.minecraftforge.client.model.data.ModelData.EMPTY)); this.gravity = 1.0F; this.quadSize /= 2.0F; this.uo = this.random.nextFloat() * 3.0F; diff --git a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch index 5a30bfd121..45a1d266a0 100644 --- a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/particle/ParticleEngine.java +++ b/net/minecraft/client/particle/ParticleEngine.java @@ -77,11 +_,11 @@ - ParticleRenderType.TERRAIN_SHEET, ParticleRenderType.PARTICLE_SHEET_OPAQUE, ParticleRenderType.PARTICLE_SHEET_LIT, ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT, ParticleRenderType.CUSTOM + ParticleRenderType.TERRAIN_SHEET, ParticleRenderType.PARTICLE_SHEET_OPAQUE, ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT, ParticleRenderType.CUSTOM ); protected ClientLevel level; - private final Map> particles = Maps.newIdentityHashMap(); @@ -14,8 +14,8 @@ private final Queue particlesToAdd = Queues.newArrayDeque(); private final Map spriteSets = Maps.newHashMap(); private final TextureAtlas textureAtlas; -@@ -212,10 +_,14 @@ - this.register(ParticleTypes.OMINOUS_SPAWNING, FlyStraightTowardsParticle.OminousSpawnProvider::new); +@@ -214,10 +_,14 @@ + this.register(ParticleTypes.BLOCK_CRUMBLE, new TerrainParticle.CrumblingProvider()); } + /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */ @@ -30,7 +30,7 @@ public void register(ParticleType p_273423_, ParticleProvider.Sprite p_273134_) { this.register( p_273423_, -@@ -232,10 +_,12 @@ +@@ -234,10 +_,12 @@ ); } @@ -44,7 +44,7 @@ } @Override -@@ -361,7 +_,7 @@ +@@ -357,7 +_,7 @@ private Particle makeParticle( T p_107396_, double p_107397_, double p_107398_, double p_107399_, double p_107400_, double p_107401_, double p_107402_ ) { @@ -53,7 +53,7 @@ return particleprovider == null ? null : particleprovider.createParticle(p_107396_, this.level, p_107397_, p_107398_, p_107399_, p_107400_, p_107401_, p_107402_); -@@ -437,11 +_,19 @@ +@@ -433,17 +_,26 @@ } } @@ -61,7 +61,7 @@ + /**@deprecated Forge: use {@link #render(LightTexture, Camera, float, net.minecraft.client.renderer.culling.Frustum)} with Frustum as additional parameter*/ + @Deprecated public void render(LightTexture p_107339_, Camera p_107340_, float p_107341_) { -+ render(p_107339_, p_107340_, p_107341_); ++ render(p_107339_, p_107340_, p_107341_, null); + } + + public void render(LightTexture p_107339_, Camera p_107340_, float p_107341_, @Nullable net.minecraft.client.renderer.culling.Frustum frustum) { @@ -73,8 +73,7 @@ + if (particlerendertype == ParticleRenderType.NO_RENDER) continue; Queue queue = this.particles.get(particlerendertype); if (queue != null && !queue.isEmpty()) { - RenderSystem.setShader(GameRenderer::getParticleShader); -@@ -449,6 +_,7 @@ + Tesselator tesselator = Tesselator.getInstance(); BufferBuilder bufferbuilder = particlerendertype.begin(tesselator, this.textureManager); if (bufferbuilder != null) { for (Particle particle : queue) { @@ -82,7 +81,7 @@ try { particle.render(bufferbuilder, p_107340_, p_107341_); } catch (Throwable throwable) { -@@ -480,7 +_,7 @@ +@@ -475,7 +_,7 @@ } public void destroy(BlockPos p_107356_, BlockState p_107357_) { @@ -91,7 +90,7 @@ VoxelShape voxelshape = p_107357_.getShape(this.level, p_107356_); double d0 = 0.25; voxelshape.forAllBoxes( -@@ -513,6 +_,7 @@ +@@ -508,6 +_,7 @@ p_107357_, p_107356_ ) @@ -99,7 +98,7 @@ ); } } -@@ -522,6 +_,13 @@ +@@ -517,6 +_,13 @@ } } @@ -113,7 +112,7 @@ public void crack(BlockPos p_107368_, Direction p_107369_) { BlockState blockstate = this.level.getBlockState(p_107368_); if (blockstate.getRenderShape() != RenderShape.INVISIBLE && blockstate.shouldSpawnTerrainParticles()) { -@@ -557,7 +_,7 @@ +@@ -552,7 +_,7 @@ d0 = (double)i + aabb.maxX + 0.1F; } diff --git a/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch index 9f31fbf65e..8534db2dd3 100644 --- a/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch @@ -25,4 +25,4 @@ + } @OnlyIn(Dist.CLIENT) - public static class DustPillarProvider implements ParticleProvider { + public static class CrumblingProvider implements ParticleProvider { diff --git a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch index 8747dd2c13..1174814098 100644 --- a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/player/AbstractClientPlayer.java +++ b/net/minecraft/client/player/AbstractClientPlayer.java -@@ -96,6 +_,6 @@ +@@ -91,6 +_,6 @@ } } -- return Mth.lerp(Minecraft.getInstance().options.fovEffectScale().get().floatValue(), 1.0F, f); -+ return net.minecraftforge.client.ForgeHooksClient.getFieldOfViewModifier(this, f); +- return Mth.lerp(p_362521_, 1.0F, f); ++ return net.minecraftforge.client.event.ForgeEventFactoryClient.fireFovModifierEvent(this, f, p_362521_).getNewFovModifier(); } } diff --git a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch index 1ef2e6b3ac..e1d931c149 100644 --- a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch @@ -1,14 +1,6 @@ --- a/net/minecraft/client/player/LocalPlayer.java +++ b/net/minecraft/client/player/LocalPlayer.java -@@ -161,6 +_,7 @@ - - @Override - public boolean hurt(DamageSource p_108662_, float p_108663_) { -+ net.minecraftforge.event.ForgeEventFactory.onLivingAttackEntity(this, p_108662_, p_108663_); - return false; - } - -@@ -304,6 +_,7 @@ +@@ -303,6 +_,7 @@ ServerboundPlayerActionPacket.Action serverboundplayeractionpacket$action = p_108701_ ? ServerboundPlayerActionPacket.Action.DROP_ALL_ITEMS : ServerboundPlayerActionPacket.Action.DROP_ITEM; @@ -16,7 +8,7 @@ ItemStack itemstack = this.getInventory().removeFromSelected(p_108701_); this.connection.send(new ServerboundPlayerActionPacket(serverboundplayeractionpacket$action, BlockPos.ZERO, Direction.DOWN)); return !itemstack.isEmpty(); -@@ -501,7 +_,11 @@ +@@ -488,7 +_,11 @@ @Override public void playSound(SoundEvent p_108651_, float p_108652_, float p_108653_) { @@ -29,7 +21,7 @@ } @Override -@@ -694,6 +_,7 @@ +@@ -682,6 +_,7 @@ && (this.isShiftKeyDown() || !this.isSleeping() && !this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.STANDING)); float f = (float)this.getAttributeValue(Attributes.SNEAKING_SPEED); this.input.tick(this.isMovingSlowly(), f); @@ -37,7 +29,7 @@ this.minecraft.getTutorial().onInput(this.input); if (this.isUsingItem() && !this.isPassenger()) { this.input.leftImpulse *= 0.2F; -@@ -722,7 +_,7 @@ +@@ -710,7 +_,7 @@ boolean flag4 = this.canStartSprinting(); boolean flag5 = this.isPassenger() ? this.getVehicle().onGround() : this.onGround(); boolean flag6 = !flag1 && !flag2; @@ -46,7 +38,7 @@ if (this.sprintTriggerTime <= 0 && !this.minecraft.options.keySprint.isDown()) { this.sprintTriggerTime = 7; } else { -@@ -730,15 +_,15 @@ +@@ -718,15 +_,15 @@ } } @@ -60,39 +52,33 @@ - boolean flag8 = flag7 || this.horizontalCollision && !this.minorHorizontalCollision || this.isInWater() && !this.isUnderWater(); + boolean flag8 = flag7 || this.horizontalCollision && !this.minorHorizontalCollision || this.isInWater() && !this.isUnderWater() || (this.isInFluidType((fluidType, height) -> this.canSwimInFluidType(fluidType)) && !this.canStartSwimming()); if (this.isSwimming()) { -- if (!this.onGround() && !this.input.shiftKeyDown && flag7 || !this.isInWater()) { -+ if (!this.onGround() && !this.input.shiftKeyDown && flag7 || !(this.isInWater() || this.isInFluidType((fluidType, height) -> this.canSwimInFluidType(fluidType)))) { +- if (!this.onGround() && !this.input.keyPresses.shift() && flag7 || !this.isInWater()) { ++ if (!this.onGround() && !this.input.keyPresses.shift() && flag7 || !(this.isInWater() || this.isInFluidType((fluidType, height) -> this.canSwimInFluidType(fluidType)))) { this.setSprinting(false); } } else if (flag8) { -@@ -772,14 +_,15 @@ - - if (this.input.jumping && !flag9 && !flag && !abilities.flying && !this.isPassenger() && !this.onClimbable()) { - ItemStack itemstack = this.getItemBySlot(EquipmentSlot.CHEST); -- if (itemstack.is(Items.ELYTRA) && ElytraItem.isFlyEnabled(itemstack) && this.tryToStartFallFlying()) { -+ if (itemstack.canElytraFly(this) && this.tryToStartFallFlying()) { - this.connection.send(new ServerboundPlayerCommandPacket(this, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING)); - } +@@ -763,8 +_,9 @@ } this.wasFallFlying = this.isFallFlying(); -- if (this.isInWater() && this.input.shiftKeyDown && this.isAffectedByFluids()) { +- if (this.isInWater() && this.input.keyPresses.shift() && this.isAffectedByFluids()) { - this.goDownInWater(); + var fluidType = this.getMaxHeightFluidType(); -+ if ((this.isInWater() || (!fluidType.isAir() && this.canSwimInFluidType(fluidType))) && this.input.shiftKeyDown && this.isAffectedByFluids()) { ++ if ((this.isInWater() || (!fluidType.isAir() && this.canSwimInFluidType(fluidType))) && this.input.keyPresses.shift() && this.isAffectedByFluids()) { + this.sinkInFluid(this.isInWater() ? net.minecraftforge.common.ForgeMod.WATER_TYPE.get() : fluidType); } if (this.isEyeInFluid(FluidTags.WATER)) { -@@ -885,6 +_,7 @@ +@@ -870,6 +_,8 @@ @Override public void rideTick() { super.rideTick(); -+ if (this.wantsToStopRiding() && this.isPassenger()) this.input.shiftKeyDown = false; ++ if (this.wantsToStopRiding() && this.isPassenger()) ++ this.input.keyPresses = this.input.keyPresses.jump(false); this.handsBusy = false; - if (this.getControlledVehicle() instanceof Boat boat) { - boat.setInput(this.input.left, this.input.right, this.input.up, this.input.down); -@@ -1142,5 +_,17 @@ + if (this.getControlledVehicle() instanceof AbstractBoat abstractboat) { + abstractboat.setInput( +@@ -1146,6 +_,18 @@ @Override public float getVisualRotationYInDegrees() { return this.getYRot(); @@ -100,7 +86,7 @@ + + public void updateSyncFields(LocalPlayer old) { + this.xLast = old.xLast; -+ this.yLast1 = old.yLast1; ++ this.yLast = old.yLast; + this.zLast = old.zLast; + this.yRotLast = old.yRotLast; + this.xRotLast = old.xRotLast; @@ -109,4 +95,5 @@ + this.wasSprinting = old.wasSprinting; + this.positionReminder = old.positionReminder; } - } + + @Override diff --git a/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch b/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch deleted file mode 100644 index 9d7b0c2108..0000000000 --- a/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/client/player/RemotePlayer.java -+++ b/net/minecraft/client/player/RemotePlayer.java -@@ -33,6 +_,7 @@ - - @Override - public boolean hurt(DamageSource p_108772_, float p_108773_) { -+ net.minecraftforge.common.ForgeHooks.onPlayerAttack(this, p_108772_, p_108773_); - return true; - } - diff --git a/patches/minecraft/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch b/patches/minecraft/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch index 2997e80a4c..f56cf7ec53 100644 --- a/patches/minecraft/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/client/renderer/DimensionSpecialEffects.java +++ b/net/minecraft/client/renderer/DimensionSpecialEffects.java -@@ -13,7 +_,7 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - - @OnlyIn(Dist.CLIENT) --public abstract class DimensionSpecialEffects { -+public abstract class DimensionSpecialEffects implements net.minecraftforge.client.extensions.IForgeDimensionSpecialEffects { - private static final Object2ObjectMap EFFECTS = Util.make(new Object2ObjectArrayMap<>(), p_108881_ -> { - DimensionSpecialEffects.OverworldEffects dimensionspecialeffects$overworldeffects = new DimensionSpecialEffects.OverworldEffects(); - p_108881_.defaultReturnValue(dimensionspecialeffects$overworldeffects); -@@ -37,7 +_,7 @@ +@@ -36,7 +_,7 @@ } public static DimensionSpecialEffects forType(DimensionType p_108877_) { @@ -17,4 +8,4 @@ + return net.minecraftforge.client.DimensionSpecialEffectsManager.getForType(p_108877_.effectsLocation()); } - @Nullable + public boolean isSunriseOrSunset(float p_361903_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/EffectInstance.java.patch b/patches/minecraft/net/minecraft/client/renderer/EffectInstance.java.patch deleted file mode 100644 index aa8d5c50a1..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/EffectInstance.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/client/renderer/EffectInstance.java -+++ b/net/minecraft/client/renderer/EffectInstance.java -@@ -58,7 +_,7 @@ - private final EffectProgram fragmentProgram; - - public EffectInstance(ResourceProvider p_334130_, String p_108942_) throws IOException { -- ResourceLocation resourcelocation = ResourceLocation.withDefaultNamespace("shaders/program/" + p_108942_ + ".json"); -+ ResourceLocation resourcelocation = ResourceLocation.tryParse(p_108942_).withPath(p -> "shaders/program/" + p + ".json"); - this.name = p_108942_; - Resource resource = p_334130_.getResourceOrThrow(resourcelocation); - -@@ -150,7 +_,7 @@ - } else { - EffectProgram effectprogram; - if (program == null) { -- ResourceLocation resourcelocation = ResourceLocation.withDefaultNamespace("shaders/program/" + p_172569_ + p_172568_.getExtension()); -+ ResourceLocation resourcelocation = ResourceLocation.tryParse(p_172569_).withPath(p -> "shaders/program/" + p + p_172568_.getExtension()); - Resource resource = p_331503_.getResourceOrThrow(resourcelocation); - - try (InputStream inputstream = resource.open()) { diff --git a/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch index 7282de92e4..c2a055fb86 100644 --- a/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch @@ -1,23 +1,27 @@ --- a/net/minecraft/client/renderer/FogRenderer.java +++ b/net/minecraft/client/renderer/FogRenderer.java -@@ -193,6 +_,12 @@ - fogBlue = fogBlue * (1.0F - f7) + fogBlue * f9 * f7; +@@ -192,6 +_,12 @@ + f2 = f2 * (1.0F - f10) + f2 * f12 * f10; } -+ Vector3f fogColor = net.minecraftforge.client.ForgeHooksClient.getFogColor(p_109019_, p_109020_, p_109021_, p_109022_, p_109023_, fogRed, fogGreen, fogBlue); ++ Vector3f fogColor = net.minecraftforge.client.ForgeHooksClient.getFogColor(p_362477_, p_364035_, p_361507_, p_361512_, p_367602_, f, f1, f2); + -+ fogRed = fogColor.x(); -+ fogGreen = fogColor.y(); -+ fogBlue = fogColor.z(); ++ f = fogColor.x(); ++ f1 = fogColor.y(); ++ f2 = fogColor.z(); + - RenderSystem.clearColor(fogRed, fogGreen, fogBlue, 0.0F); + return new Vector4f(f, f1, f2, 1.0F); } -@@ -269,6 +_,7 @@ - RenderSystem.setShaderFogStart(fogrenderer$fogdata.start); - RenderSystem.setShaderFogEnd(fogrenderer$fogdata.end); - RenderSystem.setShaderFogShape(fogrenderer$fogdata.shape); -+ net.minecraftforge.client.ForgeHooksClient.onFogRender(p_234174_, fogtype, p_234173_, p_234177_, p_234175_, fogrenderer$fogdata.start, fogrenderer$fogdata.end, fogrenderer$fogdata.shape); +@@ -270,9 +_,10 @@ + fogrenderer$fogdata.shape = FogShape.CYLINDER; + } + +- return new FogParameters( ++ var original = new FogParameters( + fogrenderer$fogdata.start, fogrenderer$fogdata.end, fogrenderer$fogdata.shape, p_365589_.x, p_365589_.y, p_365589_.z, p_365589_.w + ); ++ return net.minecraftforge.client.ForgeHooksClient.getFogParameters(p_234174_, fogtype, p_234173_, p_234177_, p_234175_, original); + } } - public static void levelFogColor() { diff --git a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch index 3b3005e1ed..2ff61dfcc8 100644 --- a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch @@ -1,82 +1,68 @@ --- a/net/minecraft/client/renderer/GameRenderer.java +++ b/net/minecraft/client/renderer/GameRenderer.java -@@ -311,6 +_,8 @@ - this.loadEffect(ResourceLocation.withDefaultNamespace("shaders/post/spider.json")); +@@ -158,6 +_,10 @@ + this.setPostEffect(ResourceLocation.withDefaultNamespace("spider")); } else if (p_109107_ instanceof EnderMan) { - this.loadEffect(ResourceLocation.withDefaultNamespace("shaders/post/invert.json")); -+ } else { -+ net.minecraftforge.client.ForgeHooksClient.loadEntityShader(p_109107_, this); + this.setPostEffect(ResourceLocation.withDefaultNamespace("invert")); ++ } else if (p_109107_ != null) { ++ var rl = net.minecraftforge.client.EntitySpectatorShaderManager.get(p_109107_.getType()); ++ if (rl != null) ++ this.setPostEffect(rl); } } -@@ -350,8 +_,11 @@ - public void processBlurEffect(float p_333718_) { - float f = (float)this.minecraft.options.getMenuBackgroundBlurriness(); - if (this.blurEffect != null && f >= 1.0F) { -+ // FORGE: Blending the blur was removed in 1.21. This is necessary for screen layering to work properly. https://github.com/MinecraftForge/MinecraftForge/issues/10114 -+ RenderSystem.enableBlend(); - this.blurEffect.setUniform("Radius", f); - this.blurEffect.process(p_333718_); -+ RenderSystem.disableBlend(); +@@ -171,8 +_,11 @@ + if (!(f < 1.0F)) { + PostChain postchain = this.minecraft.getShaderManager().getPostChain(BLUR_POST_CHAIN_ID, LevelTargetBundle.MAIN_TARGETS); + if (postchain != null) { ++ // FORGE: Blending the blur was removed in 1.21. This is necessary for screen layering to work properly. https://github.com/MinecraftForge/MinecraftForge/issues/10114 ++ RenderSystem.enableBlend(); + postchain.setUniform("Radius", f); + postchain.process(this.minecraft.getMainRenderTarget(), this.resourcePool); ++ RenderSystem.disableBlend(); + } } } - -@@ -526,6 +_,7 @@ - Pair.of(new ShaderInstance(p_250719_, "rendertype_gui_ghost_recipe_overlay", DefaultVertexFormat.POSITION_COLOR), p_286147_ -> rendertypeGuiGhostRecipeOverlayShader = p_286147_) - ); - list1.add(Pair.of(new ShaderInstance(p_250719_, "rendertype_breeze_wind", DefaultVertexFormat.NEW_ENTITY), p_308287_ -> rendertypeBreezeWindShader = p_308287_)); -+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRegisterShaders(p_250719_, list1); - this.loadBlurEffect(p_250719_); - } catch (IOException ioexception) { - list1.forEach(p_172729_ -> p_172729_.getFirst().close()); -@@ -685,7 +_,7 @@ - d0 *= Mth.lerp(this.minecraft.options.fovEffectScale().get(), 1.0, 0.85714287F); +@@ -312,7 +_,7 @@ + f *= Mth.lerp(f2, 1.0F, 0.85714287F); } -- return d0; -+ return net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeFov(this, p_109142_, p_109143_, d0, p_109144_).getFOV(); +- return f; ++ return net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeFov(this, p_109142_, p_109143_, f, p_109144_).getFOV(); } } -@@ -843,12 +_,12 @@ +@@ -468,12 +_,12 @@ (float)((double)window.getHeight() / window.getGuiScale()), 0.0F, 1000.0F, - 21000.0F + net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane() ); - RenderSystem.setProjectionMatrix(matrix4f, VertexSorting.ORTHOGRAPHIC_Z); + RenderSystem.setProjectionMatrix(matrix4f, ProjectionType.ORTHOGRAPHIC); Matrix4fStack matrix4fstack = RenderSystem.getModelViewStack(); matrix4fstack.pushMatrix(); - matrix4fstack.translation(0.0F, 0.0F, -11000.0F); + matrix4fstack.translation(0.0F, 0.0F, 10000F - net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane()); - RenderSystem.applyModelViewMatrix(); Lighting.setupFor3DItems(); GuiGraphics guigraphics = new GuiGraphics(this.minecraft, this.renderBuffers.bufferSource()); -@@ -882,7 +_,7 @@ + if (flag && p_109096_ && this.minecraft.level != null) { +@@ -499,7 +_,7 @@ } } else if (flag && this.minecraft.screen != null) { try { -- this.minecraft.screen.renderWithTooltip(guigraphics, i, j, p_343467_.getRealtimeDeltaTicks()); +- this.minecraft.screen.renderWithTooltip(guigraphics, i, j, p_343467_.getGameTimeDeltaTicks()); + net.minecraftforge.client.ForgeHooksClient.drawScreen(this.minecraft.screen, guigraphics, i, j, p_343467_.getRealtimeDeltaTicks()); } catch (Throwable throwable1) { CrashReport crashreport1 = CrashReport.forThrowable(throwable1, "Rendering screen"); CrashReportCategory crashreportcategory1 = crashreport1.addCategory("Screen render details"); -@@ -1053,12 +_,17 @@ +@@ -655,6 +_,9 @@ + if (this.minecraft.options.bobView().get()) { + this.bobView(posestack, camera.getPartialTickTime()); } - - this.resetProjectionMatrix(matrix4f); + + var cameraSetup = net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeCameraAngles(this, camera, f); + camera.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll()); - Quaternionf quaternionf = camera.rotation().conjugate(new Quaternionf()); - Matrix4f matrix4f1 = new Matrix4f().rotation(quaternionf); - this.minecraft - .levelRenderer - .prepareCullFrustum(camera.getPosition(), matrix4f1, this.getProjectionMatrix(Math.max(d0, (double)this.minecraft.options.fov().get().intValue()))); - this.minecraft.levelRenderer.renderLevel(p_342230_, flag, camera, this, this.lightTexture, matrix4f1, matrix4f); -+ this.minecraft.getProfiler().popPush("forge_render_last"); -+ net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_LEVEL.dispatch(this.minecraft.levelRenderer, posestack.last().pose(), matrix4f, this.minecraft.levelRenderer.getTicks(), camera, this.minecraft.levelRenderer.getFrustum()); - this.minecraft.getProfiler().popPush("hand"); - if (this.renderHand) { - RenderSystem.clear(256, Minecraft.ON_OSX); + + matrix4f.mul(posestack.last().pose()); + float f3 = this.minecraft.options.screenEffectScale().get().floatValue(); diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch index f81a36e73f..8c657d02ad 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/client/renderer/ItemBlockRenderTypes.java +++ b/net/minecraft/client/renderer/ItemBlockRenderTypes.java -@@ -20,6 +_,7 @@ +@@ -18,6 +_,7 @@ @OnlyIn(Dist.CLIENT) public class ItemBlockRenderTypes { + @Deprecated - private static final Map TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), p_340896_ -> { + private static final Map TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), p_357825_ -> { RenderType rendertype = RenderType.tripwire(); - p_340896_.put(Blocks.TRIPWIRE, rendertype); -@@ -335,6 +_,7 @@ - p_340896_.put(Blocks.BUBBLE_COLUMN, rendertype3); - p_340896_.put(Blocks.TINTED_GLASS, rendertype3); + p_357825_.put(Blocks.TRIPWIRE, rendertype); +@@ -340,6 +_,7 @@ + p_357825_.put(Blocks.BUBBLE_COLUMN, rendertype3); + p_357825_.put(Blocks.TINTED_GLASS, rendertype3); }); + @Deprecated private static final Map TYPE_BY_FLUID = Util.make(Maps.newHashMap(), p_109290_ -> { RenderType rendertype = RenderType.translucent(); p_109290_.put(Fluids.FLOWING_WATER, rendertype); -@@ -342,6 +_,8 @@ +@@ -347,6 +_,8 @@ }); private static boolean renderCutout; @@ -25,7 +25,7 @@ public static RenderType getChunkRenderType(BlockState p_109283_) { Block block = p_109283_.getBlock(); if (block instanceof LeavesBlock) { -@@ -352,6 +_,8 @@ +@@ -357,6 +_,8 @@ } } @@ -34,27 +34,21 @@ public static RenderType getMovingBlockRenderType(BlockState p_109294_) { Block block = p_109294_.getBlock(); if (block instanceof LeavesBlock) { -@@ -366,6 +_,8 @@ +@@ -371,6 +_,8 @@ } } + /** @deprecated Forge: Use {@link net.minecraftforge.client.RenderTypeHelper#getEntityRenderType(RenderType, boolean)} while iterating through {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.minecraftforge.client.model.data.ModelData)}. */ + @Deprecated // Note: this method does NOT support model-based render types - public static RenderType getRenderType(BlockState p_109285_, boolean p_109286_) { - RenderType rendertype = getChunkRenderType(p_109285_); - if (rendertype == RenderType.translucent()) { -@@ -379,6 +_,8 @@ + public static RenderType getRenderType(BlockState p_364446_) { + RenderType rendertype = getChunkRenderType(p_364446_); + return rendertype == RenderType.translucent() ? Sheets.translucentItemSheet() : Sheets.cutoutBlockSheet(); +@@ -385,12 +_,77 @@ } } + /** @deprecated Forge: Use {@link net.minecraft.client.resources.model.BakedModel#getRenderPasses(ItemStack, boolean)} and {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(ItemStack, boolean)}. */ + @Deprecated // Note: this method does NOT support model-based render types - public static RenderType getRenderType(ItemStack p_109280_, boolean p_109281_) { - Item item = p_109280_.getItem(); - if (item instanceof BlockItem) { -@@ -390,11 +_,74 @@ - } - public static RenderType getRenderLayer(FluidState p_109288_) { - RenderType rendertype = TYPE_BY_FLUID.get(p_109288_.getType()); + RenderType rendertype = FLUID_RENDER_TYPES.get(net.minecraftforge.registries.ForgeRegistries.FLUIDS.getDelegateOrThrow(p_109288_.getType())); @@ -81,7 +75,7 @@ + }); + + /** @deprecated Use {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.minecraftforge.client.model.data.ModelData)}. */ -+ @Deprecated(since = "1.19") ++ //@Deprecated(since = "1.19", forRemoval = true) + public static net.minecraftforge.client.ChunkRenderTypeSet getRenderLayers(BlockState state) { + Block block = state.getBlock(); + if (block instanceof LeavesBlock) { @@ -92,20 +86,20 @@ + } + + /** @deprecated Set your render type in your block model's JSON (eg. {@code "render_type": "cutout"}) or override {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.minecraftforge.client.model.data.ModelData)} */ -+ @Deprecated(since = "1.19") ++ //@Deprecated(since = "1.19", forRemoval = true) + public static void setRenderLayer(Block block, RenderType type) { + com.google.common.base.Preconditions.checkArgument(type.getChunkLayerId() >= 0, "The argument must be a valid chunk render type returned by RenderType#chunkBufferLayers()."); + setRenderLayer(block, net.minecraftforge.client.ChunkRenderTypeSet.of(type)); + } + + /** @deprecated Set your render type in your block model's JSON (eg. {@code "render_type": "cutout"}) or override {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.minecraftforge.client.model.data.ModelData)} */ -+ @Deprecated(since = "1.19") ++ //@Deprecated(since = "1.19", forRemoval = true) + public static synchronized void setRenderLayer(Block block, java.util.function.Predicate predicate) { + setRenderLayer(block, createSetFromPredicate(predicate)); + } + + /** @deprecated Set your render type in your block model's JSON (eg. {@code "render_type": "cutout"}) or override {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.minecraftforge.client.model.data.ModelData)} */ -+ @Deprecated(since = "1.19") ++ //@Deprecated(since = "1.19", forRemoval = true) + public static synchronized void setRenderLayer(Block block, net.minecraftforge.client.ChunkRenderTypeSet layers) { + checkClientLoading(); + BLOCK_RENDER_TYPES.put(net.minecraftforge.registries.ForgeRegistries.BLOCKS.getDelegateOrThrow(block), layers); diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch index 275a7e755f..4b23d605bd 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/ItemInHandRenderer.java +++ b/net/minecraft/client/renderer/ItemInHandRenderer.java -@@ -332,12 +_,14 @@ +@@ -339,12 +_,14 @@ if (iteminhandrenderer$handrenderselection.renderMainHand) { float f4 = interactionhand == InteractionHand.MAIN_HAND ? f : 0.0F; float f5 = 1.0F - Mth.lerp(p_109315_, this.oMainHandHeight, this.mainHandHeight); @@ -15,7 +15,7 @@ this.renderArmWithItem(p_109318_, p_109315_, f1, InteractionHand.OFF_HAND, f6, this.offHandItem, f7, p_109316_, p_109317_, p_109319_); } -@@ -403,7 +_,7 @@ +@@ -410,7 +_,7 @@ } else { this.renderOneHandedMap(p_109379_, p_109380_, p_109381_, p_109378_, humanoidarm, p_109376_, p_109377_); } @@ -24,7 +24,7 @@ boolean flag1 = CrossbowItem.isCharged(p_109377_); boolean flag2 = humanoidarm == HumanoidArm.RIGHT; int i = flag2 ? 1 : -1; -@@ -453,6 +_,7 @@ +@@ -460,6 +_,7 @@ ); } else { boolean flag3 = humanoidarm == HumanoidArm.RIGHT; @@ -32,7 +32,7 @@ if (p_109372_.isUsingItem() && p_109372_.getUseItemRemainingTicks() > 0 && p_109372_.getUsedItemHand() == p_109375_) { int k = flag3 ? 1 : -1; switch (p_109377_.getUseAnimation()) { -@@ -567,8 +_,16 @@ +@@ -574,8 +_,16 @@ this.offHandHeight = Mth.clamp(this.offHandHeight - 0.4F, 0.0F, 1.0F); } else { float f = localplayer.getAttackStrengthScale(1.0F); diff --git a/patches/minecraft/net/minecraft/client/renderer/LevelEventHandler.java.patch b/patches/minecraft/net/minecraft/client/renderer/LevelEventHandler.java.patch new file mode 100644 index 0000000000..cc326d9f0b --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/LevelEventHandler.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/renderer/LevelEventHandler.java ++++ b/net/minecraft/client/renderer/LevelEventHandler.java +@@ -325,7 +_,7 @@ + case 2001: + BlockState blockstate1 = Block.stateById(p_368262_); + if (!blockstate1.isAir()) { +- SoundType soundtype = blockstate1.getSoundType(); ++ SoundType soundtype = blockstate1.getSoundType(this.level, p_362689_, null); + this.level + .playLocalSound( + p_362689_, soundtype.getBreakSound(), SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F, false diff --git a/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch index f8f297461d..e84d6d70f8 100644 --- a/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch @@ -1,203 +1,183 @@ --- a/net/minecraft/client/renderer/LevelRenderer.java +++ b/net/minecraft/client/renderer/LevelRenderer.java -@@ -256,6 +_,9 @@ +@@ -111,7 +_,7 @@ + private final SkyRenderer skyRenderer = new SkyRenderer(); + private final CloudRenderer cloudRenderer = new CloudRenderer(); + private final WorldBorderRenderer worldBorderRenderer = new WorldBorderRenderer(); +- private final WeatherEffectRenderer weatherEffectRenderer = new WeatherEffectRenderer(); ++ private WeatherEffectRenderer weatherEffectRenderer = new WeatherEffectRenderer(); + @Nullable + private ClientLevel level; + private final SectionOcclusionGraph sectionOcclusionGraph = new SectionOcclusionGraph(); +@@ -487,7 +_,7 @@ + postchain1.addToFrame(framegraphbuilder, i, j, this.targets); + } + +- this.addParticlesPass(framegraphbuilder, p_109604_, p_109606_, f, fogparameters); ++ this.addParticlesPass(framegraphbuilder, p_109604_, p_109606_, f, fogparameters, frustum); + CloudStatus cloudstatus = this.minecraft.options.getCloudsType(); + if (cloudstatus != CloudStatus.OFF) { + float f2 = this.level.effects().getCloudHeight(); +@@ -569,7 +_,11 @@ + double d2 = vec3.z(); + p_369478_.push("terrain"); + this.renderSectionLayer(RenderType.solid(), d0, d1, d2, p_361439_, p_369924_); ++ // FORGE: fix flickering leaves when mods mess up the blurMipmap settings ++ var atlas = this.minecraft.getModelManager().getAtlas(net.minecraft.client.renderer.texture.TextureAtlas.LOCATION_BLOCKS); ++ atlas.setBlurMipmap(false, this.minecraft.options.mipmapLevels().get() > 0); + this.renderSectionLayer(RenderType.cutoutMipped(), d0, d1, d2, p_361439_, p_369924_); ++ atlas.restoreLastBlurMipmap(); + this.renderSectionLayer(RenderType.cutout(), d0, d1, d2, p_361439_, p_369924_); + if (this.level.effects().constantAmbientLight()) { + Lighting.setupNetherLevel(); +@@ -603,7 +_,7 @@ + multibuffersource$buffersource.endLastBatch(); + this.checkPoseStack(posestack); + p_369478_.popPush("blockentities"); +- this.renderBlockEntities(posestack, multibuffersource$buffersource, multibuffersource$buffersource1, p_364769_, f); ++ var renderOutline = this.renderBlockEntities(posestack, multibuffersource$buffersource, multibuffersource$buffersource1, p_364769_, f, p_363733_) || p_362593_; + multibuffersource$buffersource.endLastBatch(); + this.checkPoseStack(posestack); + multibuffersource$buffersource.endBatch(RenderType.solid()); +@@ -617,8 +_,8 @@ + multibuffersource$buffersource.endBatch(Sheets.hangingSignSheet()); + multibuffersource$buffersource.endBatch(Sheets.chestSheet()); + this.renderBuffers.outlineBufferSource().endOutlineBatch(); +- if (p_362593_) { +- this.renderBlockOutline(p_364769_, multibuffersource$buffersource, posestack, false); ++ if (renderOutline) { ++ this.renderBlockOutline(p_364769_, multibuffersource$buffersource, posestack, false, f); + } + + p_369478_.popPush("debug"); +@@ -648,8 +_,8 @@ + this.renderSectionLayer(RenderType.translucent(), d0, d1, d2, p_361439_, p_369924_); + p_369478_.popPush("string"); + this.renderSectionLayer(RenderType.tripwire(), d0, d1, d2, p_361439_, p_369924_); +- if (p_362593_) { +- this.renderBlockOutline(p_364769_, multibuffersource$buffersource, posestack, true); ++ if (renderOutline) { ++ this.renderBlockOutline(p_364769_, multibuffersource$buffersource, posestack, true, f); + } + + multibuffersource$buffersource.endBatch(); +@@ -657,7 +_,7 @@ + }); } - private void renderSnowAndRain(LightTexture p_109704_, float p_109705_, double p_109706_, double p_109707_, double p_109708_) { -+ if (level.effects().renderSnowAndRain(level, ticks, p_109705_, p_109704_, p_109706_, p_109707_, p_109708_)) { -+ return; -+ } - float f = this.minecraft.level.getRainLevel(p_109705_); - if (!(f <= 0.0F)) { - p_109704_.turnOnLightLayer(); -@@ -418,6 +_,9 @@ - } +- private void addParticlesPass(FrameGraphBuilder p_366471_, Camera p_363128_, LightTexture p_366434_, float p_365755_, FogParameters p_363695_) { ++ private void addParticlesPass(FrameGraphBuilder p_366471_, Camera p_363128_, LightTexture p_366434_, float p_365755_, FogParameters p_363695_, Frustum frustum) { + FramePass framepass = p_366471_.addPass("particles"); + if (this.targets.particles != null) { + this.targets.particles = framepass.readsAndWrites(this.targets.particles); +@@ -677,7 +_,7 @@ + } - public void tickRain(Camera p_109694_) { -+ if (level.effects().tickRain(level, ticks, p_109694_)) { -+ return; -+ } - float f = this.minecraft.level.getRainLevel(1.0F) / (Minecraft.useFancyGraphics() ? 1.0F : 2.0F); - if (!(f <= 0.0F)) { - RandomSource randomsource = RandomSource.create((long)this.ticks * 312987231L); -@@ -929,9 +_,11 @@ - RenderSystem.clear(16640, Minecraft.ON_OSX); - float f1 = p_109605_.getRenderDistance(); - boolean flag1 = this.minecraft.level.effects().isFoggyAt(Mth.floor(d0), Mth.floor(d1)) || this.minecraft.gui.getBossOverlay().shouldCreateWorldFog(); -+ FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_SKY, f1, flag1, f); - profilerfiller.popPush("sky"); - RenderSystem.setShader(GameRenderer::getPositionShader); - this.renderSky(p_254120_, p_330527_, f, p_109604_, flag1, () -> FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_SKY, f1, flag1, f)); -+ net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_SKY.dispatch(this, p_254120_, p_254120_, this.ticks, p_109604_, frustum); - profilerfiller.popPush("fog"); - FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f1, 32.0F), flag1, f); - profilerfiller.popPush("terrain_setup"); -@@ -940,7 +_,9 @@ - this.compileSections(p_109604_); - profilerfiller.popPush("terrain"); - this.renderSectionLayer(RenderType.solid(), d0, d1, d2, p_254120_, p_330527_); -+ this.minecraft.getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).setBlurMipmap(false, this.minecraft.options.mipmapLevels().get() > 0); // FORGE: fix flickering leaves when mods mess up the blurMipmap settings - this.renderSectionLayer(RenderType.cutoutMipped(), d0, d1, d2, p_254120_, p_330527_); -+ this.minecraft.getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).restoreLastBlurMipmap(); - this.renderSectionLayer(RenderType.cutout(), d0, d1, d2, p_254120_, p_330527_); - if (this.level.effects().constantAmbientLight()) { - Lighting.setupNetherLevel(); -@@ -983,7 +_,7 @@ - || p_109604_.isDetached() - || p_109604_.getEntity() instanceof LivingEntity && ((LivingEntity)p_109604_.getEntity()).isSleeping() + RenderStateShard.PARTICLES_TARGET.setupRenderState(); +- this.minecraft.particleEngine.render(p_366434_, p_363128_, p_365755_); ++ this.minecraft.particleEngine.render(p_366434_, p_363128_, p_365755_, frustum); + RenderStateShard.PARTICLES_TARGET.clearRenderState(); + }); + } +@@ -766,9 +_,9 @@ + || p_365712_.isDetached() + || p_365712_.getEntity() instanceof LivingEntity && ((LivingEntity)p_365712_.getEntity()).isSleeping() ) -- && (!(entity instanceof LocalPlayer) || p_109604_.getEntity() == entity)) { -+ && (!(entity instanceof LocalPlayer) || p_109604_.getEntity() == entity || (entity == minecraft.player && !minecraft.player.isSpectator()))) { //FORGE: render local player entity when it is not the renderViewEntity - this.renderedEntities++; - if (entity.tickCount == 0) { - entity.xOld = entity.getX(); -@@ -999,6 +_,9 @@ - int i = entity.getTeamColor(); - outlinebuffersource.setColor(FastColor.ARGB32.red(i), FastColor.ARGB32.green(i), FastColor.ARGB32.blue(i), 255); - } else { -+ if (this.shouldShowEntityOutlines() && entity.hasCustomOutlineRendering(this.minecraft.player)) { // FORGE: allow custom outline rendering -+ flag2 = true; -+ } - multibuffersource = multibuffersource$buffersource; +- && (!(entity instanceof LocalPlayer) || p_365712_.getEntity() == entity)) { ++ && (!(entity instanceof LocalPlayer) || p_365712_.getEntity() == entity || (entity == minecraft.player && !minecraft.player.isSpectator()))) { //FORGE: render local player entity when it is not the renderViewEntity + p_368622_.add(entity); +- if (flag1 && this.minecraft.shouldEntityAppearGlowing(entity)) { ++ if (flag1 && (this.minecraft.shouldEntityAppearGlowing(entity) || entity.hasCustomOutlineRendering(this.minecraft.player))) { + flag = true; } + } +@@ -808,9 +_,10 @@ + } + } -@@ -1014,12 +_,14 @@ - multibuffersource$buffersource.endBatch(RenderType.entityCutout(TextureAtlas.LOCATION_BLOCKS)); - multibuffersource$buffersource.endBatch(RenderType.entityCutoutNoCull(TextureAtlas.LOCATION_BLOCKS)); - multibuffersource$buffersource.endBatch(RenderType.entitySmoothCutout(TextureAtlas.LOCATION_BLOCKS)); -+ net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_ENTITIES.dispatch(this, p_254120_, p_254120_, this.ticks, p_109604_, frustum); - profilerfiller.popPush("blockentities"); - - for (SectionRenderDispatcher.RenderSection sectionrenderdispatcher$rendersection : this.visibleSections) { +- private void renderBlockEntities( +- PoseStack p_366168_, MultiBufferSource.BufferSource p_362022_, MultiBufferSource.BufferSource p_369016_, Camera p_369847_, float p_367074_ ++ private boolean renderBlockEntities( ++ PoseStack p_366168_, MultiBufferSource.BufferSource p_362022_, MultiBufferSource.BufferSource p_369016_, Camera p_369847_, float p_367074_, Frustum frustum + ) { ++ boolean customOutline = false; + Vec3 vec3 = p_369847_.getPosition(); + double d0 = vec3.x(); + double d1 = vec3.y(); +@@ -820,6 +_,7 @@ List list = sectionrenderdispatcher$rendersection.getCompiled().getRenderableBlockEntities(); if (!list.isEmpty()) { - for (BlockEntity blockentity1 : list) { -+ if (!frustum.isVisible(blockentity1.getRenderBoundingBox())) continue; - BlockPos blockpos4 = blockentity1.getBlockPos(); - MultiBufferSource multibuffersource1 = multibuffersource$buffersource; - posestack.pushPose(); -@@ -1039,6 +_,10 @@ + for (BlockEntity blockentity : list) { ++ if (!frustum.isVisible(blockentity.getRenderBoundingBox())) continue; + BlockPos blockpos = blockentity.getBlockPos(); + MultiBufferSource multibuffersource = p_362022_; + p_366168_.pushPose(); +@@ -839,6 +_,9 @@ } } -+ if (this.shouldShowEntityOutlines() && blockentity1.hasCustomOutlineRendering(this.minecraft.player)) { // FORGE: allow custom outline rendering -+ flag2 = true; -+ } ++ if (!customOutline && this.shouldShowEntityOutlines() && blockentity.hasCustomOutlineRendering(this.minecraft.player)) ++ customOutline = true; + - this.blockEntityRenderDispatcher.render(blockentity1, f, posestack, multibuffersource1); - posestack.popPose(); + this.blockEntityRenderDispatcher.render(blockentity, p_367074_, p_366168_, multibuffersource); + p_366168_.popPose(); } -@@ -1047,9 +_,13 @@ +@@ -847,13 +_,18 @@ synchronized (this.globalBlockEntities) { - for (BlockEntity blockentity : this.globalBlockEntities) { -+ if (!frustum.isVisible(blockentity.getRenderBoundingBox())) continue; - BlockPos blockpos3 = blockentity.getBlockPos(); - posestack.pushPose(); - posestack.translate((double)blockpos3.getX() - d0, (double)blockpos3.getY() - d1, (double)blockpos3.getZ() - d2); -+ if (this.shouldShowEntityOutlines() && blockentity.hasCustomOutlineRendering(this.minecraft.player)) { // FORGE: allow custom outline rendering -+ flag2 = true; -+ } - this.blockEntityRenderDispatcher.render(blockentity, f, posestack, multibuffersource$buffersource); - posestack.popPose(); + for (BlockEntity blockentity1 : this.globalBlockEntities) { ++ if (!frustum.isVisible(blockentity1.getRenderBoundingBox())) continue; + BlockPos blockpos1 = blockentity1.getBlockPos(); + p_366168_.pushPose(); + p_366168_.translate((double)blockpos1.getX() - d0, (double)blockpos1.getY() - d1, (double)blockpos1.getZ() - d2); ++ if (!customOutline && this.shouldShowEntityOutlines() && blockentity1.hasCustomOutlineRendering(this.minecraft.player)) ++ customOutline = true; + this.blockEntityRenderDispatcher.render(blockentity1, p_367074_, p_366168_, p_362022_); + p_366168_.popPose(); } -@@ -1072,6 +_,7 @@ - this.minecraft.getMainRenderTarget().bindWrite(false); } ++ ++ return customOutline; + } -+ net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_BLOCK_ENTITIES.dispatch(this, p_254120_, p_254120_, this.ticks, p_109604_, frustum); - profilerfiller.popPush("destroyProgress"); - - for (Entry> entry : this.destructionProgress.long2ObjectEntrySet()) { -@@ -1089,7 +_,8 @@ - VertexConsumer vertexconsumer1 = new SheetedDecalTextureGenerator( - this.renderBuffers.crumblingBufferSource().getBuffer(ModelBakery.DESTROY_TYPES.get(k)), posestack$pose1, 1.0F - ); -- this.minecraft.getBlockRenderer().renderBreakingTexture(this.level.getBlockState(blockpos2), blockpos2, this.level, posestack, vertexconsumer1); -+ var modelData = level.getModelDataManager().getAt(blockpos2); -+ this.minecraft.getBlockRenderer().renderBreakingTexture(this.level.getBlockState(blockpos2), blockpos2, this.level, posestack, vertexconsumer1, modelData == null ? net.minecraftforge.client.model.data.ModelData.EMPTY : modelData); - posestack.popPose(); + private void renderBlockDestroyAnimation(PoseStack p_366956_, Camera p_369324_, MultiBufferSource.BufferSource p_365998_) { +@@ -872,14 +_,14 @@ + p_366956_.translate((double)blockpos.getX() - d0, (double)blockpos.getY() - d1, (double)blockpos.getZ() - d2); + PoseStack.Pose posestack$pose = p_366956_.last(); + VertexConsumer vertexconsumer = new SheetedDecalTextureGenerator(p_365998_.getBuffer(ModelBakery.DESTROY_TYPES.get(i)), posestack$pose, 1.0F); +- this.minecraft.getBlockRenderer().renderBreakingTexture(this.level.getBlockState(blockpos), blockpos, this.level, p_366956_, vertexconsumer); ++ this.minecraft.getBlockRenderer().renderBreakingTexture(this.level.getBlockState(blockpos), blockpos, this.level, p_366956_, vertexconsumer, level.getModelDataManager().getAtOrEmpty(blockpos)); + p_366956_.popPose(); } } -@@ -1101,10 +_,13 @@ - profilerfiller.popPush("outline"); - BlockPos blockpos1 = ((BlockHitResult)hitresult).getBlockPos(); - BlockState blockstate = this.level.getBlockState(blockpos1); -+ if (!net.minecraftforge.client.ForgeHooksClient.onDrawHighlight(this, p_109604_, hitresult, f, posestack, multibuffersource$buffersource)) - if (!blockstate.isAir() && this.level.getWorldBorder().isWithinBounds(blockpos1)) { - VertexConsumer vertexconsumer2 = multibuffersource$buffersource.getBuffer(RenderType.lines()); - this.renderHitOutline(posestack, vertexconsumer2, p_109604_.getEntity(), d0, d1, d2, blockpos1, blockstate); + } + } + +- private void renderBlockOutline(Camera p_367935_, MultiBufferSource.BufferSource p_367206_, PoseStack p_365062_, boolean p_368189_) { ++ private void renderBlockOutline(Camera p_367935_, MultiBufferSource.BufferSource p_367206_, PoseStack p_365062_, boolean p_368189_, float partialTicks) { + if (this.minecraft.hitResult instanceof BlockHitResult blockhitresult) { + if (blockhitresult.getType() != HitResult.Type.MISS) { + BlockPos blockpos = blockhitresult.getBlockPos(); +@@ -890,6 +_,9 @@ + return; + } + ++ if (net.minecraftforge.client.ForgeHooksClient.onDrawHighlight(this, p_367935_, blockhitresult, partialTicks, p_365062_, p_367206_)) ++ return; ++ + Vec3 vec3 = p_367935_.getPosition(); + Boolean obool = this.minecraft.options.highContrastBlockOutline().get(); + if (obool) { +@@ -905,6 +_,8 @@ + p_367206_.endLastBatch(); + } } -+ } else if (hitresult != null && hitresult.getType() == HitResult.Type.ENTITY) { -+ net.minecraftforge.client.ForgeHooksClient.onDrawHighlight(this, p_109604_, hitresult, f, posestack, multibuffersource$buffersource); ++ } else if (this.minecraft.hitResult instanceof net.minecraft.world.phys.EntityHitResult entity) { ++ net.minecraftforge.client.ForgeHooksClient.onDrawHighlight(this, p_367935_, entity, partialTicks, p_365062_, p_367206_); } - - this.minecraft.debugRenderer.render(posestack, multibuffersource$buffersource, d0, d1, d2); -@@ -1132,7 +_,8 @@ - this.particlesTarget.copyDepthFrom(this.minecraft.getMainRenderTarget()); - RenderStateShard.PARTICLES_TARGET.setupRenderState(); - profilerfiller.popPush("particles"); -- this.minecraft.particleEngine.render(p_109606_, p_109604_, f); -+ this.minecraft.particleEngine.render(p_109606_, p_109604_, f, frustum); -+ net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES.dispatch(this, posestack.last().pose(), p_254120_, this.ticks, p_109604_, frustum); - RenderStateShard.PARTICLES_TARGET.clearRenderState(); - } else { - profilerfiller.popPush("translucent"); -@@ -1146,7 +_,8 @@ - profilerfiller.popPush("string"); - this.renderSectionLayer(RenderType.tripwire(), d0, d1, d2, p_254120_, p_330527_); - profilerfiller.popPush("particles"); -- this.minecraft.particleEngine.render(p_109606_, p_109604_, f); -+ this.minecraft.particleEngine.render(p_109606_, p_109604_, f, frustum); -+ net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES.dispatch(this, posestack.last().pose(), p_254120_, this.ticks, p_109604_, frustum); - } - - if (this.minecraft.options.getCloudsType() != CloudStatus.OFF) { -@@ -1162,6 +_,7 @@ - RenderStateShard.WEATHER_TARGET.setupRenderState(); - profilerfiller.popPush("weather"); - this.renderSnowAndRain(p_109606_, f, d0, d1, d2); -+ net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER.dispatch(this, posestack.last().pose(), p_254120_, this.ticks, p_109604_, frustum); - this.renderWorldBorder(p_109604_); - RenderStateShard.WEATHER_TARGET.clearRenderState(); - this.transparencyChain.process(p_342180_.getGameTimeDeltaTicks()); -@@ -1170,6 +_,7 @@ - RenderSystem.depthMask(false); - profilerfiller.popPush("weather"); - this.renderSnowAndRain(p_109606_, f, d0, d1, d2); -+ net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER.dispatch(this, posestack.last().pose(), p_254120_, this.ticks, p_109604_, frustum); - this.renderWorldBorder(p_109604_); - RenderSystem.depthMask(true); - } -@@ -1269,6 +_,7 @@ - shaderinstance.clear(); - VertexBuffer.unbind(); - this.minecraft.getProfiler().pop(); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(p_298012_, this, p_297481_, p_333714_, this.ticks, this.minecraft.gameRenderer.getMainCamera(), this.getFrustum()); - p_298012_.clearRenderState(); } -@@ -1519,6 +_,9 @@ - } - - public void renderSky(Matrix4f p_254034_, Matrix4f p_333200_, float p_202426_, Camera p_202427_, boolean p_202428_, Runnable p_202429_) { -+ if (level.effects().renderSky(level, ticks, p_202426_, p_202427_, p_254034_, p_202428_, p_202429_)) { -+ return; -+ } - p_202429_.run(); - if (!p_202428_) { - FogType fogtype = p_202427_.getFluidInCamera(); -@@ -1642,6 +_,9 @@ - } - - public void renderClouds(PoseStack p_254145_, Matrix4f p_254537_, Matrix4f p_330176_, float p_254364_, double p_253843_, double p_253663_, double p_253795_) { -+ if (level.effects().renderClouds(level, ticks, p_254364_, p_254145_, p_253843_, p_253663_, p_253795_, p_254537_)) { -+ return; -+ } - float f = this.level.effects().getCloudHeight(); - if (!Float.isNaN(f)) { - float f1 = 12.0F; -@@ -1901,7 +_,7 @@ +@@ -1112,7 +_,7 @@ boolean flag = false; if (this.minecraft.options.prioritizeChunkUpdates().get() == PrioritizeChunkUpdates.NEARBY) { BlockPos blockpos1 = sectionrenderdispatcher$rendersection.getOrigin().offset(8, 8, 8); @@ -206,31 +186,7 @@ } else if (this.minecraft.options.prioritizeChunkUpdates().get() == PrioritizeChunkUpdates.PLAYER_AFFECTED) { flag = sectionrenderdispatcher$rendersection.isDirtyFromPlayer(); } -@@ -2477,6 +_,14 @@ - this.viewArea.setDirty(p_109502_, p_109503_, p_109504_, p_109505_); - } - -+ public Frustum getFrustum() { -+ return this.capturedFrustum != null ? this.capturedFrustum : this.cullingFrustum; -+ } -+ -+ public int getTicks() { -+ return this.ticks; -+ } -+ - public void playJukeboxSong(Holder p_343944_, BlockPos p_342259_) { - if (this.level != null) { - this.stopJukeboxSong(p_342259_); -@@ -2886,7 +_,7 @@ - case 2001: - BlockState blockstate1 = Block.stateById(p_234307_); - if (!blockstate1.isAir()) { -- SoundType soundtype = blockstate1.getSoundType(); -+ SoundType soundtype = blockstate1.getSoundType(this.level, p_234306_, null); - this.level - .playLocalSound( - p_234306_, soundtype.getBreakSound(), SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F, false -@@ -3338,7 +_,7 @@ +@@ -1391,7 +_,7 @@ } else { int i = p_109538_.getBrightness(LightLayer.SKY, p_109540_); int j = p_109538_.getBrightness(LightLayer.BLOCK, p_109540_); @@ -239,3 +195,25 @@ if (j < k) { j = k; } +@@ -1453,5 +_,21 @@ + + public CloudRenderer getCloudRenderer() { + return this.cloudRenderer; ++ } ++ ++ public Frustum getFrustum() { ++ return this.capturedFrustum != null ? this.capturedFrustum : this.cullingFrustum; ++ } ++ ++ public int getTicks() { ++ return this.ticks; ++ } ++ ++ public WeatherEffectRenderer getWeatherEffects() { ++ return this.weatherEffectRenderer; ++ } ++ ++ public void setWeatherEffects(WeatherEffectRenderer value) { ++ this.weatherEffectRenderer = value; + } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch b/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch index 72db3bdff6..7af3a43fc3 100644 --- a/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch @@ -1,19 +1,10 @@ --- a/net/minecraft/client/renderer/LightTexture.java +++ b/net/minecraft/client/renderer/LightTexture.java -@@ -129,6 +_,8 @@ - } - } - -+ clientlevel.effects().adjustLightmapColors(clientlevel, p_109882_, f, f7, f8, j, i, vector3f1); -+ - if (f5 > 0.0F) { - float f13 = Math.max(vector3f1.x(), Math.max(vector3f1.y(), vector3f1.z())); - if (f13 < 1.0F) { -@@ -186,7 +_,7 @@ +@@ -143,7 +_,7 @@ } public static int block(int p_109884_) { -- return p_109884_ >> 4 & 65535; +- return p_109884_ >>> 4 & 15; + return (p_109884_ & 0xFFFF) >> 4; // Forge: Fix fullbright quads showing dark artifacts. Reported as MC-169806 } diff --git a/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch b/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch deleted file mode 100644 index 90b8a36253..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/client/renderer/PostChain.java -+++ b/net/minecraft/client/renderer/PostChain.java -@@ -156,7 +_,7 @@ - throw new ChainedJsonException("Render target '" + s4 + "' can't be used as depth buffer"); - } - -- ResourceLocation resourcelocation = ResourceLocation.withDefaultNamespace("textures/effect/" + s4 + ".png"); -+ ResourceLocation resourcelocation = ResourceLocation.tryParse(s4).withPath(p -> "textures/effect/" + p + ".png"); - this.resourceProvider - .getResource(resourcelocation) - .orElseThrow(() -> new ChainedJsonException("Render target or texture '" + s4 + "' does not exist")); -@@ -257,6 +_,7 @@ - public void addTempTarget(String p_110039_, int p_110040_, int p_110041_) { - RenderTarget rendertarget = new TextureTarget(p_110040_, p_110041_, true, Minecraft.ON_OSX); - rendertarget.setClearColor(0.0F, 0.0F, 0.0F, 0.0F); -+ if (screenTarget.isStencilEnabled()) rendertarget.enableStencil(); - this.customRenderTargets.put(p_110039_, rendertarget); - if (p_110040_ == this.screenWidth && p_110041_ == this.screenHeight) { - this.fullSizedTargets.add(rendertarget); diff --git a/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch b/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch index c92dea6761..e165b98c7d 100644 --- a/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/renderer/RenderType.java +++ b/net/minecraft/client/renderer/RenderType.java -@@ -674,11 +_,22 @@ - RenderType.CompositeState.builder().setShaderState(RENDERTYPE_GUI_GHOST_RECIPE_OVERLAY_SHADER).setTransparencyState(TRANSLUCENT_TRANSPARENCY).setDepthTestState(GREATER_DEPTH_TEST).setWriteMaskState(COLOR_WRITE).createCompositeState(false) +@@ -800,11 +_,22 @@ + .createCompositeState(false) ); private static final ImmutableList CHUNK_BUFFER_LAYERS = ImmutableList.of(solid(), cutoutMipped(), cutout(), translucent(), tripwire()); + static { @@ -23,7 +23,7 @@ public static RenderType solid() { return SOLID; -@@ -899,7 +_,7 @@ +@@ -1025,7 +_,7 @@ } public static RenderType text(ResourceLocation p_110498_) { @@ -32,7 +32,7 @@ } public static RenderType textBackground() { -@@ -907,19 +_,19 @@ +@@ -1033,19 +_,19 @@ } public static RenderType textIntensity(ResourceLocation p_173238_) { @@ -56,7 +56,7 @@ } public static RenderType textBackgroundSeeThrough() { -@@ -927,7 +_,7 @@ +@@ -1053,7 +_,7 @@ } public static RenderType textIntensitySeeThrough(ResourceLocation p_173241_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch index 298e2f5a17..3bf478397d 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch @@ -57,7 +57,7 @@ + } + + public static void renderFluid(Minecraft p_110726_, PoseStack p_110727_, ResourceLocation texture) { - RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShader(CoreShaders.POSITION_TEX); - RenderSystem.setShaderTexture(0, UNDERWATER_LOCATION); + RenderSystem.setShaderTexture(0, texture); BlockPos blockpos = BlockPos.containing(p_110726_.player.getX(), p_110726_.player.getEyeY(), p_110726_.player.getZ()); diff --git a/patches/minecraft/net/minecraft/client/renderer/ShaderInstance.java.patch b/patches/minecraft/net/minecraft/client/renderer/ShaderInstance.java.patch deleted file mode 100644 index c15c88d66b..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/ShaderInstance.java.patch +++ /dev/null @@ -1,58 +0,0 @@ ---- a/net/minecraft/client/renderer/ShaderInstance.java -+++ b/net/minecraft/client/renderer/ShaderInstance.java -@@ -94,10 +_,15 @@ - @Nullable - public final Uniform CHUNK_OFFSET; - -+ @Deprecated // Forge: Use the ResourceLocation variant below - public ShaderInstance(ResourceProvider p_173336_, String p_173337_, VertexFormat p_173338_) throws IOException { -- this.name = p_173337_; -+ this(p_173336_, ResourceLocation.parse(p_173337_), p_173338_); -+ } -+ -+ public ShaderInstance(ResourceProvider p_173336_, ResourceLocation shaderLocation, VertexFormat p_173338_) throws IOException { -+ this.name = shaderLocation.getNamespace().equals("minecraft") ? shaderLocation.getPath() : shaderLocation.toString(); - this.vertexFormat = p_173338_; -- ResourceLocation resourcelocation = ResourceLocation.withDefaultNamespace("shaders/core/" + p_173337_ + ".json"); -+ ResourceLocation resourcelocation = shaderLocation.withPath(p -> "shaders/core/" + p + ".json"); - - try (Reader reader = p_173336_.openAsReader(resourcelocation)) { - JsonObject jsonobject = GsonHelper.parse(reader); -@@ -177,8 +_,9 @@ - Program program1 = p_173342_.getPrograms().get(p_173343_); - Program program; - if (program1 == null) { -- String s = "shaders/core/" + p_173343_ + p_173342_.getExtension(); -- Resource resource = p_173341_.getResourceOrThrow(ResourceLocation.withDefaultNamespace(s)); -+ ResourceLocation resourcelocation = ResourceLocation.parse(p_173343_).withPath(p -> "shaders/core/" + p + p_173342_.getExtension()); -+ String s = resourcelocation.getPath(); -+ Resource resource = p_173341_.getResourceOrThrow(resourcelocation); - - try (InputStream inputstream = resource.open()) { - final String s1 = FileUtil.getFullResourcePath(s); -@@ -187,12 +_,11 @@ - - @Override - public String applyImport(boolean p_173374_, String p_173375_) { -- p_173375_ = FileUtil.normalizeResourcePath((p_173374_ ? s1 : "shaders/include/") + p_173375_); -- if (!this.importedPaths.add(p_173375_)) { -+ // Forge: use the mod's namespace to look up resources if specified -+ ResourceLocation resourcelocation = net.minecraftforge.client.ForgeHooksClient.getShaderImportLocation(s1, p_173374_, p_173375_); -+ if (!this.importedPaths.add(resourcelocation.toString())) { - return null; - } else { -- ResourceLocation resourcelocation = ResourceLocation.parse(p_173375_); -- - try { - String s2; - try (Reader reader = p_173341_.openAsReader(resourcelocation)) { -@@ -201,7 +_,8 @@ - - return s2; - } catch (IOException ioexception) { -- ShaderInstance.LOGGER.error("Could not open GLSL import {}: {}", p_173375_, ioexception.getMessage()); -+ // Forge: specify the namespace of the failed import in case of duplicates from multiple mods -+ ShaderInstance.LOGGER.error("Could not open GLSL import {}: {}", resourcelocation, ioexception.getMessage()); - return "#error " + ioexception.getMessage(); - } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch b/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch index e767b190f4..9ee0f90ac4 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 -@@ -145,11 +_,11 @@ +@@ -140,11 +_,11 @@ } private static Material createSignMaterial(WoodType p_173386_) { @@ -14,7 +14,7 @@ } public static Material getSignMaterial(WoodType p_173382_) { -@@ -208,6 +_,23 @@ +@@ -203,6 +_,23 @@ case SINGLE: default: return p_110773_; diff --git a/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch index 71096356a3..3c52740cf9 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch @@ -76,8 +76,8 @@ this.modelRenderer .renderModel( p_110914_.last(), -- p_110915_.getBuffer(ItemBlockRenderTypes.getRenderType(p_110913_, false)), -+ p_110915_.getBuffer(renderType != null ? renderType : net.minecraftforge.client.RenderTypeHelper.getEntityRenderType(rt, false)), +- p_110915_.getBuffer(ItemBlockRenderTypes.getRenderType(p_110913_)), ++ p_110915_.getBuffer(renderType != null ? renderType : net.minecraftforge.client.RenderTypeHelper.getEntityRenderType(rt)), p_110913_, bakedmodel, f, 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 cff9983696..e3d8dd1dfa 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch @@ -13,7 +13,7 @@ float f = (float)(i >> 16 & 0xFF) / 255.0F; float f1 = (float)(i >> 8 & 0xFF) / 255.0F; float f2 = (float)(i & 0xFF) / 255.0F; -@@ -181,15 +_,15 @@ +@@ -180,15 +_,15 @@ float f57 = f4 * f; float f29 = f4 * f1; float f30 = f4 * f2; @@ -37,7 +37,7 @@ } } -@@ -202,10 +_,10 @@ +@@ -201,10 +_,10 @@ float f46 = f3 * f; float f48 = f3 * f1; float f50 = f3 * f2; @@ -52,8 +52,8 @@ } int j = this.getLightColor(p_234370_, p_234371_); -@@ -259,10 +_,9 @@ - if (flag7 && !isFaceOccludedByNeighbor(p_234370_, p_234371_, direction, Math.max(f44, f45), p_234370_.getBlockState(p_234371_.relative(direction)))) { +@@ -258,10 +_,9 @@ + if (flag7 && !isFaceOccludedByNeighbor(direction, Math.max(f44, f45), p_234370_.getBlockState(p_234371_.relative(direction)))) { BlockPos blockpos = p_234371_.relative(direction); TextureAtlasSprite textureatlassprite2 = atextureatlassprite[1]; - if (!flag) { @@ -66,7 +66,7 @@ } } -@@ -275,15 +_,15 @@ +@@ -274,15 +_,15 @@ float f33 = f4 * f32 * f; float f34 = f4 * f32 * f1; float f35 = f4 * f32 * f2; @@ -90,7 +90,7 @@ } } } -@@ -345,10 +_,11 @@ +@@ -344,10 +_,11 @@ float p_343128_, float p_344448_, float p_344284_, diff --git a/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch index 0afac40f4b..5a7df23666 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/block/ModelBlockRenderer.java +++ b/net/minecraft/client/renderer/block/ModelBlockRenderer.java -@@ -40,6 +_,11 @@ +@@ -39,6 +_,11 @@ this.blockColors = p_110999_; } @@ -12,7 +12,7 @@ public void tesselateBlock( BlockAndTintGetter p_234380_, BakedModel p_234381_, -@@ -50,17 +_,19 @@ +@@ -49,16 +_,18 @@ boolean p_234386_, RandomSource p_234387_, long p_234388_, @@ -23,8 +23,7 @@ ) { - boolean flag = Minecraft.useAmbientOcclusion() && p_234382_.getLightEmission() == 0 && p_234381_.useAmbientOcclusion(); + boolean flag = Minecraft.useAmbientOcclusion() && p_234382_.getLightEmission(p_234380_, p_234383_) == 0 && p_234381_.useAmbientOcclusion(p_234382_, renderType); - Vec3 vec3 = p_234382_.getOffset(p_234380_, p_234383_); - p_234384_.translate(vec3.x, vec3.y, vec3.z); + p_234384_.translate(p_234382_.getOffset(p_234383_)); try { if (flag) { @@ -36,7 +35,7 @@ } } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Tesselating block model"); -@@ -71,6 +_,11 @@ +@@ -69,6 +_,11 @@ } } @@ -48,7 +47,7 @@ public void tesselateWithAO( BlockAndTintGetter p_234391_, BakedModel p_234392_, -@@ -81,7 +_,9 @@ +@@ -79,7 +_,9 @@ boolean p_234397_, RandomSource p_234398_, long p_234399_, @@ -59,7 +58,7 @@ ) { float[] afloat = new float[DIRECTIONS.length * 2]; BitSet bitset = new BitSet(3); -@@ -90,7 +_,7 @@ +@@ -88,7 +_,7 @@ for (Direction direction : DIRECTIONS) { p_234398_.setSeed(p_234399_); @@ -67,8 +66,8 @@ + List list = p_234392_.getQuads(p_234393_, direction, p_234398_, modelData, renderType); if (!list.isEmpty()) { blockpos$mutableblockpos.setWithOffset(p_234394_, direction); - if (!p_234397_ || Block.shouldRenderFace(p_234393_, p_234391_, p_234394_, direction, blockpos$mutableblockpos)) { -@@ -102,12 +_,17 @@ + if (!p_234397_ || Block.shouldRenderFace(p_234393_, p_234391_.getBlockState(blockpos$mutableblockpos), direction)) { +@@ -100,12 +_,17 @@ } p_234398_.setSeed(p_234399_); @@ -87,7 +86,7 @@ public void tesselateWithoutAO( BlockAndTintGetter p_234402_, BakedModel p_234403_, -@@ -118,14 +_,16 @@ +@@ -116,14 +_,16 @@ boolean p_234408_, RandomSource p_234409_, long p_234410_, @@ -105,8 +104,8 @@ + List list = p_234403_.getQuads(p_234404_, direction, p_234409_, modelData, renderType); if (!list.isEmpty()) { blockpos$mutableblockpos.setWithOffset(p_234405_, direction); - if (!p_234408_ || Block.shouldRenderFace(p_234404_, p_234402_, p_234405_, direction, blockpos$mutableblockpos)) { -@@ -136,7 +_,7 @@ + if (!p_234408_ || Block.shouldRenderFace(p_234404_, p_234402_.getBlockState(blockpos$mutableblockpos), direction)) { +@@ -134,7 +_,7 @@ } p_234409_.setSeed(p_234410_); @@ -115,7 +114,7 @@ if (!list1.isEmpty()) { this.renderModelFaceFlat(p_234402_, p_234404_, p_234405_, -1, p_234411_, true, p_234406_, p_234407_, list1, bitset); } -@@ -156,6 +_,7 @@ +@@ -154,6 +_,7 @@ ) { for (BakedQuad bakedquad : p_111018_) { this.calculateShape(p_111013_, p_111014_, p_111015_, bakedquad.getVertices(), bakedquad.getDirection(), p_111019_, p_111020_); @@ -123,7 +122,7 @@ p_111021_.calculate(p_111013_, p_111014_, p_111015_, bakedquad.getDirection(), p_111019_, p_111020_, bakedquad.isShade()); this.putQuadData( p_111013_, -@@ -321,6 +_,11 @@ +@@ -319,6 +_,11 @@ } } @@ -135,7 +134,7 @@ public void renderModel( PoseStack.Pose p_111068_, VertexConsumer p_111069_, -@@ -330,18 +_,20 @@ +@@ -328,18 +_,20 @@ float p_111073_, float p_111074_, int p_111075_, diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch index c44486e544..16df7669c3 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch @@ -1,29 +1,30 @@ --- a/net/minecraft/client/renderer/block/model/BakedQuad.java +++ b/net/minecraft/client/renderer/block/model/BakedQuad.java -@@ -12,13 +_,19 @@ - protected final Direction direction; +@@ -13,14 +_,20 @@ protected final TextureAtlasSprite sprite; private final boolean shade; + private final int lightEmission; + private final boolean hasAmbientOcclusion; - public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_) { -+ this(p_111298_, p_111299_, p_111300_, p_111301_, p_111302_, true); + public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_, int p_366759_) { ++ this(p_111298_, p_111299_, p_111300_, p_111301_, p_111302_, p_366759_, true); + } + -+ public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_, boolean hasAmbientOcclusion) { ++ public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_, int p_366759_, boolean hasAmbientOcclusion) { this.vertices = p_111298_; this.tintIndex = p_111299_; this.direction = p_111300_; this.sprite = p_111301_; this.shade = p_111302_; + this.lightEmission = p_366759_; + this.hasAmbientOcclusion = hasAmbientOcclusion; } public TextureAtlasSprite getSprite() { -@@ -43,5 +_,9 @@ +@@ -49,5 +_,9 @@ - public boolean isShade() { - return this.shade; + public int getLightEmission() { + return this.lightEmission; + } + + public boolean hasAmbientOcclusion() { 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 f44badeac4..4ee9a2633e 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/block/model/BlockModel.java +++ b/net/minecraft/client/renderer/block/model/BlockModel.java -@@ -77,9 +_,10 @@ +@@ -72,9 +_,10 @@ public BlockModel parent; @Nullable protected ResourceLocation parentLocation; @@ -11,8 +11,8 @@ + return GsonHelper.fromJson(net.minecraftforge.client.model.ExtendedBlockModelDeserializer.INSTANCE, p_111462_, BlockModel.class); } - public static BlockModel fromString(String p_111464_) { -@@ -104,10 +_,17 @@ + public BlockModel( +@@ -95,10 +_,17 @@ this.overrides = p_273099_; } @@ -30,52 +30,18 @@ public boolean hasAmbientOcclusion() { if (this.hasAmbientOcclusion != null) { return this.hasAmbientOcclusion; -@@ -136,6 +_,10 @@ - return this.overrides.isEmpty() ? ItemOverrides.EMPTY : new ItemOverrides(p_250138_, p_251800_, this.overrides); - } +@@ -130,6 +_,10 @@ + throw new IllegalStateException("BlockModel parent has to be a block model."); + } -+ public ItemOverrides getOverrides(ModelBaker p_250138_, BlockModel p_251800_, Function spriteGetter) { -+ return this.overrides.isEmpty() ? ItemOverrides.EMPTY : new ItemOverrides(p_250138_, p_251800_, this.overrides, spriteGetter); -+ } ++ if (customData.hasCustomGeometry()) { ++ customData.getCustomGeometry().resolveDependencies(p_365651_, customData); ++ } + - @Override - public Collection getDependencies() { - Set set = Sets.newHashSet(); -@@ -184,6 +_,10 @@ - blockmodel.parent = (BlockModel)unbakedmodel; + this.parent = blockmodel; } - -+ if (customData.hasCustomGeometry()) { -+ customData.getCustomGeometry().resolveParents(p_249059_, customData); -+ } -+ - this.overrides.forEach(p_247932_ -> { - UnbakedModel unbakedmodel1 = p_249059_.apply(p_247932_.getModel()); - if (!Objects.equals(unbakedmodel1, this)) { -@@ -192,13 +_,21 @@ - }); } - -+ /** -+ * @deprecated Forge: Use {@link #bake(ModelBaker, BlockModel, Function, ModelState, ResourceLocation, boolean)}. -+ */ -+ @Deprecated - @Override - public BakedModel bake(ModelBaker p_252120_, Function p_250023_, ModelState p_251130_) { - return this.bake(p_252120_, this, p_250023_, p_251130_, true); - } - -+ public BakedModel bake(ModelBaker p_249720_, BlockModel p_111451_, Function p_111452_, ModelState p_111453_, boolean p_111455_) { -+ return net.minecraftforge.client.model.geometry.UnbakedGeometryHelper.bake(this, p_249720_, p_111451_, p_111452_, p_111453_, p_111455_); -+ } -+ - public BakedModel bake( -- ModelBaker p_249720_, BlockModel p_111451_, Function p_111452_, ModelState p_111453_, boolean p_111455_ -+ ModelBaker p_249720_, BlockModel p_111451_, Function p_111452_, ModelState p_111453_, boolean p_111455_, net.minecraftforge.client.RenderTypeGroup renderTypes - ) { - TextureAtlasSprite textureatlassprite = p_111452_.apply(this.getMaterial("particle")); - if (this.getRootModel() == ModelBakery.BLOCK_ENTITY_MARKER) { -@@ -290,7 +_,18 @@ +@@ -229,7 +_,18 @@ ItemTransform itemtransform5 = this.getTransform(ItemDisplayContext.GUI); ItemTransform itemtransform6 = this.getTransform(ItemDisplayContext.GROUND); ItemTransform itemtransform7 = this.getTransform(ItemDisplayContext.FIXED); @@ -95,7 +61,7 @@ } private ItemTransform getTransform(ItemDisplayContext p_270662_) { -@@ -408,6 +_,10 @@ +@@ -347,6 +_,10 @@ public boolean lightLikeBlock() { return this == SIDE; @@ -105,4 +71,4 @@ + return name; } } - + } 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 bc4b472a5d..13b29d7ad4 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,13 +1,13 @@ --- a/net/minecraft/client/renderer/block/model/FaceBakery.java +++ b/net/minecraft/client/renderer/block/model/FaceBakery.java -@@ -57,7 +_,14 @@ +@@ -58,7 +_,14 @@ this.recalculateWinding(aint, direction); } -- return new BakedQuad(aint, p_111603_.tintIndex(), direction, p_111604_, p_111608_); +- return new BakedQuad(aint, p_111603_.tintIndex(), direction, p_111604_, p_111608_, p_364904_); + var data = p_111603_.data(); -+ net.minecraftforge.client.ForgeHooksClient.fillNormal(aint, direction, data.calculateNormals()); -+ var quad = new BakedQuad(aint, p_111603_.tintIndex(), direction, p_111604_, p_111608_, data.ambientOcclusion()); ++ //net.minecraftforge.client.ForgeHooksClient.fillNormal(aint, direction, data.calculateNormals()); ++ var quad = new BakedQuad(aint, p_111603_.tintIndex(), direction, p_111604_, p_111608_, p_364904_, data.ambientOcclusion()); + if (!net.minecraftforge.client.model.ForgeFaceData.DEFAULT.equals(data)) { + net.minecraftforge.client.model.QuadTransformers.applyingLightmap(data.blockLight(), data.skyLight()).processInPlace(quad); + net.minecraftforge.client.model.QuadTransformers.applyingColor(data.color()).processInPlace(quad); 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 deleted file mode 100644 index ec4087f3f0..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch +++ /dev/null @@ -1,50 +0,0 @@ ---- a/net/minecraft/client/renderer/block/model/ItemOverrides.java -+++ b/net/minecraft/client/renderer/block/model/ItemOverrides.java -@@ -31,7 +_,15 @@ - this.properties = new ResourceLocation[0]; - } - -+ /** -+ * @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(ModelBaker p_251211_, UnbakedModel p_111741_, List p_111743_, java.util.function.Function spriteGetter) { - this.properties = p_111743_.stream().flatMap(ItemOverride::getPredicates).map(ItemOverride.Predicate::getProperty).distinct().toArray(ResourceLocation[]::new); - Object2IntMap object2intmap = new Object2IntOpenHashMap<>(); - -@@ -43,7 +_,7 @@ - - for (int j = p_111743_.size() - 1; j >= 0; j--) { - ItemOverride itemoverride = p_111743_.get(j); -- BakedModel bakedmodel = this.bakeModel(p_251211_, p_111741_, itemoverride); -+ BakedModel bakedmodel = this.bakeModel(p_251211_, p_111741_, itemoverride, spriteGetter); - ItemOverrides.PropertyMatcher[] aitemoverrides$propertymatcher = itemoverride.getPredicates().map(p_173477_ -> { - int k = object2intmap.getInt(p_173477_.getProperty()); - return new ItemOverrides.PropertyMatcher(k, p_173477_.getValue()); -@@ -55,9 +_,9 @@ - } - - @Nullable -- private BakedModel bakeModel(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_.getModel(p_250816_.getModel()); -- return Objects.equals(unbakedmodel, p_251965_) ? null : p_249483_.bake(p_250816_.getModel(), BlockModelRotation.X0_Y0); -+ return Objects.equals(unbakedmodel, p_251965_) ? null : p_249483_.bake(p_250816_.getModel(), BlockModelRotation.X0_Y0, spriteGetter); - } - - @Nullable -@@ -89,6 +_,10 @@ - } - - return p_173465_; -+ } -+ -+ public com.google.common.collect.ImmutableList getOverrides() { -+ return com.google.common.collect.ImmutableList.copyOf(overrides); - } - - @OnlyIn(Dist.CLIENT) 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 438e617781..d34edb7658 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 -@@ -68,7 +_,7 @@ - WeightedBakedModel.Builder weightedbakedmodel$builder = new WeightedBakedModel.Builder(); +@@ -50,7 +_,7 @@ + SimpleWeightedRandomList.Builder builder = SimpleWeightedRandomList.builder(); - for (Variant variant : this.getVariants()) { + for (Variant variant : this.variants) { - BakedModel bakedmodel = p_249016_.bake(variant.getModelLocation(), variant); + BakedModel bakedmodel = p_249016_.bake(variant.getModelLocation(), variant, p_111851_); - weightedbakedmodel$builder.add(bakedmodel, variant.getWeight()); + builder.add(bakedmodel, variant.getWeight()); } 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 9b77c7a5a8..b1e9face0a 100644 --- a/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/blockentity/ChestRenderer.java +++ b/net/minecraft/client/renderer/blockentity/ChestRenderer.java -@@ -128,7 +_,7 @@ +@@ -66,7 +_,7 @@ f1 = 1.0F - f1; f1 = 1.0F - f1 * f1 * f1; int i = neighborcombineresult.apply(new BrightnessCombiner<>()).applyAsInt(p_112367_); @@ -9,10 +9,10 @@ VertexConsumer vertexconsumer = material.buffer(p_112366_, RenderType::entityCutout); if (flag1) { if (chesttype == ChestType.LEFT) { -@@ -159,5 +_,9 @@ - p_112372_.render(p_112370_, p_112371_, p_112376_, p_112377_); - p_112373_.render(p_112370_, p_112371_, p_112376_, p_112377_); - p_112374_.render(p_112370_, p_112371_, p_112376_, p_112377_); +@@ -85,5 +_,9 @@ + private void render(PoseStack p_112370_, VertexConsumer p_112371_, ChestModel p_363333_, float p_112375_, int p_112376_, int p_112377_) { + p_363333_.setupAnim(p_112375_); + p_363333_.renderToBuffer(p_112370_, p_112371_, p_112376_, p_112377_); + } + + protected Material getMaterial(T blockEntity, ChestType chestType) { diff --git a/patches/minecraft/net/minecraft/client/renderer/culling/Frustum.java.patch b/patches/minecraft/net/minecraft/client/renderer/culling/Frustum.java.patch index ea5f2a5dec..6ef8b31af8 100644 --- a/patches/minecraft/net/minecraft/client/renderer/culling/Frustum.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/culling/Frustum.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/renderer/culling/Frustum.java +++ b/net/minecraft/client/renderer/culling/Frustum.java -@@ -70,6 +_,8 @@ +@@ -71,6 +_,8 @@ } public boolean isVisible(AABB p_113030_) { + // Forge: exit early for infinite bounds, these would otherwise fail in the intersection test at certain camera angles (GH-9321) + if (p_113030_.equals(net.minecraftforge.common.extensions.IForgeBlockEntity.INFINITE_EXTENT_AABB)) return true; - return this.cubeInFrustum(p_113030_.minX, p_113030_.minY, p_113030_.minZ, p_113030_.maxX, p_113030_.maxY, p_113030_.maxZ); + int i = this.cubeInFrustum(p_113030_.minX, p_113030_.minY, p_113030_.minZ, p_113030_.maxX, p_113030_.maxY, p_113030_.maxZ); + return i == -2 || i == -1; } - diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/BoatRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/BoatRenderer.java.patch deleted file mode 100644 index 5e7b9506b6..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/entity/BoatRenderer.java.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/net/minecraft/client/renderer/entity/BoatRenderer.java -+++ b/net/minecraft/client/renderer/entity/BoatRenderer.java -@@ -76,7 +_,7 @@ - p_113932_.mulPose(new Quaternionf().setAngleAxis(p_113929_.getBubbleAngle(p_113931_) * (float) (Math.PI / 180.0), 1.0F, 0.0F, 1.0F)); - } - -- Pair> pair = this.boatResources.get(p_113929_.getVariant()); -+ Pair> pair = getModelWithLocation(p_113929_); - ResourceLocation resourcelocation = pair.getFirst(); - ListModel listmodel = pair.getSecond(); - p_113932_.scale(-1.0F, -1.0F, 1.0F); -@@ -95,7 +_,12 @@ - super.render(p_113929_, p_113930_, p_113931_, p_113932_, p_113933_, p_113934_); - } - -+ @Deprecated // forge: override getModelWithLocation to change the texture / model - public ResourceLocation getTextureLocation(Boat p_113927_) { - return this.boatResources.get(p_113927_.getVariant()).getFirst(); -+ } -+ -+ public Pair> getModelWithLocation(Boat boat) { -+ return this.boatResources.get(boat.getVariant()); - } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch index 72b29df98d..2f716bb1a2 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java +++ b/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java -@@ -222,12 +_,12 @@ +@@ -243,12 +_,12 @@ ) { AABB aabb = p_114444_.getBoundingBox().move(-p_114444_.getX(), -p_114444_.getY(), -p_114444_.getZ()); - LevelRenderer.renderLineBox(p_114442_, p_114443_, aabb, p_343193_, p_342304_, p_342638_, 1.0F); + ShapeRenderer.renderLineBox(p_114442_, p_114443_, aabb, p_343193_, p_342304_, p_342638_, 1.0F); - if (p_114444_ instanceof EnderDragon) { + if (p_114444_.isMultipartEntity()) { double d0 = -Mth.lerp((double)p_114445_, p_114444_.xOld, p_114444_.getX()); @@ -15,18 +15,18 @@ p_114442_.pushPose(); double d3 = d0 + Mth.lerp((double)p_114445_, enderdragonpart.xOld, enderdragonpart.getX()); double d4 = d1 + Mth.lerp((double)p_114445_, enderdragonpart.yOld, enderdragonpart.getY()); -@@ -467,6 +_,10 @@ +@@ -481,6 +_,10 @@ return this.itemInHandRenderer; } -+ public Map> getSkinMap() { ++ public Map> getSkinMap() { + return java.util.Collections.unmodifiableMap(playerRenderers); + } + @Override public void onResourceManagerReload(ResourceManager p_174004_) { EntityRendererProvider.Context entityrendererprovider$context = new EntityRendererProvider.Context( -@@ -474,5 +_,6 @@ +@@ -488,5 +_,6 @@ ); this.renderers = EntityRenderers.createEntityRenderers(entityrendererprovider$context); this.playerRenderers = EntityRenderers.createPlayerRenderers(entityrendererprovider$context); diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch index b5632d614f..ea9bdb5fc5 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/client/renderer/entity/EntityRenderer.java +++ b/net/minecraft/client/renderer/entity/EntityRenderer.java -@@ -94,8 +_,9 @@ - } +@@ -104,8 +_,9 @@ + renderLeash(p_114488_, p_114489_, entityrenderstate$leashstate); } -- if (this.shouldShowName(p_114485_)) { -- this.renderNameTag(p_114485_, p_114485_.getDisplayName(), p_114488_, p_114489_, p_114490_, p_114487_); -+ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.fireRenderNameTagEvent(p_114485_, p_114485_.getDisplayName(), this, p_114488_, p_114489_, p_114490_, p_114487_); -+ if (!event.getResult().isDenied() && (event.getResult().isAllowed() || this.shouldShowName(p_114485_))) { -+ this.renderNameTag(p_114485_, event.getContent(), p_114488_, p_114489_, p_114490_, p_114487_); +- if (p_370221_.nameTag != null) { +- this.renderNameTag(p_370221_, p_370221_.nameTag, p_114488_, p_114489_, p_114490_); ++ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.fireRenderNameTagEvent(p_370221_, p_370221_.nameTag, this, p_114488_, p_114489_, p_114490_); ++ if (!event.getResult().isDenied() && (event.getResult().isAllowed() || p_370221_.nameTag != null)) { ++ this.renderNameTag(p_370221_, event.getContent(), p_114488_, p_114489_, p_114490_); } } -@@ -181,7 +_,7 @@ +@@ -268,7 +_,7 @@ + } - protected void renderNameTag(T p_114498_, Component p_114499_, PoseStack p_114500_, MultiBufferSource p_114501_, int p_114502_, float p_334448_) { - double d0 = this.entityRenderDispatcher.distanceToSqr(p_114498_); -- if (!(d0 > 4096.0)) { -+ if (net.minecraftforge.client.ForgeHooksClient.isNameplateInRenderDistance(p_114498_, d0)) { - Vec3 vec3 = p_114498_.getAttachments().getNullable(EntityAttachment.NAME_TAG, 0, p_114498_.getViewYRot(p_334448_)); - if (vec3 != null) { - boolean flag = !p_114498_.isDiscrete(); + p_367427_.distanceToCameraSq = this.entityRenderDispatcher.distanceToSqr(p_367571_); +- boolean flag = p_367427_.distanceToCameraSq < 4096.0 && this.shouldShowName(p_367571_, p_367427_.distanceToCameraSq); ++ boolean flag = net.minecraftforge.client.ForgeHooksClient.isNameplateInRenderDistance(p_367571_, p_367427_.distanceToCameraSq) && this.shouldShowName(p_367571_, p_367427_.distanceToCameraSq); + if (flag) { + p_367427_.nameTag = this.getNameTag(p_367571_); + p_367427_.nameTagAttachment = p_367571_.getAttachments().getNullable(EntityAttachment.NAME_TAG, 0, p_367571_.getYRot(p_363243_)); diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch deleted file mode 100644 index 943a237a06..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- a/net/minecraft/client/renderer/entity/FallingBlockRenderer.java -+++ b/net/minecraft/client/renderer/entity/FallingBlockRenderer.java -@@ -34,20 +_,26 @@ - p_114637_.pushPose(); - BlockPos blockpos = BlockPos.containing(p_114634_.getX(), p_114634_.getBoundingBox().maxY, p_114634_.getZ()); - p_114637_.translate(-0.5, 0.0, -0.5); -+ var model = this.dispatcher.getBlockModel(blockstate); -+ for (var renderType : model.getRenderTypes(blockstate, RandomSource.create(blockstate.getSeed(p_114634_.getStartPos())), net.minecraftforge.client.model.data.ModelData.EMPTY)) { -+ renderType = net.minecraftforge.client.RenderTypeHelper.getMovingBlockRenderType(renderType); - this.dispatcher - .getModelRenderer() - .tesselateBlock( - level, -- this.dispatcher.getBlockModel(blockstate), -+ model, - blockstate, - blockpos, - p_114637_, -- p_114638_.getBuffer(ItemBlockRenderTypes.getMovingBlockRenderType(blockstate)), -+ p_114638_.getBuffer(renderType), - false, - RandomSource.create(), - blockstate.getSeed(p_114634_.getStartPos()), -- OverlayTexture.NO_OVERLAY -+ OverlayTexture.NO_OVERLAY, -+ net.minecraftforge.client.model.data.ModelData.EMPTY, -+ renderType - ); -+ } - p_114637_.popPose(); - super.render(p_114634_, p_114635_, p_114636_, p_114637_, p_114638_, p_114639_); - } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/FishingHookRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/FishingHookRenderer.java.patch index d72638d9e6..2f4a714384 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/FishingHookRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/FishingHookRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/FishingHookRenderer.java +++ b/net/minecraft/client/renderer/entity/FishingHookRenderer.java -@@ -64,7 +_,7 @@ +@@ -63,7 +_,7 @@ private Vec3 getPlayerHandPos(Player p_328037_, float p_328369_, float p_332926_) { int i = p_328037_.getMainArm() == HumanoidArm.RIGHT ? 1 : -1; ItemStack itemstack = p_328037_.getMainHandItem(); diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java.patch new file mode 100644 index 0000000000..df02d369b4 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java ++++ b/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java +@@ -40,7 +_,7 @@ + p_369040_.isCrouching = p_362179_.isCrouching(); + p_369040_.isFallFlying = p_362179_.isFallFlying(); + p_369040_.isVisuallySwimming = p_362179_.isVisuallySwimming(); +- p_369040_.isPassenger = p_362179_.isPassenger(); ++ p_369040_.isPassenger = p_362179_.isPassenger() && (p_362179_.getVehicle() != null && p_362179_.getVehicle().shouldRiderSit());; + p_369040_.speedValue = 1.0F; + if (p_369040_.isFallFlying) { + p_369040_.speedValue = (float)p_362179_.getDeltaMovement().lengthSqr(); 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 c7a13658e9..58e4236fa3 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch @@ -1,27 +1,18 @@ --- a/net/minecraft/client/renderer/entity/ItemFrameRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemFrameRenderer.java -@@ -91,6 +_,7 @@ +@@ -98,6 +_,7 @@ - int j = mapid != null ? p_115076_.getRotation() % 4 * 2 : p_115076_.getRotation(); - p_115079_.mulPose(Axis.ZP.rotationDegrees((float)j * 360.0F / 8.0F)); -+ if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderItemInFrame(p_115076_, this, p_115079_, p_115080_, p_115081_)) { + int j = mapid != null ? p_361692_.rotation % 4 * 2 : p_361692_.rotation; + p_115061_.mulPose(Axis.ZP.rotationDegrees((float)j * 360.0F / 8.0F)); ++ if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderItemInFrame(p_361692_, this, p_115061_, p_115062_, p_115063_)) { if (mapid != null) { - p_115079_.mulPose(Axis.ZP.rotationDegrees(180.0F)); - float f = 0.0078125F; + p_115061_.mulPose(Axis.ZP.rotationDegrees(180.0F)); + float f2 = 0.0078125F; @@ -110,6 +_,7 @@ - itemstack, ItemDisplayContext.FIXED, k, OverlayTexture.NO_OVERLAY, p_115079_, p_115080_, p_115076_.level(), p_115076_.getId() - ); - } + int k = this.getLightVal(p_361692_.isGlowFrame, 15728880, p_115063_); + p_115061_.scale(0.5F, 0.5F, 0.5F); + this.itemRenderer.render(itemstack, ItemDisplayContext.FIXED, false, p_115061_, p_115062_, k, OverlayTexture.NO_OVERLAY, p_361692_.itemModel); + } + } } - p_115079_.popPose(); -@@ -121,7 +_,7 @@ - - private ModelResourceLocation getFrameModelResourceLoc(T p_174213_, ItemStack p_174214_) { - boolean flag = p_174213_.getType() == EntityType.GLOW_ITEM_FRAME; -- if (p_174214_.is(Items.FILLED_MAP)) { -+ if (p_174214_.getItem() instanceof MapItem) { - return flag ? GLOW_MAP_FRAME_LOCATION : MAP_FRAME_LOCATION; - } else { - return flag ? GLOW_FRAME_LOCATION : FRAME_LOCATION; 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 757253a920..0e583b1cc9 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch @@ -1,63 +1,54 @@ --- a/net/minecraft/client/renderer/entity/ItemRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemRenderer.java -@@ -68,7 +_,7 @@ - public ItemRenderer(Minecraft p_266926_, TextureManager p_266774_, ModelManager p_266850_, ItemColors p_267016_, BlockEntityWithoutLevelRenderer p_267049_) { - this.minecraft = p_266926_; - this.textureManager = p_266774_; -- this.itemModelShaper = new ItemModelShaper(p_266850_); -+ this.itemModelShaper = new net.minecraftforge.client.model.ForgeItemModelShaper(p_266850_);; - this.blockEntityRenderer = p_267049_; - - for (Item item : BuiltInRegistries.ITEM) { -@@ -118,7 +_,7 @@ - } +@@ -152,7 +_,7 @@ + float p_368655_ + ) { + p_366810_.pushPose(); +- p_369691_.getTransforms().getTransform(p_369628_).apply(p_365876_, p_366810_); ++ p_369691_ = p_369691_.applyTransform(p_369628_, p_366810_, p_365876_); + p_366810_.translate(-0.5F, -0.5F, p_368655_); + this.renderItem(p_368265_, p_369628_, p_366810_, p_363829_, p_363235_, p_368132_, p_369691_, p_366607_); + p_366810_.popPose(); +@@ -169,7 +_,8 @@ + boolean p_366488_ + ) { + if (!p_367824_.isCustomRenderer() && (!p_364096_.is(Items.TRIDENT) || p_366488_)) { +- RenderType rendertype = ItemBlockRenderTypes.getRenderType(p_364096_); ++ for (var model : p_367824_.getRenderPasses(p_364096_, true)) { ++ for (var rendertype : model.getRenderTypes(p_364096_, true)) { + VertexConsumer vertexconsumer; + if (hasAnimatedTexture(p_364096_) && p_364096_.hasFoil()) { + PoseStack.Pose posestack$pose = p_370127_.last().copy(); +@@ -185,8 +_,11 @@ } -- p_115151_.getTransforms().getTransform(p_270188_).apply(p_115146_, p_115147_); -+ p_115151_ = p_115151_.applyTransform(p_270188_, p_115147_, p_115146_); - p_115147_.translate(-0.5F, -0.5F, -0.5F); - if (!p_115151_.isCustomRenderer() && (!p_115144_.is(Items.TRIDENT) || flag)) { - boolean flag1; -@@ -129,7 +_,8 @@ - flag1 = true; - } + this.renderModelLists(p_367824_, p_364096_, p_363416_, p_367651_, p_370127_, vertexconsumer); ++ } ++ } + } else { +- this.blockEntityRenderer.renderByItem(p_364096_, p_362035_, p_370127_, p_365365_, p_363416_, p_367651_); ++ var blockEntityRenderer = net.minecraftforge.client.extensions.common.IClientItemExtensions.of(p_364096_).getCustomRenderer(); ++ blockEntityRenderer.renderByItem(p_364096_, p_362035_, p_370127_, p_365365_, p_363416_, p_367651_); + } + } -- RenderType rendertype = ItemBlockRenderTypes.getRenderType(p_115144_, flag1); -+ for (var model : p_115151_.getRenderPasses(p_115144_, flag1)) { -+ for (var rendertype : model.getRenderTypes(p_115144_, flag1)) { - VertexConsumer vertexconsumer; - if (hasAnimatedTexture(p_115144_) && p_115144_.hasFoil()) { - PoseStack.Pose posestack$pose = p_115147_.last().copy(); -@@ -146,9 +_,11 @@ - vertexconsumer = getFoilBuffer(p_115148_, rendertype, true, p_115144_.hasFoil()); - } - -- this.renderModelLists(p_115151_, p_115144_, p_115149_, p_115150_, p_115147_, vertexconsumer); -+ this.renderModelLists(model, p_115144_, p_115149_, p_115150_, p_115147_, vertexconsumer); -+ } -+ } - } else { -- this.blockEntityRenderer.renderByItem(p_115144_, p_270188_, p_115147_, p_115148_, p_115149_, p_115150_); -+ net.minecraftforge.client.extensions.common.IClientItemExtensions.of(p_115144_).getCustomRenderer().renderByItem(p_115144_, p_270188_, p_115147_, p_115148_, p_115149_, p_115150_); - } - - p_115147_.popPose(); -@@ -199,7 +_,7 @@ - float f1 = (float)FastColor.ARGB32.red(i) / 255.0F; - float f2 = (float)FastColor.ARGB32.green(i) / 255.0F; - float f3 = (float)FastColor.ARGB32.blue(i) / 255.0F; +@@ -232,7 +_,7 @@ + float f1 = (float)ARGB.red(i) / 255.0F; + float f2 = (float)ARGB.green(i) / 255.0F; + float f3 = (float)ARGB.blue(i) / 255.0F; - p_115164_.putBulkData(posestack$pose, bakedquad, f1, f2, f3, f, p_115167_, p_115168_); + p_115164_.putBulkData(posestack$pose, bakedquad, f1, f2, f3, f, p_115167_, p_115168_, true); } } -@@ -252,5 +_,9 @@ +@@ -275,6 +_,10 @@ @Override public void onResourceManagerReload(ResourceManager p_115105_) { - this.itemModelShaper.rebuildCache(); + this.itemModelShaper.invalidateCache(); + } + + public BlockEntityWithoutLevelRenderer getBlockEntityRenderer() { + return blockEntityRenderer; } - } + + @Nullable 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 d4ca2fcc5b..66ba5e8c4e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch @@ -1,38 +1,27 @@ --- a/net/minecraft/client/renderer/entity/LivingEntityRenderer.java +++ b/net/minecraft/client/renderer/entity/LivingEntityRenderer.java -@@ -50,14 +_,16 @@ +@@ -69,6 +_,7 @@ } - public void render(T p_115308_, float p_115309_, float p_115310_, PoseStack p_115311_, MultiBufferSource p_115312_, int p_115313_) { -+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderLivingPre(p_115308_, this, p_115310_, p_115311_, p_115312_, p_115313_)) return; + public void render(S p_364280_, PoseStack p_115311_, MultiBufferSource p_115312_, int p_115313_) { ++ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderLivingPre(p_364280_, this, p_115311_, p_115312_, p_115313_)) return; p_115311_.pushPose(); - this.model.attackTime = this.getAttackAnim(p_115308_, p_115310_); -- this.model.riding = p_115308_.isPassenger(); -+ boolean shouldSit = p_115308_.isPassenger() && (p_115308_.getVehicle() != null && p_115308_.getVehicle().shouldRiderSit()); -+ this.model.riding = shouldSit; - this.model.young = p_115308_.isBaby(); - float f = Mth.rotLerp(p_115310_, p_115308_.yBodyRotO, p_115308_.yBodyRot); - float f1 = Mth.rotLerp(p_115310_, p_115308_.yHeadRotO, p_115308_.yHeadRot); - float f2 = f1 - f; -- if (p_115308_.isPassenger() && p_115308_.getVehicle() instanceof LivingEntity livingentity) { -+ if (shouldSit && p_115308_.getVehicle() instanceof LivingEntity livingentity) { - f = Mth.rotLerp(p_115310_, livingentity.yBodyRotO, livingentity.yBodyRot); - f2 = f1 - f; - float f7 = Mth.wrapDegrees(f2); -@@ -101,7 +_,7 @@ - p_115311_.translate(0.0F, -1.501F, 0.0F); - float f4 = 0.0F; - float f5 = 0.0F; -- if (!p_115308_.isPassenger() && p_115308_.isAlive()) { -+ if (!shouldSit && p_115308_.isAlive()) { - f4 = p_115308_.walkAnimation.speed(p_115310_); - f5 = p_115308_.walkAnimation.position(p_115310_); - if (p_115308_.isBaby()) { -@@ -134,6 +_,7 @@ + if (p_364280_.hasPose(Pose.SLEEPING)) { + Direction direction = p_364280_.bedOrientation; +@@ -104,6 +_,7 @@ p_115311_.popPose(); - super.render(p_115308_, p_115309_, p_115310_, p_115311_, p_115312_, p_115313_); -+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderLivingPost(p_115308_, this, p_115310_, p_115311_, p_115312_, p_115313_); + super.render(p_364280_, p_115311_, p_115312_, p_115313_); ++ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderLivingPost(p_364280_, this, p_115311_, p_115312_, p_115313_); } - @Nullable + protected boolean shouldRenderLayers(S p_360804_) { +@@ -284,7 +_,7 @@ + + p_363057_.isFullyFrozen = p_368665_.isFullyFrozen(); + p_363057_.isBaby = p_368665_.isBaby(); +- p_363057_.isInWater = p_368665_.isInWater(); ++ p_363057_.isInWater = p_368665_.isInWater() || p_368665_.isInFluidType((fluidType, height) -> p_368665_.canSwimInFluidType(fluidType)); + p_363057_.isAutoSpinAttack = p_368665_.isAutoSpinAttack(); + p_363057_.hasRedOverlay = p_368665_.hurtTime > 0 || p_368665_.deathTime > 0; + ItemStack itemstack1 = p_368665_.getItemBySlot(EquipmentSlot.HEAD); diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/layers/ElytraLayer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/layers/ElytraLayer.java.patch deleted file mode 100644 index d83385a390..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/entity/layers/ElytraLayer.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/net/minecraft/client/renderer/entity/layers/ElytraLayer.java -+++ b/net/minecraft/client/renderer/entity/layers/ElytraLayer.java -@@ -23,7 +_,7 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - - @OnlyIn(Dist.CLIENT) --public class ElytraLayer> extends RenderLayer { -+public class ElytraLayer> extends RenderLayer implements net.minecraftforge.client.extensions.IForgeElytraLayer { - public static final ResourceLocation WINGS_LOCATION = ResourceLocation.withDefaultNamespace("textures/entity/elytra.png"); - private final ElytraModel elytraModel; - -@@ -45,7 +_,7 @@ - float p_116960_ - ) { - ItemStack itemstack = p_116954_.getItemBySlot(EquipmentSlot.CHEST); -- if (itemstack.is(Items.ELYTRA)) { -+ if (shouldRender(itemstack, p_116954_)) { - ResourceLocation resourcelocation; - if (p_116954_ instanceof AbstractClientPlayer abstractclientplayer) { - PlayerSkin playerskin = abstractclientplayer.getSkin(); -@@ -54,10 +_,10 @@ - } else if (playerskin.capeTexture() != null && abstractclientplayer.isModelPartShown(PlayerModelPart.CAPE)) { - resourcelocation = playerskin.capeTexture(); - } else { -- resourcelocation = WINGS_LOCATION; -+ resourcelocation = getElytraTexture(itemstack, p_116954_); - } - } else { -- resourcelocation = WINGS_LOCATION; -+ resourcelocation = getElytraTexture(itemstack, p_116954_); - } - - p_116951_.pushPose(); diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch index 8185980959..b9ccf1179a 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch @@ -1,67 +1,36 @@ --- a/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java +++ b/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java -@@ -66,22 +_,24 @@ - if (armoritem.getEquipmentSlot() == p_117122_) { - this.getParentModel().copyPropertiesTo(p_117124_); - this.setPartVisibility(p_117124_, p_117122_); -+ net.minecraft.client.model.Model model = getArmorModelHook(p_117121_, itemstack, p_117122_, p_117124_); - boolean flag = this.usesInnerModel(p_117122_); - ArmorMaterial armormaterial = armoritem.getMaterial().value(); - int i = itemstack.is(ItemTags.DYEABLE) ? FastColor.ARGB32.opaque(DyedItemColor.getOrDefault(itemstack, -6265536)) : -1; +@@ -45,22 +_,23 @@ + } - for (ArmorMaterial.Layer armormaterial$layer : armormaterial.layers()) { - int j = armormaterial$layer.dyeable() ? i : -1; -- this.renderModel(p_117119_, p_117120_, p_117123_, p_117124_, j, armormaterial$layer.texture(flag)); -+ var texture = net.minecraftforge.client.ForgeHooksClient.getArmorTexture(p_117121_, itemstack, p_117122_, armormaterial$layer, flag); -+ this.renderModel(p_117119_, p_117120_, p_117123_, model, j, texture); - } + public void render(PoseStack p_117085_, MultiBufferSource p_117086_, int p_117087_, S p_364101_, float p_117089_, float p_117090_) { +- this.renderArmorPiece(p_117085_, p_117086_, p_364101_.chestItem, EquipmentSlot.CHEST, p_117087_, this.getArmorModel(p_364101_, EquipmentSlot.CHEST)); +- this.renderArmorPiece(p_117085_, p_117086_, p_364101_.legsItem, EquipmentSlot.LEGS, p_117087_, this.getArmorModel(p_364101_, EquipmentSlot.LEGS)); +- this.renderArmorPiece(p_117085_, p_117086_, p_364101_.feetItem, EquipmentSlot.FEET, p_117087_, this.getArmorModel(p_364101_, EquipmentSlot.FEET)); +- this.renderArmorPiece(p_117085_, p_117086_, p_364101_.headItem, EquipmentSlot.HEAD, p_117087_, this.getArmorModel(p_364101_, EquipmentSlot.HEAD)); ++ this.renderArmorPiece(p_117085_, p_117086_, p_364101_.chestItem, EquipmentSlot.CHEST, p_117087_, this.getArmorModel(p_364101_, EquipmentSlot.CHEST), p_364101_); ++ this.renderArmorPiece(p_117085_, p_117086_, p_364101_.legsItem, EquipmentSlot.LEGS, p_117087_, this.getArmorModel(p_364101_, EquipmentSlot.LEGS), p_364101_); ++ this.renderArmorPiece(p_117085_, p_117086_, p_364101_.feetItem, EquipmentSlot.FEET, p_117087_, this.getArmorModel(p_364101_, EquipmentSlot.FEET), p_364101_); ++ this.renderArmorPiece(p_117085_, p_117086_, p_364101_.headItem, EquipmentSlot.HEAD, p_117087_, this.getArmorModel(p_364101_, EquipmentSlot.HEAD), p_364101_); + } - ArmorTrim armortrim = itemstack.get(DataComponents.TRIM); - if (armortrim != null) { -- this.renderTrim(armoritem.getMaterial(), p_117119_, p_117120_, p_117123_, armortrim, p_117124_, flag); -+ this.renderTrim(armoritem.getMaterial(), p_117119_, p_117120_, p_117123_, armortrim, model, flag); - } - - if (itemstack.hasFoil()) { -- this.renderGlint(p_117119_, p_117120_, p_117123_, p_117124_); -+ this.renderGlint(p_117119_, p_117120_, p_117123_, model); - } - } +- private void renderArmorPiece(PoseStack p_117119_, MultiBufferSource p_117120_, ItemStack p_366444_, EquipmentSlot p_117122_, int p_117123_, A p_117124_) { ++ private void renderArmorPiece(PoseStack p_117119_, MultiBufferSource p_117120_, ItemStack p_366444_, EquipmentSlot p_117122_, int p_117123_, A p_117124_, S state) { + Equippable equippable = p_366444_.get(DataComponents.EQUIPPABLE); + if (equippable != null && shouldRender(equippable, p_117122_)) { + this.getParentModel().copyPropertiesTo(p_117124_); + this.setPartVisibility(p_117124_, p_117122_); ++ var model = this.getArmorModel(state, p_117122_, p_366444_, p_117124_); + ResourceLocation resourcelocation = equippable.model().orElseThrow(); + EquipmentModel.LayerType equipmentmodel$layertype = this.usesInnerModel(p_117122_) + ? EquipmentModel.LayerType.HUMANOID_LEGGINGS + : EquipmentModel.LayerType.HUMANOID; +- this.equipmentRenderer.renderLayers(equipmentmodel$layertype, resourcelocation, p_117124_, p_366444_, p_117119_, p_117120_, p_117123_); ++ this.equipmentRenderer.renderLayers(equipmentmodel$layertype, resourcelocation, model, p_366444_, p_117119_, p_117120_, p_117123_); } -@@ -111,12 +_,20 @@ } - private void renderModel(PoseStack p_289664_, MultiBufferSource p_289689_, int p_289681_, A p_289658_, int p_342257_, ResourceLocation p_328978_) { -+ renderModel(p_289664_, p_289689_, p_289681_, (net.minecraft.client.model.Model)p_289658_, p_342257_, p_328978_); -+ } -+ -+ private void renderModel(PoseStack p_289664_, MultiBufferSource p_289689_, int p_289681_, net.minecraft.client.model.Model p_289658_, int p_342257_, ResourceLocation p_328978_) { - VertexConsumer vertexconsumer = p_289689_.getBuffer(RenderType.armorCutoutNoCull(p_328978_)); - p_289658_.renderToBuffer(p_289664_, vertexconsumer, p_289681_, OverlayTexture.NO_OVERLAY, p_342257_); - } - -+ private void renderTrim(Holder p_331988_, PoseStack p_289687_, MultiBufferSource p_289643_, int p_289683_, ArmorTrim p_289692_, A p_289663_, boolean p_289651_) { -+ renderTrim(p_331988_, p_289687_, p_289643_, p_289683_, p_289692_, (net.minecraft.client.model.Model)p_289663_, p_289651_); -+ } -+ - private void renderTrim( -- Holder p_331988_, PoseStack p_289687_, MultiBufferSource p_289643_, int p_289683_, ArmorTrim p_289692_, A p_289663_, boolean p_289651_ -+ Holder p_331988_, PoseStack p_289687_, MultiBufferSource p_289643_, int p_289683_, ArmorTrim p_289692_, net.minecraft.client.model.Model p_289663_, boolean p_289651_ - ) { - TextureAtlasSprite textureatlassprite = this.armorTrimAtlas.getSprite(p_289651_ ? p_289692_.innerTexture(p_331988_) : p_289692_.outerTexture(p_331988_)); - VertexConsumer vertexconsumer = textureatlassprite.wrap(p_289643_.getBuffer(Sheets.armorTrimsSheet(p_289692_.pattern().value().decal()))); -@@ -124,6 +_,10 @@ - } - - private void renderGlint(PoseStack p_289673_, MultiBufferSource p_289654_, int p_289649_, A p_289659_) { -+ renderGlint(p_289673_, p_289654_, p_289649_, (net.minecraft.client.model.Model)p_289659_); -+ } -+ -+ private void renderGlint(PoseStack p_289673_, MultiBufferSource p_289654_, int p_289649_, net.minecraft.client.model.Model p_289659_) { - p_289659_.renderToBuffer(p_289673_, p_289654_.getBuffer(RenderType.armorEntityGlint()), p_289649_, OverlayTexture.NO_OVERLAY); - } - -@@ -133,5 +_,12 @@ +@@ -97,5 +_,12 @@ private boolean usesInnerModel(EquipmentSlot p_117129_) { return p_117129_ == EquipmentSlot.LEGS; @@ -70,7 +39,7 @@ + /** + * Hook to allow item-sensitive armor model. for HumanoidArmorLayer. + */ -+ protected net.minecraft.client.model.Model getArmorModelHook(T entity, ItemStack itemStack, EquipmentSlot slot, A model) { -+ return net.minecraftforge.client.ForgeHooksClient.getArmorModel(entity, itemStack, slot, model); ++ protected net.minecraft.client.model.Model getArmorModel(S state, EquipmentSlot slot, ItemStack itemStack, A _default) { ++ return net.minecraftforge.client.ForgeHooksClient.getArmorModel(state, itemStack, slot, _default); } } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/layers/WingsLayer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/layers/WingsLayer.java.patch new file mode 100644 index 0000000000..fbd8e17bcf --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/entity/layers/WingsLayer.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/renderer/entity/layers/WingsLayer.java ++++ b/net/minecraft/client/renderer/entity/layers/WingsLayer.java +@@ -49,7 +_,7 @@ + } + + @Nullable +- private static ResourceLocation getPlayerElytraTexture(HumanoidRenderState p_364125_) { ++ protected ResourceLocation getPlayerElytraTexture(HumanoidRenderState p_364125_) { + if (p_364125_ instanceof PlayerRenderState playerrenderstate) { + PlayerSkin playerskin = playerrenderstate.skin; + if (playerskin.elytraTexture() != null) { 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 65cd8bff5e..1bc538ebf4 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 @@ -1,51 +1,48 @@ --- a/net/minecraft/client/renderer/entity/player/PlayerRenderer.java +++ b/net/minecraft/client/renderer/entity/player/PlayerRenderer.java -@@ -68,7 +_,9 @@ - - public void render(AbstractClientPlayer p_117788_, float p_117789_, float p_117790_, PoseStack p_117791_, MultiBufferSource p_117792_, int p_117793_) { - this.setModelProperties(p_117788_); -+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderPlayerPre(p_117788_, this, p_117790_, p_117791_, p_117792_, p_117793_)) return; - super.render(p_117788_, p_117789_, p_117790_, p_117791_, p_117792_, p_117793_); -+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderPlayerPost(p_117788_, this, p_117790_, p_117791_, p_117792_, p_117793_); - } - - public Vec3 getRenderOffset(AbstractClientPlayer p_117785_, float p_117786_) { -@@ -140,10 +_,15 @@ - if (useanim == UseAnim.BRUSH) { - return HumanoidModel.ArmPose.BRUSH; - } -- } else if (!p_117795_.swinging && itemstack.is(Items.CROSSBOW) && CrossbowItem.isCharged(itemstack)) { -+ } else if (!p_117795_.swinging && itemstack.getItem() instanceof CrossbowItem && CrossbowItem.isCharged(itemstack)) { +@@ -128,6 +_,9 @@ return HumanoidModel.ArmPose.CROSSBOW_HOLD; } -+ var forgeArmPose = net.minecraftforge.client.extensions.common.IClientItemExtensions.of(itemstack).getArmPose(p_117795_, p_117796_, itemstack); -+ if (forgeArmPose != null) { -+ return forgeArmPose; -+ } ++ if (p_362189_.pose != null) ++ return p_362189_.pose; + return HumanoidModel.ArmPose.ITEM; } } -@@ -185,10 +_,12 @@ +@@ -217,7 +_,8 @@ + ItemStack itemstack = p_361341_.getItemInHand(p_364300_); + p_365410_.isEmpty = itemstack.isEmpty(); + p_365410_.useAnimation = !itemstack.isEmpty() ? itemstack.getUseAnimation() : null; +- p_365410_.holdsChargedCrossbow = itemstack.is(Items.CROSSBOW) && CrossbowItem.isCharged(itemstack); ++ p_365410_.holdsChargedCrossbow = itemstack.getItem() instanceof CrossbowItem && CrossbowItem.isCharged(itemstack); ++ p_365410_.pose = net.minecraftforge.client.extensions.common.IClientItemExtensions.of(itemstack).getArmPose(p_361341_, p_364300_, itemstack); } - public void renderRightHand(PoseStack p_117771_, MultiBufferSource p_117772_, int p_117773_, AbstractClientPlayer p_117774_) { -+ if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderArm(p_117771_, p_117772_, p_117773_, p_117774_, HumanoidArm.RIGHT)) - this.renderHand(p_117771_, p_117772_, p_117773_, p_117774_, this.model.rightArm, this.model.rightSleeve); + private static void extractCapeState(AbstractClientPlayer p_366404_, PlayerRenderState p_365208_, float p_366613_) { +@@ -251,10 +_,12 @@ } - public void renderLeftHand(PoseStack p_117814_, MultiBufferSource p_117815_, int p_117816_, AbstractClientPlayer p_117817_) { -+ if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderArm(p_117814_, p_117815_, p_117816_, p_117817_, HumanoidArm.LEFT)) - this.renderHand(p_117814_, p_117815_, p_117816_, p_117817_, this.model.leftArm, this.model.leftSleeve); + public void renderRightHand(PoseStack p_117771_, MultiBufferSource p_117772_, int p_117773_, ResourceLocation p_364347_, boolean p_367689_) { ++ if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderArm(p_117771_, p_117772_, p_117773_, HumanoidArm.RIGHT)) + this.renderHand(p_117771_, p_117772_, p_117773_, p_364347_, this.model.rightArm, p_367689_); } -@@ -230,7 +_,7 @@ - } - } else if (f > 0.0F) { - super.setupRotations(p_117802_, p_117803_, p_117804_, p_117805_, p_117806_, p_335509_); -- float f4 = p_117802_.isInWater() ? -90.0F - f1 : -90.0F; -+ float f4 = p_117802_.isInWater() || p_117802_.isInFluidType((fluidType, height) -> p_117802_.canSwimInFluidType(fluidType)) ? -90.0F - f1 : -90.0F; - float f5 = Mth.lerp(f, 0.0F, f4); - p_117803_.mulPose(Axis.XP.rotationDegrees(f5)); - if (p_117802_.isVisuallySwimming()) { + public void renderLeftHand(PoseStack p_117814_, MultiBufferSource p_117815_, int p_117816_, ResourceLocation p_368419_, boolean p_362915_) { ++ if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderArm(p_117814_, p_117815_, p_117816_, HumanoidArm.LEFT)) + this.renderHand(p_117814_, p_117815_, p_117816_, p_368419_, this.model.leftArm, p_362915_); + } + +@@ -293,5 +_,12 @@ + } else { + super.setupRotations(p_369667_, p_117803_, p_117804_, p_117805_); + } ++ } ++ ++ @Override ++ public void render(PlayerRenderState state, PoseStack pose, MultiBufferSource source, int p_115313_) { ++ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderLivingPre(state, this, pose, source, p_115313_)) return; ++ super.render(state, pose, source, p_115313_); ++ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderLivingPre(state, this, pose, source, p_115313_); + } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/state/PlayerRenderState.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/state/PlayerRenderState.java.patch new file mode 100644 index 0000000000..b6f256947b --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/entity/state/PlayerRenderState.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/renderer/entity/state/PlayerRenderState.java ++++ b/net/minecraft/client/renderer/entity/state/PlayerRenderState.java +@@ -48,6 +_,8 @@ + + @OnlyIn(Dist.CLIENT) + public static class HandState { ++ @Nullable ++ public net.minecraft.client.model.HumanoidModel.ArmPose pose; + public boolean isEmpty = true; + @Nullable + public ItemUseAnimation useAnimation; diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch index bf404ccb0a..2e4f937714 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch @@ -1,13 +1,22 @@ --- a/net/minecraft/client/renderer/texture/AbstractTexture.java +++ b/net/minecraft/client/renderer/texture/AbstractTexture.java -@@ -76,4 +_,18 @@ +@@ -20,6 +_,8 @@ + RenderSystem.assertOnRenderThreadOrInit(); + int i; + int j; ++ this.blur = p_117961_; ++ this.mipmap = p_117962_; + if (p_117961_) { + i = p_117962_ ? 9987 : 9729; + j = 9729; +@@ -76,5 +_,18 @@ + @Override public void close() { - } ++ } + + // FORGE: This seems to have been stripped out, but we need it -+ private boolean lastBlur; -+ private boolean lastMipmap; ++ private boolean blur, mipmap, lastBlur, lastMipmap; + + public void setBlurMipmap(boolean blur, boolean mipmap) { + this.lastBlur = this.blur; @@ -17,5 +26,5 @@ + + public void restoreLastBlurMipmap() { + setFilter(this.lastBlur, this.lastMipmap); -+ } + } } 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 932d60a8a0..74dc5c4615 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/texture/MipmapGenerator.java +++ b/net/minecraft/client/renderer/texture/MipmapGenerator.java -@@ -25,12 +_,16 @@ +@@ -26,12 +_,16 @@ anativeimage[0] = p_251300_[0]; boolean flag = hasTransparentPixel(anativeimage[0]); @@ -18,7 +18,7 @@ int j = nativeimage1.getWidth(); int k = nativeimage1.getHeight(); -@@ -48,6 +_,7 @@ +@@ -49,6 +_,7 @@ ) ); } 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 f9412ff740..7d90e2f6ac 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch @@ -8,7 +8,7 @@ } @Override -@@ -172,5 +_,10 @@ +@@ -168,5 +_,10 @@ public void updateFilter(SpriteLoader.Preparations p_251993_) { this.setFilter(false, p_251993_.mipLevel() > 0); 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 36a57d6f9b..e29adf0202 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch @@ -11,6 +11,6 @@ + y += this.contents.animatedTexture.getFrameY(frameIndex) * this.contents.height; + } + -+ return this.contents.getOriginalImage().getPixelRGBA(x, y); ++ return this.contents.getOriginalImage().getPixel(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 ba0aece560..ffc20a35c0 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 -@@ -77,4 +_,9 @@ +@@ -78,4 +_,9 @@ public FormattedCharSequence getVisualOrder(FormattedText p_118925_) { return FormattedBidiReorder.reorder(p_118925_, this.defaultRightToLeft); } diff --git a/patches/minecraft/net/minecraft/client/resources/model/BakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/BakedModel.java.patch index 66ca18afa9..76d5076125 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/BakedModel.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/BakedModel.java.patch @@ -24,5 +24,5 @@ + @Deprecated + default ItemTransforms getTransforms() { return ItemTransforms.NO_TRANSFORMS; } - ItemOverrides getOverrides(); - } + default BakedOverrides overrides() { + return BakedOverrides.EMPTY; diff --git a/patches/minecraft/net/minecraft/client/resources/model/DelegateBakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/DelegateBakedModel.java.patch new file mode 100644 index 0000000000..f710941d44 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/model/DelegateBakedModel.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/client/resources/model/DelegateBakedModel.java ++++ b/net/minecraft/client/resources/model/DelegateBakedModel.java +@@ -25,8 +_,18 @@ + } + + @Override ++ public List getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand, net.minecraftforge.client.model.data.ModelData extraData, @Nullable net.minecraft.client.renderer.RenderType renderType) { ++ return this.parent.getQuads(state, side, rand, extraData, renderType); ++ } ++ ++ @Override + public boolean useAmbientOcclusion() { + return this.parent.useAmbientOcclusion(); ++ } ++ ++ @Override ++ public boolean useAmbientOcclusion(BlockState state, net.minecraft.client.renderer.RenderType renderType) { ++ return this.parent.useAmbientOcclusion(state, renderType); + } + + @Override diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelBaker.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelBaker.java.patch index 8653853b3a..1c60620d9c 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelBaker.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelBaker.java.patch @@ -1,17 +1,14 @@ --- a/net/minecraft/client/resources/model/ModelBaker.java +++ b/net/minecraft/client/resources/model/ModelBaker.java -@@ -6,9 +_,13 @@ +@@ -5,6 +_,10 @@ import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) -public interface ModelBaker { +public interface ModelBaker extends net.minecraftforge.client.extensions.IForgeModelBaker { - UnbakedModel getModel(ResourceLocation p_252194_); - + /** + * @deprecated Forge: Use {@link #bake(ResourceLocation, ModelState, java.util.function.Function)} instead. + */ + @Deprecated - @Nullable BakedModel bake(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 c2772890aa..9db274c44f 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch @@ -1,17 +1,6 @@ --- a/net/minecraft/client/resources/model/ModelBakery.java +++ b/net/minecraft/client/resources/model/ModelBakery.java -@@ -115,6 +_,10 @@ - p_252014_.popPush("special"); - this.loadSpecialItemModelAndDependencies(ItemRenderer.TRIDENT_IN_HAND_MODEL); - this.loadSpecialItemModelAndDependencies(ItemRenderer.SPYGLASS_IN_HAND_MODEL); -+ Set additionalModels = new HashSet<>(); -+ net.minecraftforge.client.ForgeHooksClient.onRegisterAdditionalModels(additionalModels); -+ for (var rl : additionalModels) -+ this.registerModel(rl, this.getModel(rl.id())); - this.topLevelModels.values().forEach(p_247954_ -> p_247954_.resolveParents(this::getModel)); - p_252014_.pop(); - } -@@ -244,14 +_,24 @@ +@@ -94,25 +_,39 @@ } @Override @@ -37,18 +26,16 @@ ModelBakery.this.bakedCache.put(modelbakery$bakedcachekey, bakedmodel1); return bakedmodel1; } -@@ -259,11 +_,16 @@ + } - @Nullable BakedModel bakeUncached(UnbakedModel p_343761_, ModelState p_342939_) { + return bakeUncached(p_343761_, p_342939_, this.modelTextureGetter); + } + -+ @Nullable + BakedModel bakeUncached(UnbakedModel p_343761_, ModelState p_342939_, Function sprites) { - if (p_343761_ instanceof BlockModel blockmodel && blockmodel.getRootModel() == ModelBakery.GENERATION_MARKER) { -- return ModelBakery.ITEM_MODEL_GENERATOR.generateBlockModel(this.modelTextureGetter, blockmodel).bake(this, blockmodel, this.modelTextureGetter, p_342939_, false); -+ return ModelBakery.ITEM_MODEL_GENERATOR.generateBlockModel(sprites, blockmodel).bake(this, blockmodel, sprites, p_342939_, false); + if (p_343761_ instanceof BlockModel blockmodel && blockmodel.getRootModel() == SpecialModels.GENERATED_MARKER) { +- return ModelBakery.ITEM_MODEL_GENERATOR.generateBlockModel(this.modelTextureGetter, blockmodel).bake(this.modelTextureGetter, p_342939_, false); ++ return ModelBakery.ITEM_MODEL_GENERATOR.generateBlockModel(sprites, blockmodel).bake(sprites, p_342939_, false); } - return p_343761_.bake(this, this.modelTextureGetter, p_342939_); 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 af3c263673..59d82dd6c6 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/resources/model/ModelManager.java +++ b/net/minecraft/client/resources/model/ModelManager.java -@@ -63,13 +_,14 @@ +@@ -71,13 +_,14 @@ TextureAtlas.LOCATION_BLOCKS, ResourceLocation.withDefaultNamespace("blocks") ); @@ -16,15 +16,15 @@ public ModelManager(TextureManager p_119406_, BlockColors p_119407_, int p_119408_) { this.blockColors = p_119407_; -@@ -100,6 +_,7 @@ - Executor p_249221_ +@@ -102,6 +_,7 @@ + public final CompletableFuture reload( + PreparableReloadListener.PreparationBarrier p_249079_, ResourceManager p_251134_, Executor p_250550_, Executor p_249221_ ) { - p_250336_.startTick(); + net.minecraftforge.client.model.geometry.GeometryLoaderManager.init(); - CompletableFuture> completablefuture = loadBlockModels(p_251134_, p_250550_); - CompletableFuture>> completablefuture1 = loadBlockStates(p_251134_, p_250550_); - CompletableFuture completablefuture2 = completablefuture.thenCombineAsync( -@@ -214,6 +_,8 @@ + UnbakedModel unbakedmodel = MissingBlockModel.missingModel(); + BlockStateModelLoader blockstatemodelloader = new BlockStateModelLoader(unbakedmodel); + CompletableFuture> completablefuture = loadBlockModels(p_251134_, p_250550_); +@@ -253,6 +_,8 @@ .collect(Collectors.joining("\n")) ) ); @@ -32,17 +32,17 @@ + net.minecraftforge.client.ForgeHooksClient.onModifyBakingResult(p_248945_.getBakedTopLevelModels(), p_248945_); p_252136_.popPush("dispatch"); Map map = p_248945_.getBakedTopLevelModels(); - BakedModel bakedmodel = map.get(ModelBakery.MISSING_MODEL_VARIANT); -@@ -243,6 +_,8 @@ + BakedModel bakedmodel = map.get(MissingBlockModel.VARIANT); +@@ -284,6 +_,8 @@ this.bakedRegistry = modelbakery.getBakedTopLevelModels(); - this.modelGroups = modelbakery.getModelGroups(); + this.modelGroups = p_248996_.modelGroups; this.missingModel = p_248996_.missingModel; + this.modelBakery = modelbakery; + net.minecraftforge.client.ForgeHooksClient.onModelBake(this, this.bakedRegistry, modelbakery); p_251960_.popPush("cache"); this.blockModelShaper.replaceCache(p_248996_.modelCache); p_251960_.pop(); -@@ -268,6 +_,7 @@ +@@ -308,6 +_,7 @@ } public TextureAtlas getAtlas(ResourceLocation p_119429_) { @@ -50,7 +50,7 @@ return this.atlases.getAtlas(p_119429_); } -@@ -278,6 +_,10 @@ +@@ -318,6 +_,10 @@ public void updateMaxMipLevel(int p_119411_) { this.maxMipmapLevels = p_119411_; diff --git a/patches/minecraft/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch index bcfef0c097..2460df51f7 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch @@ -1,29 +1,7 @@ --- a/net/minecraft/client/resources/model/MultiPartBakedModel.java +++ b/net/minecraft/client/resources/model/MultiPartBakedModel.java -@@ -20,7 +_,7 @@ - import org.apache.commons.lang3.tuple.Pair; - - @OnlyIn(Dist.CLIENT) --public class MultiPartBakedModel implements BakedModel { -+public class MultiPartBakedModel implements net.minecraftforge.client.model.IDynamicBakedModel { - private final List, BakedModel>> selectors; - protected final boolean hasAmbientOcclusion; - protected final boolean isGui3d; -@@ -29,10 +_,12 @@ - protected final ItemTransforms transforms; - protected final ItemOverrides overrides; - private final Map selectorCache = new Reference2ObjectOpenHashMap<>(); -+ private final BakedModel defaultModel; - - public MultiPartBakedModel(List, BakedModel>> p_119462_) { +@@ -33,11 +_,7 @@ this.selectors = p_119462_; - BakedModel bakedmodel = p_119462_.iterator().next().getRight(); -+ this.defaultModel = bakedmodel; - this.hasAmbientOcclusion = bakedmodel.useAmbientOcclusion(); - this.isGui3d = bakedmodel.isGui3d(); - this.usesBlockLight = bakedmodel.usesBlockLight(); -@@ -41,11 +_,7 @@ - this.overrides = bakedmodel.getOverrides(); } - @Override @@ -35,75 +13,40 @@ BitSet bitset = this.selectorCache.get(p_235050_); if (bitset == null) { bitset = new BitSet(); -@@ -59,17 +_,27 @@ +@@ -50,19 +_,45 @@ this.selectorCache.put(p_235050_, bitset); } + return bitset; + } -- List list = Lists.newArrayList(); +- List list = new ArrayList<>(); + // FORGE: Implement our overloads (here and below) so child models can have custom logic + public List getQuads(@Nullable BlockState p_235050_, @Nullable Direction p_235051_, RandomSource p_235052_, net.minecraftforge.client.model.data.ModelData modelData, @Nullable net.minecraft.client.renderer.RenderType renderType) { + if (p_235050_ == null) { + return Collections.emptyList(); + } else { + BitSet bitset = getSelectors(p_235050_); -+ List> list = Lists.newArrayList(); - long k = p_235052_.nextLong(); ++ List list = new ArrayList<>();; + long j = p_235052_.nextLong(); - for (int j = 0; j < bitset.length(); j++) { - if (bitset.get(j)) { -- list.addAll(this.selectors.get(j).getRight().getQuads(p_235050_, p_235051_, RandomSource.create(k))); -+ var model = this.selectors.get(j).getRight(); -+ if (renderType == null || model.getRenderTypes(p_235050_, p_235052_, modelData).contains(renderType)) // FORGE: Only put quad data if the model is using the render type passed -+ list.add(model.getQuads(p_235050_, p_235051_, RandomSource.create(k), net.minecraftforge.client.model.data.MultipartModelData.resolve(modelData, model), renderType)); + for (int k = 0; k < bitset.length(); k++) { + if (bitset.get(k)) { + p_235052_.setSeed(j); +- list.addAll(this.selectors.get(k).model.getQuads(p_235050_, p_235051_, p_235052_)); ++ var model = this.selectors.get(k).model(); ++ // FORGE: Only put quad data if the model is using the render type passed ++ if (renderType != null && !model.getRenderTypes(p_235050_, p_235052_, modelData).contains(renderType)) ++ continue; ++ var data = net.minecraftforge.client.model.data.MultipartModelData.resolve(modelData, model); ++ list.addAll(model.getQuads(p_235050_, p_235051_, p_235052_, data, renderType)); } } - return list; +- } + return net.minecraftforge.common.util.ConcatenatedListView.of(list); - } - } - -@@ -79,6 +_,16 @@ - } - - @Override -+ public boolean useAmbientOcclusion(BlockState state) { -+ return this.defaultModel.useAmbientOcclusion(state); -+ } -+ -+ @Override -+ public boolean useAmbientOcclusion(BlockState state, net.minecraft.client.renderer.RenderType renderType) { -+ return this.defaultModel.useAmbientOcclusion(state, renderType); -+ } -+ -+ @Override - public boolean isGui3d() { - return this.isGui3d; - } -@@ -94,14 +_,37 @@ - } - - @Override -+ @Deprecated - public TextureAtlasSprite getParticleIcon() { - return this.particleIcon; - } - -+ public TextureAtlasSprite getParticleIcon(net.minecraftforge.client.model.data.ModelData modelData) { -+ return this.defaultModel.getParticleIcon(modelData); -+ } -+ - @Override -+ @Deprecated - public ItemTransforms getTransforms() { - return this.transforms; - } -+ -+ public BakedModel applyTransform(net.minecraft.world.item.ItemDisplayContext transformType, com.mojang.blaze3d.vertex.PoseStack poseStack, boolean applyLeftHandTransform) { -+ return this.defaultModel.applyTransform(transformType, poseStack, applyLeftHandTransform); ++ } + } + + @Override // FORGE: Get render types based on the selectors matched by the given block state @@ -111,13 +54,12 @@ + var renderTypeSets = new java.util.LinkedList(); + var selectors = getSelectors(state); + for (int i = 0; i < selectors.length(); i++) { -+ if (selectors.get(i)) { -+ renderTypeSets.add(this.selectors.get(i).getRight().getRenderTypes(state, rand, data)); -+ } ++ if (selectors.get(i)) { ++ renderTypeSets.add(this.selectors.get(i).model().getRenderTypes(state, rand, data)); ++ } + } + + return net.minecraftforge.client.ChunkRenderTypeSet.union(renderTypeSets); -+ } + } - @Override - public ItemOverrides getOverrides() { + @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/resources/model/SimpleBakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/SimpleBakedModel.java.patch index e417bfbbbb..12a2fc2bc1 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/SimpleBakedModel.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/SimpleBakedModel.java.patch @@ -1,43 +1,43 @@ --- a/net/minecraft/client/resources/model/SimpleBakedModel.java +++ b/net/minecraft/client/resources/model/SimpleBakedModel.java -@@ -26,6 +_,15 @@ +@@ -25,6 +_,15 @@ + protected final boolean usesBlockLight; protected final TextureAtlasSprite particleIcon; protected final ItemTransforms transforms; - protected final ItemOverrides overrides; + protected final net.minecraftforge.client.ChunkRenderTypeSet blockRenderTypes; + protected final List itemRenderTypes; + protected final List fabulousItemRenderTypes; + -+ /** @deprecated Forge: Use {@linkplain #SimpleBakedModel(List, Map, boolean, boolean, boolean, TextureAtlasSprite, ItemTransforms, ItemOverrides, net.minecraftforge.client.RenderTypeGroup) variant with RenderTypeGroup} **/ ++ /** @deprecated Forge: Use {@linkplain #SimpleBakedModel(List, Map, boolean, boolean, boolean, TextureAtlasSprite, ItemTransforms, net.minecraftforge.client.RenderTypeGroup) variant with RenderTypeGroup} **/ + @Deprecated -+ public SimpleBakedModel(List p_119489_, Map> p_119490_, boolean p_119491_, boolean p_119492_, boolean p_119493_, TextureAtlasSprite p_119494_, ItemTransforms p_119495_, ItemOverrides p_119496_) { -+ this(p_119489_, p_119490_, p_119491_, p_119492_, p_119493_, p_119494_, p_119495_, p_119496_, net.minecraftforge.client.RenderTypeGroup.EMPTY); ++ public SimpleBakedModel(List p_119489_, Map> p_119490_, boolean p_119491_, boolean p_119492_, boolean p_119493_, TextureAtlasSprite p_119494_, ItemTransforms p_119495_) { ++ this(p_119489_, p_119490_, p_119491_, p_119492_, p_119493_, p_119494_, p_119495_, net.minecraftforge.client.RenderTypeGroup.EMPTY); + } public SimpleBakedModel( List p_119489_, -@@ -35,7 +_,8 @@ +@@ -33,7 +_,8 @@ + boolean p_119492_, boolean p_119493_, TextureAtlasSprite p_119494_, - ItemTransforms p_119495_, -- ItemOverrides p_119496_ -+ ItemOverrides p_119496_, +- ItemTransforms p_119495_ ++ ItemTransforms p_119495_, + net.minecraftforge.client.RenderTypeGroup renderTypes ) { this.unculledFaces = p_119489_; this.culledFaces = p_119490_; -@@ -45,6 +_,9 @@ +@@ -42,6 +_,9 @@ + this.usesBlockLight = p_119492_; this.particleIcon = p_119494_; this.transforms = p_119495_; - this.overrides = p_119496_; + this.blockRenderTypes = !renderTypes.isEmpty() ? net.minecraftforge.client.ChunkRenderTypeSet.of(renderTypes.block()) : null; + this.itemRenderTypes = !renderTypes.isEmpty() ? List.of(renderTypes.entity()) : null; + this.fabulousItemRenderTypes = !renderTypes.isEmpty() ? List.of(renderTypes.entityFabulous()) : null; } @Override -@@ -87,6 +_,25 @@ - return this.overrides; +@@ -79,6 +_,25 @@ + return this.transforms; } + @Override @@ -61,8 +61,8 @@ + @OnlyIn(Dist.CLIENT) public static class Builder { - private final List unculledFaces = Lists.newArrayList(); -@@ -133,12 +_,18 @@ + private final ImmutableList.Builder unculledFaces = ImmutableList.builder(); +@@ -124,13 +_,19 @@ return this; } @@ -76,9 +76,10 @@ if (this.particleIcon == null) { throw new RuntimeException("Missing particle!"); } else { + Map> map = Maps.transformValues(this.culledFaces, ImmutableList.Builder::build); return new SimpleBakedModel( -- this.unculledFaces, this.culledFaces, this.hasAmbientOcclusion, this.usesBlockLight, this.isGui3d, this.particleIcon, this.transforms, this.overrides -+ this.unculledFaces, this.culledFaces, this.hasAmbientOcclusion, this.usesBlockLight, this.isGui3d, this.particleIcon, this.transforms, this.overrides, this.renderTypes +- this.unculledFaces.build(), new EnumMap<>(map), this.hasAmbientOcclusion, this.usesBlockLight, this.isGui3d, this.particleIcon, this.transforms ++ this.unculledFaces.build(), new EnumMap<>(map), this.hasAmbientOcclusion, this.usesBlockLight, this.isGui3d, this.particleIcon, this.transforms, this.renderTypes ); } } diff --git a/patches/minecraft/net/minecraft/client/resources/model/WeightedBakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/WeightedBakedModel.java.patch index 1b90ce2d34..d1adf4f964 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/WeightedBakedModel.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/WeightedBakedModel.java.patch @@ -1,67 +1,12 @@ --- a/net/minecraft/client/resources/model/WeightedBakedModel.java +++ b/net/minecraft/client/resources/model/WeightedBakedModel.java -@@ -17,7 +_,7 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - - @OnlyIn(Dist.CLIENT) --public class WeightedBakedModel implements BakedModel { -+public class WeightedBakedModel implements net.minecraftforge.client.model.IDynamicBakedModel { - private final int totalWeight; - private final List> list; - private final BakedModel wrapped; -@@ -28,10 +_,11 @@ - this.wrapped = p_119544_.get(0).data(); +@@ -24,4 +_,9 @@ + public List getQuads(@Nullable BlockState p_235058_, @Nullable Direction p_235059_, RandomSource p_235060_) { + return this.list.getRandomValue(p_235060_).map(p_358058_ -> p_358058_.getQuads(p_235058_, p_235059_, p_235060_)).orElse(Collections.emptyList()); } - -+ // FORGE: Implement our overloads (here and below) so child models can have custom logic - @Override -- public List getQuads(@Nullable BlockState p_235058_, @Nullable Direction p_235059_, RandomSource p_235060_) { -+ public List getQuads(@Nullable BlockState p_235058_, @Nullable Direction p_235059_, RandomSource p_235060_, net.minecraftforge.client.model.data.ModelData modelData, @Nullable net.minecraft.client.renderer.RenderType renderType) { - return WeightedRandom.getWeightedItem(this.list, Math.abs((int)p_235060_.nextLong()) % this.totalWeight) -- .map(p_325578_ -> p_325578_.data().getQuads(p_235058_, p_235059_, p_235060_)) -+ .map(p_325578_ -> p_325578_.data().getQuads(p_235058_, p_235059_, p_235060_, modelData, renderType)) - .orElse(Collections.emptyList()); - } - -@@ -41,6 +_,16 @@ - } - - @Override -+ public boolean useAmbientOcclusion(BlockState state) { -+ return this.wrapped.useAmbientOcclusion(state); -+ } + + @Override -+ public boolean useAmbientOcclusion(BlockState state, net.minecraft.client.renderer.RenderType renderType) { -+ return this.wrapped.useAmbientOcclusion(state, renderType); ++ public List getQuads(@Nullable BlockState p_235058_, @Nullable Direction p_235059_, RandomSource p_235060_, net.minecraftforge.client.model.data.ModelData extraData, @Nullable net.minecraft.client.renderer.RenderType renderType) { ++ return this.list.getRandomValue(p_235060_).map(p_358058_ -> p_358058_.getQuads(p_235058_, p_235059_, p_235060_, extraData, renderType)).orElse(Collections.emptyList()); + } -+ -+ @Override - public boolean isGui3d() { - return this.wrapped.isGui3d(); - } -@@ -61,8 +_,24 @@ - } - - @Override -+ public TextureAtlasSprite getParticleIcon(net.minecraftforge.client.model.data.ModelData modelData) { -+ return this.wrapped.getParticleIcon(modelData); -+ } -+ -+ @Override - public ItemTransforms getTransforms() { - return this.wrapped.getTransforms(); -+ } -+ -+ public BakedModel applyTransform(net.minecraft.world.item.ItemDisplayContext transformType, com.mojang.blaze3d.vertex.PoseStack poseStack, boolean applyLeftHandTransform) { -+ return this.wrapped.applyTransform(transformType, poseStack, applyLeftHandTransform); -+ } -+ -+ @Override // FORGE: Get render types based on the active weighted model -+ public net.minecraftforge.client.ChunkRenderTypeSet getRenderTypes(BlockState state, RandomSource rand, net.minecraftforge.client.model.data.ModelData data) { -+ return WeightedRandom.getWeightedItem(this.list, Math.abs((int)rand.nextLong()) % this.totalWeight) -+ .map((p_235065_) -> p_235065_.data().getRenderTypes(state, rand, data)) -+ .orElse(net.minecraftforge.client.ChunkRenderTypeSet.none()); - } - - @Override + } diff --git a/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch b/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch index 17e10dcb03..b2486624c3 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 -@@ -73,11 +_,12 @@ +@@ -71,11 +_,12 @@ this.setPvpAllowed(true); this.setFlightAllowed(true); this.initializeKeyPair(); @@ -14,7 +14,7 @@ } @Override -@@ -225,6 +_,7 @@ +@@ -218,6 +_,7 @@ @Override public void halt(boolean p_120053_) { diff --git a/patches/minecraft/net/minecraft/commands/CommandSourceStack.java.patch b/patches/minecraft/net/minecraft/commands/CommandSourceStack.java.patch index 48afb0d1b4..582c6309e6 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 -@@ -43,7 +_,7 @@ +@@ -46,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 fc1c3ea1a4..551520c845 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 -@@ -214,7 +_,7 @@ +@@ -219,7 +_,7 @@ JfrCommand.register(this.dispatcher); } @@ -9,7 +9,7 @@ TestCommand.register(this.dispatcher); RaidCommand.register(this.dispatcher, p_230944_); DebugPathCommand.register(this.dispatcher); -@@ -248,6 +_,7 @@ +@@ -253,6 +_,7 @@ if (p_230943_.includeIntegrated) { PublishCommand.register(this.dispatcher); } @@ -17,10 +17,10 @@ this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer()); } -@@ -266,9 +_,18 @@ +@@ -271,9 +_,18 @@ public void performCommand(ParseResults p_242844_, String p_242841_) { CommandSourceStack commandsourcestack = p_242844_.getContext().getSource(); - commandsourcestack.getServer().getProfiler().push(() -> "/" + p_242841_); + Profiler.get().push(() -> "/" + p_242841_); - ContextChain contextchain = finishParsing(p_242844_, p_242841_, commandsourcestack); try { @@ -37,7 +37,7 @@ if (contextchain != null) { executeCommandInContext( commandsourcestack, -@@ -359,7 +_,8 @@ +@@ -364,7 +_,8 @@ Map, CommandNode> map = Maps.newHashMap(); RootCommandNode rootcommandnode = new RootCommandNode<>(); map.put(this.dispatcher.getRoot(), rootcommandnode); diff --git a/patches/minecraft/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch b/patches/minecraft/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch deleted file mode 100644 index 654f6dde16..0000000000 --- a/patches/minecraft/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/commands/arguments/ResourceLocationArgument.java -+++ b/net/minecraft/commands/arguments/ResourceLocationArgument.java -@@ -27,7 +_,7 @@ - - public static AdvancementHolder getAdvancement(CommandContext p_106988_, String p_106989_) throws CommandSyntaxException { - ResourceLocation resourcelocation = getId(p_106988_, p_106989_); -- AdvancementHolder advancementholder = p_106988_.getSource().getServer().getAdvancements().get(resourcelocation); -+ AdvancementHolder advancementholder = p_106988_.getSource().getAdvancement(resourcelocation); - if (advancementholder == null) { - throw ERROR_UNKNOWN_ADVANCEMENT.create(resourcelocation); - } else { -@@ -36,7 +_,7 @@ - } - - public static RecipeHolder getRecipe(CommandContext p_106995_, String p_106996_) throws CommandSyntaxException { -- RecipeManager recipemanager = p_106995_.getSource().getServer().getRecipeManager(); -+ RecipeManager recipemanager = p_106995_.getSource().getRecipeManager(); - ResourceLocation resourcelocation = getId(p_106995_, p_106996_); - return recipemanager.byKey(resourcelocation).orElseThrow(() -> ERROR_UNKNOWN_RECIPE.create(resourcelocation)); - } diff --git a/patches/minecraft/net/minecraft/core/DefaultedMappedRegistry.java.patch b/patches/minecraft/net/minecraft/core/DefaultedMappedRegistry.java.patch index 1a6db17495..66acdbabb1 100644 --- a/patches/minecraft/net/minecraft/core/DefaultedMappedRegistry.java.patch +++ b/patches/minecraft/net/minecraft/core/DefaultedMappedRegistry.java.patch @@ -2,8 +2,8 @@ +++ b/net/minecraft/core/DefaultedMappedRegistry.java @@ -44,7 +_,7 @@ @Override - public T get(@Nullable ResourceLocation p_260004_) { - T t = super.get(p_260004_); + public T getValue(@Nullable ResourceLocation p_365640_) { + T t = super.getValue(p_365640_); - return t == null ? this.defaultValue.value() : t; + return t == null && this.defaultValue != null ? this.defaultValue.value() : t; // Add null check as it errors out in validation } diff --git a/patches/minecraft/net/minecraft/core/Direction.java.patch b/patches/minecraft/net/minecraft/core/Direction.java.patch new file mode 100644 index 0000000000..d0dabc7787 --- /dev/null +++ b/patches/minecraft/net/minecraft/core/Direction.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/core/Direction.java ++++ b/net/minecraft/core/Direction.java +@@ -49,6 +_,10 @@ + private final Vec3i normal; + private final Vec3 normalVec3; + private static final Direction[] VALUES = values(); ++ private static final List VALUES_VIEW = java.util.Collections.unmodifiableList(Arrays.asList(VALUES)); ++ public static final List valuesView() { ++ return VALUES_VIEW; ++ } + private static final Direction[] BY_3D_DATA = Arrays.stream(VALUES) + .sorted(Comparator.comparingInt(p_235687_ -> p_235687_.data3d)) + .toArray(Direction[]::new); diff --git a/patches/minecraft/net/minecraft/core/Holder.java.patch b/patches/minecraft/net/minecraft/core/Holder.java.patch index 2a0730b6bd..7bb20cf603 100644 --- a/patches/minecraft/net/minecraft/core/Holder.java.patch +++ b/patches/minecraft/net/minecraft/core/Holder.java.patch @@ -24,10 +24,10 @@ T value(); boolean isBound(); -@@ -232,6 +_,10 @@ +@@ -241,6 +_,10 @@ @Override public Stream> tags() { - return this.tags.stream(); + return this.boundTags().stream(); + } + + public Type getType() { diff --git a/patches/minecraft/net/minecraft/core/HolderSet.java.patch b/patches/minecraft/net/minecraft/core/HolderSet.java.patch index 955724aa6f..9d3b2176df 100644 --- a/patches/minecraft/net/minecraft/core/HolderSet.java.patch +++ b/patches/minecraft/net/minecraft/core/HolderSet.java.patch @@ -9,7 +9,7 @@ Stream> stream(); int size(); -@@ -174,6 +_,7 @@ +@@ -182,6 +_,7 @@ public void bind(List> p_205836_) { this.contents = List.copyOf(p_205836_); @@ -17,7 +17,7 @@ } public TagKey key() { -@@ -208,6 +_,12 @@ +@@ -225,6 +_,12 @@ @Override public boolean canSerializeIn(HolderOwner p_256542_) { return this.owner.canSerializeIn(p_256542_); diff --git a/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch b/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch index fb3faec4a1..0bb3f1bfee 100644 --- a/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch +++ b/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java -@@ -114,6 +_,7 @@ +@@ -86,6 +_,7 @@ @Override public Holder.Reference register(ResourceKey p_256252_, T p_256591_, RegistrationInfo p_329661_) { @@ -8,16 +8,16 @@ this.validateWrite(p_256252_); Objects.requireNonNull(p_256252_); Objects.requireNonNull(p_256591_); -@@ -135,6 +_,8 @@ - reference.bindKey(p_256252_); - } else { - reference = this.byKey.computeIfAbsent(p_256252_, p_258168_ -> Holder.Reference.createStandAlone(this.holderOwner(), (ResourceKey)p_258168_)); -+ // Forge: Bind the value immediately so it can be queried while the registry is not frozen -+ reference.bindValue(p_256591_); - } +@@ -104,6 +_,8 @@ + reference.bindKey(p_256252_); + } else { + reference = this.byKey.computeIfAbsent(p_256252_, p_358082_ -> Holder.Reference.createStandAlone(this, (ResourceKey)p_358082_)); ++ // Forge: Bind the value immediately so it can be queried while the registry is not frozen ++ reference.bindValue(p_256591_); + } - this.byKey.put(p_256252_, reference); -@@ -327,7 +_,6 @@ + this.byKey.put(p_256252_, reference); +@@ -275,7 +_,6 @@ return this; } else { this.frozen = true; @@ -25,7 +25,7 @@ List list = this.byKey .entrySet() .stream() -@@ -343,7 +_,8 @@ +@@ -291,7 +_,8 @@ throw new IllegalStateException("Some intrusive holders were not registered: " + this.unregisteredIntrusiveHolders.values()); } @@ -34,13 +34,11 @@ + //this.unregisteredIntrusiveHolders = null; } - return this; -@@ -440,5 +_,24 @@ - @Override - public HolderLookup.RegistryLookup asLookup() { - return this.lookup; -+ } -+ + if (this.allTags.isBound()) { +@@ -390,6 +_,26 @@ + }; + } + + public boolean isIntrusive() { + return this.unregisteredIntrusiveHolders != null; + } @@ -58,5 +56,21 @@ + @Deprecated + public void unfreeze() { + this.frozen = false; - } - } ++ this.allTags = MappedRegistry.TagSet.unbound(); ++ } ++ + @Override + public Registry.PendingTags prepareTagReload(TagLoader.LoadResult p_368827_) { + if (!this.frozen) { +@@ -437,6 +_,11 @@ + @Override + public HolderLookup.RegistryLookup lookup() { + return registrylookup; ++ } ++ ++ @Override ++ public List> getPending(TagKey key) { ++ return map.getOrDefault(key, List.of()); + } + + @Override diff --git a/patches/minecraft/net/minecraft/core/Registry.java.patch b/patches/minecraft/net/minecraft/core/Registry.java.patch new file mode 100644 index 0000000000..2ca4381be8 --- /dev/null +++ b/patches/minecraft/net/minecraft/core/Registry.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/core/Registry.java ++++ b/net/minecraft/core/Registry.java +@@ -180,5 +_,7 @@ + void apply(); + + int size(); ++ ++ List> getPending(TagKey key); + } + } diff --git a/patches/minecraft/net/minecraft/core/RegistrySetBuilder.java.patch b/patches/minecraft/net/minecraft/core/RegistrySetBuilder.java.patch index 5ca022f762..a6a93e6d29 100644 --- a/patches/minecraft/net/minecraft/core/RegistrySetBuilder.java.patch +++ b/patches/minecraft/net/minecraft/core/RegistrySetBuilder.java.patch @@ -40,7 +40,7 @@ return lookupFromMap(p_313093_, lifecycle, p_312548_, map); } } -@@ -266,6 +_,11 @@ +@@ -265,6 +_,11 @@ @Override public HolderGetter lookup(ResourceKey> p_255961_) { return (HolderGetter)BuildState.this.registries.getOrDefault(p_255961_.location(), BuildState.this.lookup); diff --git a/patches/minecraft/net/minecraft/core/RegistrySynchronization.java.patch b/patches/minecraft/net/minecraft/core/RegistrySynchronization.java.patch index e8c7cf1bfd..e9f27461d4 100644 --- a/patches/minecraft/net/minecraft/core/RegistrySynchronization.java.patch +++ b/patches/minecraft/net/minecraft/core/RegistrySynchronization.java.patch @@ -4,8 +4,8 @@ import net.minecraft.server.packs.repository.KnownPack; public class RegistrySynchronization { -- public static final Set>> NETWORKABLE_REGISTRIES = RegistryDataLoader.SYNCHRONIZED_REGISTRIES -+ public static final Set>> NETWORKABLE_REGISTRIES = net.minecraftforge.registries.DataPackRegistriesHooks.grabNetworkableRegistries(() -> RegistryDataLoader.SYNCHRONIZED_REGISTRIES +- private static final Set>> NETWORKABLE_REGISTRIES = RegistryDataLoader.SYNCHRONIZED_REGISTRIES ++ private static final Set>> NETWORKABLE_REGISTRIES = net.minecraftforge.registries.DataPackRegistriesHooks.grabNetworkableRegistries(() -> RegistryDataLoader.SYNCHRONIZED_REGISTRIES .stream() .map(RegistryDataLoader.RegistryData::key) - .collect(Collectors.toUnmodifiableSet()); diff --git a/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch index 0febe30724..0c8b8a1c0b 100644 --- a/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch +++ b/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch @@ -1,30 +1,28 @@ --- a/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java -@@ -35,21 +_,22 @@ +@@ -29,18 +_,22 @@ double d2 = vec3.y() + (double)((float)direction.getStepY() * 1.125F); double d3 = vec3.z() + (double)direction.getStepZ() * d0; BlockPos blockpos = p_123375_.pos().relative(direction); -+ Boat boat = (Boat)(this.isChestBoat ? new ChestBoat(serverlevel, d0, d1, d2) : new Boat(serverlevel, d0, d1, d2)); -+ boat.setVariant(this.type); -+ boat.setYRot(direction.toYRot()); ++ AbstractBoat abstractboat = this.type.create(serverlevel, EntitySpawnReason.DISPENSER); ++ if (abstractboat == null) { ++ return this.defaultDispenseItemBehavior.dispense(p_123375_, p_123376_); ++ } ++ abstractboat.setYRot(direction.toYRot()); double d4; - if (serverlevel.getFluidState(blockpos).is(FluidTags.WATER)) { -+ if (boat.canBoatInFluid(serverlevel.getFluidState(blockpos))) { ++ if (abstractboat.canBoatInFluid(serverlevel.getFluidState(blockpos))) { d4 = 1.0; } else { - if (!serverlevel.getBlockState(blockpos).isAir() || !serverlevel.getFluidState(blockpos.below()).is(FluidTags.WATER)) { -+ if (!serverlevel.getBlockState(blockpos).isAir() || !boat.canBoatInFluid(serverlevel.getFluidState(blockpos.below()))) { ++ if (!serverlevel.getBlockState(blockpos).isAir() || !abstractboat.canBoatInFluid(serverlevel.getFluidState(blockpos.below()))) { return this.defaultDispenseItemBehavior.dispense(p_123375_, p_123376_); } d4 = 0.0; } -- Boat boat = (Boat)(this.isChestBoat ? new ChestBoat(serverlevel, d1, d2 + d4, d3) : new Boat(serverlevel, d1, d2 + d4, d3)); - EntityType.createDefaultStackConfig(serverlevel, p_123376_, null).accept(boat); -- boat.setVariant(this.type); -- boat.setYRot(direction.toYRot()); -+ boat.setPos(d1, d2 + d4, d3); - serverlevel.addFreshEntity(boat); - p_123376_.shrink(1); - return p_123376_; +- AbstractBoat abstractboat = this.type.create(serverlevel, EntitySpawnReason.DISPENSER); + if (abstractboat != null) { + abstractboat.setInitialPos(d1, d2 + d4, d3); + EntityType.createDefaultStackConfig(serverlevel, p_123376_, null).accept(abstractboat); diff --git a/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index d014643a91..fbcbfdd3ef 100644 --- a/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch +++ b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -232,7 +_,7 @@ - DispensibleContainerItem dispensiblecontaineritem = (DispensibleContainerItem)p_333855_.getItem(); - BlockPos blockpos = p_333645_.pos().relative(p_333645_.state().getValue(DispenserBlock.FACING)); - Level level = p_333645_.level(); +@@ -193,7 +_,7 @@ + DispensibleContainerItem dispensiblecontaineritem = (DispensibleContainerItem)p_335219_.getItem(); + BlockPos blockpos = p_335842_.pos().relative(p_335842_.state().getValue(DispenserBlock.FACING)); + Level level = p_335842_.level(); - if (dispensiblecontaineritem.emptyContents(null, level, blockpos, null)) { -+ if (dispensiblecontaineritem.emptyContents(null, level, blockpos, null, p_333855_)) { - dispensiblecontaineritem.checkExtraContent(null, level, p_333855_, blockpos); - return this.consumeWithRemainder(p_333645_, p_333855_, new ItemStack(Items.BUCKET)); ++ if (dispensiblecontaineritem.emptyContents(null, level, blockpos, null, p_335219_)) { + dispensiblecontaineritem.checkExtraContent(null, level, p_335219_, blockpos); + return this.consumeWithRemainder(p_335842_, p_335219_, new ItemStack(Items.BUCKET)); } else { -@@ -283,9 +_,11 @@ +@@ -244,9 +_,11 @@ } else if (CampfireBlock.canLight(blockstate) || CandleBlock.canLight(blockstate) || CandleCakeBlock.canLight(blockstate)) { serverlevel.setBlockAndUpdate(blockpos, blockstate.setValue(BlockStateProperties.LIT, Boolean.valueOf(true))); serverlevel.gameEvent(null, GameEvent.BLOCK_CHANGE, blockpos); - } else if (blockstate.getBlock() instanceof TntBlock) { - TntBlock.explode(serverlevel, blockpos); - serverlevel.removeBlock(blockpos, false); -+ } else if (blockstate.isFlammable(serverlevel, blockpos, p_333039_.state().getValue(DispenserBlock.FACING).getOpposite())) { -+ blockstate.onCaughtFire(serverlevel, blockpos, p_333039_.state().getValue(DispenserBlock.FACING).getOpposite(), null); ++ } else if (blockstate.isFlammable(serverlevel, blockpos, p_332842_.state().getValue(DispenserBlock.FACING).getOpposite())) { ++ blockstate.onCaughtFire(serverlevel, blockpos, p_332842_.state().getValue(DispenserBlock.FACING).getOpposite(), null); + if (blockstate.getBlock() instanceof TntBlock) { + serverlevel.removeBlock(blockpos, false); + } diff --git a/patches/minecraft/net/minecraft/core/particles/ItemParticleOption.java.patch b/patches/minecraft/net/minecraft/core/particles/ItemParticleOption.java.patch index 43de589407..b4a87ed6d0 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 -@@ -24,7 +_,7 @@ +@@ -25,7 +_,7 @@ throw new IllegalArgumentException("Empty stacks are not allowed"); } else { this.type = p_123705_; diff --git a/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch b/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch index ac84d09b4c..b0db883bc3 100644 --- a/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch +++ b/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/core/registries/BuiltInRegistries.java +++ b/net/minecraft/core/registries/BuiltInRegistries.java -@@ -240,7 +_,9 @@ +@@ -246,7 +_,9 @@ ) { - Bootstrap.checkBootstrapCalled(() -> "registry " + p_259230_); + Bootstrap.checkBootstrapCalled(() -> "registry " + p_259230_.location()); ResourceLocation resourcelocation = p_259230_.location(); - LOADERS.put(resourcelocation, () -> p_259210_.run(p_260327_)); + var maybeWrapped = net.minecraftforge.registries.GameData.getWrapper(p_259230_, p_260327_); @@ -11,12 +11,12 @@ WRITABLE_REGISTRY.register((ResourceKey)p_259230_, p_260327_, RegistrationInfo.BUILT_IN); return p_260327_; } -@@ -275,7 +_,7 @@ +@@ -282,7 +_,7 @@ - if (p_325821_ instanceof DefaultedRegistry) { - ResourceLocation resourcelocation = ((DefaultedRegistry)p_325821_).getDefaultKey(); -- Validate.notNull(p_325821_.get(resourcelocation), "Missing default of DefaultedMappedRegistry: " + resourcelocation); -+ Validate.notNull(p_325821_.get(resourcelocation), "Missing default of DefaultedMappedRegistry: " + p_325821_.key() + " - " + resourcelocation); + if (p_358159_ instanceof DefaultedRegistry) { + ResourceLocation resourcelocation = ((DefaultedRegistry)p_358159_).getDefaultKey(); +- Validate.notNull(p_358159_.getValue(resourcelocation), "Missing default of DefaultedMappedRegistry: " + resourcelocation); ++ Validate.notNull(p_358159_.get(resourcelocation), "Missing default of DefaultedMappedRegistry: " + p_358159_.key() + " - " + resourcelocation); } }); } diff --git a/patches/minecraft/net/minecraft/core/registries/Registries.java.patch b/patches/minecraft/net/minecraft/core/registries/Registries.java.patch index 4637f5075c..82007db607 100644 --- a/patches/minecraft/net/minecraft/core/registries/Registries.java.patch +++ b/patches/minecraft/net/minecraft/core/registries/Registries.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/registries/Registries.java +++ b/net/minecraft/core/registries/Registries.java -@@ -237,10 +_,14 @@ +@@ -245,10 +_,14 @@ } public static String elementsDirPath(ResourceKey> p_343743_) { diff --git a/patches/minecraft/net/minecraft/data/Main.java.patch b/patches/minecraft/net/minecraft/data/Main.java.patch index 66110d152f..542d84046a 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 -@@ -77,8 +_,15 @@ +@@ -86,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); -@@ -86,6 +_,13 @@ +@@ -95,6 +_,13 @@ boolean flag3 = flag || optionset.has(optionspec3); boolean flag4 = flag || optionset.has(optionspec4); boolean flag5 = flag || optionset.has(optionspec5); @@ -31,7 +31,7 @@ DataGenerator datagenerator = createStandardGenerator( path, optionset.valuesOf(optionspec8).stream().map(p_129659_ -> Paths.get(p_129659_)).collect(Collectors.toList()), -@@ -98,6 +_,7 @@ +@@ -107,6 +_,7 @@ true ); datagenerator.run(); diff --git a/patches/minecraft/net/minecraft/data/loot/BlockLootSubProvider.java.patch b/patches/minecraft/net/minecraft/data/loot/BlockLootSubProvider.java.patch index 4bc864c8e6..f339433da3 100644 --- a/patches/minecraft/net/minecraft/data/loot/BlockLootSubProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/loot/BlockLootSubProvider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/loot/BlockLootSubProvider.java +++ b/net/minecraft/data/loot/BlockLootSubProvider.java -@@ -641,12 +_,16 @@ +@@ -668,12 +_,16 @@ protected abstract void generate(); @@ -16,5 +16,5 @@ - for (Block block : BuiltInRegistries.BLOCK) { + for (Block block : getKnownBlocks()) { if (block.isEnabled(this.enabledFeatures)) { - ResourceKey resourcekey = block.getLootTable(); - if (resourcekey != BuiltInLootTables.EMPTY && set.add(resourcekey)) { + block.getLootTable() + .ifPresent( diff --git a/patches/minecraft/net/minecraft/data/loot/EntityLootSubProvider.java.patch b/patches/minecraft/net/minecraft/data/loot/EntityLootSubProvider.java.patch index 4ee7637be6..4bacd5425a 100644 --- a/patches/minecraft/net/minecraft/data/loot/EntityLootSubProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/loot/EntityLootSubProvider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/loot/EntityLootSubProvider.java +++ b/net/minecraft/data/loot/EntityLootSubProvider.java -@@ -96,12 +_,16 @@ +@@ -104,12 +_,16 @@ public abstract void generate(); @@ -13,18 +13,9 @@ this.generate(); Set> set = new HashSet<>(); - BuiltInRegistries.ENTITY_TYPE -- .holders() +- .listElements() + this.getKnownEntityTypes() + .map(EntityType::builtInRegistryHolder) .forEach( - p_266624_ -> { - EntityType entitytype = p_266624_.value(); -@@ -151,7 +_,7 @@ - } - } - -- protected static boolean canHaveLootTable(EntityType p_249029_) { -+ protected boolean canHaveLootTable(EntityType p_249029_) { - return SPECIAL_LOOT_TABLE_TYPES.contains(p_249029_) || p_249029_.getCategory() != MobCategory.MISC; - } - + p_358214_ -> { + EntityType entitytype = p_358214_.value(); diff --git a/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch b/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch index 358c799666..b1a4044b4d 100644 --- a/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch @@ -4,13 +4,13 @@ private CompletableFuture run(CachedOutput p_327970_, HolderLookup.Provider p_331092_) { WritableRegistry writableregistry = new MappedRegistry<>(Registries.LOOT_TABLE, Lifecycle.experimental()); Map map = new Object2ObjectOpenHashMap<>(); -- this.subProviders.forEach(p_341016_ -> p_341016_.provider().apply(p_331092_).generate((p_325864_, p_325865_) -> { -+ this.getTables().forEach(p_341016_ -> p_341016_.provider().apply(p_331092_).generate((p_325864_, p_325865_) -> { - ResourceLocation resourcelocation = sequenceIdForLootTable(p_325864_); +- this.subProviders.forEach(p_341016_ -> p_341016_.provider().apply(p_331092_).generate((p_358218_, p_358219_) -> { ++ this.getTables().forEach(p_341016_ -> p_341016_.provider().apply(p_331092_).generate((p_358218_, p_358219_) -> { + ResourceLocation resourcelocation = sequenceIdForLootTable(p_358218_); ResourceLocation resourcelocation1 = map.put(RandomSequence.seedForKey(resourcelocation), resourcelocation); if (resourcelocation1 != null) { @@ -78,18 +_,8 @@ - HolderGetter.Provider holdergetter$provider = new RegistryAccess.ImmutableRegistryAccess(List.of(writableregistry)).freeze().asGetterLookup(); + HolderGetter.Provider holdergetter$provider = new RegistryAccess.ImmutableRegistryAccess(List.of(writableregistry)).freeze(); ValidationContext validationcontext = new ValidationContext(problemreporter$collector, LootContextParamSets.ALL_PARAMS, holdergetter$provider); - for (ResourceKey resourcekey : Sets.difference(this.requiredTables, writableregistry.registryKeySet())) { @@ -18,12 +18,12 @@ - } + validate(writableregistry, validationcontext, problemreporter$collector); -- writableregistry.holders() +- writableregistry.listElements() - .forEach( -- p_325854_ -> p_325854_.value() +- p_358221_ -> p_358221_.value() - .validate( -- validationcontext.setParams(p_325854_.value().getParamSet()) -- .enterElement("{" + p_325854_.key().location() + "}", p_325854_.key()) +- validationcontext.setContextKeySet(p_358221_.value().getParamSet()) +- .enterElement("{" + p_358221_.key().location() + "}", p_358221_.key()) - ) - ); Multimap multimap = problemreporter$collector.get(); @@ -44,10 +44,10 @@ + report.report("Missing built-in table: " + resourcekey.location()); + } + -+ map.holders().forEach(table -> table.value().validate( -+ validationcontext.setParams(table.value().getParamSet()) ++ map.listElements().forEach(table -> table.value().validate( ++ validationcontext.setContextKeySet(table.value().getParamSet()) + .enterElement("{" + table.key().location() + "}", table.key()) + )); } - public static record SubProviderEntry(Function provider, LootContextParamSet paramSet) { + public static record SubProviderEntry(Function provider, ContextKeySet paramSet) { diff --git a/patches/minecraft/net/minecraft/data/recipes/RecipeOutput.java.patch b/patches/minecraft/net/minecraft/data/recipes/RecipeOutput.java.patch index db6f969a5e..52d2892b79 100644 --- a/patches/minecraft/net/minecraft/data/recipes/RecipeOutput.java.patch +++ b/patches/minecraft/net/minecraft/data/recipes/RecipeOutput.java.patch @@ -4,8 +4,8 @@ import net.minecraft.world.item.crafting.Recipe; public interface RecipeOutput { -- void accept(ResourceLocation p_310578_, Recipe p_312265_, @Nullable AdvancementHolder p_310407_); -+ default void accept(ResourceLocation id, Recipe recipe, @Nullable AdvancementHolder advancement) { +- void accept(ResourceKey> p_367162_, Recipe p_360758_, @Nullable AdvancementHolder p_361155_); ++ default void accept(ResourceKey> id, Recipe recipe, @Nullable AdvancementHolder advancement) { + if (advancement == null) { + accept(id, recipe, null, null); + } else { @@ -15,9 +15,9 @@ + } + } + -+ void accept(ResourceLocation id, Recipe recipe, @Nullable ResourceLocation advancementId, @Nullable com.google.gson.JsonElement advancement); ++ void accept(ResourceKey> id, Recipe recipe, @Nullable net.minecraft.resources.ResourceLocation advancementId, @Nullable com.google.gson.JsonElement advancement); + + net.minecraft.core.HolderLookup.Provider registry(); Advancement.Builder advancement(); - } + diff --git a/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch b/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch index 3569cad450..d8e7f0c25c 100644 --- a/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch @@ -1,55 +1,64 @@ --- a/net/minecraft/data/recipes/RecipeProvider.java +++ b/net/minecraft/data/recipes/RecipeProvider.java -@@ -84,21 +_,16 @@ - this.buildRecipes( - new RecipeOutput() { - @Override -- public void accept(ResourceLocation p_312383_, Recipe p_312007_, @Nullable AdvancementHolder p_311384_) { -+ public void accept(ResourceLocation p_312383_, Recipe p_312007_, @Nullable ResourceLocation advancementId, @Nullable com.google.gson.JsonElement advancement) { - if (!set.add(p_312383_)) { - throw new IllegalStateException("Duplicate recipe " + p_312383_); - } else { - list.add(DataProvider.saveStable(p_331109_, p_328892_, Recipe.CODEC, p_312007_, RecipeProvider.this.recipePathProvider.json(p_312383_))); -- if (p_311384_ != null) { -- list.add( -- DataProvider.saveStable( -- p_331109_, -- p_328892_, -- Advancement.CODEC, -- p_311384_.value(), -- RecipeProvider.this.advancementPathProvider.json(p_311384_.id()) -- ) -- ); -+ if (advancement != null) { -+ var saveAdvancementFuture = saveAdvancement(p_331109_, advancementId, advancement); -+ if (saveAdvancementFuture != null) { -+ list.add(saveAdvancementFuture); -+ } - } - } - } -@@ -107,9 +_,24 @@ - public Advancement.Builder advancement() { - return Advancement.Builder.recipeAdvancement().parent(RecipeBuilder.ROOT_RECIPE_ADVANCEMENT); - } -+ -+ @Override -+ public HolderLookup.Provider registry() { -+ return p_328892_; -+ } - } - ); - return CompletableFuture.allOf(list.toArray(CompletableFuture[]::new)); -+ } -+ -+ /** -+ * 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. -+ */ -+ @Nullable -+ protected CompletableFuture saveAdvancement(CachedOutput output, ResourceLocation advancementId, com.google.gson.JsonElement advancement) { -+ return DataProvider.saveStable(output, advancement, this.advancementPathProvider.json(advancementId)); +@@ -732,7 +_,7 @@ + RecipeBuilder create(RecipeProvider p_363045_, ItemLike p_362746_, ItemLike p_364674_); } - protected CompletableFuture buildAdvancement(CachedOutput p_253674_, HolderLookup.Provider p_335995_, AdvancementHolder p_297687_) { +- protected abstract static class Runner implements DataProvider { ++ public abstract static class Runner implements DataProvider { + private final PackOutput packOutput; + private final CompletableFuture registries; + +@@ -752,13 +_,13 @@ + final List> list = new ArrayList<>(); + RecipeOutput recipeoutput = new RecipeOutput() { + @Override +- public void accept(ResourceKey> p_361204_, Recipe p_363495_, @Nullable AdvancementHolder p_364191_) { ++ public void accept(ResourceKey> p_361204_, Recipe p_363495_, @Nullable net.minecraft.resources.ResourceLocation advancementId, @Nullable com.google.gson.JsonElement advancement) { + if (!set.add(p_361204_)) { + throw new IllegalStateException("Duplicate recipe " + p_361204_.location()); + } else { + this.saveRecipe(p_361204_, p_363495_); +- if (p_364191_ != null) { +- this.saveAdvancement(p_364191_); ++ if (advancement != null && advancementId != null) { ++ this.saveAdvancement(advancementId, advancement); + } + } + } +@@ -773,7 +_,9 @@ + AdvancementHolder advancementholder = Advancement.Builder.recipeAdvancement() + .addCriterion("impossible", CriteriaTriggers.IMPOSSIBLE.createCriterion(new ImpossibleTrigger.TriggerInstance())) + .build(RecipeBuilder.ROOT_RECIPE_ADVANCEMENT); +- this.saveAdvancement(advancementholder); ++ var ops = registry().createSerializationContext(com.mojang.serialization.JsonOps.INSTANCE); ++ var json = Advancement.CODEC.encodeStart(ops, advancementholder.value()).getOrThrow(IllegalStateException::new); ++ this.saveAdvancement(advancementholder.id(), json); + } + + private void saveRecipe(ResourceKey> p_368864_, Recipe p_368184_) { +@@ -784,16 +_,19 @@ + ); + } + +- private void saveAdvancement(AdvancementHolder p_361824_) { ++ private void saveAdvancement(net.minecraft.resources.ResourceLocation id, com.google.gson.JsonElement advancement) { + list.add( + DataProvider.saveStable( + p_363906_, +- p_362805_, +- Advancement.CODEC, +- p_361824_.value(), +- packoutput$pathprovider1.json(p_361824_.id()) ++ advancement, ++ packoutput$pathprovider1.json(id) + ) + ); ++ } ++ ++ @Override ++ public HolderLookup.Provider registry() { ++ return p_362805_; + } + }; + this.createRecipeProvider(p_362805_, recipeoutput).buildRecipes(); diff --git a/patches/minecraft/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch b/patches/minecraft/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch index 2984723d77..61b728f2b1 100644 --- a/patches/minecraft/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch +++ b/patches/minecraft/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch @@ -35,7 +35,7 @@ @@ -52,6 +_,7 @@ PackOutput.PathProvider packoutput$pathprovider = this.output.createRegistryElementsPathProvider(resourcekey); return CompletableFuture.allOf( - p_341079_.listElements() + p_358460_.listElements() + .filter(holder -> this.namespacePredicate.test(holder.key().location().getNamespace())) .map( p_256105_ -> dumpValue( diff --git a/patches/minecraft/net/minecraft/data/registries/RegistryPatchGenerator.java.patch b/patches/minecraft/net/minecraft/data/registries/RegistryPatchGenerator.java.patch index a9e6ebe83e..09e3ac09cf 100644 --- a/patches/minecraft/net/minecraft/data/registries/RegistryPatchGenerator.java.patch +++ b/patches/minecraft/net/minecraft/data/registries/RegistryPatchGenerator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/registries/RegistryPatchGenerator.java +++ b/net/minecraft/data/registries/RegistryPatchGenerator.java -@@ -20,7 +_,7 @@ +@@ -21,7 +_,7 @@ p_309945_ -> { RegistryAccess.Frozen registryaccess$frozen = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY); Cloner.Factory cloner$factory = new Cloner.Factory(); diff --git a/patches/minecraft/net/minecraft/data/registries/VanillaRegistries.java.patch b/patches/minecraft/net/minecraft/data/registries/VanillaRegistries.java.patch index 94e1887dfc..2831c7f25b 100644 --- a/patches/minecraft/net/minecraft/data/registries/VanillaRegistries.java.patch +++ b/patches/minecraft/net/minecraft/data/registries/VanillaRegistries.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/data/registries/VanillaRegistries.java +++ b/net/minecraft/data/registries/VanillaRegistries.java -@@ -68,6 +_,7 @@ - .add(Registries.ENCHANTMENT, Enchantments::bootstrap) +@@ -72,6 +_,7 @@ .add(Registries.ENCHANTMENT_PROVIDER, VanillaEnchantmentProviders::bootstrap) - .add(Registries.JUKEBOX_SONG, JukeboxSongs::bootstrap); + .add(Registries.JUKEBOX_SONG, JukeboxSongs::bootstrap) + .add(Registries.INSTRUMENT, Instruments::bootstrap); + public static final List>> DATAPACK_REGISTRY_KEYS = BUILDER.getEntryKeys(); private static void validateThatAllBiomeFeaturesHaveBiomeFilter(HolderLookup.Provider p_256242_) { diff --git a/patches/minecraft/net/minecraft/gametest/framework/GameTestHelper.java.patch b/patches/minecraft/net/minecraft/gametest/framework/GameTestHelper.java.patch index 5951ac4dbd..eb14a7fbe2 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/GameTestHelper.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/GameTestHelper.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestHelper.java +++ b/net/minecraft/gametest/framework/GameTestHelper.java -@@ -61,7 +_,7 @@ +@@ -65,7 +_,7 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; diff --git a/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch b/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch index 6b2d695316..fc1f8979a4 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/gametest/framework/GameTestServer.java +++ b/net/minecraft/gametest/framework/GameTestServer.java -@@ -79,7 +_,7 @@ +@@ -83,7 +_,7 @@ } else { p_206609_.reload(); WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration( -- new DataPackConfig(new ArrayList<>(p_206609_.getAvailableIds()), List.of()), FeatureFlags.REGISTRY.allFlags() -+ new DataPackConfig(new ArrayList<>(p_206609_.getSelectedIds()), List.of()), FeatureFlags.REGISTRY.allFlags() // Forge: Use the selected datapacks as this takes sorting into account. +- new DataPackConfig(new ArrayList<>(p_206609_.getAvailableIds()), List.of()), ENABLED_FEATURES ++ new DataPackConfig(new ArrayList<>(p_206609_.getSelectedIds()), List.of()), ENABLED_FEATURES // Forge: Use the selected datapacks as this takes sorting into account. ); LevelSettings levelsettings = new LevelSettings("Test Level", GameType.CREATIVE, false, Difficulty.NORMAL, true, TEST_GAME_RULES, worlddataconfiguration); WorldLoader.PackConfig worldloader$packconfig = new WorldLoader.PackConfig(p_206609_, worlddataconfiguration, false, true); -@@ -138,6 +_,7 @@ +@@ -142,6 +_,7 @@ @Override public boolean initServer() { diff --git a/patches/minecraft/net/minecraft/locale/Language.java.patch b/patches/minecraft/net/minecraft/locale/Language.java.patch index f90eeb3e5b..18ce036ffe 100644 --- a/patches/minecraft/net/minecraft/locale/Language.java.patch +++ b/patches/minecraft/net/minecraft/locale/Language.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/locale/Language.java +++ b/net/minecraft/locale/Language.java -@@ -37,7 +_,8 @@ - Builder builder = ImmutableMap.builder(); - BiConsumer biconsumer = builder::put; +@@ -38,7 +_,8 @@ + BiConsumer biconsumer = map::put; parseTranslations(biconsumer, "/assets/minecraft/lang/en_us.json"); -- final Map map = builder.build(); -+ final Map map = new java.util.HashMap<>(builder.build()); + deprecatedtranslationsinfo.applyToMap(map); +- final Map map1 = Map.copyOf(map); + net.minecraftforge.server.LanguageHook.captureLanguageMap(map); ++ final Map map1 = map; return new Language() { @Override public String getOrDefault(String p_128127_, String p_265421_) { -@@ -62,6 +_,11 @@ +@@ -63,6 +_,11 @@ ) .isPresent(); } @@ -22,7 +22,7 @@ }; } -@@ -89,6 +_,8 @@ +@@ -90,6 +_,8 @@ public static void inject(Language p_128115_) { instance = p_128115_; } diff --git a/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch b/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch index 428ea89b9e..2b423269a7 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 -@@ -1589,4 +_,8 @@ +@@ -1624,4 +_,8 @@ public boolean release(int p_130347_) { return this.source.release(p_130347_); } diff --git a/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch index ade480adf7..73a96bb3ef 100644 --- a/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java +++ b/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java -@@ -35,7 +_,7 @@ +@@ -36,7 +_,7 @@ public record ClientboundCustomPayloadPacket(CustomPacketPayload payload) implements Packet { private static final int MAX_PAYLOAD_SIZE = 1048576; public static final StreamCodec GAMEPLAY_STREAM_CODEC = CustomPacketPayload.codec( @@ -9,7 +9,7 @@ Util.make( Lists.newArrayList( new CustomPacketPayload.TypeAndCodec<>(BrandPayload.TYPE, BrandPayload.STREAM_CODEC), -@@ -64,7 +_,7 @@ +@@ -66,7 +_,7 @@ ) .map(ClientboundCustomPayloadPacket::new, ClientboundCustomPayloadPacket::payload); public static final StreamCodec CONFIG_STREAM_CODEC = CustomPacketPayload.codec( diff --git a/patches/minecraft/net/minecraft/recipebook/PlaceRecipe.java.patch b/patches/minecraft/net/minecraft/recipebook/PlaceRecipe.java.patch deleted file mode 100644 index 1d50f967b3..0000000000 --- a/patches/minecraft/net/minecraft/recipebook/PlaceRecipe.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/recipebook/PlaceRecipe.java -+++ b/net/minecraft/recipebook/PlaceRecipe.java -@@ -9,9 +_,9 @@ - default void placeRecipe(int p_135409_, int p_135410_, int p_135411_, RecipeHolder p_298822_, Iterator p_135413_, int p_135414_) { - int i = p_135409_; - int j = p_135410_; -- if (p_298822_.value() instanceof ShapedRecipe shapedrecipe) { -- i = shapedrecipe.getWidth(); -- j = shapedrecipe.getHeight(); -+ if (p_298822_.value() instanceof net.minecraftforge.common.crafting.IShapedRecipe shapedrecipe) { -+ i = shapedrecipe.getRecipeWidth(); -+ j = shapedrecipe.getRecipeHeight(); - } - - int k1 = 0; diff --git a/patches/minecraft/net/minecraft/resources/RegistryDataLoader.java.patch b/patches/minecraft/net/minecraft/resources/RegistryDataLoader.java.patch index 36419345c4..197e01f037 100644 --- a/patches/minecraft/net/minecraft/resources/RegistryDataLoader.java.patch +++ b/patches/minecraft/net/minecraft/resources/RegistryDataLoader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/resources/RegistryDataLoader.java +++ b/net/minecraft/resources/RegistryDataLoader.java -@@ -70,7 +_,7 @@ +@@ -80,7 +_,7 @@ Lifecycle lifecycle = p_326161_.map(KnownPack::isVanilla).map(p_326166_ -> Lifecycle.stable()).orElse(Lifecycle.experimental()); return new RegistrationInfo(p_326161_, lifecycle); }); @@ -9,7 +9,7 @@ new RegistryDataLoader.RegistryData<>(Registries.DIMENSION_TYPE, DimensionType.DIRECT_CODEC), new RegistryDataLoader.RegistryData<>(Registries.BIOME, Biome.DIRECT_CODEC), new RegistryDataLoader.RegistryData<>(Registries.CHAT_TYPE, ChatType.DIRECT_CODEC), -@@ -100,7 +_,7 @@ +@@ -112,7 +_,7 @@ public static final List> DIMENSION_REGISTRIES = List.of( new RegistryDataLoader.RegistryData<>(Registries.LEVEL_STEM, LevelStem.CODEC) ); @@ -18,29 +18,18 @@ new RegistryDataLoader.RegistryData<>(Registries.BIOME, Biome.NETWORK_CODEC), new RegistryDataLoader.RegistryData<>(Registries.CHAT_TYPE, ChatType.DIRECT_CODEC), new RegistryDataLoader.RegistryData<>(Registries.TRIM_PATTERN, TrimPattern.DIRECT_CODEC), -@@ -114,6 +_,10 @@ - new RegistryDataLoader.RegistryData<>(Registries.JUKEBOX_SONG, JukeboxSong.DIRECT_CODEC) +@@ -127,6 +_,10 @@ + new RegistryDataLoader.RegistryData<>(Registries.INSTRUMENT, Instrument.DIRECT_CODEC) ); + public static java.util.stream.Stream> getWorldGenAndDimensionStream() { + return java.util.stream.Stream.concat(RegistryDataLoader.WORLDGEN_REGISTRIES.stream(), RegistryDataLoader.DIMENSION_REGISTRIES.stream()); + } + - public static RegistryAccess.Frozen load(ResourceManager p_252046_, RegistryAccess p_249916_, List> p_250344_) { - return load((p_326156_, p_326157_) -> p_326156_.loadFromResources(p_252046_, p_326157_), p_249916_, p_250344_); - } -@@ -151,7 +_,9 @@ - }); - if (!map.isEmpty()) { - logErrors(map); -- throw new IllegalStateException("Failed to load registries due to above errors"); -+ var buf = new StringBuilder("Failed to load registries, see debug.log for more details:"); -+ map.forEach((k,v) -> buf.append("\n\t").append(k.toString()).append(": ").append(v.getMessage())); -+ throw new IllegalStateException(buf.toString()); - } else { - return new RegistryAccess.ImmutableRegistryAccess(list.stream().map(RegistryDataLoader.Loader::registry).toList()).freeze(); - } -@@ -200,7 +_,7 @@ + public static RegistryAccess.Frozen load( + ResourceManager p_252046_, List> p_250344_, List> p_366741_ + ) { +@@ -243,7 +_,7 @@ private static void loadElementFromResource( WritableRegistry p_330991_, @@ -49,7 +38,7 @@ RegistryOps p_332135_, ResourceKey p_332850_, Resource p_335244_, -@@ -208,7 +_,23 @@ +@@ -251,7 +_,23 @@ ) throws IOException { try (Reader reader = p_335244_.openAsReader()) { JsonElement jsonelement = JsonParser.parseReader(reader); @@ -74,7 +63,7 @@ E e = dataresult.getOrThrow(); p_330991_.register(p_332850_, e, p_332222_); } -@@ -224,6 +_,7 @@ +@@ -267,6 +_,7 @@ String s = Registries.elementsDirPath(p_331358_.key()); FileToIdConverter filetoidconverter = FileToIdConverter.json(s); RegistryOps registryops = RegistryOps.create(JsonOps.INSTANCE, p_333035_); @@ -82,7 +71,7 @@ for (Entry entry : filetoidconverter.listMatchingResources(p_335634_).entrySet()) { ResourceLocation resourcelocation = entry.getKey(); -@@ -232,7 +_,7 @@ +@@ -275,7 +_,7 @@ RegistrationInfo registrationinfo = REGISTRATION_INFO_CACHE.apply(resource.knownPackInfo()); try { @@ -91,9 +80,9 @@ } catch (Exception exception) { p_335074_.put( resourcekey, -@@ -253,7 +_,9 @@ - List list = p_331925_.get(p_332518_.key()); - if (list != null) { +@@ -298,7 +_,9 @@ + RegistryDataLoader.NetworkedRegistryData registrydataloader$networkedregistrydata = p_331925_.get(p_332518_.key()); + if (registrydataloader$networkedregistrydata != null) { RegistryOps registryops = RegistryOps.create(NbtOps.INSTANCE, p_329253_); - RegistryOps registryops1 = RegistryOps.create(JsonOps.INSTANCE, p_329253_); + RegistryOps registryops1 = RegistryOps.create(JsonOps.INSTANCE, p_329253_) @@ -102,7 +91,7 @@ String s = Registries.elementsDirPath(p_332518_.key()); FileToIdConverter filetoidconverter = FileToIdConverter.json(s); -@@ -276,7 +_,7 @@ +@@ -321,7 +_,7 @@ try { Resource resource = p_332010_.getResourceOrThrow(resourcelocation); diff --git a/patches/minecraft/net/minecraft/server/Bootstrap.java.patch b/patches/minecraft/net/minecraft/server/Bootstrap.java.patch index 36f0b6660a..cff7b40ec6 100644 --- a/patches/minecraft/net/minecraft/server/Bootstrap.java.patch +++ b/patches/minecraft/net/minecraft/server/Bootstrap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Bootstrap.java +++ b/net/minecraft/server/Bootstrap.java -@@ -52,6 +_,8 @@ +@@ -53,6 +_,8 @@ CauldronInteraction.bootStrap(); BuiltInRegistries.bootStrap(); CreativeModeTabs.validate(); @@ -9,7 +9,7 @@ wrapStreams(); bootstrapDuration.set(Duration.between(instant, Instant.now()).toMillis()); } -@@ -117,7 +_,6 @@ +@@ -119,7 +_,6 @@ Commands.validate(); } diff --git a/patches/minecraft/net/minecraft/server/Main.java.patch b/patches/minecraft/net/minecraft/server/Main.java.patch index be15eb6543..aa3287d912 100644 --- a/patches/minecraft/net/minecraft/server/Main.java.patch +++ b/patches/minecraft/net/minecraft/server/Main.java.patch @@ -82,11 +82,11 @@ try { WorldLoader.InitConfig worldloader$initconfig = loadOrCreateConfig(dedicatedserversettings.getProperties(), dynamic1, flag, packrepository); @@ -214,6 +_,16 @@ - worlddimensions = dedicatedserverproperties.createDimensions(p_308589_.datapackWorldgen()); + worlddimensions = dedicatedserverproperties.createDimensions(p_358511_.datapackWorldgen()); } + //Forge: Do a write-read-cycle to inject modded dimensions on first start of a dedicated server into its generated world dimensions list. -+ var dynamicops = net.minecraft.resources.RegistryOps.create(net.minecraft.nbt.NbtOps.INSTANCE, p_308589_.datapackWorldgen()); ++ var dynamicops = net.minecraft.resources.RegistryOps.create(net.minecraft.nbt.NbtOps.INSTANCE, p_358511_.datapackWorldgen()); + worlddimensions = WorldDimensions.CODEC.encoder() + .encodeStart(dynamicops, worlddimensions) + .flatMap((writtenPayloadWithModdedDimensions) -> @@ -96,7 +96,7 @@ + .orElse(worlddimensions); + WorldDimensions.Complete worlddimensions$complete = worlddimensions.bake(registry); - Lifecycle lifecycle = worlddimensions$complete.lifecycle().add(p_308589_.datapackWorldgen().allRegistriesLifecycle()); + Lifecycle lifecycle = worlddimensions$complete.lifecycle().add(p_358511_.datapackWorldgen().allRegistriesLifecycle()); return new WorldLoader.DataLoadOutput<>( @@ -244,9 +_,16 @@ diff --git a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch index 7cd2453a73..2cbe540287 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 -@@ -264,7 +_,7 @@ +@@ -275,7 +_,7 @@ public static S spin(Function p_129873_) { AtomicReference atomicreference = new AtomicReference<>(); @@ -9,7 +9,7 @@ thread.setUncaughtExceptionHandler((p_177909_, p_177910_) -> LOGGER.error("Uncaught exception in server thread", p_177910_)); if (Runtime.getRuntime().availableProcessors() > 4) { thread.setPriority(8); -@@ -367,6 +_,7 @@ +@@ -381,6 +_,7 @@ this.readScoreboard(dimensiondatastorage); this.commandStorage = new CommandStorage(dimensiondatastorage); WorldBorder worldborder = serverlevel.getWorldBorder(); @@ -17,7 +17,7 @@ if (!serverleveldata.isInitialized()) { try { setInitialSpawn(serverlevel, serverleveldata, worldoptions.generateBonusChest(), flag); -@@ -416,6 +_,7 @@ +@@ -430,6 +_,7 @@ ); worldborder.addListener(new BorderChangeListener.DelegateBorderChangeListener(serverlevel1.getWorldBorder())); this.levels.put(resourcekey1, serverlevel1); @@ -25,15 +25,15 @@ } } -@@ -427,6 +_,7 @@ +@@ -441,6 +_,7 @@ p_177898_.setSpawn(BlockPos.ZERO.above(80), 0.0F); } else { ServerChunkCache serverchunkcache = p_177897_.getChunkSource(); + if (net.minecraftforge.event.ForgeEventFactory.onCreateWorldSpawn(p_177897_, p_177898_)) return; ChunkPos chunkpos = new ChunkPos(serverchunkcache.randomState().sampler().findSpawnPosition()); int i = serverchunkcache.getGenerator().getSpawnHeight(p_177897_); - if (i < p_177897_.getMinBuildHeight()) { -@@ -508,6 +_,7 @@ + if (i < p_177897_.getMinY()) { +@@ -522,6 +_,7 @@ ChunkPos chunkpos = new ChunkPos(k); serverlevel1.getChunkSource().updateChunkForced(chunkpos, true); } @@ -41,7 +41,7 @@ } } -@@ -615,6 +_,7 @@ +@@ -629,6 +_,7 @@ for (ServerLevel serverlevel2 : this.getAllLevels()) { if (serverlevel2 != null) { try { @@ -49,7 +49,7 @@ serverlevel2.close(); } catch (IOException ioexception1) { LOGGER.error("Exception closing the level", (Throwable)ioexception1); -@@ -661,9 +_,11 @@ +@@ -675,9 +_,11 @@ throw new IllegalStateException("Failed to initialize server"); } @@ -61,16 +61,16 @@ while (this.running) { long i; -@@ -708,6 +_,8 @@ +@@ -729,6 +_,8 @@ this.isReady = true; JvmProfiler.INSTANCE.onServerTick(this.smoothedTickTimeMillis); } + net.minecraftforge.server.ServerLifecycleHooks.handleServerStopping(this); + net.minecraftforge.server.ServerLifecycleHooks.expectServerStopped(); // Forge: Has to come before MinecraftServer#onServerCrash to avoid race conditions - } catch (Throwable throwable1) { - LOGGER.error("Encountered an unexpected exception", throwable1); - CrashReport crashreport = constructOrExtractCrashReport(throwable1); -@@ -719,6 +_,7 @@ + } catch (Throwable throwable2) { + LOGGER.error("Encountered an unexpected exception", throwable2); + CrashReport crashreport = constructOrExtractCrashReport(throwable2); +@@ -740,6 +_,7 @@ LOGGER.error("We were unable to save this crash report to disk."); } @@ -78,7 +78,7 @@ this.onServerCrash(crashreport); } finally { try { -@@ -731,6 +_,7 @@ +@@ -752,6 +_,7 @@ this.services.profileCache().clearExecutor(); } @@ -86,10 +86,10 @@ this.onServerExit(); } } -@@ -894,12 +_,14 @@ +@@ -941,12 +_,14 @@ + } + } - public void tickServer(BooleanSupplier p_129871_) { - long i = Util.getNanos(); + net.minecraftforge.event.ForgeEventFactory.onPreServerTick(p_129871_, this); this.tickCount++; this.tickRateManager.tick(); @@ -101,15 +101,15 @@ } this.ticksUntilAutosave--; -@@ -921,6 +_,7 @@ - this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float)j / (float)TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F; +@@ -964,6 +_,7 @@ + this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float)k / (float)TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F; this.logTickMethodTime(i); - this.profiler.pop(); + profilerfiller.pop(); + net.minecraftforge.event.ForgeEventFactory.onPostServerTick(p_129871_, this); } - private void logTickMethodTime(long p_331549_) { -@@ -960,7 +_,8 @@ + private void autoSave() { +@@ -1013,7 +_,8 @@ Optional.of(serverstatus$players), Optional.of(ServerStatus.Version.current()), Optional.ofNullable(this.statusIcon), @@ -119,45 +119,45 @@ ); } -@@ -990,7 +_,8 @@ +@@ -1044,7 +_,8 @@ this.getFunctions().tick(); - this.profiler.popPush("levels"); + profilerfiller.popPush("levels"); - for (ServerLevel serverlevel : this.getAllLevels()) { + for (ServerLevel serverlevel : this.getWorldArray()) { + long tickStart = Util.getNanos(); - this.profiler.push(() -> serverlevel + " " + serverlevel.dimension().location()); + profilerfiller.push(() -> serverlevel + " " + serverlevel.dimension().location()); if (this.tickCount % 20 == 0) { - this.profiler.push("timeSync"); -@@ -999,6 +_,7 @@ + profilerfiller.push("timeSync"); +@@ -1053,6 +_,7 @@ } - this.profiler.push("tick"); + profilerfiller.push("tick"); + net.minecraftforge.event.ForgeEventFactory.onPreLevelTick(serverlevel, p_129954_); try { serverlevel.tick(p_129954_); -@@ -1007,16 +_,18 @@ +@@ -1061,16 +_,18 @@ serverlevel.fillReportDetails(crashreport); throw new ReportedException(crashreport); } + net.minecraftforge.event.ForgeEventFactory.onPostLevelTick(serverlevel, p_129954_); - this.profiler.pop(); - this.profiler.pop(); + profilerfiller.pop(); + profilerfiller.pop(); + perWorldTickTimes.computeIfAbsent(serverlevel.dimension(), k -> new long[100])[this.tickCount % 100] = Util.getNanos() - tickStart; } - this.profiler.popPush("connection"); - this.getConnection().tick(); - this.profiler.popPush("players"); + profilerfiller.popPush("connection"); + this.tickConnection(); + profilerfiller.popPush("players"); this.playerList.tick(); - if (SharedConstants.IS_RUNNING_IN_IDE && this.tickRateManager.runsNormally()) { + if (net.minecraftforge.gametest.ForgeGameTestHooks.isGametestEnabled() && this.tickRateManager.runsNormally()) { GameTestTicker.SINGLETON.tick(); } -@@ -1112,7 +_,7 @@ +@@ -1171,7 +_,7 @@ @DontObfuscate public String getServerModName() { @@ -166,15 +166,15 @@ } public SystemReport fillSystemReport(SystemReport p_177936_) { -@@ -1467,6 +_,7 @@ - this.getPlayerList().reloadResources(); +@@ -1523,6 +_,7 @@ this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary()); this.structureTemplateManager.onResourceManagerReload(this.resources.resourceManager); + this.fuelValues = FuelValues.vanillaBurnTimes(this.registries.compositeAccess(), this.worldData.enabledFeatures()); + this.getPlayerList().getPlayers().forEach(this.getPlayerList()::sendPlayerPermissionLevel); //Forge: Fix newly added/modified commands not being sent to the client when commands reload. }, this); if (this.isSameThread()) { this.managedBlock(completablefuture::isDone); -@@ -1476,12 +_,15 @@ +@@ -1532,12 +_,15 @@ } public static WorldDataConfiguration configurePackRepository(PackRepository p_248681_, WorldDataConfiguration p_331931_, boolean p_249869_, boolean p_330480_) { @@ -191,7 +191,7 @@ } else { Set set = Sets.newLinkedHashSet(); -@@ -1982,6 +_,48 @@ +@@ -2041,6 +_,48 @@ public ServerLinks serverLinks() { return ServerLinks.EMPTY; @@ -239,4 +239,4 @@ + return resources; } - public static record ReloadableResources(CloseableResourceManager resourceManager, ReloadableServerResources managers) implements AutoCloseable { + protected int pauseWhileEmptySeconds() { diff --git a/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch b/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch index 010a3a816e..29ec4b54ef 100644 --- a/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch +++ b/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch @@ -7,9 +7,9 @@ + net.minecraftforge.event.ForgeEventFactory.onAdvancementGrant(this.player, p_298135_, advancementprogress, p_135990_); if (!flag1 && advancementprogress.isDone()) { p_298135_.value().rewards().grant(this.player); - p_298135_.value().display().ifPresent(p_341116_ -> { + p_298135_.value().display().ifPresent(p_358518_ -> { @@ -180,6 +_,7 @@ - this.playerList.broadcastSystemMessage(p_341116_.getType().createAnnouncement(p_298135_, this.player), false); + this.playerList.broadcastSystemMessage(p_358518_.getType().createAnnouncement(p_298135_, this.player), false); } }); + net.minecraftforge.event.ForgeEventFactory.onAdvancementEarned(this.player, p_298135_); diff --git a/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch b/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch index ce7f05cf3a..5385db346e 100644 --- a/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch +++ b/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch @@ -1,30 +1,31 @@ --- a/net/minecraft/server/ReloadableServerResources.java +++ b/net/minecraft/server/ReloadableServerResources.java -@@ -39,15 +_,18 @@ - private final TagManager tagManager; +@@ -26,6 +_,7 @@ private final ServerAdvancementManager advancements; private final ServerFunctionLibrary functionLibrary; + private final List> postponedTags; + private final net.minecraftforge.common.crafting.conditions.ICondition.IContext context; - private ReloadableServerResources(RegistryAccess.Frozen p_206857_, FeatureFlagSet p_250695_, Commands.CommandSelection p_206858_, int p_206859_) { - this.fullRegistryHolder = new ReloadableServerRegistries.Holder(p_206857_); - this.registryLookup = new ReloadableServerResources.ConfigurableRegistryLookup(p_206857_); - this.registryLookup.missingTagAccessPolicy(ReloadableServerResources.MissingTagAccessPolicy.CREATE_NEW); -- this.recipes = new RecipeManager(this.registryLookup); - this.tagManager = new TagManager(p_206857_); - this.commands = new Commands(p_206858_, CommandBuildContext.simple(this.registryLookup, p_250695_)); -- this.advancements = new ServerAdvancementManager(this.registryLookup); + private ReloadableServerResources( + LayeredRegistryAccess p_368059_, +@@ -37,9 +_,11 @@ + ) { + this.fullRegistryHolder = new ReloadableServerRegistries.Holder(p_368059_.compositeAccess()); + this.postponedTags = p_364269_; +- this.recipes = new RecipeManager(p_363207_); + this.commands = new Commands(p_206858_, CommandBuildContext.simple(p_363207_, p_250695_)); +- this.advancements = new ServerAdvancementManager(p_363207_); + // Forge: Create context object and pass it to the recipe manager. -+ this.context = new net.minecraftforge.common.crafting.conditions.ConditionContext(this.tagManager); -+ this.recipes = new RecipeManager(this.registryLookup, this.context); -+ this.advancements = new ServerAdvancementManager(this.registryLookup, this.context); ++ this.context = new net.minecraftforge.common.crafting.conditions.ConditionContext(this.postponedTags); ++ this.recipes = new RecipeManager(p_363207_, this.context); ++ this.advancements = new ServerAdvancementManager(p_363207_, this.context); this.functionLibrary = new ServerFunctionLibrary(p_206859_, this.commands.getDispatcher()); } -@@ -88,8 +_,10 @@ - .thenCompose( - p_326196_ -> { - ReloadableServerResources reloadableserverresources = new ReloadableServerResources(p_326196_.compositeAccess(), p_250212_, p_249301_, p_251126_); +@@ -83,8 +_,10 @@ + ReloadableServerResources reloadableserverresources = new ReloadableServerResources( + p_358539_.layers(), p_358539_.lookupWithUpdatedTags(), p_250212_, p_249301_, p_366334_, p_251126_ + ); + var listeners = new java.util.ArrayList<>(reloadableserverresources.listeners()); + listeners.addAll(net.minecraftforge.event.ForgeEventFactory.onResourceReload(reloadableserverresources, p_330376_.compositeAccess())); return SimpleReloadInstance.create( @@ -32,19 +33,11 @@ + p_248588_, listeners, p_249136_, p_249601_, DATA_RELOAD_INITIAL_TASK, LOGGER.isDebugEnabled() ) .done() - .whenComplete( -@@ -104,6 +_,7 @@ - this.tagManager.getResult().forEach(p_326197_ -> updateRegistryTags(this.fullRegistryHolder.get(), (TagManager.LoadResult)p_326197_)); - AbstractFurnaceBlockEntity.invalidateCache(); - Blocks.rebuildCache(); -+ net.minecraftforge.event.ForgeEventFactory.onTagsUpdated(this.fullRegistryHolder.get(), false, false); - } + .thenApply(p_214306_ -> reloadableserverresources); +@@ -94,5 +_,14 @@ - private static void updateRegistryTags(RegistryAccess p_206871_, TagManager.LoadResult p_206872_) { -@@ -115,6 +_,15 @@ - Collectors.toUnmodifiableMap(p_214303_ -> TagKey.create(resourcekey, p_214303_.getKey()), p_214312_ -> List.copyOf(p_214312_.getValue())) - ); - p_206871_.registryOrThrow(resourcekey).bindTags(map); + public void updateStaticRegistryTags() { + this.postponedTags.forEach(Registry.PendingTags::apply); + } + + /** @@ -55,5 +48,4 @@ + public net.minecraftforge.common.crafting.conditions.ICondition.IContext getConditionContext() { + return this.context; } - - static class ConfigurableRegistryLookup implements HolderLookup.Provider { + } diff --git a/patches/minecraft/net/minecraft/server/ServerAdvancementManager.java.patch b/patches/minecraft/net/minecraft/server/ServerAdvancementManager.java.patch index e70f38f5b7..fc1d5acac1 100644 --- a/patches/minecraft/net/minecraft/server/ServerAdvancementManager.java.patch +++ b/patches/minecraft/net/minecraft/server/ServerAdvancementManager.java.patch @@ -1,35 +1,21 @@ --- a/net/minecraft/server/ServerAdvancementManager.java +++ b/net/minecraft/server/ServerAdvancementManager.java -@@ -32,10 +_,18 @@ - private Map advancements = Map.of(); +@@ -26,8 +_,17 @@ private AdvancementTree tree = new AdvancementTree(); private final HolderLookup.Provider registries; -+ private final net.minecraftforge.common.crafting.conditions.ICondition.IContext context; //Forge: add context -+ /** @deprecated Forge: use {@linkplain ServerAdvancementManager#ServerAdvancementManager(LootDataManager, net.minecraftforge.common.crafting.conditions.ICondition.IContext) constructor with context}. */ -+ @Deprecated ++ /** @deprecated Forge: use {@linkplain ServerAdvancementManager#ServerAdvancementManager(net.minecraftforge.common.crafting.conditions.ICondition.IContext) constructor with context}. */ public ServerAdvancementManager(HolderLookup.Provider p_336198_) { +- super(p_336198_, Advancement.CODEC, Registries.elementsDirPath(Registries.ADVANCEMENT)); + this(p_336198_, net.minecraftforge.common.crafting.conditions.ICondition.IContext.EMPTY); + } + + public ServerAdvancementManager(HolderLookup.Provider p_336198_, net.minecraftforge.common.crafting.conditions.ICondition.IContext context) { - super(GSON, Registries.elementsDirPath(Registries.ADVANCEMENT)); ++ super( ++ p_336198_.createSerializationContext(com.mojang.serialization.JsonOps.INSTANCE) ++ .>withContext( ++ net.minecraftforge.common.crafting.conditions.ICondition.IContext.KEY, context ++ ), Advancement.CODEC, Registries.elementsDirPath(Registries.ADVANCEMENT)); this.registries = p_336198_; -+ this.context = context; } - protected void apply(Map p_136034_, ResourceManager p_136035_, ProfilerFiller p_136036_) { -@@ -43,7 +_,12 @@ - Builder builder = ImmutableMap.builder(); - p_136034_.forEach((p_326203_, p_326204_) -> { - try { -- Advancement advancement = Advancement.CODEC.parse(registryops, p_326204_).getOrThrow(JsonParseException::new); -+ var json = net.minecraftforge.common.ForgeHooks.readConditionalAdvancement(registryops, (com.google.gson.JsonObject)p_326204_); -+ if (json == null) { -+ LOGGER.debug("Skipping loading advancement {} as its conditions were not met", p_326204_); -+ return; -+ } -+ Advancement advancement = Advancement.CODEC.parse(registryops, json).getOrThrow(JsonParseException::new); - this.validate(p_326203_, advancement); - builder.put(p_326203_, new AdvancementHolder(p_326203_, advancement)); - } catch (Exception exception) { diff --git a/patches/minecraft/net/minecraft/server/commands/SpreadPlayersCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/SpreadPlayersCommand.java.patch index 34aa9d369a..d14347a016 100644 --- a/patches/minecraft/net/minecraft/server/commands/SpreadPlayersCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/SpreadPlayersCommand.java.patch @@ -20,4 +20,4 @@ + event.getTargetZ(), Set.of(), entity.getYRot(), - entity.getXRot() + entity.getXRot(), diff --git a/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch index 21cfb08708..cd4a8fa277 100644 --- a/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/server/commands/TeleportCommand.java +++ b/net/minecraft/server/commands/TeleportCommand.java -@@ -269,6 +_,9 @@ +@@ -277,6 +_,9 @@ float p_139023_, - @Nullable TeleportCommand.LookAt p_139024_ + @Nullable LookAt p_365991_ ) throws CommandSyntaxException { -+ net.minecraftforge.event.entity.EntityTeleportEvent.TeleportCommand event = net.minecraftforge.event.ForgeEventFactory.onEntityTeleportCommand(p_139016_, p_139018_, p_139019_, p_139020_); ++ var event = net.minecraftforge.event.ForgeEventFactory.onEntityTeleportCommand(p_139016_, p_139018_, p_139019_, p_139020_); + if (event.isCanceled()) return; + p_139018_ = event.getTargetX(); p_139019_ = event.getTargetY(); p_139020_ = event.getTargetZ(); BlockPos blockpos = BlockPos.containing(p_139018_, p_139019_, p_139020_); diff --git a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch index 1b4d4e76a0..cdc1aeba92 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 -@@ -80,6 +_,8 @@ +@@ -79,6 +_,8 @@ @Nullable private DebugSampleSubscriptionTracker debugSampleSubscriptionTracker; private final ServerLinks serverLinks; @@ -9,7 +9,7 @@ public DedicatedServer( Thread p_214789_, -@@ -103,6 +_,7 @@ +@@ -102,6 +_,7 @@ Thread thread = new Thread("Server console handler") { @Override public void run() { @@ -17,7 +17,7 @@ BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); String s1; -@@ -183,11 +_,13 @@ +@@ -182,11 +_,13 @@ long i = Util.getNanos(); SkullBlockEntity.setup(this.services, this); GameProfileCache.setUsesAuthentication(this.usesAuthentication()); @@ -31,7 +31,7 @@ if (dedicatedserverproperties.announcePlayerAchievements != null) { this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS).set(dedicatedserverproperties.announcePlayerAchievements, this); } -@@ -215,7 +_,12 @@ +@@ -214,7 +_,12 @@ LOGGER.info("JMX monitoring enabled"); } @@ -45,7 +45,7 @@ } } -@@ -293,6 +_,11 @@ +@@ -275,6 +_,11 @@ if (this.queryThreadGs4 != null) { this.queryThreadGs4.stop(); } @@ -57,7 +57,7 @@ } @Override -@@ -546,7 +_,12 @@ +@@ -528,7 +_,12 @@ @Override public void stopServer() { diff --git a/patches/minecraft/net/minecraft/server/dedicated/ServerWatchdog.java.patch b/patches/minecraft/net/minecraft/server/dedicated/ServerWatchdog.java.patch index f5a7f6692e..24d22b6512 100644 --- a/patches/minecraft/net/minecraft/server/dedicated/ServerWatchdog.java.patch +++ b/patches/minecraft/net/minecraft/server/dedicated/ServerWatchdog.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/dedicated/ServerWatchdog.java +++ b/net/minecraft/server/dedicated/ServerWatchdog.java -@@ -49,7 +_,7 @@ - ThreadMXBean threadmxbean = ManagementFactory.getThreadMXBean(); - ThreadInfo[] athreadinfo = threadmxbean.dumpAllThreads(true, true); - StringBuilder stringbuilder = new StringBuilder(); -- Error error = new Error("Watchdog"); -+ Error error = new Error(String.format(java.util.Locale.ENGLISH, "ServerHangWatchdog detected that a single server tick took %.2f seconds (should be max 0.05)", k / 1000F)); // Forge: don't just make a crash report with a seemingly-inexplicable Error +@@ -78,7 +_,7 @@ + ThreadMXBean threadmxbean = ManagementFactory.getThreadMXBean(); + ThreadInfo[] athreadinfo = threadmxbean.dumpAllThreads(true, true); + StringBuilder stringbuilder = new StringBuilder(); +- Error error = new Error("Watchdog"); ++ Error error = new Error(String.format(java.util.Locale.ENGLISH, "ServerHangWatchdog detected that a single server tick took too long")); // Forge: don't just make a crash report with a seemingly-inexplicable Error - for (ThreadInfo threadinfo : athreadinfo) { - if (threadinfo.getThreadId() == this.server.getRunningThread().getId()) { + for (ThreadInfo threadinfo : athreadinfo) { + if (threadinfo.getThreadId() == p_368427_) { diff --git a/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch b/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch index 2885a9d41a..987f9b20bd 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 -@@ -388,6 +_,7 @@ +@@ -393,6 +_,7 @@ this.modified = true; } @@ -8,7 +8,7 @@ return p_140179_; } } -@@ -498,6 +_,7 @@ +@@ -519,6 +_,7 @@ if (this.pendingUnloads.remove(p_140182_, p_140183_) && chunkaccess != null) { if (chunkaccess instanceof LevelChunk levelchunk) { levelchunk.setLoaded(false); @@ -16,15 +16,15 @@ } this.save(chunkaccess); -@@ -744,6 +_,7 @@ - - this.level.getProfiler().incrementCounter("chunkSave"); - CompoundTag compoundtag = ChunkSerializer.write(this.level, p_140259_); -+ net.minecraftforge.event.ForgeEventFactory.onChunkDataSave(p_140259_, p_140259_.getWorldForge() != null ? p_140259_.getWorldForge() : this.level, compoundtag); - this.write(chunkpos, compoundtag).exceptionally(p_341222_ -> { - this.level.getServer().reportChunkSaveFailure(p_341222_, this.storageInfo(), chunkpos); - return null; -@@ -1061,7 +_,7 @@ +@@ -769,6 +_,7 @@ + this.activeChunkWrites.incrementAndGet(); + SerializableChunkData serializablechunkdata = SerializableChunkData.copyOf(this.level, p_140259_); + CompletableFuture completablefuture = CompletableFuture.supplyAsync(serializablechunkdata::write, Util.backgroundExecutor()); ++ net.minecraftforge.event.ForgeEventFactory.onChunkDataSave(p_140259_, p_140259_.getWorldForge() != null ? p_140259_.getWorldForge() : this.level, serializablechunkdata); + this.write(chunkpos, completablefuture::join).handle((p_358676_, p_358677_) -> { + if (p_358677_ != null) { + this.level.getServer().reportChunkSaveFailure(p_358677_, this.storageInfo(), chunkpos); +@@ -1102,7 +_,7 @@ } protected void addEntity(Entity p_140200_) { diff --git a/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch b/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch index 3b597e1c22..870608f05b 100644 --- a/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch +++ b/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/level/DistanceManager.java +++ b/net/minecraft/server/level/DistanceManager.java -@@ -53,6 +_,7 @@ +@@ -50,6 +_,7 @@ final Executor mainThreadExecutor; private long ticketTickCounter; private int simulationDistance = 10; + private final Long2ObjectOpenHashMap>> forcedTickets = new Long2ObjectOpenHashMap<>(); protected DistanceManager(Executor p_140774_, Executor p_140775_) { - ProcessorHandle processorhandle = ProcessorHandle.of("player ticket throttler", p_140775_::execute); -@@ -152,6 +_,11 @@ + TaskScheduler taskscheduler = TaskScheduler.wrapExecutor("player ticket throttler", p_140775_); +@@ -150,6 +_,11 @@ if (p_140786_.getTicketLevel() < i) { this.ticketTracker.update(p_140785_, p_140786_.getTicketLevel(), true); } @@ -20,7 +20,7 @@ } void removeTicket(long p_140819_, Ticket p_140820_) { -@@ -164,6 +_,14 @@ +@@ -162,6 +_,14 @@ } this.ticketTracker.update(p_140819_, getTicketLevelAt(sortedarrayset), false); @@ -35,7 +35,7 @@ } public void addTicket(TicketType p_140793_, ChunkPos p_140794_, int p_140795_, T p_140796_) { -@@ -176,14 +_,22 @@ +@@ -174,14 +_,22 @@ } public void addRegionTicket(TicketType p_140841_, ChunkPos p_140842_, int p_140843_, T p_140844_) { @@ -60,10 +60,10 @@ long i = p_140851_.toLong(); this.removeTicket(i, ticket); this.tickingTicketsTracker.removeTicket(i, ticket); -@@ -267,6 +_,11 @@ +@@ -270,6 +_,11 @@ public String getDebugStatus() { - return this.ticketThrottler.getDebugStatus(); + return this.ticketDispatcher.getDebugStatus(); + } + + public boolean shouldForceTicks(long chunkPos) { diff --git a/patches/minecraft/net/minecraft/server/level/GenerationChunkHolder.java.patch b/patches/minecraft/net/minecraft/server/level/GenerationChunkHolder.java.patch index 69e2783e59..89763996a3 100644 --- a/patches/minecraft/net/minecraft/server/level/GenerationChunkHolder.java.patch +++ b/patches/minecraft/net/minecraft/server/level/GenerationChunkHolder.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/level/GenerationChunkHolder.java +++ b/net/minecraft/server/level/GenerationChunkHolder.java -@@ -33,6 +_,9 @@ - private final AtomicReferenceArray>> futures = new AtomicReferenceArray<>(CHUNK_STATUSES.size()); +@@ -34,6 +_,9 @@ private final AtomicReference task = new AtomicReference<>(); private final AtomicInteger generationRefCount = new AtomicInteger(); + private volatile CompletableFuture generationSaveSyncFuture = CompletableFuture.completedFuture(null); + /** Forge: Used to bypass the future chain when loading chunks, because modders can do weird things that cause deadlocks, modders should never touch this **/ + @org.jetbrains.annotations.ApiStatus.Internal + public net.minecraft.world.level.chunk.LevelChunk currentlyLoading; diff --git a/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch b/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch index 162572d021..0b24fb64c0 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 -@@ -172,6 +_,10 @@ +@@ -187,6 +_,10 @@ if (chunkholder == null) { return null; } else { @@ -11,16 +11,7 @@ ChunkAccess chunkaccess1 = chunkholder.getChunkIfPresent(ChunkStatus.FULL); if (chunkaccess1 != null) { this.storeInCache(i, chunkaccess1, ChunkStatus.FULL); -@@ -342,7 +_,7 @@ - for (ServerChunkCache.ChunkAndHolder serverchunkcache$chunkandholder : list) { - LevelChunk levelchunk1 = serverchunkcache$chunkandholder.chunk; - ChunkPos chunkpos = levelchunk1.getPos(); -- if (this.level.isNaturalSpawningAllowed(chunkpos) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkpos)) { -+ if ((this.level.isNaturalSpawningAllowed(chunkpos) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkpos)) || this.distanceManager.shouldForceTicks(chunkpos.toLong())) { - levelchunk1.incrementInhabitedTime(j); - if (flag1 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkpos)) { - NaturalSpawner.spawnForChunk(this.level, levelchunk1, naturalspawner$spawnstate, this.spawnFriendlies, this.spawnEnemies, flag); -@@ -421,11 +_,19 @@ +@@ -466,11 +_,19 @@ } public void addRegionTicket(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 6cd7d89fe1..630433297c 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 -@@ -239,6 +_,7 @@ +@@ -278,6 +_,7 @@ public void removePairing(ServerPlayer p_8535_) { this.entity.stopSeenByPlayer(p_8535_); p_8535_.connection.send(new ClientboundRemoveEntitiesPacket(this.entity.getId())); @@ -8,7 +8,7 @@ } public void addPairing(ServerPlayer p_8542_) { -@@ -246,6 +_,7 @@ +@@ -285,6 +_,7 @@ this.sendPairingData(p_8542_, list::add); p_8542_.connection.send(new ClientboundBundlePacket(list)); this.entity.startSeenByPlayer(p_8542_); diff --git a/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch b/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch index b0ff12cccb..f7b1e1decd 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 -@@ -199,11 +_,12 @@ +@@ -202,11 +_,12 @@ private final List customSpawners; @Nullable private EndDragonFight dragonFight; @@ -14,7 +14,7 @@ public ServerLevel( MinecraftServer p_214999_, -@@ -286,6 +_,12 @@ +@@ -289,6 +_,12 @@ this.sleepStatus = new SleepStatus(); this.gameEventDispatcher = new GameEventDispatcher(this); this.randomSequences = Objects.requireNonNullElseGet(p_288977_, () -> this.getDataStorage().computeIfAbsent(RandomSequences.factory(i), "random_sequences")); @@ -27,7 +27,7 @@ } @Deprecated -@@ -326,8 +_,8 @@ +@@ -330,8 +_,8 @@ int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { @@ -38,7 +38,7 @@ } this.wakeUpAllPlayers(); -@@ -365,7 +_,8 @@ +@@ -369,7 +_,8 @@ this.handlingTick = false; profilerfiller.pop(); @@ -48,15 +48,15 @@ if (flag1) { this.resetEmptyTime(); } -@@ -396,6 +_,7 @@ - p_308944_.stopRiding(); +@@ -398,6 +_,7 @@ + p_358707_.stopRiding(); } -+ if (p_308944_.isRemoved() || p_308944_ instanceof net.minecraftforge.entity.PartEntity) return; ++ if (p_358707_.isRemoved() || p_358707_ instanceof net.minecraftforge.entity.PartEntity) return; profilerfiller.push("tick"); - this.guardEntityTick(this::tickNonPassenger, p_308944_); + this.guardEntityTick(this::tickNonPassenger, p_358707_); profilerfiller.pop(); -@@ -527,6 +_,7 @@ +@@ -525,6 +_,7 @@ BlockPos blockpos = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, p_300602_); BlockPos blockpos1 = blockpos.below(); Biome biome = this.getBiome(blockpos).value(); @@ -64,7 +64,7 @@ if (biome.shouldFreeze(this, blockpos1)) { this.setBlockAndUpdate(blockpos1, Blocks.ICE.defaultBlockState()); } -@@ -702,8 +_,8 @@ +@@ -700,8 +_,8 @@ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0.0F)); } @@ -75,23 +75,23 @@ } } -@@ -739,6 +_,7 @@ +@@ -738,6 +_,7 @@ p_8648_.tickCount++; - this.getProfiler().push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_8648_.getType()).toString()); + profilerfiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_8648_.getType()).toString()); profilerfiller.incrementCounter("tickNonPassenger"); + if (p_8648_.canUpdate()) p_8648_.tick(); - this.getProfiler().pop(); + profilerfiller.pop(); -@@ -756,6 +_,7 @@ - ProfilerFiller profilerfiller = this.getProfiler(); +@@ -755,6 +_,7 @@ + ProfilerFiller profilerfiller = Profiler.get(); profilerfiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_8664_.getType()).toString()); profilerfiller.incrementCounter("tickPassenger"); + if (p_8664_.canUpdate()) p_8664_.rideTick(); profilerfiller.pop(); -@@ -788,6 +_,7 @@ +@@ -787,6 +_,7 @@ } else { this.entityManager.autoSave(); } @@ -99,7 +99,7 @@ } } -@@ -877,6 +_,7 @@ +@@ -881,6 +_,7 @@ } private void addPlayer(ServerPlayer p_8854_) { @@ -107,7 +107,7 @@ Entity entity = this.getEntities().get(p_8854_.getUUID()); if (entity != null) { LOGGER.warn("Force-added player with duplicate UUID {}", p_8854_.getUUID()); -@@ -884,7 +_,8 @@ +@@ -888,7 +_,8 @@ this.removePlayerImmediately((ServerPlayer)entity, Entity.RemovalReason.DISCARDED); } @@ -117,7 +117,7 @@ } private boolean addEntity(Entity p_8873_) { -@@ -892,7 +_,12 @@ +@@ -896,7 +_,12 @@ LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityType.getKey(p_8873_.getType())); return false; } else { @@ -131,7 +131,7 @@ } } -@@ -940,6 +_,12 @@ +@@ -944,6 +_,12 @@ float p_263390_, long p_263403_ ) { @@ -144,7 +144,7 @@ this.server .getPlayerList() .broadcast( -@@ -957,6 +_,12 @@ +@@ -961,6 +_,12 @@ public void playSeededSound( @Nullable Player p_263545_, Entity p_263544_, Holder p_263491_, SoundSource p_263542_, float p_263530_, float p_263520_, long p_263490_ ) { @@ -157,7 +157,7 @@ this.server .getPlayerList() .broadcast( -@@ -1000,6 +_,7 @@ +@@ -1019,6 +_,7 @@ @Override public void gameEvent(Holder p_334475_, Vec3 p_215042_, GameEvent.Context p_215043_) { @@ -165,26 +165,49 @@ this.gameEventDispatcher.post(p_334475_, p_215042_, p_215043_); } -@@ -1038,11 +_,17 @@ +@@ -1057,16 +_,24 @@ @Override public void updateNeighborsAt(BlockPos p_215045_, Block p_215046_) { -+ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(this, p_215045_, this.getBlockState(p_215045_), java.util.EnumSet.allOf(Direction.class), false).isCanceled()) return; - this.neighborUpdater.updateNeighborsAtExceptFromFacing(p_215045_, p_215046_, null); ++ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(this, p_215045_, this.getBlockState(p_215045_), java.util.EnumSet.allOf(Direction.class), false)) ++ return; + this.updateNeighborsAt(p_215045_, p_215046_, ExperimentalRedstoneUtils.initialOrientation(this, null, null)); } @Override - public void updateNeighborsAtExceptFromFacing(BlockPos p_215052_, Block p_215053_, Direction p_215054_) { -+ java.util.EnumSet directions = java.util.EnumSet.allOf(Direction.class); -+ directions.remove(p_215054_); -+ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(this, p_215052_, this.getBlockState(p_215052_), directions, false).isCanceled()) { -+ return; -+ } - this.neighborUpdater.updateNeighborsAtExceptFromFacing(p_215052_, p_215053_, p_215054_); + public void updateNeighborsAt(BlockPos p_362530_, Block p_362552_, @Nullable Orientation p_367766_) { ++ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(this, p_362530_, this.getBlockState(p_362530_), java.util.EnumSet.allOf(Direction.class), false)) ++ return; + this.neighborUpdater.updateNeighborsAtExceptFromFacing(p_362530_, p_362552_, null, p_367766_); } -@@ -1660,6 +_,11 @@ - return crashreportcategory; + @Override + public void updateNeighborsAtExceptFromFacing(BlockPos p_215052_, Block p_215053_, Direction p_215054_, @Nullable Orientation p_370072_) { ++ var directions = java.util.EnumSet.allOf(Direction.class); ++ directions.remove(p_215054_); ++ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(this, p_215052_, this.getBlockState(p_215052_), directions, false)) ++ return; + this.neighborUpdater.updateNeighborsAtExceptFromFacing(p_215052_, p_215053_, p_215054_, p_370072_); + } + +@@ -1112,12 +_,14 @@ + Explosion.BlockInteraction explosion$blockinteraction = switch (p_255827_) { + case NONE -> Explosion.BlockInteraction.KEEP; + case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); +- case MOB -> this.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? this.getDestroyType(GameRules.RULE_MOB_EXPLOSION_DROP_DECAY) : Explosion.BlockInteraction.KEEP; ++ case MOB -> net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this, p_256039_) ? this.getDestroyType(GameRules.RULE_MOB_EXPLOSION_DROP_DECAY) : Explosion.BlockInteraction.KEEP; + case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY); + case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK; + }; + Vec3 vec3 = new Vec3(p_256067_, p_256370_, p_256153_); + ServerExplosion serverexplosion = new ServerExplosion(this, p_256039_, p_255778_, p_256002_, vec3, p_256045_, p_255686_, explosion$blockinteraction); ++ if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this, serverexplosion)) ++ return; + serverexplosion.explode(); + ParticleOptions particleoptions = serverexplosion.isSmall() ? p_310962_ : p_310322_; + +@@ -1691,6 +_,11 @@ + return this.chunkSource.getGenerator().getSeaLevel(); } + @Override @@ -195,7 +218,7 @@ final class EntityCallbacks implements LevelCallback { public void onCreated(Entity p_143355_) { } -@@ -1694,8 +_,8 @@ +@@ -1725,8 +_,8 @@ ServerLevel.this.navigatingMobs.add(mob); } @@ -206,7 +229,7 @@ ServerLevel.this.dragonParts.put(enderdragonpart.getId(), enderdragonpart); } } -@@ -1721,13 +_,16 @@ +@@ -1752,13 +_,16 @@ ServerLevel.this.navigatingMobs.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 f580d5f603..74dc4ea541 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 -@@ -162,7 +_,8 @@ +@@ -181,7 +_,8 @@ import net.minecraft.world.scores.criteria.ObjectiveCriteria; import org.slf4j.Logger; @@ -10,40 +10,40 @@ private static final Logger LOGGER = LogUtils.getLogger(); private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_XZ = 32; private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y = 10; -@@ -653,6 +_,7 @@ +@@ -846,6 +_,7 @@ @Override public void die(DamageSource p_9035_) { + if (net.minecraftforge.event.ForgeEventFactory.onLivingDeath(this, p_9035_)) return; this.gameEvent(GameEvent.ENTITY_DIE); - boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); + boolean flag = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); if (flag) { -@@ -849,6 +_,7 @@ +@@ -1041,6 +_,7 @@ + @Nullable - @Override - public Entity changeDimension(DimensionTransition p_344993_) { -+ if (net.minecraftforge.event.ForgeEventFactory.onTravelToDimension(this, p_344993_.newLevel().dimension())) return null; + public ServerPlayer teleport(TeleportTransition p_361322_) { ++ if (net.minecraftforge.event.ForgeEventFactory.onTravelToDimension(this, p_361322_.newLevel().dimension())) return null; if (this.isRemoved()) { return null; } else { -@@ -879,7 +_,7 @@ +@@ -1068,7 +_,7 @@ PlayerList playerlist = this.server.getPlayerList(); playerlist.sendPlayerPermissionLevel(this); serverlevel1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); - this.unsetRemoved(); + this.revive(); - serverlevel1.getProfiler().push("moving"); + ProfilerFiller profilerfiller = Profiler.get(); + profilerfiller.push("moving"); if (resourcekey == Level.OVERWORLD && serverlevel.dimension() == Level.NETHER) { - this.enteredNetherPosition = this.position(); -@@ -908,6 +_,7 @@ +@@ -1092,6 +_,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; -+ net.minecraftforge.event.ForgeEventFactory.onPlayerChangedDimension(this, resourcekey, p_344993_.newLevel().dimension()); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerChangedDimension(this, resourcekey, p_361322_.newLevel().dimension()); return this; } } -@@ -943,6 +_,9 @@ +@@ -1132,6 +_,9 @@ @Override public Either startSleepInBed(BlockPos p_9115_) { @@ -53,7 +53,7 @@ Direction direction = this.level().getBlockState(p_9115_).getValue(HorizontalDirectionalBlock.FACING); if (this.isSleeping() || !this.isAlive()) { return Either.left(Player.BedSleepingProblem.OTHER_PROBLEM); -@@ -954,7 +_,7 @@ +@@ -1143,7 +_,7 @@ return Either.left(Player.BedSleepingProblem.OBSTRUCTED); } else { this.setRespawnPosition(this.level().dimension(), p_9115_, this.getYRot(), false, true); @@ -62,7 +62,7 @@ return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW); } else { if (!this.isCreative()) { -@@ -1000,6 +_,7 @@ +@@ -1189,6 +_,7 @@ } private boolean bedInRange(BlockPos p_9117_, Direction p_9118_) { @@ -70,7 +70,7 @@ return this.isReachableBedBlock(p_9117_) || this.isReachableBedBlock(p_9117_.relative(p_9118_.getOpposite())); } -@@ -1114,6 +_,7 @@ +@@ -1303,6 +_,7 @@ this.connection.send(new ClientboundOpenScreenPacket(abstractcontainermenu.containerId, abstractcontainermenu.getType(), p_9033_.getDisplayName())); this.initMenu(abstractcontainermenu); this.containerMenu = abstractcontainermenu; @@ -78,7 +78,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1163,6 +_,7 @@ +@@ -1352,6 +_,7 @@ public void doCloseContainer() { this.containerMenu.removed(this); this.inventoryMenu.transferState(this.containerMenu); @@ -86,7 +86,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -1395,6 +_,15 @@ +@@ -1575,6 +_,15 @@ this.setShoulderEntityLeft(p_9016_.getShoulderEntityLeft()); this.setShoulderEntityRight(p_9016_.getShoulderEntityRight()); this.setLastDeathLocation(p_9016_.getLastDeathLocation()); @@ -102,7 +102,7 @@ } @Override -@@ -1496,6 +_,7 @@ +@@ -1676,6 +_,7 @@ public boolean setGameMode(GameType p_143404_) { boolean flag = this.isSpectator(); @@ -110,7 +110,7 @@ if (!this.gameMode.changeGameModeForPlayer(p_143404_)) { return false; } else { -@@ -1642,6 +_,9 @@ +@@ -1840,6 +_,9 @@ public void setCamera(@Nullable Entity p_9214_) { Entity entity = this.getCamera(); this.camera = (Entity)(p_9214_ == null ? this : p_9214_); @@ -120,7 +120,7 @@ if (entity != this.camera) { if (this.camera.level() instanceof ServerLevel serverlevel) { this.teleportTo( -@@ -1680,7 +_,11 @@ +@@ -1878,7 +_,11 @@ @Nullable public Component getTabListDisplayName() { @@ -132,8 +132,8 @@ + return this.tabListDisplayName; } - @Override -@@ -1733,6 +_,9 @@ + public int getTabListOrder() { +@@ -1925,6 +_,9 @@ } public void setRespawnPosition(ResourceKey p_9159_, @Nullable BlockPos p_9160_, float p_9161_, boolean p_9162_, boolean p_9163_) { @@ -143,7 +143,7 @@ if (p_9160_ != null) { boolean flag = p_9160_.equals(this.respawnPosition) && p_9159_.equals(this.respawnDimension); if (p_9163_ && !flag) { -@@ -1790,6 +_,9 @@ +@@ -1982,6 +_,9 @@ if (itementity == null) { return null; } else { @@ -153,7 +153,7 @@ this.level().addFreshEntity(itementity); ItemStack itemstack = itementity.getItem(); if (p_9087_) { -@@ -1861,9 +_,12 @@ +@@ -2088,9 +_,12 @@ public boolean drop(boolean p_182295_) { Inventory inventory = this.getInventory(); @@ -166,8 +166,8 @@ + return net.minecraftforge.common.ForgeHooks.onPlayerTossEvent(this, itemstack, true) != null; } - public boolean allowsListing() { -@@ -1955,6 +_,75 @@ + @Override +@@ -2189,6 +_,75 @@ @Nullable public BlockPos getRaidOmenPosition() { return this.raidOmenPosition; diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch index 956b8ee582..83954ef15a 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -133,6 +_,10 @@ +@@ -131,6 +_,10 @@ } public void handleBlockBreakAction(BlockPos p_215120_, ServerboundPlayerActionPacket.Action p_215121_, Direction p_215122_, int p_215123_, int p_215124_) { @@ -10,8 +10,8 @@ + } if (!this.player.canInteractWithBlock(p_215120_, 1.0)) { this.debugLogging(p_215120_, false, p_215124_, "too far"); - } else if (p_215120_.getY() >= p_215123_) { -@@ -161,6 +_,7 @@ + } else if (p_215120_.getY() > p_215123_) { +@@ -159,6 +_,7 @@ float f = 1.0F; BlockState blockstate = this.level.getBlockState(p_215120_); if (!blockstate.isAir()) { @@ -19,7 +19,7 @@ EnchantmentHelper.onHitBlock( this.level, this.player.getMainHandItem(), -@@ -172,6 +_,7 @@ +@@ -170,6 +_,7 @@ p_343810_ -> this.player.onEquippedItemBroken(p_343810_, EquipmentSlot.MAINHAND) ); blockstate.attack(this.level, p_215120_, this.player); @@ -27,7 +27,7 @@ f = blockstate.getDestroyProgress(this.player, this.player.level(), p_215120_); } -@@ -238,7 +_,8 @@ +@@ -236,7 +_,8 @@ public boolean destroyBlock(BlockPos p_9281_) { BlockState blockstate1 = this.level.getBlockState(p_9281_); @@ -37,7 +37,7 @@ return false; } else { BlockEntity blockentity = this.level.getBlockEntity(p_9281_); -@@ -246,30 +_,47 @@ +@@ -244,30 +_,47 @@ if (block instanceof GameMasterBlock && !this.player.canUseGameMasterBlocks()) { this.level.sendBlockUpdated(p_9281_, blockstate1, blockstate1, 3); return false; @@ -92,16 +92,16 @@ } public InteractionResult useItem(ServerPlayer p_9262_, Level p_9263_, ItemStack p_9264_, InteractionHand p_9265_) { -@@ -278,6 +_,8 @@ - } else if (p_9262_.getCooldowns().isOnCooldown(p_9264_.getItem())) { +@@ -276,6 +_,8 @@ + } else if (p_9262_.getCooldowns().isOnCooldown(p_9264_)) { return InteractionResult.PASS; } else { + InteractionResult cancelResult = net.minecraftforge.common.ForgeHooks.onItemRightClick(p_9262_, p_9265_); + if (cancelResult != null) return cancelResult; int i = p_9264_.getCount(); int j = p_9264_.getDamageValue(); - InteractionResultHolder interactionresultholder = p_9264_.use(p_9263_, p_9262_, p_9265_); -@@ -310,6 +_,11 @@ + InteractionResult interactionresult = p_9264_.use(p_9263_, p_9262_, p_9265_); +@@ -314,6 +_,11 @@ if (!blockstate.getBlock().isEnabled(p_9267_.enabledFeatures())) { return InteractionResult.FAIL; } else if (this.gameModeForPlayer == GameType.SPECTATOR) { @@ -113,7 +113,7 @@ MenuProvider menuprovider = blockstate.getMenuProvider(p_9267_, blockpos); if (menuprovider != null) { p_9266_.openMenu(menuprovider); -@@ -318,10 +_,16 @@ +@@ -322,10 +_,16 @@ return InteractionResult.PASS; } } else { @@ -128,17 +128,17 @@ ItemStack itemstack = p_9268_.copy(); - if (!flag1) { + if (event.getUseBlock() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY && !flag1)) { - ItemInteractionResult iteminteractionresult = blockstate.useItemOn(p_9266_.getItemInHand(p_9269_), p_9267_, p_9266_, p_9269_, p_9270_); - if (iteminteractionresult.consumesAction()) { + InteractionResult interactionresult = blockstate.useItemOn(p_9266_.getItemInHand(p_9269_), p_9267_, p_9266_, p_9269_, p_9270_); + if (interactionresult.consumesAction()) { CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger(p_9266_, blockpos, itemstack); -@@ -337,8 +_,8 @@ +@@ -341,8 +_,8 @@ } } -- if (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_.getItem())) { +- if (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_)) { - UseOnContext useoncontext = new UseOnContext(p_9266_, p_9269_, p_9270_); -+ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_.getItem()))) { ++ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_))) { + if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) return InteractionResult.PASS; - InteractionResult interactionresult1; + InteractionResult interactionresult2; if (this.isCreative()) { int i = p_9268_.getCount(); diff --git a/patches/minecraft/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch index b574a6b213..2424aebd03 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -83,6 +_,7 @@ +@@ -90,6 +_,7 @@ @Override public void handleCustomPayload(ServerboundCustomPayloadPacket p_300164_) { @@ -8,7 +8,7 @@ } @Override -@@ -186,5 +_,9 @@ +@@ -193,5 +_,9 @@ protected CommonListenerCookie createCookie(ClientInformation p_297318_) { return new CommonListenerCookie(this.playerProfile(), this.latency, p_297318_, this.transferred); diff --git a/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 110fdcfeba..f3a9390aac 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 -@@ -1014,9 +_,10 @@ +@@ -1021,9 +_,10 @@ switch (serverboundplayeractionpacket$action) { case SWAP_ITEM_WITH_OFFHAND: if (!this.player.isSpectator()) { @@ -14,7 +14,7 @@ this.player.stopUsingItem(); } -@@ -1207,8 +_,9 @@ +@@ -1214,8 +_,9 @@ } CompletableFuture completablefuture = this.filterTextPacket(playerchatmessage.signedContent()); @@ -25,7 +25,7 @@ PlayerChatMessage playerchatmessage1 = playerchatmessage.withUnsignedContent(component).filter(p_296589_.mask()); this.broadcastChatMessage(playerchatmessage1); }); -@@ -1531,7 +_,7 @@ +@@ -1537,7 +_,7 @@ @Override public void onInteraction(InteractionHand p_143682_, Vec3 p_143683_) { @@ -34,7 +34,7 @@ } @Override -@@ -1812,6 +_,7 @@ +@@ -1847,6 +_,7 @@ @Override public void handleCustomPayload(ServerboundCustomPayloadPacket p_329963_) { 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 395fec336e..a1e4e7d2b5 100644 --- a/patches/minecraft/net/minecraft/server/packs/repository/PackRepository.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/repository/PackRepository.java.patch @@ -9,7 +9,7 @@ } public static String displayPackList(Collection p_331712_) { -@@ -115,6 +_,10 @@ +@@ -120,6 +_,10 @@ @Nullable public Pack getPack(String p_10508_) { return this.available.get(p_10508_); 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 00214f465c..7c0e20fde1 100644 --- a/patches/minecraft/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch @@ -1,11 +1,27 @@ --- a/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java +++ b/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java -@@ -49,4 +_,8 @@ +@@ -55,7 +_,13 @@ + ResourceLocation resourcelocation1 = filetoidconverter.fileToId(resourcelocation); + + try (Reader reader = entry.getValue().openAsReader()) { +- p_368755_.parse(p_369854_, JsonParser.parseReader(reader)).ifSuccess(p_370131_ -> { ++ var json = JsonParser.parseReader(reader); ++ json = net.minecraftforge.common.ForgeHooks.readConditional(p_369854_, json); ++ if (json == null) { ++ LOGGER.debug("Skipping loading {} as its conditions were not met", resourcelocation); ++ continue; ++ } ++ p_368755_.parse(p_369854_, json).ifSuccess(p_370131_ -> { + if (p_279404_.putIfAbsent(resourcelocation1, (T)p_370131_) != null) { + throw new IllegalStateException("Duplicate data file ignored with ID " + resourcelocation1); + } +@@ -64,5 +_,9 @@ + LOGGER.error("Couldn't parse data file '{}' from '{}'", resourcelocation1, resourcelocation, jsonparseexception); } } - } ++ } + + protected ResourceLocation getPreparedPath(ResourceLocation rl) { + return rl.withPath(this.directory + "/" + rl.getPath() + ".json"); -+ } + } } diff --git a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch index 286a187fdb..575f4babbd 100644 --- a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch +++ b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -128,6 +_,7 @@ +@@ -129,6 +_,7 @@ private boolean allowCommandsForAllPlayers; private static final boolean ALLOW_LOGOUTIVATOR = false; private int sendAllPlayerInfoIn; @@ -8,23 +8,23 @@ public PlayerList(MinecraftServer p_203842_, LayeredRegistryAccess p_251844_, PlayerDataStorage p_203844_, int p_203845_) { this.server = p_203842_; -@@ -199,6 +_,7 @@ - servergamepacketlistenerimpl.send(new ClientboundChangeDifficultyPacket(leveldata.getDifficulty(), leveldata.isDifficultyLocked())); +@@ -201,6 +_,7 @@ servergamepacketlistenerimpl.send(new ClientboundPlayerAbilitiesPacket(p_11263_.getAbilities())); - servergamepacketlistenerimpl.send(new ClientboundSetCarriedItemPacket(p_11263_.getInventory().selected)); + servergamepacketlistenerimpl.send(new ClientboundSetHeldSlotPacket(p_11263_.getInventory().selected)); + RecipeManager recipemanager = this.server.getRecipeManager(); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.OnDatapackSyncEvent(this, null)); - servergamepacketlistenerimpl.send(new ClientboundUpdateRecipesPacket(this.server.getRecipeManager().getOrderedRecipes())); + servergamepacketlistenerimpl.send(new ClientboundUpdateRecipesPacket(recipemanager.getSynchronizedItemProperties(), recipemanager.getSynchronizedStonecutterRecipes())); this.sendPlayerPermissionLevel(p_11263_); p_11263_.getStats().markAllDirty(); -@@ -261,6 +_,7 @@ - } - +@@ -232,6 +_,7 @@ + p_11263_.loadAndSpawnEnderpearls(optional1); + p_11263_.loadAndSpawnParentVehicle(optional1); p_11263_.initInventoryMenu(); + net.minecraftforge.event.ForgeEventFactory.firePlayerLoggedIn(p_11263_); } protected void updateEntireScoreboard(ServerScoreboard p_11274_, ServerPlayer p_11275_) { -@@ -326,6 +_,7 @@ +@@ -297,6 +_,7 @@ optional = Optional.of(compoundtag); p_11225_.load(compoundtag); LOGGER.debug("loading single player"); @@ -32,7 +32,7 @@ } else { optional = this.playerIo.load(p_11225_); } -@@ -334,6 +_,7 @@ +@@ -305,6 +_,7 @@ } protected void save(ServerPlayer p_11277_) { @@ -40,7 +40,7 @@ this.playerIo.save(p_11277_); ServerStatsCounter serverstatscounter = this.stats.get(p_11277_.getUUID()); if (serverstatscounter != null) { -@@ -347,6 +_,7 @@ +@@ -318,6 +_,7 @@ } public void remove(ServerPlayer p_11287_) { @@ -48,15 +48,15 @@ ServerLevel serverlevel = p_11287_.serverLevel(); p_11287_.awardStat(Stats.LEAVE_GAME); this.save(p_11287_); -@@ -467,6 +_,7 @@ +@@ -443,6 +_,7 @@ this.playersByUUID.put(serverplayer.getUUID(), serverplayer); serverplayer.initInventoryMenu(); serverplayer.setHealth(serverplayer.getHealth()); + net.minecraftforge.event.ForgeEventFactory.firePlayerRespawnEvent(serverplayer, p_11238_); - if (!p_11238_) { - BlockPos blockpos = BlockPos.containing(dimensiontransition.pos()); - BlockState blockstate = serverlevel.getBlockState(blockpos); -@@ -572,6 +_,7 @@ + BlockPos blockpos = serverplayer.getRespawnPosition(); + ServerLevel serverlevel2 = this.server.getLevel(serverplayer.getRespawnDimension()); + if (!p_11238_ && blockpos != null && serverlevel2 != null) { +@@ -549,6 +_,7 @@ } public void op(GameProfile p_11254_) { @@ -64,7 +64,7 @@ this.ops.add(new ServerOpListEntry(p_11254_, this.server.getOperatorUserPermissionLevel(), this.ops.canBypassPlayerLimit(p_11254_))); ServerPlayer serverplayer = this.getPlayer(p_11254_.getId()); if (serverplayer != null) { -@@ -580,6 +_,7 @@ +@@ -557,6 +_,7 @@ } public void deop(GameProfile p_11281_) { @@ -72,7 +72,7 @@ this.ops.remove(p_11281_); ServerPlayer serverplayer = this.getPlayer(p_11281_.getId()); if (serverplayer != null) { -@@ -793,13 +_,6 @@ +@@ -770,13 +_,6 @@ if (serverstatscounter == null) { File file1 = this.server.getWorldPath(LevelResource.PLAYER_STATS_DIR).toFile(); File file2 = new File(file1, uuid + ".json"); @@ -86,7 +86,7 @@ serverstatscounter = new ServerStatsCounter(this.server, file2); this.stats.put(uuid, serverstatscounter); -@@ -844,7 +_,7 @@ +@@ -821,7 +_,7 @@ } public List getPlayers() { @@ -95,11 +95,11 @@ } @Nullable -@@ -861,6 +_,7 @@ +@@ -838,6 +_,7 @@ playeradvancements.reload(this.server.getAdvancements()); } + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.OnDatapackSyncEvent(this, null)); this.broadcastAll(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(this.registries))); - ClientboundUpdateRecipesPacket clientboundupdaterecipespacket = new ClientboundUpdateRecipesPacket(this.server.getRecipeManager().getOrderedRecipes()); - + RecipeManager recipemanager = this.server.getRecipeManager(); + ClientboundUpdateRecipesPacket clientboundupdaterecipespacket = new ClientboundUpdateRecipesPacket(recipemanager.getSynchronizedItemProperties(), recipemanager.getSynchronizedStonecutterRecipes()); diff --git a/patches/minecraft/net/minecraft/stats/RecipeBookSettings.java.patch b/patches/minecraft/net/minecraft/stats/RecipeBookSettings.java.patch index dbf7d65162..40f1016c00 100644 --- a/patches/minecraft/net/minecraft/stats/RecipeBookSettings.java.patch +++ b/patches/minecraft/net/minecraft/stats/RecipeBookSettings.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/stats/RecipeBookSettings.java +++ b/net/minecraft/stats/RecipeBookSettings.java -@@ -11,7 +_,7 @@ - import net.minecraft.world.inventory.RecipeBookType; - - public final class RecipeBookSettings { +@@ -14,7 +_,7 @@ + public static final StreamCodec STREAM_CODEC = StreamCodec.ofMember( + RecipeBookSettings::write, RecipeBookSettings::read + ); - private static final Map> TAG_FIELDS = ImmutableMap.of( + private static final Map> TAG_FIELDS = new java.util.HashMap<>(ImmutableMap.of( RecipeBookType.CRAFTING, Pair.of("isGuiOpen", "isFilteringCraftable"), RecipeBookType.FURNACE, -@@ -20,7 +_,7 @@ +@@ -23,7 +_,7 @@ Pair.of("isBlastingFurnaceGuiOpen", "isBlastingFurnaceFilteringCraftable"), RecipeBookType.SMOKER, Pair.of("isSmokerGuiOpen", "isSmokerFilteringCraftable") @@ -18,9 +18,9 @@ private final Map states; private RecipeBookSettings(Map p_12730_) { -@@ -158,5 +_,10 @@ - public String toString() { - return "[open=" + this.open + ", filtering=" + this.filtering + "]"; +@@ -146,5 +_,10 @@ + public RecipeBookSettings.TypeSettings setFiltering(boolean p_366242_) { + return new RecipeBookSettings.TypeSettings(this.open, p_366242_); } + } + diff --git a/patches/minecraft/net/minecraft/tags/BannerPatternTags.java.patch b/patches/minecraft/net/minecraft/tags/BannerPatternTags.java.patch index 355a3d43c1..3e9f00ad8c 100644 --- a/patches/minecraft/net/minecraft/tags/BannerPatternTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/BannerPatternTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/BannerPatternTags.java +++ b/net/minecraft/tags/BannerPatternTags.java -@@ -21,4 +_,12 @@ +@@ -23,4 +_,12 @@ private static TagKey create(String p_215798_) { return TagKey.create(Registries.BANNER_PATTERN, ResourceLocation.withDefaultNamespace(p_215798_)); } diff --git a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch index 8581cb4546..40dec3ec8d 100644 --- a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/BlockTags.java +++ b/net/minecraft/tags/BlockTags.java -@@ -196,4 +_,12 @@ +@@ -198,4 +_,12 @@ private static TagKey create(String p_203847_) { return TagKey.create(Registries.BLOCK, ResourceLocation.withDefaultNamespace(p_203847_)); } diff --git a/patches/minecraft/net/minecraft/tags/DamageTypeTags.java.patch b/patches/minecraft/net/minecraft/tags/DamageTypeTags.java.patch index 6f2cd11ec6..0183498935 100644 --- a/patches/minecraft/net/minecraft/tags/DamageTypeTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/DamageTypeTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/DamageTypeTags.java +++ b/net/minecraft/tags/DamageTypeTags.java -@@ -42,4 +_,12 @@ +@@ -43,4 +_,12 @@ private static TagKey create(String p_270635_) { return TagKey.create(Registries.DAMAGE_TYPE, ResourceLocation.withDefaultNamespace(p_270635_)); } diff --git a/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch b/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch index d0abf71b84..abe499b01e 100644 --- a/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/EntityTypeTags.java +++ b/net/minecraft/tags/EntityTypeTags.java -@@ -43,4 +_,12 @@ +@@ -44,4 +_,12 @@ private static TagKey> create(String p_203849_) { return TagKey.create(Registries.ENTITY_TYPE, ResourceLocation.withDefaultNamespace(p_203849_)); } diff --git a/patches/minecraft/net/minecraft/tags/ItemTags.java.patch b/patches/minecraft/net/minecraft/tags/ItemTags.java.patch index 48c69a06a6..51f93d1c30 100644 --- a/patches/minecraft/net/minecraft/tags/ItemTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/ItemTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/ItemTags.java +++ b/net/minecraft/tags/ItemTags.java -@@ -159,4 +_,12 @@ +@@ -183,4 +_,12 @@ private static TagKey bind(String p_203855_) { return TagKey.create(Registries.ITEM, ResourceLocation.withDefaultNamespace(p_203855_)); } diff --git a/patches/minecraft/net/minecraft/tags/TagEntry.java.patch b/patches/minecraft/net/minecraft/tags/TagEntry.java.patch index 0519e7f3df..c0351dbc9b 100644 --- a/patches/minecraft/net/minecraft/tags/TagEntry.java.patch +++ b/patches/minecraft/net/minecraft/tags/TagEntry.java.patch @@ -18,4 +18,4 @@ + public interface Lookup { @Nullable - T element(ResourceLocation p_215956_); + T element(ResourceLocation p_215956_, boolean p_362986_); diff --git a/patches/minecraft/net/minecraft/tags/TagKey.java.patch b/patches/minecraft/net/minecraft/tags/TagKey.java.patch index f4fbc72a0c..555214864c 100644 --- a/patches/minecraft/net/minecraft/tags/TagKey.java.patch +++ b/patches/minecraft/net/minecraft/tags/TagKey.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/TagKey.java +++ b/net/minecraft/tags/TagKey.java -@@ -36,6 +_,10 @@ +@@ -42,6 +_,10 @@ return (TagKey)VALUES.intern(new TagKey<>(p_203883_, p_203884_)); } diff --git a/patches/minecraft/net/minecraft/tags/TagLoader.java.patch b/patches/minecraft/net/minecraft/tags/TagLoader.java.patch index d30dfc1f4f..420dbc738d 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 -@@ -57,6 +_,7 @@ +@@ -64,6 +_,7 @@ String s = resource.sourcePackId(); tagfile.entries().forEach(p_215997_ -> list.add(new TagLoader.EntryWithSource(p_215997_, s))); @@ -8,39 +8,38 @@ } catch (Exception exception) { LOGGER.error("Couldn't read tag list {} from {} in data pack {}", resourcelocation1, resourcelocation, resource.sourcePackId(), exception); } -@@ -67,16 +_,18 @@ +@@ -74,16 +_,17 @@ } - private Either, Collection> build(TagEntry.Lookup p_215979_, List p_215980_) { -- Builder builder = ImmutableSet.builder(); + private Either, List> tryBuildTag(TagEntry.Lookup p_215979_, List p_215980_) { +- SequencedSet sequencedset = new LinkedHashSet<>(); + var builder = new java.util.LinkedHashSet(); // Order is important, as ImmutableSet is ordered and some people rely on that. https://github.com/MinecraftForge/MinecraftForge/issues/9774 List list = new ArrayList<>(); for (TagLoader.EntryWithSource tagloader$entrywithsource : p_215980_) { -- if (!tagloader$entrywithsource.entry().build(p_215979_, builder::add)) { +- if (!tagloader$entrywithsource.entry().build(p_215979_, sequencedset::add)) { + if (!tagloader$entrywithsource.entry().build(p_215979_, tagloader$entrywithsource.remove() ? builder::remove : builder::add)) { + if (!tagloader$entrywithsource.remove()) // Treat all removals as optional at runtime. If it was missing, then it could of never been added. -+ list.add(tagloader$entrywithsource); } } -- return list.isEmpty() ? Either.right(builder.build()) : Either.left(list); +- return list.isEmpty() ? Either.right(List.copyOf(sequencedset)) : Either.left(list); + return list.isEmpty() ? Either.right(List.copyOf(builder)) : Either.left(list); } - public Map> build(Map> p_203899_) { -@@ -104,7 +_,7 @@ - p_215977_ -> LOGGER.error( + public Map> build(Map> p_203899_) { +@@ -111,7 +_,7 @@ + p_358772_ -> LOGGER.error( "Couldn't load tag {} as it is missing following references: {}", - p_284682_, -- p_215977_.stream().map(Objects::toString).collect(Collectors.joining(", ")) -+ p_215977_.stream().map(Objects::toString).collect(Collectors.joining(", \n\t")) + p_358780_, +- p_358772_.stream().map(Objects::toString).collect(Collectors.joining(", ")) ++ p_358772_.stream().map(Objects::toString).collect(Collectors.joining(", \n\t")) ) ) - .ifRight(p_216001_ -> map.put(p_284682_, (Collection)p_216001_)) -@@ -116,7 +_,11 @@ - return this.build(this.load(p_203901_)); + .ifRight(p_369415_ -> map.put(p_358780_, (List)p_369415_)) +@@ -188,7 +_,11 @@ + } } - public static record EntryWithSource(TagEntry entry, String source) { diff --git a/patches/minecraft/net/minecraft/util/SpawnUtil.java.patch b/patches/minecraft/net/minecraft/util/SpawnUtil.java.patch index 81f29753b8..11e50ccc72 100644 --- a/patches/minecraft/net/minecraft/util/SpawnUtil.java.patch +++ b/patches/minecraft/net/minecraft/util/SpawnUtil.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/util/SpawnUtil.java +++ b/net/minecraft/util/SpawnUtil.java -@@ -34,7 +_,7 @@ +@@ -35,7 +_,7 @@ if (p_216406_.getWorldBorder().isWithinBounds(blockpos$mutableblockpos) && moveToPossibleSpawnPosition(p_216406_, p_216410_, blockpos$mutableblockpos, p_216411_)) { - T t = (T)p_216404_.create(p_216406_, null, blockpos$mutableblockpos, p_216405_, false, false); + T t = (T)p_216404_.create(p_216406_, null, blockpos$mutableblockpos, p_369127_, false, false); if (t != null) { -- if (t.checkSpawnRules(p_216406_, p_216405_) && t.checkSpawnObstruction(p_216406_)) { -+ if (net.minecraftforge.event.ForgeEventFactory.checkSpawnPosition(t, p_216406_, p_216405_)) { +- if (t.checkSpawnRules(p_216406_, p_369127_) && t.checkSpawnObstruction(p_216406_)) { ++ if (net.minecraftforge.event.ForgeEventFactory.checkSpawnPosition(t, p_216406_, p_369127_)) { p_216406_.addFreshEntityWithPassengers(t); return Optional.of(t); } diff --git a/patches/minecraft/net/minecraft/util/context/ContextMap.java.patch b/patches/minecraft/net/minecraft/util/context/ContextMap.java.patch new file mode 100644 index 0000000000..9230f0a2f4 --- /dev/null +++ b/patches/minecraft/net/minecraft/util/context/ContextMap.java.patch @@ -0,0 +1,24 @@ +--- a/net/minecraft/util/context/ContextMap.java ++++ b/net/minecraft/util/context/ContextMap.java +@@ -39,6 +_,10 @@ + return (T)this.params.getOrDefault(p_368195_, p_368521_); + } + ++ public Set> keySet() { ++ return java.util.Collections.unmodifiableSet(this.params.keySet()); ++ } ++ + public static class Builder { + private final Map, Object> params = new IdentityHashMap<>(); + +@@ -83,6 +_,10 @@ + return new ContextMap(this.params); + } + } ++ } ++ ++ public ContextMap create() { ++ return new ContextMap(this.params); + } + } + } diff --git a/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch b/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch index 93f66196fb..34813ecc6d 100644 --- a/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch +++ b/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/MobEffect.java +++ b/net/minecraft/world/effect/MobEffect.java -@@ -35,7 +_,8 @@ +@@ -36,7 +_,8 @@ import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlags; @@ -10,9 +10,9 @@ public static final Codec> CODEC = BuiltInRegistries.MOB_EFFECT.holderByNameCodec(); public static final StreamCodec> STREAM_CODEC = ByteBufCodecs.holderRegistry(Registries.MOB_EFFECT); private static final int AMBIENT_ALPHA = Mth.floor(38.25F); -@@ -56,12 +_,14 @@ - int i = p_326747_.isAmbient() ? AMBIENT_ALPHA : 255; - return ColorParticleOption.create(ParticleTypes.ENTITY_EFFECT, FastColor.ARGB32.color(i, p_19452_)); +@@ -57,12 +_,14 @@ + int i = p_358853_.isAmbient() ? AMBIENT_ALPHA : 255; + return ColorParticleOption.create(ParticleTypes.ENTITY_EFFECT, ARGB.color(i, p_19452_)); }; + initClient(); } @@ -25,7 +25,7 @@ } public int getBlendDurationTicks() { -@@ -186,4 +_,28 @@ +@@ -187,4 +_,28 @@ return new AttributeModifier(this.id, this.amount * (double)(p_332230_ + 1), this.operation); } } diff --git a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch index 92bc190f9f..6ea927d4d2 100644 --- a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -128,7 +_,7 @@ +@@ -136,7 +_,7 @@ import net.minecraft.world.scores.Team; import org.slf4j.Logger; --public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, CommandSource, ScoreHolder { -+public abstract class Entity extends net.minecraftforge.common.capabilities.CapabilityProvider implements SyncedDataHolder, Nameable, EntityAccess, CommandSource, ScoreHolder, net.minecraftforge.common.extensions.IForgeEntity { +-public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder { ++public abstract class Entity extends net.minecraftforge.common.capabilities.CapabilityProvider implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, net.minecraftforge.common.extensions.IForgeEntity { private static final Logger LOGGER = LogUtils.getLogger(); public static final String ID_TAG = "id"; public static final String PASSENGERS_TAG = "Passengers"; -@@ -149,6 +_,7 @@ +@@ -157,6 +_,7 @@ private static final double LAVA_SLOW_FLOW_SCALE = 0.0023333333333333335; public static final String UUID_TAG = "UUID"; private static double viewScale = 1.0; @@ -17,7 +17,7 @@ private final EntityType type; private int id = ENTITY_COUNTER.incrementAndGet(); public boolean blocksBuilding; -@@ -194,8 +_,10 @@ +@@ -201,8 +_,10 @@ public int tickCount; private int remainingFireTicks = -this.getFireImmuneTicks(); protected boolean wasTouchingWater; @@ -28,15 +28,15 @@ private final Set> fluidOnEyes = new HashSet<>(); public int invulnerableTime; protected boolean firstTick = true; -@@ -243,6 +_,7 @@ - private BlockState inBlockState = null; +@@ -251,6 +_,7 @@ + private final LongSet visitedBlocks = new LongOpenHashSet(); public Entity(EntityType p_19870_, Level p_19871_) { + super(Entity.class); this.type = p_19870_; this.level = p_19871_; this.dimensions = p_19870_.getDimensions(); -@@ -262,6 +_,8 @@ +@@ -270,6 +_,8 @@ this.entityData = synchedentitydata$builder.build(); this.setPos(0.0, 0.0, 0.0); this.eyeHeight = this.dimensions.eyeHeight(); @@ -45,7 +45,7 @@ } public boolean isColliding(BlockPos p_20040_, BlockState p_20041_) { -@@ -349,6 +_,7 @@ +@@ -357,6 +_,7 @@ public void remove(Entity.RemovalReason p_146834_) { this.setRemoved(p_146834_); @@ -53,7 +53,7 @@ } public void onClientRemoval() { -@@ -465,7 +_,7 @@ +@@ -476,7 +_,7 @@ if (this.isInLava()) { this.lavaHurt(); @@ -62,31 +62,22 @@ } this.checkBelowWorld(); -@@ -673,7 +_,7 @@ - double d1 = vec3.x; - double d2 = vec3.y; - double d3 = vec3.z; -- this.flyDist = this.flyDist + (float)(vec3.length() * 0.6); -+ this.flyDist = (float)((double)this.flyDist + vec3.length() * 0.6D); - BlockPos blockpos1 = this.getOnPos(); - BlockState blockstate1 = this.level().getBlockState(blockpos1); - boolean flag1 = this.isStateClimbable(blockstate1); -@@ -717,12 +_,12 @@ - this.setRemainingFireTicks(-this.getFireImmuneTicks()); - } - -- if (this.wasOnFire && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { -+ if (this.wasOnFire && (this.isInPowderSnow || this.isInWaterRainOrBubble() || this.isInFluidType((fluidType, height) -> this.canFluidExtinguish(fluidType)))) { - this.playEntityOnFireExtinguishedSound(); - } - } - -- if (this.isOnFire() && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { -+ if (this.isOnFire() && (this.isInPowderSnow || this.isInWaterRainOrBubble() || this.isInFluidType((fluidType, height) -> this.canFluidExtinguish(fluidType)))) { +@@ -767,12 +_,12 @@ this.setRemainingFireTicks(-this.getFireImmuneTicks()); } -@@ -812,9 +_,7 @@ +- if (this.wasOnFire && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { ++ if (this.wasOnFire && (this.isInPowderSnow || this.isInWaterRainOrBubble() || this.isInFluidType((fluidType, height) -> this.canFluidExtinguish(fluidType)))) { + this.playEntityOnFireExtinguishedSound(); + } + } + +- if (this.isOnFire() && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { ++ if (this.isOnFire() && (this.isInPowderSnow || this.isInWaterRainOrBubble() || this.isInFluidType((fluidType, height) -> this.canFluidExtinguish(fluidType)))) { + this.setRemainingFireTicks(-this.getFireImmuneTicks()); + } + } +@@ -852,9 +_,7 @@ return blockpos; } else { BlockState blockstate = this.level().getBlockState(blockpos); @@ -97,7 +88,7 @@ ? blockpos.atY(Mth.floor(this.position.y - (double)p_216987_)) : blockpos; } -@@ -1078,19 +_,19 @@ +@@ -1138,19 +_,19 @@ return !blockstate.is(BlockTags.INSIDE_STEP_SOUND_BLOCKS) && !blockstate.is(BlockTags.COMBINATION_STEP_SOUND_BLOCKS) ? p_278049_ : blockpos; } @@ -123,7 +114,7 @@ this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch()); } -@@ -1241,27 +_,33 @@ +@@ -1301,27 +_,33 @@ public void updateSwimming() { if (this.isSwimming()) { @@ -142,7 +133,7 @@ - double d0 = this.level().dimensionType().ultraWarm() ? 0.007 : 0.0023333333333333335; - boolean flag = this.updateFluidHeightAndDoFluidPushing(FluidTags.LAVA, d0); - return this.isInWater() || flag; -+ if (!(this.getVehicle() instanceof Boat)) { ++ if (!(this.getVehicle() instanceof AbstractBoat)) { + this.fallDistance *= this.forgeFluidTypeHeight.object2DoubleEntrySet().stream().filter(e -> !e.getKey().isAir() && !e.getKey().isVanilla()).map(e -> this.getFluidFallDistanceModifier(e.getKey())).min(Float::compare).orElse(1F); + if (this.isInFluidType((fluidType, height) -> !fluidType.isAir() && !fluidType.isVanilla() && this.canFluidExtinguish(fluidType))) this.clearFire(); + } @@ -151,11 +142,11 @@ void updateInWaterStateAndDoWaterCurrentPushing() { + java.util.function.BooleanSupplier updateFluidHeight = () -> this.updateFluidHeightAndDoFluidPushing(FluidTags.WATER, 0.014D); - if (this.getVehicle() instanceof Boat boat && !boat.isUnderWater()) { + if (this.getVehicle() instanceof AbstractBoat abstractboat && !abstractboat.isUnderWater()) { - this.wasTouchingWater = false; - return; + updateFluidHeight = () -> { -+ this.updateFluidHeightAndDoFluidPushing(state -> this.shouldUpdateFluidWhileBoating(state, boat)); ++ this.updateFluidHeightAndDoFluidPushing(state -> this.shouldUpdateFluidWhileBoating(state, abstractboat)); + return false; + }; } @@ -165,15 +156,15 @@ if (!this.wasTouchingWater && !this.firstTick) { this.doWaterSplashEffect(); } -@@ -1277,6 +_,7 @@ +@@ -1337,6 +_,7 @@ private void updateFluidOnEyes() { this.wasEyeInWater = this.isEyeInFluid(FluidTags.WATER); this.fluidOnEyes.clear(); + this.forgeFluidTypeOnEyes = net.minecraftforge.common.ForgeMod.EMPTY_TYPE.get(); double d0 = this.getEyeY(); - if (this.getVehicle() instanceof Boat boat && !boat.isUnderWater() && boat.getBoundingBox().maxY >= d0 && boat.getBoundingBox().minY <= d0) { - return; -@@ -1286,7 +_,7 @@ + if (this.getVehicle() instanceof AbstractBoat abstractboat + && !abstractboat.isUnderWater() +@@ -1349,7 +_,7 @@ FluidState fluidstate = this.level().getFluidState(blockpos); double d1 = (double)((float)blockpos.getY() + fluidstate.getHeight(this.level(), blockpos)); if (d1 > d0) { @@ -182,7 +173,7 @@ } } -@@ -1340,12 +_,13 @@ +@@ -1403,12 +_,13 @@ } public boolean canSpawnSprintParticle() { @@ -197,7 +188,7 @@ if (blockstate.getRenderShape() != RenderShape.INVISIBLE) { Vec3 vec3 = this.getDeltaMovement(); BlockPos blockpos1 = this.blockPosition(); -@@ -1361,7 +_,7 @@ +@@ -1424,7 +_,7 @@ this.level() .addParticle( @@ -206,7 +197,7 @@ d0, this.getY() + 0.1, d1, -@@ -1372,12 +_,15 @@ +@@ -1435,12 +_,15 @@ } } @@ -223,7 +214,7 @@ } public void moveRelative(float p_19921_, Vec3 p_19922_) { -@@ -1711,6 +_,11 @@ +@@ -1810,6 +_,11 @@ p_20241_.putBoolean("HasVisualFire", this.hasVisualFire); } @@ -235,7 +226,7 @@ if (!this.tags.isEmpty()) { ListTag listtag = new ListTag(); -@@ -1801,6 +_,9 @@ +@@ -1901,6 +_,9 @@ this.setGlowingTag(p_20259_.getBoolean("Glowing")); this.setTicksFrozen(p_20259_.getInt("TicksFrozen")); this.hasVisualFire = p_20259_.getBoolean("HasVisualFire"); @@ -245,16 +236,16 @@ if (p_20259_.contains("Tags", 9)) { this.tags.clear(); ListTag listtag3 = p_20259_.getList("Tags", 8); -@@ -1885,6 +_,8 @@ +@@ -1983,6 +_,8 @@ } else { - ItemEntity itementity = new ItemEntity(this.level(), this.getX(), this.getY() + (double)p_19986_, this.getZ(), p_19985_); + ItemEntity itementity = new ItemEntity(p_364149_, this.getX(), this.getY() + (double)p_367722_, this.getZ(), p_366908_); itementity.setDefaultPickUpDelay(); + if (captureDrops() != null) captureDrops().add(itementity); + else - this.level().addFreshEntity(itementity); + p_364149_.addFreshEntity(itementity); return itementity; } -@@ -1952,6 +_,7 @@ +@@ -2050,6 +_,7 @@ public void rideTick() { this.setDeltaMovement(Vec3.ZERO); @@ -262,7 +253,7 @@ this.tick(); if (this.isPassenger()) { this.getVehicle().positionRider(this); -@@ -2010,6 +_,7 @@ +@@ -2110,6 +_,7 @@ } } @@ -270,7 +261,7 @@ if (p_19967_ || this.canRide(p_19966_) && p_19966_.canAddPassenger(this)) { if (this.isPassenger()) { this.stopRiding(); -@@ -2041,6 +_,7 @@ +@@ -2141,6 +_,7 @@ public void removeVehicle() { if (this.vehicle != null) { Entity entity = this.vehicle; @@ -278,7 +269,7 @@ this.vehicle = null; entity.removePassenger(this); } -@@ -2090,6 +_,8 @@ +@@ -2190,6 +_,8 @@ return this.passengers.isEmpty(); } @@ -287,7 +278,7 @@ protected boolean couldAcceptPassenger() { return true; } -@@ -2274,7 +_,7 @@ +@@ -2378,7 +_,7 @@ } public boolean isVisuallyCrawling() { @@ -296,16 +287,16 @@ } public void setSwimming(boolean p_20283_) { -@@ -2383,7 +_,7 @@ +@@ -2491,7 +_,7 @@ this.igniteForSeconds(8.0F); } -- this.hurt(this.damageSources().lightningBolt(), 5.0F); -+ this.hurt(this.damageSources().lightningBolt(), p_19928_.getDamage()); +- this.hurtServer(p_19927_, this.damageSources().lightningBolt(), 5.0F); ++ this.hurtServer(p_19927_, this.damageSources().lightningBolt(), p_19928_.getDamage()); } public void onAboveBubbleCol(boolean p_20313_) { -@@ -2478,7 +_,7 @@ +@@ -2586,7 +_,7 @@ } protected Component getTypeName() { @@ -314,7 +305,7 @@ } public boolean is(Entity p_20356_) { -@@ -2685,6 +_,7 @@ +@@ -2879,6 +_,7 @@ return this.stringUUID; } @@ -322,7 +313,7 @@ public boolean isPushedByFluid() { return true; } -@@ -3127,9 +_,17 @@ +@@ -3283,9 +_,17 @@ return Mth.lerp(p_344421_, this.yRotO, this.yRot); } @@ -341,7 +332,7 @@ } else { AABB aabb = this.getBoundingBox().deflate(0.001); int i = Mth.floor(aabb.minX); -@@ -3144,25 +_,28 @@ +@@ -3300,25 +_,28 @@ Vec3 vec3 = Vec3.ZERO; int k1 = 0; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); @@ -377,7 +368,7 @@ } } } -@@ -3170,27 +_,28 @@ +@@ -3326,27 +_,28 @@ } } @@ -416,7 +407,7 @@ } } -@@ -3203,7 +_,10 @@ +@@ -3359,7 +_,10 @@ return !this.level().hasChunksAt(i, k, j, l); } @@ -427,7 +418,7 @@ return this.fluidHeight.getDouble(p_204037_); } -@@ -3219,7 +_,9 @@ +@@ -3375,7 +_,9 @@ return this.dimensions.height(); } @@ -437,7 +428,7 @@ return new ClientboundAddEntityPacket(this, p_344981_); } -@@ -3340,6 +_,11 @@ +@@ -3496,6 +_,11 @@ this.levelCallback.onMove(); } @@ -449,7 +440,7 @@ } public void checkDespawn() { -@@ -3493,6 +_,100 @@ +@@ -3648,6 +_,100 @@ float f1 = (float)Mth.lerp(d0, (double)this.getXRot(), p_298926_); this.setPos(d1, d2, d3); this.setRot(f, f1); @@ -488,7 +479,7 @@ + } + + @Override -+ public boolean canTrample(BlockState state, BlockPos pos, float fallDistance) { ++ public boolean canTrample(ServerLevel level, BlockState state, BlockPos pos, float fallDistance) { + return level.random.nextFloat() < fallDistance - 0.5F + && this instanceof LivingEntity + && (this instanceof Player || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(level, this)) diff --git a/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch index 00811710d4..83d5cc3081 100644 --- a/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -723,6 +_,11 @@ +@@ -893,6 +_,11 @@ private final float spawnDimensionsScale; private final FeatureFlagSet requiredFeatures; @@ -9,33 +9,22 @@ + private final java.util.function.ToIntFunction> updateIntervalSupplier; + private final java.util.function.BiFunction customClientFactory; + - private static EntityType register(String p_20635_, EntityType.Builder p_20636_) { - return Registry.register(BuiltInRegistries.ENTITY_TYPE, p_20635_, p_20636_.build(p_20635_)); + private static EntityType register(ResourceKey> p_368406_, EntityType.Builder p_363129_) { + return Registry.register(BuiltInRegistries.ENTITY_TYPE, p_368406_, p_363129_.build(p_368406_)); } -@@ -735,6 +_,10 @@ - return BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(p_20633_)); - } - -+ public EntityType(EntityType.EntityFactory p_273268_, MobCategory p_272918_, boolean p_273417_, boolean p_273389_, boolean p_273556_, boolean p_272654_, ImmutableSet p_273631_, EntityDimensions p_272946_, float p_332711_, int p_272895_, int p_273451_, FeatureFlagSet p_273518_) { -+ this(p_273268_, p_272918_, p_273417_, p_273389_, p_273556_, p_272654_, p_273631_, p_272946_, p_332711_, p_272895_, p_273451_, p_273518_, null); -+ } -+ - public EntityType( - EntityType.EntityFactory p_273268_, - MobCategory p_272918_, -@@ -747,7 +_,8 @@ - float p_332711_, - int p_272895_, +@@ -927,7 +_,8 @@ int p_273451_, + String p_367006_, + Optional> p_364691_, - FeatureFlagSet p_273518_ + FeatureFlagSet p_273518_, + Builder builder ) { this.factory = p_273268_; this.category = p_272918_; -@@ -761,6 +_,10 @@ - this.clientTrackingRange = p_272895_; - this.updateInterval = p_273451_; +@@ -943,6 +_,10 @@ + this.descriptionId = p_367006_; + this.lootTable = p_364691_; this.requiredFeatures = p_273518_; + this.velocityUpdateSupplier = builder == null || builder.velocityUpdateSupplier == null ? EntityType::defaultVelocitySupplier : builder.velocityUpdateSupplier; + this.trackingRangeSupplier = builder == null || builder.trackingRangeSupplier == null ? EntityType::defaultTrackingRangeSupplier : builder.trackingRangeSupplier; @@ -44,7 +33,7 @@ } @Nullable -@@ -1037,14 +_,26 @@ +@@ -1214,14 +_,26 @@ } public int clientTrackingRange() { @@ -71,12 +60,12 @@ return this != PLAYER && this != LLAMA_SPIT && this != WITHER -@@ -1080,6 +_,12 @@ - return this.builtInRegistryHolder; +@@ -1273,6 +_,12 @@ + return (p_358865_, p_358866_) -> new ChestRaft(p_358865_, p_358866_, p_368732_); } + public T customClientSpawn(net.minecraftforge.network.packets.SpawnEntity packet, Level world) { -+ if (customClientFactory == null) return this.create(world); ++ if (customClientFactory == null) return this.create(world, EntitySpawnReason.LOAD); + return customClientFactory.apply(packet, world); + } + public Stream>> getTags() {return this.builtInRegistryHolder().tags();} @@ -84,10 +73,10 @@ public static class Builder { private final EntityType.EntityFactory factory; private final MobCategory category; -@@ -1094,6 +_,10 @@ - private float spawnDimensionsScale = 1.0F; - private EntityAttachments.Builder attachments = EntityAttachments.builder(); - private FeatureFlagSet requiredFeatures = FeatureFlags.VANILLA_SET; +@@ -1291,6 +_,10 @@ + ResourceKey.create(Registries.LOOT_TABLE, p_358877_.location().withPrefix("entities/")) + ); + private DependantName, String> descriptionId = p_358878_ -> Util.makeDescriptionId("entity", p_358878_.location()); + private java.util.function.Predicate> velocityUpdateSupplier = EntityType::defaultVelocitySupplier; + private java.util.function.ToIntFunction> trackingRangeSupplier = EntityType::defaultTrackingRangeSupplier; + private java.util.function.ToIntFunction> updateIntervalSupplier = EntityType::defaultUpdateIntervalSupplier; @@ -95,7 +84,7 @@ private Builder(EntityType.EntityFactory p_20696_, MobCategory p_20697_) { this.factory = p_20696_; -@@ -1202,6 +_,30 @@ +@@ -1404,6 +_,30 @@ return this; } @@ -123,13 +112,13 @@ + return this; + } + - public EntityType build(String p_20713_) { + public EntityType build(ResourceKey> p_369693_) { if (this.serialize) { - Util.fetchChoiceType(References.ENTITY_TREE, p_20713_); -@@ -1219,7 +_,8 @@ - this.spawnDimensionsScale, - this.clientTrackingRange, + Util.fetchChoiceType(References.ENTITY_TREE, p_369693_.location().toString()); +@@ -1423,7 +_,8 @@ this.updateInterval, + this.descriptionId.get(p_369693_), + this.lootTable.get(p_369693_), - this.requiredFeatures + this.requiredFeatures, + this diff --git a/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch b/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch index d0985b72f7..0a1a4bf62f 100644 --- a/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/ExperienceOrb.java +++ b/net/minecraft/world/entity/ExperienceOrb.java -@@ -110,7 +_,8 @@ - this.move(MoverType.SELF, this.getDeltaMovement()); +@@ -111,7 +_,8 @@ + this.applyEffectsFromBlocks(); float f = 0.98F; if (this.onGround()) { - f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F; @@ -10,15 +10,7 @@ } this.setDeltaMovement(this.getDeltaMovement().multiply((double)f, 0.98, (double)f)); -@@ -191,6 +_,7 @@ - - @Override - public boolean hurt(DamageSource p_20785_, float p_20786_) { -+ if (this.level().isClientSide || this.isRemoved()) return false; //Forge: Fixes MC-53850 - if (this.isInvulnerableTo(p_20785_)) { - return false; - } else if (this.level().isClientSide) { -@@ -226,6 +_,7 @@ +@@ -230,6 +_,7 @@ public void playerTouch(Player p_20792_) { if (p_20792_ instanceof ServerPlayer serverplayer) { if (p_20792_.takeXpDelay == 0) { diff --git a/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch b/patches/minecraft/net/minecraft/world/entity/LightningBolt.java.patch index 5006d229f1..8b84f83a8f 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 -@@ -38,6 +_,7 @@ +@@ -39,6 +_,7 @@ private ServerPlayer cause; private final Set hitEntities = Sets.newHashSet(); private int blocksSetOnFire; diff --git a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch index 97995a6289..bed8da5e30 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 -@@ -132,7 +_,7 @@ +@@ -137,7 +_,7 @@ import net.minecraft.world.scores.Scoreboard; import org.slf4j.Logger; @@ -9,7 +9,16 @@ private static final Logger LOGGER = LogUtils.getLogger(); private static final String TAG_ACTIVE_EFFECTS = "active_effects"; private static final ResourceLocation SPEED_MODIFIER_POWDER_SNOW_ID = ResourceLocation.withDefaultNamespace("powder_snow"); -@@ -260,7 +_,8 @@ +@@ -173,6 +_,8 @@ + public static final float EXTRA_RENDER_CULLING_SIZE_WITH_BIG_HAT = 0.5F; + public static final float DEFAULT_BABY_SCALE = 0.5F; + public static final String ATTRIBUTES_FIELD = "attributes"; ++ /** Forge: Use a variant that calls {@link ItemStack#isMonsterDisguise(Player, net.minecraft.world.entity.monster.Monster)} and {@link net.minecraftforge.event.entity.living.MonsterDisguiseEvent} */ ++ @Deprecated + public static final Predicate PLAYER_NOT_WEARING_DISGUISE_ITEM = p_358894_ -> { + if (p_358894_ instanceof Player player) { + ItemStack itemstack = player.getItemBySlot(EquipmentSlot.HEAD); +@@ -272,7 +_,8 @@ this.setYRot((float)(Math.random() * (float) (Math.PI * 2))); this.yHeadRot = this.getYRot(); NbtOps nbtops = NbtOps.INSTANCE; @@ -19,29 +28,27 @@ } public Brain getBrain() { -@@ -314,7 +_,10 @@ +@@ -326,7 +_,8 @@ .add(Attributes.EXPLOSION_KNOCKBACK_RESISTANCE) .add(Attributes.WATER_MOVEMENT_EFFICIENCY) .add(Attributes.MOVEMENT_EFFICIENCY) - .add(Attributes.ATTACK_KNOCKBACK); + .add(Attributes.ATTACK_KNOCKBACK) -+ .add(Attributes.JUMP_STRENGTH) -+ .add(net.minecraftforge.common.ForgeMod.SWIM_SPEED.getHolder().get()) -+ .add(net.minecraftforge.common.ForgeMod.NAMETAG_DISTANCE.getHolder().get()); ++ .add(Attributes.JUMP_STRENGTH); } @Override -@@ -342,7 +_,8 @@ +@@ -354,7 +_,8 @@ float f = (float)Mth.ceil((double)this.fallDistance - d7); double d4 = Math.min((double)(0.2F + f / 15.0F), 2.5); int i = (int)(150.0 * d4); -- ((ServerLevel)this.level()).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, p_20992_), d0, d1, d2, i, 0.0, 0.0, 0.0, 0.15F); +- serverlevel.sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, p_20992_), d0, d1, d2, i, 0.0, 0.0, 0.0, 0.15F); + if (!p_20992_.addLandingEffects((ServerLevel) this.level(), p_20993_, p_20992_, this, i)) + ((ServerLevel)this.level()).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, p_20992_).setPos(p_20993_), d0, d1, d2, i, 0.0, 0.0, 0.0, 0.15F); } } -@@ -352,6 +_,7 @@ +@@ -364,6 +_,7 @@ } } @@ -49,7 +56,7 @@ public final boolean canBreatheUnderwater() { return this.getType().is(EntityTypeTags.CAN_BREATHE_UNDER_WATER); } -@@ -397,6 +_,10 @@ +@@ -410,6 +_,10 @@ } } @@ -60,7 +67,7 @@ if (this.isEyeInFluid(FluidTags.WATER) && !this.level().getBlockState(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())).is(Blocks.BUBBLE_COLUMN)) { boolean flag1 = !this.canBreatheUnderwater() && !MobEffectUtil.hasWaterBreathing(this) && (!flag || !((Player)this).getAbilities().invulnerable); -@@ -442,7 +_,7 @@ +@@ -455,7 +_,7 @@ } } @@ -69,7 +76,7 @@ this.extinguishFire(); } -@@ -769,7 +_,8 @@ +@@ -782,7 +_,8 @@ } if (p_21096_.contains("Brain", 10)) { @@ -79,16 +86,16 @@ } } -@@ -781,7 +_,7 @@ +@@ -794,7 +_,7 @@ Holder holder = iterator.next(); MobEffectInstance mobeffectinstance = this.activeEffects.get(holder); if (!mobeffectinstance.tick(this, () -> this.onEffectUpdated(mobeffectinstance, true, null))) { - if (!this.level().isClientSide) { + if (!this.level().isClientSide && !net.minecraftforge.event.ForgeEventFactory.onLivingEffectExpire(this, mobeffectinstance)) { iterator.remove(); - this.onEffectRemoved(mobeffectinstance); + this.onEffectsRemoved(List.of(mobeffectinstance)); } -@@ -862,6 +_,7 @@ +@@ -875,6 +_,7 @@ } } @@ -96,20 +103,7 @@ return d0; } -@@ -903,7 +_,11 @@ - - boolean flag; - for (flag = false; iterator.hasNext(); flag = true) { -- this.onEffectRemoved(iterator.next()); -+ var effect = iterator.next(); -+ if (net.minecraftforge.event.ForgeEventFactory.onLivingEffectRemove(this, effect)) { -+ continue; -+ } -+ this.onEffectRemoved(effect); - iterator.remove(); - } - -@@ -938,6 +_,7 @@ +@@ -944,6 +_,7 @@ } else { MobEffectInstance mobeffectinstance = this.activeEffects.get(p_147208_.getEffect()); boolean flag = false; @@ -117,7 +111,7 @@ if (mobeffectinstance == null) { this.activeEffects.put(p_147208_.getEffect(), p_147208_); this.onEffectAdded(p_147208_, p_147209_); -@@ -954,6 +_,10 @@ +@@ -960,6 +_,10 @@ } public boolean canBeAffected(MobEffectInstance p_21197_) { @@ -128,7 +122,7 @@ if (this.getType().is(EntityTypeTags.IMMUNE_TO_INFESTED)) { return !p_21197_.is(MobEffects.INFESTED); } else if (this.getType().is(EntityTypeTags.IMMUNE_TO_OOZING)) { -@@ -987,6 +_,9 @@ +@@ -993,6 +_,9 @@ } public boolean removeEffect(Holder p_335910_) { @@ -137,8 +131,18 @@ + } MobEffectInstance mobeffectinstance = this.removeEffectNoUpdate(p_335910_); if (mobeffectinstance != null) { - this.onEffectRemoved(mobeffectinstance); -@@ -1065,6 +_,10 @@ + this.onEffectsRemoved(List.of(mobeffectinstance)); +@@ -1036,6 +_,9 @@ + this.effectsDirty = true; + if (!this.level().isClientSide) { + for (MobEffectInstance mobeffectinstance : p_364717_) { ++ if (net.minecraftforge.event.ForgeEventFactory.onLivingEffectRemove(this, mobeffectinstance)) { ++ continue; ++ } + mobeffectinstance.getEffect().value().removeAttributeModifiers(this.getAttributes()); + + for (Entity entity : this.getPassengers()) { +@@ -1074,6 +_,10 @@ } public void heal(float p_21116_) { @@ -149,39 +153,39 @@ float f = this.getHealth(); if (f > 0.0F) { this.setHealth(f + p_21116_); -@@ -1085,6 +_,9 @@ +@@ -1094,6 +_,9 @@ @Override - public boolean hurt(DamageSource p_21016_, float p_21017_) { -+ if (!net.minecraftforge.common.ForgeHooks.onLivingAttack(this, p_21016_, p_21017_)) { + public boolean hurtServer(ServerLevel p_361743_, DamageSource p_361865_, float p_365677_) { ++ if (!net.minecraftforge.common.ForgeHooks.onLivingAttack(this, p_361865_, p_365677_)) { + return false; + } - if (this.isInvulnerableTo(p_21016_)) { + if (this.isInvulnerableTo(p_361743_, p_361865_)) { return false; - } else if (this.level().isClientSide) { -@@ -1103,14 +_,18 @@ + } else if (this.isDeadOrDying()) { +@@ -1114,14 +_,18 @@ boolean flag = false; float f1 = 0.0F; - if (p_21017_ > 0.0F && this.isDamageSourceBlocked(p_21016_)) { -+ var ev = net.minecraftforge.event.ForgeEventFactory.onShieldBlock(this, p_21016_, p_21017_); + if (p_365677_ > 0.0F && this.isDamageSourceBlocked(p_361865_)) { ++ var ev = net.minecraftforge.event.ForgeEventFactory.onShieldBlock(this, p_361865_, p_365677_); + if (!ev.isCanceled()) { + if (ev.shieldTakesDamage()) - this.hurtCurrentlyUsedShield(p_21017_); -- f1 = p_21017_; -- p_21017_ = 0.0F; + this.hurtCurrentlyUsedShield(p_365677_); +- f1 = p_365677_; +- p_365677_ = 0.0F; + f1 = ev.getBlockedDamage(); -+ p_21017_ -= ev.getBlockedDamage(); - if (!p_21016_.is(DamageTypeTags.IS_PROJECTILE) && p_21016_.getDirectEntity() instanceof LivingEntity livingentity) { ++ p_365677_ -= ev.getBlockedDamage(); + if (!p_361865_.is(DamageTypeTags.IS_PROJECTILE) && p_361865_.getDirectEntity() instanceof LivingEntity livingentity) { this.blockUsingShield(livingentity); } - flag = true; -+ flag = p_21017_ <= 0; ++ flag = p_365677_ <= 0; + } } - if (p_21016_.is(DamageTypeTags.IS_FREEZING) && this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { -@@ -1151,7 +_,7 @@ + if (p_361865_.is(DamageTypeTags.IS_FREEZING) && this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { +@@ -1166,7 +_,7 @@ if (entity instanceof Player player1) { this.lastHurtByPlayerTime = 100; this.lastHurtByPlayer = player1; @@ -190,25 +194,25 @@ this.lastHurtByPlayerTime = 100; if (wolf.getOwner() instanceof Player player) { this.lastHurtByPlayer = player; -@@ -1216,7 +_,7 @@ - if (this instanceof ServerPlayer) { - CriteriaTriggers.ENTITY_HURT_PLAYER.trigger((ServerPlayer)this, p_21016_, f, p_21017_, flag); +@@ -1231,7 +_,7 @@ + if (this instanceof ServerPlayer serverplayer) { + CriteriaTriggers.ENTITY_HURT_PLAYER.trigger(serverplayer, p_361865_, f, p_365677_, flag); if (f1 > 0.0F && f1 < 3.4028235E37F) { -- ((ServerPlayer)this).awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, Math.round(f1 * 10.0F)); +- serverplayer.awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, Math.round(f1 * 10.0F)); + ((ServerPlayer)this).awardStat(Stats.CUSTOM.get(Stats.DAMAGE_BLOCKED_BY_SHIELD), Math.round(f1 * 10.0F)); } } -@@ -1244,7 +_,7 @@ - +@@ -1261,7 +_,7 @@ for (InteractionHand interactionhand : InteractionHand.values()) { ItemStack itemstack1 = this.getItemInHand(interactionhand); -- if (itemstack1.is(Items.TOTEM_OF_UNDYING)) { -+ if (itemstack1.is(Items.TOTEM_OF_UNDYING) && net.minecraftforge.common.ForgeHooks.onLivingUseTotem(this, p_21263_, itemstack1, interactionhand)) { + deathprotection = itemstack1.get(DataComponents.DEATH_PROTECTION); +- if (deathprotection != null) { ++ if (deathprotection != null && net.minecraftforge.common.ForgeHooks.onLivingUseTotem(this, p_21263_, itemstack1, interactionhand)) { itemstack = itemstack1.copy(); itemstack1.shrink(1); break; -@@ -1330,6 +_,7 @@ +@@ -1345,6 +_,7 @@ } public void die(DamageSource p_21014_) { @@ -216,12 +220,12 @@ if (!this.isRemoved() && !this.dead) { Entity entity = p_21014_.getEntity(); LivingEntity livingentity = this.getKillCredit(); -@@ -1365,10 +_,10 @@ - if (!this.level().isClientSide) { +@@ -1380,10 +_,10 @@ + if (this.level() instanceof ServerLevel serverlevel) { boolean flag = false; if (p_21269_ instanceof WitherBoss) { -- if (this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level(), p_21269_)) { +- if (serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, p_21269_)) { BlockPos blockpos = this.blockPosition(); BlockState blockstate = Blocks.WITHER_ROSE.defaultBlockState(); - if (this.level().getBlockState(blockpos).isAir() && blockstate.canSurvive(this.level(), blockpos)) { @@ -229,18 +233,18 @@ this.level().setBlock(blockpos, blockstate, 3); flag = true; } -@@ -1383,6 +_,7 @@ +@@ -1398,6 +_,7 @@ } protected void dropAllDeathLoot(ServerLevel p_342160_, DamageSource p_21192_) { + this.captureDrops(new java.util.ArrayList<>()); boolean flag = this.lastHurtByPlayerTime > 0; if (this.shouldDropLoot() && p_342160_.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - this.dropFromLootTable(p_21192_, flag); -@@ -1391,6 +_,11 @@ + this.dropFromLootTable(p_342160_, p_21192_, flag); +@@ -1406,6 +_,11 @@ - this.dropEquipment(); - this.dropExperience(p_21192_.getEntity()); + this.dropEquipment(p_342160_); + this.dropExperience(p_342160_, p_21192_.getEntity()); + + var drops = captureDrops(null); + if (!net.minecraftforge.event.ForgeEventFactory.onLivingDrops(this, p_21192_, drops, lastHurtByPlayerTime > 0)) { @@ -248,18 +252,18 @@ + } } - protected void dropEquipment() { -@@ -1400,7 +_,8 @@ - if (this.level() instanceof ServerLevel serverlevel - && !this.wasExperienceConsumed() - && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { -- ExperienceOrb.award(serverlevel, this.position(), this.getExperienceReward(serverlevel, p_342525_)); -+ int reward = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.lastHurtByPlayer, this.getExperienceReward(serverlevel, p_342525_)); -+ ExperienceOrb.award(serverlevel, this.position(), reward); + protected void dropEquipment(ServerLevel p_365823_) { +@@ -1413,7 +_,8 @@ + + protected void dropExperience(ServerLevel p_370040_, @Nullable Entity p_342525_) { + if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && p_370040_.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { +- ExperienceOrb.award(p_370040_, this.position(), this.getExperienceReward(p_370040_, p_342525_)); ++ int reward = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.lastHurtByPlayer, this.getExperienceReward(p_370040_, p_342525_)); ++ ExperienceOrb.award(p_370040_, this.position(), reward); } } -@@ -1438,6 +_,11 @@ +@@ -1489,6 +_,11 @@ } public void knockback(double p_147241_, double p_147242_, double p_147243_) { @@ -271,7 +275,7 @@ p_147241_ *= 1.0 - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); if (!(p_147241_ <= 0.0)) { this.hasImpulse = true; -@@ -1523,6 +_,13 @@ +@@ -1566,6 +_,13 @@ } else { BlockPos blockpos = this.blockPosition(); BlockState blockstate = this.getInBlockState(); @@ -285,7 +289,7 @@ if (blockstate.is(BlockTags.CLIMBABLE)) { this.lastClimbablePos = Optional.of(blockpos); return true; -@@ -1560,6 +_,10 @@ +@@ -1627,6 +_,10 @@ @Override public boolean causeFallDamage(float p_147187_, float p_147188_, DamageSource p_147189_) { @@ -296,7 +300,7 @@ boolean flag = super.causeFallDamage(p_147187_, p_147188_, p_147189_); int i = this.calculateFallDamage(p_147187_, p_147188_); if (i > 0) { -@@ -1587,9 +_,10 @@ +@@ -1654,9 +_,10 @@ int i = Mth.floor(this.getX()); int j = Mth.floor(this.getY() - 0.2F); int k = Mth.floor(this.getZ()); @@ -309,7 +313,7 @@ this.playSound(soundtype.getFallSound(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F); } } -@@ -1649,9 +_,9 @@ +@@ -1717,9 +_,9 @@ float f2 = f1 - p_21194_; if (f2 > 0.0F && f2 < 3.4028235E37F) { if (this instanceof ServerPlayer) { @@ -321,16 +325,16 @@ } } } -@@ -1679,6 +_,8 @@ +@@ -1747,6 +_,8 @@ - protected void actuallyHurt(DamageSource p_21240_, float p_21241_) { - if (!this.isInvulnerableTo(p_21240_)) { + protected void actuallyHurt(ServerLevel p_365124_, DamageSource p_21240_, float p_21241_) { + if (!this.isInvulnerableTo(p_365124_, p_21240_)) { + p_21241_ = net.minecraftforge.common.ForgeHooks.onLivingHurt(this, p_21240_, p_21241_); + if (p_21241_ <= 0) return; p_21241_ = this.getDamageAfterArmorAbsorb(p_21240_, p_21241_); p_21241_ = this.getDamageAfterMagicAbsorb(p_21240_, p_21241_); float f1 = Math.max(p_21241_ - this.getAbsorptionAmount(), 0.0F); -@@ -1688,6 +_,7 @@ +@@ -1756,6 +_,7 @@ serverplayer.awardStat(Stats.DAMAGE_DEALT_ABSORBED, Math.round(f * 10.0F)); } @@ -338,7 +342,7 @@ if (f1 != 0.0F) { this.getCombatTracker().recordDamage(p_21240_, f1); this.setHealth(this.getHealth() - f1); -@@ -1747,6 +_,8 @@ +@@ -1815,6 +_,8 @@ } public void swing(InteractionHand p_21012_, boolean p_21013_) { @@ -347,7 +351,7 @@ if (!this.swinging || this.swingTime >= this.getCurrentSwingDuration() / 2 || this.swingTime < 0) { this.swingTime = -1; this.swinging = true; -@@ -1858,9 +_,10 @@ +@@ -1927,9 +_,10 @@ } private void swapHandItems() { @@ -361,7 +365,7 @@ } @Override -@@ -2064,15 +_,18 @@ +@@ -2147,15 +_,18 @@ } this.hasImpulse = true; @@ -382,42 +386,54 @@ } protected float getWaterSlowDown() { -@@ -2097,7 +_,8 @@ +@@ -2179,8 +_,8 @@ + public void travel(Vec3 p_21280_) { + if (this.isControlledByLocalInstance()) { + FluidState fluidstate = this.level().getFluidState(this.blockPosition()); +- if ((this.isInWater() || this.isInLava()) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { +- this.travelInFluid(p_21280_); ++ if ((this.isInWater() || (this.isInFluidType(fluidstate) && fluidstate.getFluidType() != net.minecraftforge.common.ForgeMod.LAVA_TYPE.get())) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { ++ this.travelInFluid(p_21280_, fluidstate); + } else if (this.isFallFlying()) { + this.travelFallFlying(); + } else { +@@ -2191,7 +_,7 @@ + + private void travelInAir(Vec3 p_362087_) { + BlockPos blockpos = this.getBlockPosBelowThatAffectsMyMovement(); +- float f = this.onGround() ? this.level().getBlockState(blockpos).getBlock().getFriction() : 1.0F; ++ float f = this.onGround() ? this.level().getBlockState(blockpos).getFriction(level(), blockpos, this) : 1.0F; + float f1 = f * 0.91F; + Vec3 vec3 = this.handleRelativeFrictionAndCalculateMovement(p_362087_, f); + double d0 = vec3.y; +@@ -2214,11 +_,16 @@ + } + } + +- private void travelInFluid(Vec3 p_362114_) { ++ @Deprecated // FORGE: Use the version that takes a FluidState ++ private void travelInFluid(Vec3 p_365480_) { ++ this.travelInFluid(p_365480_, net.minecraft.world.level.material.Fluids.WATER.defaultFluidState()); ++ } ++ ++ private void travelInFluid(Vec3 p_362114_, FluidState fluidstate) { + boolean flag = this.getDeltaMovement().y <= 0.0; + double d0 = this.getY(); + double d1 = this.getEffectiveGravity(); +- if (this.isInWater()) { ++ if (this.isInWater() || (this.isInFluidType(fluidstate) && !this.moveInFluid(fluidstate, p_362114_, d0))) { + float f = this.isSprinting() ? 0.9F : this.getWaterSlowDown(); + float f1 = 0.02F; + float f2 = (float)this.getAttributeValue(Attributes.WATER_MOVEMENT_EFFICIENCY); +@@ -2235,6 +_,7 @@ + f = 0.96F; } - FluidState fluidstate = this.level().getFluidState(this.blockPosition()); -- if (this.isInWater() && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { -+ if ((this.isInWater() || (this.isInFluidType(fluidstate) && fluidstate.getFluidType() != net.minecraftforge.common.ForgeMod.LAVA_TYPE.get())) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { -+ if (this.isInWater() || (this.isInFluidType(fluidstate) && !this.moveInFluid(fluidstate, p_21280_, d0))) { - double d9 = this.getY(); - float f4 = this.isSprinting() ? 0.9F : this.getWaterSlowDown(); - float f5 = 0.02F; -@@ -2115,6 +_,7 @@ - f4 = 0.96F; - } - -+ f5 *= this.getAttributeValue(net.minecraftforge.common.ForgeMod.SWIM_SPEED.getHolder().get()); - this.moveRelative(f5, p_21280_); - this.move(MoverType.SELF, this.getDeltaMovement()); - Vec3 vec36 = this.getDeltaMovement(); -@@ -2128,6 +_,7 @@ - if (this.horizontalCollision && this.isFree(vec32.x, vec32.y + 0.6F - this.getY() + d9, vec32.z)) { - this.setDeltaMovement(vec32.x, 0.3F, vec32.z); - } -+ } - } else if (this.isInLava() && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { - double d8 = this.getY(); - this.moveRelative(0.02F, p_21280_); -@@ -2190,7 +_,7 @@ - } - } else { - BlockPos blockpos = this.getBlockPosBelowThatAffectsMyMovement(); -- float f2 = this.level().getBlockState(blockpos).getBlock().getFriction(); -+ float f2 = this.level().getBlockState(blockpos).getFriction(level(), blockpos, this); - float f3 = this.onGround() ? f2 * 0.91F : 0.91F; - Vec3 vec35 = this.handleRelativeFrictionAndCalculateMovement(p_21280_, f2); - double d2 = vec35.y; -@@ -2283,7 +_,7 @@ ++ f1 *= this.getAttributeValue(net.minecraftforge.common.ForgeMod.SWIM_SPEED.getHolder().get()); + this.moveRelative(f1, p_362114_); + this.move(MoverType.SELF, this.getDeltaMovement()); + Vec3 vec3 = this.getDeltaMovement(); +@@ -2383,7 +_,7 @@ double d0 = Mth.clamp(p_21298_.x, -0.15F, 0.15F); double d1 = Mth.clamp(p_21298_.z, -0.15F, 0.15F); double d2 = Math.max(p_21298_.y, -0.15F); @@ -426,7 +442,7 @@ d2 = 0.0; } -@@ -2316,6 +_,7 @@ +@@ -2416,6 +_,7 @@ @Override public void tick() { @@ -434,7 +450,7 @@ super.tick(); this.updatingUsingItem(); this.updateSwimAmount(); -@@ -2465,6 +_,7 @@ +@@ -2568,6 +_,7 @@ }; ItemStack itemstack1 = this.getItemBySlot(equipmentslot); if (this.equipmentHasChanged(itemstack, itemstack1)) { @@ -442,8 +458,8 @@ if (map == null) { map = Maps.newEnumMap(EquipmentSlot.class); } -@@ -2636,6 +_,10 @@ - this.level().getProfiler().push("jump"); +@@ -2727,6 +_,10 @@ + profilerfiller.push("jump"); if (this.jumping && this.isAffectedByFluids()) { double d3; + var fluidType = this.getMaxHeightFluidType(); @@ -453,7 +469,7 @@ if (this.isInLava()) { d3 = this.getFluidHeight(FluidTags.LAVA); } else { -@@ -2646,15 +_,19 @@ +@@ -2737,15 +_,19 @@ double d4 = this.getFluidJumpThreshold(); if (!flag || this.onGround() && !(d3 > d4)) { if (!this.isInLava() || this.onGround() && !(d3 > d4)) { @@ -475,16 +491,7 @@ } } else { this.noJumpDelay = 0; -@@ -2719,6 +_,8 @@ - boolean flag = this.getSharedFlag(7); - if (flag && !this.onGround() && !this.isPassenger() && !this.hasEffect(MobEffects.LEVITATION)) { - ItemStack itemstack = this.getItemBySlot(EquipmentSlot.CHEST); -+ flag = itemstack.canElytraFly(this) && itemstack.elytraFlightTick(this, this.fallFlyTicks); -+ if (false) //Forge: Moved to ElytraItem - if (itemstack.is(Items.ELYTRA) && ElytraItem.isFlyEnabled(itemstack)) { - flag = true; - int i = this.fallFlyTicks + 1; -@@ -2979,8 +_,11 @@ +@@ -3095,8 +_,11 @@ private void updatingUsingItem() { if (this.isUsingItem()) { @@ -497,7 +504,7 @@ this.updateUsingItem(this.useItem); } else { this.stopUsingItem(); -@@ -2989,12 +_,16 @@ +@@ -3105,8 +_,12 @@ } protected void updateUsingItem(ItemStack p_147201_) { @@ -506,16 +513,12 @@ + } + if (this.getUseItemRemainingTicks() > 0) p_147201_.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); - if (this.shouldTriggerItemUseEffects()) { - this.triggerItemUseEffects(p_147201_, 5); - } - - if (--this.useItemRemaining == 0 && !this.level().isClientSide && !p_147201_.useOnRelease()) { + if (--this.useItemRemaining <= 0 && !this.level().isClientSide && !p_147201_.useOnRelease()) { this.completeUsingItem(); } } -@@ -3029,8 +_,12 @@ +@@ -3134,8 +_,12 @@ public void startUsingItem(InteractionHand p_21159_) { ItemStack itemstack = this.getItemInHand(p_21159_); if (!itemstack.isEmpty() && !this.isUsingItem()) { @@ -529,7 +532,7 @@ if (!this.level().isClientSide) { this.setLivingEntityFlag(1, true); this.setLivingEntityFlag(2, p_21159_ == InteractionHand.OFF_HAND); -@@ -3099,6 +_,9 @@ +@@ -3187,6 +_,9 @@ vec31 = vec31.xRot(-this.getXRot() * (float) (Math.PI / 180.0)); vec31 = vec31.yRot(-this.getYRot() * (float) (Math.PI / 180.0)); vec31 = vec31.add(this.getX(), this.getEyeY(), this.getZ()); @@ -539,17 +542,17 @@ this.level() .addParticle( new ItemParticleOption(ParticleTypes.ITEM, p_21061_), -@@ -3120,7 +_,9 @@ +@@ -3207,7 +_,9 @@ + this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { - this.triggerItemUseEffects(this.useItem, 16); + ItemStack copy = this.useItem.copy(); ItemStack itemstack = this.useItem.finishUsingItem(this.level(), this); + itemstack = net.minecraftforge.event.ForgeEventFactory.onItemUseFinish(this, copy, getUseItemRemainingTicks(), itemstack); if (itemstack != this.useItem) { this.setItemInHand(interactionhand, itemstack); } -@@ -3145,7 +_,13 @@ +@@ -3235,7 +_,13 @@ public void releaseUsingItem() { if (!this.useItem.isEmpty()) { @@ -563,7 +566,7 @@ if (this.useItem.useOnRelease()) { this.updatingUsingItem(); } -@@ -3155,6 +_,7 @@ +@@ -3245,6 +_,7 @@ } public void stopUsingItem() { @@ -571,17 +574,17 @@ if (!this.level().isClientSide) { boolean flag = this.isUsingItem(); this.setLivingEntityFlag(1, false); -@@ -3170,7 +_,8 @@ - public boolean isBlocking() { +@@ -3265,7 +_,8 @@ + public ItemStack getItemBlockingWith() { if (this.isUsingItem() && !this.useItem.isEmpty()) { Item item = this.useItem.getItem(); -- return item.getUseAnimation(this.useItem) != UseAnim.BLOCK ? false : item.getUseDuration(this.useItem, this) - this.useItemRemaining >= 5; +- if (item.getUseAnimation(this.useItem) != ItemUseAnimation.BLOCK) { + boolean canBlock = this.useItem.canPerformAction(net.minecraftforge.common.ToolActions.SHIELD_BLOCK); -+ return !canBlock ? false : item.getUseDuration(this.useItem, this) - this.useItemRemaining >= 5; - } else { - return false; - } -@@ -3311,8 +_,8 @@ ++ if (!canBlock) { + return null; + } else { + return item.getUseDuration(this.useItem, this) - this.useItemRemaining < 5 ? null : this.useItem; +@@ -3410,8 +_,8 @@ } BlockState blockstate = this.level().getBlockState(p_21141_); @@ -592,11 +595,11 @@ } this.setPose(Pose.SLEEPING); -@@ -3327,15 +_,15 @@ +@@ -3426,15 +_,15 @@ } private boolean checkBedExists() { -- return this.getSleepingPos().map(p_341272_ -> this.level().getBlockState(p_341272_).getBlock() instanceof BedBlock).orElse(false); +- return this.getSleepingPos().map(p_358885_ -> this.level().getBlockState(p_358885_).getBlock() instanceof BedBlock).orElse(false); + return this.getSleepingPos().map(p_341272_ -> net.minecraftforge.event.ForgeEventFactory.fireSleepingLocationCheck(this, p_341272_)).orElse(false); } @@ -611,7 +614,7 @@ Vec3 vec31 = BedBlock.findStandUpPosition(this.getType(), this.level(), p_261435_, direction, this.getYRot()).orElseGet(() -> { BlockPos blockpos = p_261435_.above(); return new Vec3((double)blockpos.getX() + 0.5, (double)blockpos.getY() + 0.1, (double)blockpos.getZ() + 0.5); -@@ -3356,7 +_,9 @@ +@@ -3455,7 +_,9 @@ @Nullable public Direction getBedOrientation() { BlockPos blockpos = this.getSleepingPos().orElse(null); @@ -622,7 +625,7 @@ } @Override -@@ -3365,7 +_,7 @@ +@@ -3464,7 +_,7 @@ } public ItemStack getProjectile(ItemStack p_21272_) { @@ -630,17 +633,17 @@ + return net.minecraftforge.common.ForgeHooks.getProjectile(this, p_21272_, ItemStack.EMPTY); } - public final ItemStack eat(Level p_21067_, ItemStack p_21068_) { -@@ -3431,6 +_,8 @@ + private static byte entityEventForEquipmentBreak(EquipmentSlot p_21267_) { +@@ -3519,6 +_,8 @@ } - public EquipmentSlot getEquipmentSlotForItem(ItemStack p_147234_) { + public final EquipmentSlot getEquipmentSlotForItem(ItemStack p_147234_) { + final EquipmentSlot slot = p_147234_.getEquipmentSlot(); + if (slot != null) return slot; // FORGE: Allow modders to set a non-default equipment slot for a stack; e.g. a non-armor chestplate-slot item - Equipable equipable = Equipable.get(p_147234_); - if (equipable != null) { - EquipmentSlot equipmentslot = equipable.getEquipmentSlot(); -@@ -3557,5 +_,42 @@ + Equippable equippable = p_147234_.get(DataComponents.EQUIPPABLE); + return equippable != null && this.canUseSlot(equippable.slot()) ? equippable.slot() : EquipmentSlot.MAINHAND; + } +@@ -3650,5 +_,42 @@ } public static record Fallsounds(SoundEvent small, SoundEvent big) { diff --git a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch index 980f543d39..416e0e89de 100644 --- a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -131,6 +_,9 @@ +@@ -133,6 +_,9 @@ private Leashable.LeashData leashData; private BlockPos restrictCenter = BlockPos.ZERO; private float restrictRadius = -1.0F; + @Nullable -+ private MobSpawnType spawnType; ++ private EntitySpawnReason spawnReason; + private boolean spawnCancelled = false; protected Mob(EntityType p_21368_, Level p_21369_) { super(p_21368_, p_21369_); -@@ -237,7 +_,10 @@ +@@ -239,7 +_,10 @@ } public void setTarget(@Nullable LivingEntity p_21544_) { @@ -22,25 +22,25 @@ } @Override -@@ -425,6 +_,10 @@ +@@ -421,6 +_,10 @@ if (this.isNoAi()) { p_21484_.putBoolean("NoAI", this.isNoAi()); } + -+ if (this.spawnType != null) { -+ p_21484_.putString("forge:spawn_type", this.spawnType.name()); ++ if (this.spawnReason != null) { ++ p_21484_.putString("forge:spawn_type", this.spawnReason.name()); + } } @Override -@@ -484,6 +_,14 @@ +@@ -480,6 +_,14 @@ } this.setNoAi(p_21450_.getBoolean("NoAI")); + + if (p_21450_.contains("forge:spawn_type")) { + try { -+ this.spawnType = MobSpawnType.valueOf(p_21450_.getString("forge:spawn_type")); ++ this.spawnReason = EntitySpawnReason.valueOf(p_21450_.getString("forge:spawn_type")); + } catch (Exception ex) { + p_21450_.remove("forge:spawn_type"); + } @@ -48,16 +48,16 @@ } @Override -@@ -535,7 +_,7 @@ - public void aiStep() { - super.aiStep(); - this.level().getProfiler().push("looting"); -- if (!this.level().isClientSide && this.canPickUpLoot() && this.isAlive() && !this.dead && this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (!this.level().isClientSide && this.canPickUpLoot() && this.isAlive() && !this.dead && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level(), this)) { +@@ -532,7 +_,7 @@ + && this.canPickUpLoot() + && this.isAlive() + && !this.dead +- && serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, this)) { Vec3i vec3i = this.getPickupReach(); for (ItemEntity itementity : this.level() -@@ -699,6 +_,14 @@ +@@ -700,6 +_,14 @@ this.discard(); } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) { Entity entity = this.level().getNearestPlayer(this, -1.0); @@ -72,7 +72,7 @@ if (entity != null) { double d0 = entity.distanceToSqr(this); int i = this.getType().getCategory().getDespawnDistance(); -@@ -1121,6 +_,16 @@ +@@ -1116,6 +_,16 @@ } } @@ -81,23 +81,23 @@ + * Overrides are allowed. Do not wrap super calls within override (as that will cause stack overflows).
+ * Vanilla calls are replaced with a transformer, and are not visible in source.
+ *

-+ * Be certain to either call super.finalizeSpawn or set the {@link #spawnType} field from within your override. ++ * Be certain to either call super.finalizeSpawn or set the {@link #spawnReason} field from within your override. + * @see {@link net.minecraftforge.event.ForgeEventFactory#onFinalizeSpawn onFinalizeSpawn} for additional documentation. + */ + @Deprecated + @org.jetbrains.annotations.ApiStatus.OverrideOnly @Nullable - public SpawnGroupData finalizeSpawn(ServerLevelAccessor p_21434_, DifficultyInstance p_21435_, MobSpawnType p_21436_, @Nullable SpawnGroupData p_21437_) { + public SpawnGroupData finalizeSpawn(ServerLevelAccessor p_21434_, DifficultyInstance p_21435_, EntitySpawnReason p_369316_, @Nullable SpawnGroupData p_21437_) { RandomSource randomsource = p_21434_.getRandom(); -@@ -1132,6 +_,7 @@ +@@ -1127,6 +_,7 @@ } this.setLeftHanded(randomsource.nextFloat() < 0.05F); -+ this.spawnType = p_21436_; ++ this.spawnReason = p_369316_; return p_21437_; } -@@ -1457,15 +_,25 @@ +@@ -1438,15 +_,25 @@ return false; } @@ -124,7 +124,7 @@ @VisibleForTesting public void removeFreeWill() { this.removeAllGoals(p_341273_ -> true); -@@ -1491,5 +_,40 @@ +@@ -1472,6 +_,41 @@ public ItemStack getPickResult() { SpawnEggItem spawneggitem = SpawnEggItem.byId(this.getType()); return spawneggitem == null ? null : new ItemStack(spawneggitem); @@ -137,8 +137,8 @@ + * This is set via {@link Mob#finalizeSpawn}, so you should not call this from within that method, instead using the parameter. + */ + @Nullable -+ public final MobSpawnType getSpawnType() { -+ return this.spawnType; ++ public final EntitySpawnReason getSpawnReason() { ++ return this.spawnReason; + } + + /** @@ -164,4 +164,5 @@ + } + this.spawnCancelled = cancel; } - } + + @Override diff --git a/patches/minecraft/net/minecraft/world/entity/Shearable.java.patch b/patches/minecraft/net/minecraft/world/entity/Shearable.java.patch index 4b46f86f3f..050d4b581c 100644 --- a/patches/minecraft/net/minecraft/world/entity/Shearable.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Shearable.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/entity/Shearable.java +++ b/net/minecraft/world/entity/Shearable.java -@@ -2,8 +_,14 @@ - +@@ -4,8 +_,14 @@ import net.minecraft.sounds.SoundSource; + import net.minecraft.world.item.ItemStack; -public interface Shearable { +public interface Shearable extends net.minecraftforge.common.IForgeShearable { + /** @deprecated Use {@link net.minecraftforge.common.IForgeShearable#onSheared} */ - void shear(SoundSource p_21749_); + void shear(ServerLevel p_368224_, SoundSource p_21749_, ItemStack p_362173_); + /** @deprecated Use {@link net.minecraftforge.common.IForgeShearable#isShearable} */ boolean readyForShearing(); diff --git a/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch b/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch index 241491793e..54d1956bdb 100644 --- a/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/SpawnPlacements.java +++ b/net/minecraft/world/entity/SpawnPlacements.java -@@ -46,6 +_,7 @@ +@@ -47,6 +_,7 @@ public class SpawnPlacements { private static final Map, SpawnPlacements.Data> DATA_BY_TYPE = Maps.newHashMap(); @@ -8,20 +8,20 @@ private static void register( EntityType p_21755_, SpawnPlacementType p_331557_, Heightmap.Types p_21757_, SpawnPlacements.SpawnPredicate p_21758_ ) { -@@ -73,7 +_,8 @@ - EntityType p_217075_, ServerLevelAccessor p_217076_, MobSpawnType p_217077_, BlockPos p_217078_, RandomSource p_217079_ +@@ -74,7 +_,8 @@ + EntityType p_217075_, ServerLevelAccessor p_217076_, EntitySpawnReason p_369208_, BlockPos p_217078_, RandomSource p_217079_ ) { SpawnPlacements.Data spawnplacements$data = DATA_BY_TYPE.get(p_217075_); -- return spawnplacements$data == null || spawnplacements$data.predicate.test((EntityType)p_217075_, p_217076_, p_217077_, p_217078_, p_217079_); -+ boolean vanillaResult = spawnplacements$data == null || spawnplacements$data.predicate.test((EntityType)p_217075_, p_217076_, p_217077_, p_217078_, p_217079_); -+ return net.minecraftforge.event.ForgeEventFactory.checkSpawnPlacements(p_217075_, p_217076_, p_217077_, p_217078_, p_217079_, vanillaResult); +- return spawnplacements$data == null || spawnplacements$data.predicate.test((EntityType)p_217075_, p_217076_, p_369208_, p_217078_, p_217079_); ++ boolean vanillaResult = spawnplacements$data == null || spawnplacements$data.predicate.test((EntityType)p_217075_, p_217076_, p_369208_, p_217078_, p_217079_); ++ return net.minecraftforge.event.ForgeEventFactory.checkSpawnPlacements(p_217075_, p_217076_, p_369208_, p_217078_, p_217079_, vanillaResult); } static { -@@ -159,5 +_,13 @@ +@@ -164,5 +_,13 @@ @FunctionalInterface public interface SpawnPredicate { - boolean test(EntityType p_217081_, ServerLevelAccessor p_217082_, MobSpawnType p_217083_, BlockPos p_217084_, RandomSource p_217085_); + boolean test(EntityType p_217081_, ServerLevelAccessor p_217082_, EntitySpawnReason p_365908_, BlockPos p_217084_, RandomSource p_217085_); + } + + // ******* FORGE START. INTERNAL USE ONLY! ****** // diff --git a/patches/minecraft/net/minecraft/world/entity/TamableAnimal.java.patch b/patches/minecraft/net/minecraft/world/entity/TamableAnimal.java.patch index 63b7f63295..d84c309d97 100644 --- a/patches/minecraft/net/minecraft/world/entity/TamableAnimal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/TamableAnimal.java.patch @@ -1,17 +1,19 @@ --- a/net/minecraft/world/entity/TamableAnimal.java +++ b/net/minecraft/world/entity/TamableAnimal.java -@@ -218,11 +_,14 @@ +@@ -219,13 +_,16 @@ @Override public void die(DamageSource p_21809_) { + // FORGE: Super moved to top so that death message would be cancelled properly -+ net.minecraft.network.chat.Component deathMessage = this.getCombatTracker().getDeathMessage(); ++ var deathMessage = this.getCombatTracker().getDeathMessage(); + super.die(p_21809_); + + if (this.dead) - if (!this.level().isClientSide && this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES) && this.getOwner() instanceof ServerPlayer) { -- this.getOwner().sendSystemMessage(this.getCombatTracker().getDeathMessage()); -+ this.getOwner().sendSystemMessage(deathMessage); + if (this.level() instanceof ServerLevel serverlevel + && serverlevel.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES) + && this.getOwner() instanceof ServerPlayer serverplayer) { +- serverplayer.sendSystemMessage(this.getCombatTracker().getDeathMessage()); ++ serverplayer.sendSystemMessage(deathMessage); } - - super.die(p_21809_); 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 92207df0e3..e3e7877afe 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,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java +++ b/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java -@@ -174,11 +_,12 @@ +@@ -177,11 +_,12 @@ .build(); public static AttributeSupplier getSupplier(EntityType 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 c12d851169..d6dd940464 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,11 +1,11 @@ --- a/net/minecraft/world/entity/ai/behavior/StartAttacking.java +++ b/net/minecraft/world/entity/ai/behavior/StartAttacking.java -@@ -30,7 +_,11 @@ - if (!p_258774_.canAttack(livingentity)) { +@@ -28,7 +_,11 @@ + if (!p_359049_.canAttack(livingentity)) { return false; } else { - p_258778_.set(livingentity); -+ var changeTargetEvent = net.minecraftforge.event.ForgeEventFactory.onLivingChangeTargetBehavior(p_258774_, livingentity); ++ var changeTargetEvent = net.minecraftforge.event.ForgeEventFactory.onLivingChangeTargetBehavior(p_359049_, livingentity); + if (changeTargetEvent.isCanceled()) + return false; + diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/Swim.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/Swim.java.patch index d645f277f5..088cae90ad 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/behavior/Swim.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/Swim.java.patch @@ -3,7 +3,7 @@ @@ -14,7 +_,7 @@ } - public static boolean shouldSwim(Mob p_327994_) { + public static boolean shouldSwim(T p_327994_) { - return p_327994_.isInWater() && p_327994_.getFluidHeight(FluidTags.WATER) > p_327994_.getFluidJumpThreshold() || p_327994_.isInLava(); + return p_327994_.isInWater() &&p_327994_.getFluidHeight(FluidTags.WATER) > p_327994_.getFluidJumpThreshold() || p_327994_.isInLava() || p_327994_.isInFluidType((fluidType, height) -> p_327994_.canSwimInFluidType(fluidType) && height > p_327994_.getFluidJumpThreshold()); } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch index ea19e899b5..9415b1fb4c 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch @@ -1,13 +1,11 @@ --- a/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java +++ b/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java -@@ -32,9 +_,7 @@ +@@ -32,7 +_,7 @@ if (!super.canUse()) { return false; } else { -- return !this.mob.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) -- ? false -- : this.isValidDifficulty(this.mob.level().getDifficulty()) && !this.isOpen(); -+ return !net.minecraftforge.common.ForgeHooks.canEntityDestroy(this.mob.level(), this.doorPos, this.mob) ? false : this.isValidDifficulty(this.mob.level().getDifficulty()) && !this.isOpen(); +- return !getServerLevel(this.mob).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ++ return !net.minecraftforge.common.ForgeHooks.canEntityDestroy(getServerLevel(this.mob.level()), this.doorPos, this.mob) + ? false + : this.isValidDifficulty(this.mob.level().getDifficulty()) && !this.isOpen(); } - } - diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch index 47a10c47df..e66e871ad1 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch @@ -4,8 +4,8 @@ if (this.eatAnimationTick == this.adjustedTickDelay(4)) { BlockPos blockpos = this.mob.blockPosition(); if (IS_TALL_GRASS.test(this.level.getBlockState(blockpos))) { -- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level, this.mob)) { +- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(this.level), this.mob)) { this.level.destroyBlock(blockpos, false); } @@ -13,8 +13,8 @@ } else { BlockPos blockpos1 = blockpos.below(); if (this.level.getBlockState(blockpos1).is(Blocks.GRASS_BLOCK)) { -- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level, this.mob)) { +- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(this.level), this.mob)) { this.level.levelEvent(2001, blockpos1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())); this.level.setBlock(blockpos1, Blocks.DIRT.defaultBlockState(), 2); } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch index 5e6641597e..befbd929da 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch @@ -4,8 +4,8 @@ @Override public boolean canUse() { -- if (!this.removerMob.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.removerMob.level(), this.removerMob)) { +- if (!getServerLevel(this.removerMob).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(this.removerMob.level()), this.removerMob)) { return false; } else if (this.nextStartTick > 0) { this.nextStartTick--; 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 d32b201c43..9251d759c4 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 -@@ -235,10 +_,10 @@ +@@ -252,10 +_,10 @@ Vec3 vec3 = this.getTempMobPos(); this.maxDistanceToWaypoint = this.mob.getBbWidth() > 0.75F ? this.mob.getBbWidth() / 2.0F : 0.75F - this.mob.getBbWidth() / 2.0F; Vec3i vec3i = this.path.getNextNodePos(); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/village/VillageSiege.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/village/VillageSiege.java.patch index f98a696d36..6a3315f081 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/village/VillageSiege.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/village/VillageSiege.java.patch @@ -17,7 +17,7 @@ Zombie zombie; try { - zombie = new Zombie(p_27017_); -+ zombie = EntityType.ZOMBIE.create(p_27017_); //Forge: Direct Initialization is deprecated, use EntityType. - zombie.finalizeSpawn(p_27017_, p_27017_.getCurrentDifficultyAt(zombie.blockPosition()), MobSpawnType.EVENT, null); ++ zombie = EntityType.ZOMBIE.create(p_27017_, EntitySpawnReason.EVENT); //Forge: Direct Initialization is deprecated, use EntityType. + zombie.finalizeSpawn(p_27017_, p_27017_.getCurrentDifficultyAt(zombie.blockPosition()), EntitySpawnReason.EVENT, null); } catch (Exception exception) { LOGGER.warn("Failed to create zombie for village siege at {}", vec3, exception); 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 358930f268..25c0bf3820 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 @@ -13,7 +13,7 @@ private static PoiType register(Registry p_218085_, ResourceKey p_218086_, Set p_218087_, int p_218088_, int p_218089_) { PoiType poitype = new PoiType(p_218087_, p_218088_, p_218089_); Registry.register(p_218085_, p_218086_, poitype); -- registerBlockStates(p_218085_.getHolderOrThrow(p_218086_), p_218087_); +- registerBlockStates(p_218085_.getOrThrow(p_218086_), p_218087_); return poitype; } diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch index ac25b38902..fc2d58de78 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Animal.java +++ b/net/minecraft/world/entity/animal/Animal.java -@@ -201,6 +_,17 @@ +@@ -221,6 +_,17 @@ public void spawnChildFromBreeding(ServerLevel p_27564_, Animal p_27565_) { AgeableMob ageablemob = this.getBreedOffspring(p_27564_, p_27565_); 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 441ff9de5c..add7ac13fd 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch @@ -1,15 +1,17 @@ --- a/net/minecraft/world/entity/animal/Bee.java +++ b/net/minecraft/world/entity/animal/Bee.java -@@ -491,7 +_,7 @@ - return false; +@@ -502,7 +_,9 @@ + if (this.hivePos == null) { + return null; } else { - BlockEntity blockentity = this.level().getBlockEntity(this.hivePos); -- return blockentity != null && blockentity.getType() == BlockEntityType.BEEHIVE; -+ return blockentity instanceof BeehiveBlockEntity; +- return this.isTooFarAway(this.hivePos) ? null : this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null); ++ if (!this.isTooFarAway(this.hivePos) && this.level().getBlockEntity(this.hivePos) instanceof BeehiveBlockEntity hiveEntity) ++ return hiveEntity; ++ return null; } } -@@ -640,13 +_,22 @@ +@@ -648,13 +_,22 @@ } @Override 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 c2c0de3235..ea562ef2eb 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch @@ -1,17 +1,18 @@ --- a/net/minecraft/world/entity/animal/Cat.java +++ b/net/minecraft/world/entity/animal/Cat.java -@@ -368,9 +_,9 @@ +@@ -371,10 +_,10 @@ } } else if (this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) { if (!this.level().isClientSide()) { - this.usePlayerItem(p_28153_, p_28154_, itemstack); FoodProperties foodproperties = itemstack.get(DataComponents.FOOD); this.heal(foodproperties != null ? (float)foodproperties.nutrition() : 1.0F); + this.playEatingSound(); + this.usePlayerItem(p_28153_, p_28154_, itemstack); } - return InteractionResult.sidedSuccess(this.level().isClientSide()); -@@ -430,7 +_,7 @@ + return InteractionResult.SUCCESS; +@@ -435,7 +_,7 @@ } private void tryToTame(Player p_333297_) { 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 d43d59f0cc..4781cc76a7 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/animal/Fox.java +++ b/net/minecraft/world/entity/animal/Fox.java -@@ -835,6 +_,16 @@ +@@ -834,6 +_,16 @@ protected void breed() { - ServerLevel serverlevel = (ServerLevel)this.level; + ServerLevel serverlevel = this.level; Fox fox = (Fox)this.animal.getBreedOffspring(serverlevel, this.partner); + var event = net.minecraftforge.event.ForgeEventFactory.onBabySpawn(animal, partner, fox); + fox = (Fox)event.getChild(); @@ -17,16 +17,16 @@ if (fox != null) { ServerPlayer serverplayer = this.animal.getLoveCause(); ServerPlayer serverplayer1 = this.partner.getLoveCause(); -@@ -918,7 +_,7 @@ +@@ -917,7 +_,7 @@ } protected void onReachedTarget() { -- if (Fox.this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(Fox.this.level(), Fox.this)) { +- if (getServerLevel(Fox.this.level()).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(Fox.this.level()), Fox.this)) { BlockState blockstate = Fox.this.level().getBlockState(this.blockPos); if (blockstate.is(Blocks.SWEET_BERRY_BUSH)) { this.pickSweetBerries(blockstate); -@@ -977,7 +_,7 @@ +@@ -976,7 +_,7 @@ @Override public boolean canUse() { 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 0560a476ba..b1cbf3d6ce 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch @@ -1,61 +1,57 @@ --- a/net/minecraft/world/entity/animal/MushroomCow.java +++ b/net/minecraft/world/entity/animal/MushroomCow.java -@@ -108,7 +_,7 @@ +@@ -110,7 +_,7 @@ this.playSound(soundevent, 1.0F, 1.0F); - return InteractionResult.sidedSuccess(this.level().isClientSide); + return InteractionResult.SUCCESS; - } else if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { -+ } else if (false && itemstack.is(Items.SHEARS) && this.readyForShearing()) { //Forge: Moved to onSheared - this.shear(SoundSource.PLAYERS); - this.gameEvent(GameEvent.SHEAR, p_28941_); - if (!this.level().isClientSide) { -@@ -163,8 +_,13 @@ ++ } else if (false && itemstack.is(Items.SHEARS) && this.readyForShearing()) { + if (this.level() instanceof ServerLevel serverlevel) { + this.shear(serverlevel, SoundSource.PLAYERS, itemstack); + this.gameEvent(GameEvent.SHEAR, p_28941_); +@@ -165,15 +_,26 @@ @Override - public void shear(SoundSource p_28924_) { -+ shearInternal(p_28924_).forEach(s -> this.level().addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(1.0D), this.getZ(), s))); + public void shear(ServerLevel p_369641_, SoundSource p_28924_, ItemStack p_364876_) { ++ for (var stack : shearInternal(p_369641_, p_28924_, p_364876_)) { ++ for (int i = 0; i < stack.getCount(); i++) { ++ this.level().addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(1.0D), this.getZ(), stack.copyWithCount(1))); ++ } ++ } + } + -+ private java.util.List shearInternal(SoundSource p_28924_) { - this.level().playSound(null, this, SoundEvents.MOOSHROOM_SHEAR, p_28924_, 1.0F, 1.0F); - if (!this.level().isClientSide()) { -+ if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.COW, time -> {})) return java.util.Collections.emptyList(); - Cow cow = EntityType.COW.create(this.level()); - if (cow != null) { - ((ServerLevel)this.level()).sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(0.5), this.getZ(), 1, 0.0, 0.0, 0.0, 0.0); -@@ -183,17 +_,16 @@ - - cow.setInvulnerable(this.isInvulnerable()); - this.level().addFreshEntity(cow); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, cow); - -+ var items = new java.util.ArrayList(); - for (int i = 0; i < 5; i++) { -- this.level() -- .addFreshEntity( -- new ItemEntity( -- this.level(), this.getX(), this.getY(1.0), this.getZ(), new ItemStack(this.getVariant().blockState.getBlock()) -- ) -- ); -+ items.add(new ItemStack(this.getVariant().blockState.getBlock())); - } -+ return items; - } - } -+ return java.util.Collections.emptyList(); ++ private java.util.List shearInternal(ServerLevel p_369641_, SoundSource p_28924_, ItemStack p_364876_) { ++ var ret = new java.util.ArrayList(); ++ if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.COW, time -> {})) ++ return ret; + p_369641_.playSound(null, this, SoundEvents.MOOSHROOM_SHEAR, p_28924_, 1.0F, 1.0F); + this.convertTo(EntityType.COW, ConversionParams.single(this, false, false), p_359168_ -> { + p_369641_.sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(0.5), this.getZ(), 1, 0.0, 0.0, 0.0, 0.0); + this.dropFromShearingLootTable(p_369641_, BuiltInLootTables.SHEAR_MOOSHROOM, p_364876_, (p_359169_, p_359170_) -> { +- for (int i = 0; i < p_359170_.getCount(); i++) { +- p_359169_.addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(1.0), this.getZ(), p_359170_.copyWithCount(1))); +- } ++ ret.add(p_359170_); + }); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_359168_); + }); ++ return ret; } @Override -@@ -255,6 +_,12 @@ +@@ -233,6 +_,15 @@ } - return mushroomcow$mushroomtype2; + return mushroomcow$variant2; + } + + @Override + public java.util.List onSheared(@org.jetbrains.annotations.Nullable Player player, @org.jetbrains.annotations.NotNull ItemStack item, Level world, BlockPos pos, int fortune) { -+ this.gameEvent(GameEvent.SHEAR, player); -+ return shearInternal(player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS); ++ if (world instanceof ServerLevel server) { ++ this.gameEvent(GameEvent.SHEAR, player); ++ return shearInternal(server, player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, item); ++ } ++ return java.util.Collections.emptyList(); } - public static enum MushroomType implements StringRepresentable { + public static enum Variant implements StringRepresentable { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch index 2c47fe2550..59bf6610b5 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Ocelot.java +++ b/net/minecraft/world/entity/animal/Ocelot.java -@@ -160,7 +_,7 @@ +@@ -159,7 +_,7 @@ if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && p_29021_.distanceToSqr(this) < 9.0) { this.usePlayerItem(p_29021_, p_29022_, itemstack); if (!this.level().isClientSide) { 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 dbbe84225e..3cbbc44bc0 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 -@@ -257,7 +_,7 @@ +@@ -259,7 +_,7 @@ } if (!this.level().isClientSide) { 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 fe73f68408..d8b774599e 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch @@ -1,19 +1,18 @@ --- a/net/minecraft/world/entity/animal/Pig.java +++ b/net/minecraft/world/entity/animal/Pig.java -@@ -204,7 +_,7 @@ +@@ -205,13 +_,14 @@ @Override public void thunderHit(ServerLevel p_29473_, LightningBolt p_29474_) { - if (p_29473_.getDifficulty() != Difficulty.PEACEFUL) { + if (p_29473_.getDifficulty() != Difficulty.PEACEFUL && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.ZOMBIFIED_PIGLIN, (timer) -> {})) { - ZombifiedPiglin zombifiedpiglin = EntityType.ZOMBIFIED_PIGLIN.create(p_29473_); - if (zombifiedpiglin != null) { - zombifiedpiglin.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD)); -@@ -217,6 +_,7 @@ + ZombifiedPiglin zombifiedpiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, false, true), p_359172_ -> { + if (this.getMainHandItem().isEmpty()) { + p_359172_.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD)); } - zombifiedpiglin.setPersistenceRequired(); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zombifiedpiglin); - p_29473_.addFreshEntity(zombifiedpiglin); - this.discard(); - } else { + p_359172_.setPersistenceRequired(); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_359172_); + }); + if (zombifiedpiglin == null) { + super.thunderHit(p_29473_, p_29474_); 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 a9ffb636dc..ef62dc5797 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/animal/Rabbit.java +++ b/net/minecraft/world/entity/animal/Rabbit.java -@@ -527,7 +_,7 @@ +@@ -528,7 +_,7 @@ @Override public boolean canUse() { if (this.nextStartTick <= 0) { -- if (!this.rabbit.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.rabbit.level(), this.rabbit)) { +- if (!getServerLevel(this.rabbit).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(this.rabbit.level()), this.rabbit)) { return false; } 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 a69eadb85b..7922e58efc 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch @@ -1,48 +1,55 @@ --- a/net/minecraft/world/entity/animal/Sheep.java +++ b/net/minecraft/world/entity/animal/Sheep.java -@@ -212,7 +_,7 @@ +@@ -161,7 +_,7 @@ @Override public InteractionResult mobInteract(Player p_29853_, InteractionHand p_29854_) { ItemStack itemstack = p_29853_.getItemInHand(p_29854_); - if (itemstack.is(Items.SHEARS)) { + if (false && itemstack.is(Items.SHEARS)) { // Forge: Moved to onSheared - if (!this.level().isClientSide && this.readyForShearing()) { - this.shear(SoundSource.PLAYERS); + if (this.level() instanceof ServerLevel serverlevel && this.readyForShearing()) { + this.shear(serverlevel, SoundSource.PLAYERS, itemstack); this.gameEvent(GameEvent.SHEAR, p_29853_); -@@ -228,12 +_,24 @@ +@@ -177,12 +_,26 @@ @Override - public void shear(SoundSource p_29819_) { -+ dropShearedItems(shearInternal(p_29819_)); + public void shear(ServerLevel p_365174_, SoundSource p_29819_, ItemStack p_361058_) { ++ dropItems(p_365174_, shearInternal(p_365174_, p_29819_, p_361058_)); + } + -+ private java.util.List shearInternal(SoundSource p_29819_) { - this.level().playSound(null, this, SoundEvents.SHEEP_SHEAR, p_29819_, 1.0F, 1.0F); - this.setSheared(true); - int i = 1 + this.random.nextInt(3); - ++ private java.util.List shearInternal(ServerLevel p_365174_, SoundSource p_29819_, ItemStack p_361058_) { + var ret = new java.util.ArrayList(); - for (int j = 0; j < i; j++) { -- ItemEntity itementity = this.spawnAtLocation(ITEM_BY_DYE.get(this.getColor()), 1); -+ ret.add(new ItemStack(ITEM_BY_DYE.get(this.getColor()))); -+ } + p_365174_.playSound(null, this, SoundEvents.SHEEP_SHEAR, p_29819_, 1.0F, 1.0F); + this.dropFromShearingLootTable( + p_365174_, + BuiltInLootTables.SHEAR_SHEEP, + p_361058_, + (p_359182_, p_359183_) -> { ++ ret.add(p_359183_); ++ } ++ ); ++ this.setSheared(true); + return ret; + } + -+ private void dropShearedItems(java.util.List items) { -+ for (var stack : items) { -+ ItemEntity itementity = this.spawnAtLocation(stack, 1); - if (itementity != null) { - itementity.setDeltaMovement( - itementity.getDeltaMovement() -@@ -366,5 +_,10 @@ - - private static CraftingInput makeCraftInput(DyeColor p_344668_, DyeColor p_344678_) { - return CraftingInput.of(2, 1, List.of(new ItemStack(DyeItem.byColor(p_344668_)), new ItemStack(DyeItem.byColor(p_344678_)))); ++ private void dropItems(ServerLevel p_359182_, java.util.Collection items) { ++ for (var p_359183_ : items) { + for (int i = 0; i < p_359183_.getCount(); i++) { + ItemEntity itementity = this.spawnAtLocation(p_359182_, p_359183_.copyWithCount(1), 1.0F); + if (itementity != null) { +@@ -197,8 +_,14 @@ + } + } + } +- ); +- this.setSheared(true); + } + + @Override + public java.util.List onSheared(@Nullable Player player, ItemStack item, Level world, BlockPos pos, int fortune) { -+ return shearInternal(player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS); ++ if (world instanceof ServerLevel server) { ++ return shearInternal(server, player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, item); ++ } ++ return java.util.Collections.emptyList(); } - } + + @Override diff --git a/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch index 001d9e9f03..90fd6357b9 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/animal/SnowGolem.java +++ b/net/minecraft/world/entity/animal/SnowGolem.java -@@ -38,7 +_,7 @@ - import net.minecraft.world.level.gameevent.GameEvent; +@@ -41,7 +_,7 @@ + import net.minecraft.world.level.storage.loot.BuiltInLootTables; import net.minecraft.world.phys.Vec3; -public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackMob { @@ -9,16 +9,16 @@ private static final EntityDataAccessor DATA_PUMPKIN_ID = SynchedEntityData.defineId(SnowGolem.class, EntityDataSerializers.BYTE); private static final byte PUMPKIN_FLAG = 16; -@@ -92,7 +_,7 @@ - this.hurt(this.damageSources().onFire(), 1.0F); +@@ -95,7 +_,7 @@ + this.hurtServer(serverlevel, this.damageSources().onFire(), 1.0F); } -- if (!this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level(), this)) { +- if (!serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, this)) { return; } -@@ -103,7 +_,7 @@ +@@ -106,7 +_,7 @@ int k = Mth.floor(this.getY()); int l = Mth.floor(this.getZ() + (double)((float)(i / 2 % 2 * 2 - 1) * 0.25F)); BlockPos blockpos = new BlockPos(j, k, l); @@ -27,16 +27,16 @@ this.level().setBlockAndUpdate(blockpos, blockstate); this.level().gameEvent(GameEvent.BLOCK_PLACE, blockpos, GameEvent.Context.of(this, blockstate)); } -@@ -127,7 +_,7 @@ +@@ -136,7 +_,7 @@ @Override protected InteractionResult mobInteract(Player p_29920_, InteractionHand p_29921_) { ItemStack itemstack = p_29920_.getItemInHand(p_29921_); - if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { + if (false && itemstack.is(Items.SHEARS) && this.readyForShearing()) { //Forge: Moved to onSheared - this.shear(SoundSource.PLAYERS); - this.gameEvent(GameEvent.SHEAR, p_29920_); - if (!this.level().isClientSide) { -@@ -189,4 +_,16 @@ + if (this.level() instanceof ServerLevel serverlevel) { + this.shear(serverlevel, SoundSource.PLAYERS, itemstack); + this.gameEvent(GameEvent.SHEAR, p_29920_); +@@ -196,4 +_,18 @@ public Vec3 getLeashOffset() { return new Vec3(0.0, (double)(0.75F * this.getEyeHeight()), (double)(this.getBbWidth() * 0.4F)); } @@ -46,9 +46,11 @@ + public java.util.List onSheared(@Nullable Player player, @org.jetbrains.annotations.NotNull ItemStack item, Level world, BlockPos pos, int fortune) { + world.playSound(null, this, SoundEvents.SNOW_GOLEM_SHEAR, player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, 1.0F, 1.0F); + this.gameEvent(GameEvent.SHEAR, player); -+ if (!world.isClientSide()) { ++ if (!world.isClientSide() && world instanceof ServerLevel server) { + setPumpkin(false); -+ return java.util.Collections.singletonList(new ItemStack(Items.CARVED_PUMPKIN)); ++ var ret = new java.util.ArrayList(); ++ this.dropFromShearingLootTable(server, BuiltInLootTables.SHEAR_SNOW_GOLEM, item, (slevel, stack) -> ret.add(stack)); ++ return ret; + } + return java.util.Collections.emptyList(); + } diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch index 68027b0b29..65b7adf79a 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Wolf.java +++ b/net/minecraft/world/entity/animal/Wolf.java -@@ -87,7 +_,7 @@ +@@ -85,7 +_,7 @@ import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.phys.Vec3; @@ -9,26 +9,29 @@ private static final EntityDataAccessor DATA_INTERESTED_ID = SynchedEntityData.defineId(Wolf.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor DATA_COLLAR_COLOR = SynchedEntityData.defineId(Wolf.class, EntityDataSerializers.INT); private static final EntityDataAccessor DATA_REMAINING_ANGER_TIME = SynchedEntityData.defineId(Wolf.class, EntityDataSerializers.INT); -@@ -448,16 +_,11 @@ - this.setBodyArmorItem(itemstack.copyWithCount(1)); - itemstack.consume(1, p_30412_); - return InteractionResult.SUCCESS; -- } else if (itemstack.is(Items.SHEARS) -+ } else if (itemstack.canPerformAction(net.minecraftforge.common.ToolActions.SHEARS_HARVEST) - && this.isOwnedBy(p_30412_) - && this.hasArmor() - && (!EnchantmentHelper.has(this.getBodyArmorItem(), EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE) || p_30412_.isCreative())) { -- itemstack.hurtAndBreak(1, p_30412_, getSlotForHand(p_30413_)); -- this.playSound(SoundEvents.ARMOR_UNEQUIP_WOLF); -- ItemStack itemstack1 = this.getBodyArmorItem(); -- this.setBodyArmorItem(ItemStack.EMPTY); -- this.spawnAtLocation(itemstack1); -- return InteractionResult.SUCCESS; -+ return InteractionResult.PASS; - } else if (ArmorMaterials.ARMADILLO.value().repairIngredient().get().test(itemstack) - && this.isInSittingPose() - && this.hasArmor() -@@ -496,7 +_,7 @@ +@@ -430,19 +_,11 @@ + this.setBodyArmorItem(itemstack.copyWithCount(1)); + itemstack.consume(1, p_30412_); + return InteractionResult.SUCCESS; +- } else if (itemstack.is(Items.SHEARS) ++ } else if (itemstack.canPerformAction(net.minecraftforge.common.ToolActions.SHEARS_HARVEST) + && this.isOwnedBy(p_30412_) + && this.isWearingBodyArmor() + && (!EnchantmentHelper.has(this.getBodyArmorItem(), EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE) || p_30412_.isCreative())) { +- itemstack.hurtAndBreak(1, p_30412_, getSlotForHand(p_30413_)); +- this.playSound(SoundEvents.ARMOR_UNEQUIP_WOLF); +- ItemStack itemstack1 = this.getBodyArmorItem(); +- this.setBodyArmorItem(ItemStack.EMPTY); +- if (this.level() instanceof ServerLevel serverlevel) { +- this.spawnAtLocation(serverlevel, itemstack1); +- } +- +- return InteractionResult.SUCCESS; ++ return InteractionResult.PASS; + } else if (this.isInSittingPose() + && this.isWearingBodyArmor() + && this.isOwnedBy(p_30412_) +@@ -477,7 +_,7 @@ } private void tryToTame(Player p_336244_) { @@ -37,7 +40,7 @@ this.tame(p_336244_); this.navigation.stop(); this.setTarget(null); -@@ -648,6 +_,24 @@ +@@ -625,6 +_,24 @@ return true; } @@ -45,12 +48,12 @@ + + @Override + public boolean isShearable(ItemStack item, Level world, BlockPos pos) { -+ return this.hasArmor(); ++ return this.isWearingBodyArmor(); + } + + @Override + public java.util.List onSheared(@org.jetbrains.annotations.Nullable Player player, @org.jetbrains.annotations.NotNull ItemStack item, Level world, BlockPos pos, int fortune) { -+ if (!this.hasArmor() || (player != null && !this.isOwnedBy(player)) || ++ if (!this.isWearingBodyArmor() || (player != null && !this.isOwnedBy(player)) || + (EnchantmentHelper.has(this.getBodyArmorItem(), EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE) && (player == null || !player.isCreative())) + ) + return java.util.Collections.emptyList(); 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 38350686a6..daf26fdbaf 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,14 +1,11 @@ --- a/net/minecraft/world/entity/animal/allay/Allay.java +++ b/net/minecraft/world/entity/animal/allay/Allay.java -@@ -365,10 +_,7 @@ - @Override - public boolean wantsToPickUp(ItemStack p_218387_) { +@@ -367,7 +_,7 @@ + public boolean wantsToPickUp(ServerLevel p_363882_, ItemStack p_218387_) { ItemStack itemstack = this.getItemInHand(InteractionHand.MAIN_HAND); -- return !itemstack.isEmpty() -- && this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) -- && this.inventory.canAddItem(p_218387_) -- && this.allayConsidersItemEqual(itemstack, p_218387_); -+ return !itemstack.isEmpty() && this.inventory.canAddItem(p_218387_) && this.allayConsidersItemEqual(itemstack, p_218387_) && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level(), this); + return !itemstack.isEmpty() +- && p_363882_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ++ && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_363882_, this) + && this.inventory.canAddItem(p_218387_) + && this.allayConsidersItemEqual(itemstack, p_218387_); } - - private boolean allayConsidersItemEqual(ItemStack p_252278_, ItemStack p_250405_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/camel/Camel.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/camel/Camel.java.patch index 6b5a5b0c43..b42f0888e3 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/camel/Camel.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/camel/Camel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/camel/Camel.java +++ b/net/minecraft/world/entity/animal/camel/Camel.java -@@ -329,7 +_,7 @@ +@@ -330,7 +_,7 @@ @Override protected void playStepSound(BlockPos p_252056_, BlockState p_251457_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/frog/Tadpole.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/frog/Tadpole.java.patch deleted file mode 100644 index a3487d5ac5..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/animal/frog/Tadpole.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/world/entity/animal/frog/Tadpole.java -+++ b/net/minecraft/world/entity/animal/frog/Tadpole.java -@@ -225,6 +_,7 @@ - - private void ageUp() { - if (this.level() instanceof ServerLevel serverlevel) { -+ if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.FROG, timer -> this.ticksToBeFrog = this.age + timer)) return; - Frog frog = EntityType.FROG.create(this.level()); - if (frog != null) { - frog.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); -@@ -239,6 +_,7 @@ - frog.fudgePositionAfterSizeChange(this.getDimensions(this.getPose())); - this.playSound(SoundEvents.TADPOLE_GROW_UP, 0.15F, 1.0F); - serverlevel.addFreshEntityWithPassengers(frog); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, frog); - this.discard(); - } - } 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 17543f5e41..1cff62e726 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 -@@ -303,6 +_,11 @@ +@@ -312,6 +_,11 @@ @Override public boolean causeFallDamage(float p_149499_, float p_149500_, DamageSource p_149501_) { @@ -12,7 +12,7 @@ if (p_149499_ > 1.0F) { this.playSound(SoundEvents.HORSE_LAND, 0.4F, 1.0F); } -@@ -348,6 +_,7 @@ +@@ -357,6 +_,7 @@ this.inventory.addListener(this); this.syncSaddleToClients(); @@ -20,7 +20,7 @@ } protected void syncSaddleToClients() { -@@ -393,9 +_,9 @@ +@@ -402,9 +_,9 @@ protected void playStepSound(BlockPos p_30584_, BlockState p_30585_) { if (!p_30585_.liquid()) { BlockState blockstate = this.level().getBlockState(p_30584_.above()); @@ -32,7 +32,7 @@ } if (this.isVehicle() && this.canGallop) { -@@ -818,6 +_,7 @@ +@@ -825,6 +_,7 @@ float f1 = Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)); this.setDeltaMovement(this.getDeltaMovement().add((double)(-0.4F * f * p_248808_), 0.0, (double)(0.4F * f1 * p_248808_))); } @@ -40,7 +40,7 @@ } protected void playJumpSound() { -@@ -1134,6 +_,26 @@ +@@ -1141,6 +_,26 @@ public final Container getBodyArmorAccess() { return this.bodyArmorAccess; diff --git a/patches/minecraft/net/minecraft/world/entity/animal/horse/Llama.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/horse/Llama.java.patch index dff853f622..50d36b46d1 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/horse/Llama.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/horse/Llama.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/Llama.java +++ b/net/minecraft/world/entity/animal/horse/Llama.java -@@ -371,6 +_,10 @@ +@@ -355,6 +_,10 @@ @Override public boolean causeFallDamage(float p_149538_, float p_149539_, DamageSource p_149540_) { 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 5f25f31d7d..2400f2c96e 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,63 +1,16 @@ --- a/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java +++ b/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java -@@ -31,33 +_,38 @@ +@@ -31,6 +_,13 @@ @Override public void tick() { ServerLevel serverlevel = (ServerLevel)this.horse.level(); -- DifficultyInstance difficultyinstance = serverlevel.getCurrentDifficultyAt(this.horse.blockPosition()); -- this.horse.setTrap(false); -- this.horse.setTamed(true); -- this.horse.setAge(0); -- LightningBolt lightningbolt = EntityType.LIGHTNING_BOLT.create(serverlevel); -- if (lightningbolt != null) { -- lightningbolt.moveTo(this.horse.getX(), this.horse.getY(), this.horse.getZ()); -- lightningbolt.setVisualOnly(true); -- serverlevel.addFreshEntity(lightningbolt); -- Skeleton skeleton = this.createSkeleton(difficultyinstance, this.horse); -- if (skeleton != null) { -- skeleton.startRiding(this.horse); -- serverlevel.addFreshEntityWithPassengers(skeleton); + // Forge: Trigger the trap in a tick task to avoid crashes when mods add goals to skeleton horses + // (MC-206338/Forge PR #7509) -+ serverlevel.getServer().tell(new net.minecraft.server.TickTask(serverlevel.getServer().getTickCount(), () -> { -+ if (!this.horse.isAlive()) return; -+ DifficultyInstance difficultyinstance = serverlevel.getCurrentDifficultyAt(this.horse.blockPosition()); -+ this.horse.setTrap(false); -+ this.horse.setTamed(true); -+ this.horse.setAge(0); -+ LightningBolt lightningbolt = EntityType.LIGHTNING_BOLT.create(serverlevel); -+ if (lightningbolt != null) { -+ lightningbolt.moveTo(this.horse.getX(), this.horse.getY(), this.horse.getZ()); -+ lightningbolt.setVisualOnly(true); -+ serverlevel.addFreshEntity(lightningbolt); -+ Skeleton skeleton = this.createSkeleton(difficultyinstance, this.horse); -+ if (skeleton != null) { -+ skeleton.startRiding(this.horse); -+ serverlevel.addFreshEntityWithPassengers(skeleton); - -- for (int i = 0; i < 3; i++) { -- AbstractHorse abstracthorse = this.createHorse(difficultyinstance); -- if (abstracthorse != null) { -- Skeleton skeleton1 = this.createSkeleton(difficultyinstance, abstracthorse); -- if (skeleton1 != null) { -- skeleton1.startRiding(abstracthorse); -- abstracthorse.push(this.horse.getRandom().triangle(0.0, 1.1485), 0.0, this.horse.getRandom().triangle(0.0, 1.1485)); -- serverlevel.addFreshEntityWithPassengers(abstracthorse); -+ for (int i = 0; i < 3; i++) { -+ AbstractHorse abstracthorse = this.createHorse(difficultyinstance); -+ if (abstracthorse != null) { -+ Skeleton skeleton1 = this.createSkeleton(difficultyinstance, abstracthorse); -+ if (skeleton1 != null) { -+ skeleton1.startRiding(abstracthorse); -+ abstracthorse.push(this.horse.getRandom().triangle(0.0, 1.1485), 0.0, this.horse.getRandom().triangle(0.0, 1.1485)); -+ serverlevel.addFreshEntityWithPassengers(abstracthorse); -+ } - } - } - } - } -- } -+ })); - } - - @Nullable ++ serverlevel.getServer().schedule(serverlevel.getServer().wrapRunnable(() -> this.convert(serverlevel))); ++ } ++ ++ private void convert(ServerLevel serverlevel) { ++ if (!this.horse.isAlive()) return; + DifficultyInstance difficultyinstance = serverlevel.getCurrentDifficultyAt(this.horse.blockPosition()); + this.horse.setTrap(false); + this.horse.setTamed(true); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch index 66702d0c90..7c81e17a79 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java +++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java -@@ -300,8 +_,7 @@ +@@ -293,8 +_,7 @@ } if (this.tickCount % 10 == 0) { 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 0a49eb7059..5ebfeea3f0 100644 --- a/patches/minecraft/net/minecraft/world/entity/boss/EnderDragonPart.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/boss/EnderDragonPart.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/EnderDragonPart.java +++ b/net/minecraft/world/entity/boss/EnderDragonPart.java -@@ -13,13 +_,13 @@ +@@ -14,13 +_,13 @@ import net.minecraft.world.entity.boss.enderdragon.EnderDragon; import net.minecraft.world.item.ItemStack; diff --git a/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch b/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch index aaf4ee5a84..a6e2d83146 100644 --- a/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java -@@ -105,6 +_,15 @@ +@@ -103,6 +_,15 @@ + this.setHealth(this.getMaxHealth()); this.noPhysics = true; - this.noCulling = true; this.phaseManager = new EnderDragonPhaseManager(this); + this.setId(ENTITY_COUNTER.getAndAdd(this.subEntities.length + 1) + 1); // Forge: Fix MC-158205: Make sure part ids are successors of parent mob id + } @@ -16,8 +16,8 @@ } public void setDragonFight(EndDragonFight p_287736_) { -@@ -172,8 +_,19 @@ - return adouble; +@@ -151,8 +_,19 @@ + p_330342_.define(DATA_PHASE, EnderDragonPhase.HOVERING.getId()); } + @org.jetbrains.annotations.Nullable private Player unlimitedLastHurtByPlayer = null; @@ -36,36 +36,36 @@ this.processFlappingMovement(); if (this.level().isClientSide) { this.setHealth(this.getHealth()); -@@ -475,7 +_,7 @@ +@@ -445,7 +_,7 @@ BlockPos blockpos = new BlockPos(k1, l1, i2); - BlockState blockstate = this.level().getBlockState(blockpos); + BlockState blockstate = p_363273_.getBlockState(blockpos); if (!blockstate.isAir() && !blockstate.is(BlockTags.DRAGON_TRANSPARENT)) { -- if (this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { -+ if (net.minecraftforge.common.ForgeHooks.canEntityDestroy(this.level(), blockpos, this) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { - flag1 = this.level().removeBlock(blockpos, false) || flag1; +- if (p_363273_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { ++ if (net.minecraftforge.common.ForgeHooks.canEntityDestroy(p_363273_, blockpos, this) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { + flag1 = p_363273_.removeBlock(blockpos, false) || flag1; } else { flag = true; -@@ -571,7 +_,8 @@ +@@ -540,7 +_,8 @@ - if (this.level() instanceof ServerLevel) { - if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && flag) { -- ExperienceOrb.award((ServerLevel)this.level(), this.position(), Mth.floor((float)i * 0.08F)); + if (this.level() instanceof ServerLevel serverlevel) { + if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && serverlevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { +- ExperienceOrb.award(serverlevel, this.position(), Mth.floor((float)i * 0.08F)); + int award = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.unlimitedLastHurtByPlayer, Mth.floor((float)i * 0.08F)); -+ ExperienceOrb.award((ServerLevel) this.level(), this.position(), award); ++ ExperienceOrb.award(serverlevel, this.position(), award); } if (this.dragonDeathTime == 1 && !this.isSilent()) { -@@ -582,7 +_,8 @@ +@@ -551,7 +_,8 @@ this.move(MoverType.SELF, new Vec3(0.0, 0.1F, 0.0)); - if (this.dragonDeathTime == 200 && this.level() instanceof ServerLevel) { - if (flag) { -- ExperienceOrb.award((ServerLevel)this.level(), this.position(), Mth.floor((float)i * 0.2F)); + if (this.dragonDeathTime == 200 && this.level() instanceof ServerLevel serverlevel1) { + if (serverlevel1.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { +- ExperienceOrb.award(serverlevel1, this.position(), Mth.floor((float)i * 0.2F)); + int award = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.unlimitedLastHurtByPlayer, Mth.floor((float)i * 0.2F)); -+ ExperienceOrb.award((ServerLevel) this.level(), this.position(), award); ++ ExperienceOrb.award(serverlevel1, this.position(), award); } if (this.dragonFight != null) { -@@ -916,6 +_,7 @@ +@@ -864,6 +_,7 @@ @Override public void recreateFromPacket(ClientboundAddEntityPacket p_218825_) { super.recreateFromPacket(p_218825_); @@ -73,7 +73,7 @@ EnderDragonPart[] aenderdragonpart = this.getSubEntities(); for (int i = 0; i < aenderdragonpart.length; i++) { -@@ -931,5 +_,15 @@ +@@ -879,5 +_,15 @@ @Override protected float sanitizeScale(float p_333905_) { return 1.0F; 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 e04e823263..2728a9cee9 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,24 +1,24 @@ --- a/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java -@@ -316,7 +_,7 @@ +@@ -315,7 +_,7 @@ if (this.destroyBlocksTick > 0) { this.destroyBlocksTick--; -- if (this.destroyBlocksTick == 0 && this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (this.destroyBlocksTick == 0 && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level(), this)) { +- if (this.destroyBlocksTick == 0 && p_363567_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (this.destroyBlocksTick == 0 && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_363567_, this)) { boolean flag = false; int l = Mth.floor(this.getBbWidth() / 2.0F + 1.0F); int i1 = Mth.floor(this.getBbHeight()); -@@ -325,7 +_,7 @@ +@@ -324,7 +_,7 @@ this.getBlockX() - l, this.getBlockY(), this.getBlockZ() - l, this.getBlockX() + l, this.getBlockY() + i1, this.getBlockZ() + l )) { - BlockState blockstate = this.level().getBlockState(blockpos); + BlockState blockstate = p_363567_.getBlockState(blockpos); - if (canDestroy(blockstate)) { -+ if (blockstate.canEntityDestroy(this.level(), blockpos, this) && net.minecraftforge.event.ForgeEventFactory.onEntityDestroyBlock(this, blockpos, blockstate)) { - flag = this.level().destroyBlock(blockpos, true, this) || flag; ++ if (blockstate.canEntityDestroy(p_363567_, blockpos, this) && net.minecraftforge.event.ForgeEventFactory.onEntityDestroyBlock(this, blockpos, blockstate)) { + flag = p_363567_.destroyBlock(blockpos, true, this) || flag; } } -@@ -344,6 +_,10 @@ +@@ -343,6 +_,10 @@ } } diff --git a/patches/minecraft/net/minecraft/world/entity/decoration/ArmorStand.java.patch b/patches/minecraft/net/minecraft/world/entity/decoration/ArmorStand.java.patch deleted file mode 100644 index 2d87f092d4..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/decoration/ArmorStand.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/entity/decoration/ArmorStand.java -+++ b/net/minecraft/world/entity/decoration/ArmorStand.java -@@ -72,8 +_,7 @@ - public static final EntityDataAccessor DATA_RIGHT_ARM_POSE = SynchedEntityData.defineId(ArmorStand.class, EntityDataSerializers.ROTATIONS); - public static final EntityDataAccessor DATA_LEFT_LEG_POSE = SynchedEntityData.defineId(ArmorStand.class, EntityDataSerializers.ROTATIONS); - public static final EntityDataAccessor DATA_RIGHT_LEG_POSE = SynchedEntityData.defineId(ArmorStand.class, EntityDataSerializers.ROTATIONS); -- private static final Predicate RIDABLE_MINECARTS = p_31582_ -> p_31582_ instanceof AbstractMinecart -- && ((AbstractMinecart)p_31582_).getMinecartType() == AbstractMinecart.Type.RIDEABLE; -+ private static final Predicate RIDABLE_MINECARTS = p_31582_ -> p_31582_ instanceof AbstractMinecart abstractMinecart && abstractMinecart.canBeRidden(); - private final NonNullList handItems = NonNullList.withSize(2, ItemStack.EMPTY); - private final NonNullList armorItems = NonNullList.withSize(4, ItemStack.EMPTY); - private boolean invisible; diff --git a/patches/minecraft/net/minecraft/world/entity/decoration/HangingEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/decoration/HangingEntity.java.patch index bf591e12c6..b16a8430e1 100644 --- a/patches/minecraft/net/minecraft/world/entity/decoration/HangingEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/decoration/HangingEntity.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/entity/decoration/HangingEntity.java +++ b/net/minecraft/world/entity/decoration/HangingEntity.java -@@ -59,6 +_,8 @@ +@@ -60,6 +_,8 @@ } else { - boolean flag = BlockPos.betweenClosedStream(this.calculateSupportBox()).allMatch(p_341437_ -> { - BlockState blockstate = this.level().getBlockState(p_341437_); -+ if (net.minecraft.world.level.block.Block.canSupportCenter(this.level(), p_341437_, this.direction)) + boolean flag = BlockPos.betweenClosedStream(this.calculateSupportBox()).allMatch(p_359231_ -> { + BlockState blockstate = this.level().getBlockState(p_359231_); ++ if (net.minecraft.world.level.block.Block.canSupportCenter(this.level(), p_359231_, this.direction)) + return true; return blockstate.isSolid() || DiodeBlock.isDiode(blockstate); }); 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 a9557c2961..38f8fc8b4e 100644 --- a/patches/minecraft/net/minecraft/world/entity/item/FallingBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/item/FallingBlockEntity.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -138,7 +_,7 @@ - if (!this.level().isClientSide && (this.isAlive() || this.forceTickAfterTeleportToDuplicate)) { +@@ -148,7 +_,7 @@ + if (this.level() instanceof ServerLevel serverlevel && (this.isAlive() || this.forceTickAfterTeleportToDuplicate)) { BlockPos blockpos = this.blockPosition(); boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock; - boolean flag1 = flag && this.level().getFluidState(blockpos).is(FluidTags.WATER); @@ -9,7 +9,7 @@ double d0 = this.getDeltaMovement().lengthSqr(); if (flag && d0 > 1.0) { BlockHitResult blockhitresult = this.level() -@@ -151,7 +_,7 @@ +@@ -161,7 +_,7 @@ this ) ); 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 a050c6c622..55b39f2d98 100644 --- a/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -46,8 +46,8 @@ if (this.isInWater() && this.getFluidHeight(FluidTags.WATER) > 0.1F) { this.setUnderwaterMovement(); } else if (this.isInLava() && this.getFluidHeight(FluidTags.LAVA) > 0.1F) { -@@ -153,7 +_,8 @@ - this.move(MoverType.SELF, this.getDeltaMovement()); +@@ -154,7 +_,8 @@ + this.applyEffectsFromBlocks(); float f = 0.98F; if (this.onGround()) { - f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F; @@ -56,7 +56,7 @@ } this.setDeltaMovement(this.getDeltaMovement().multiply((double)f, 0.98, (double)f)); -@@ -185,7 +_,16 @@ +@@ -186,7 +_,16 @@ } } @@ -74,16 +74,16 @@ this.discard(); } } -@@ -282,7 +_,7 @@ - this.health = (int)((float)this.health - p_32014_); - this.gameEvent(GameEvent.ENTITY_DAMAGE, p_32013_.getEntity()); +@@ -294,7 +_,7 @@ + this.health = (int)((float)this.health - p_362683_); + this.gameEvent(GameEvent.ENTITY_DAMAGE, p_364841_.getEntity()); if (this.health <= 0) { - this.getItem().onDestroyed(this); -+ this.getItem().onDestroyed(this, p_32013_); ++ this.getItem().onDestroyed(this, p_364841_); this.discard(); } -@@ -295,6 +_,7 @@ +@@ -312,6 +_,7 @@ p_32050_.putShort("Health", (short)this.health); p_32050_.putShort("Age", (short)this.age); p_32050_.putShort("PickupDelay", (short)this.pickupDelay); @@ -91,7 +91,7 @@ if (this.thrower != null) { p_32050_.putUUID("Thrower", this.thrower); } -@@ -316,6 +_,10 @@ +@@ -333,6 +_,10 @@ this.pickupDelay = p_32034_.getShort("PickupDelay"); } @@ -102,7 +102,7 @@ if (p_32034_.hasUUID("Owner")) { this.target = p_32034_.getUUID("Owner"); } -@@ -340,10 +_,17 @@ +@@ -357,10 +_,17 @@ @Override public void playerTouch(Player p_32040_) { if (!this.level().isClientSide) { @@ -121,7 +121,7 @@ p_32040_.take(this, i); if (itemstack.isEmpty()) { this.discard(); -@@ -437,7 +_,7 @@ +@@ -454,7 +_,7 @@ public void makeFakeItem() { this.setNeverPickUp(); @@ -129,4 +129,4 @@ + this.age = getItem().getEntityLifespan(this.level()) - 1; } - public float getSpin(float p_32009_) { + public static float getSpin(float p_32009_, float p_369793_) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch index 0cd95f1cfc..09906ac37d 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/AbstractSkeleton.java +++ b/net/minecraft/world/entity/monster/AbstractSkeleton.java -@@ -157,7 +_,7 @@ +@@ -159,7 +_,7 @@ if (this.level() != null && !this.level().isClientSide) { this.goalSelector.removeGoal(this.meleeGoal); this.goalSelector.removeGoal(this.bowGoal); @@ -9,7 +9,7 @@ if (itemstack.is(Items.BOW)) { int i = this.getHardAttackInterval(); if (this.level().getDifficulty() != Difficulty.HARD) { -@@ -182,9 +_,12 @@ +@@ -184,9 +_,12 @@ @Override public void performRangedAttack(LivingEntity p_32141_, float p_32142_) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Bogged.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Bogged.java.patch index cf37f0cb6b..e2610cea20 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Bogged.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Bogged.java.patch @@ -1,49 +1,29 @@ --- a/net/minecraft/world/entity/monster/Bogged.java +++ b/net/minecraft/world/entity/monster/Bogged.java -@@ -74,7 +_,7 @@ +@@ -70,7 +_,7 @@ @Override protected InteractionResult mobInteract(Player p_335303_, InteractionHand p_335145_) { ItemStack itemstack = p_335303_.getItemInHand(p_335145_); - if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { + if (false && itemstack.is(Items.SHEARS) && this.readyForShearing()) { // Forge: move to onSheared - this.shear(SoundSource.PLAYERS); - this.gameEvent(GameEvent.SHEAR, p_335303_); - if (!this.level().isClientSide) { -@@ -129,12 +_,20 @@ - + if (this.level() instanceof ServerLevel serverlevel) { + this.shear(serverlevel, SoundSource.PLAYERS, itemstack); + this.gameEvent(GameEvent.SHEAR, p_335303_); +@@ -137,5 +_,17 @@ @Override - public void shear(SoundSource p_332421_) { -- this.level().playSound(null, this, SoundEvents.BOGGED_SHEAR, p_332421_, 1.0F, 1.0F); -- this.spawnShearedMushrooms(); -+ shearInternal(p_332421_).stream().forEach(stack -> this.spawnAtLocation(stack, this.getBbHeight())); + public boolean readyForShearing() { + return !this.isSheared() && this.isAlive(); + } + + @Override + public java.util.List onSheared(@org.jetbrains.annotations.Nullable Player player, @org.jetbrains.annotations.NotNull ItemStack item, Level world, net.minecraft.core.BlockPos pos, int fortune) { -+ this.gameEvent(GameEvent.SHEAR, player); -+ return shearInternal(player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS); -+ } -+ -+ private java.util.List shearInternal(SoundSource sound) { -+ this.level().playSound(null, this, SoundEvents.BOGGED_SHEAR, sound, 1.0F, 1.0F); - this.setSheared(true); -- } - -- private void spawnShearedMushrooms() { -+ var ret = new java.util.ArrayList(); - if (this.level() instanceof ServerLevel serverlevel) { - LootTable loottable = serverlevel.getServer().reloadableRegistries().getLootTable(BuiltInLootTables.BOGGED_SHEAR); - LootParams lootparams = new LootParams.Builder(serverlevel) -@@ -143,9 +_,11 @@ - .create(LootContextParamSets.SHEARING); - - for (ItemStack itemstack : loottable.getRandomItems(lootparams)) { -- this.spawnAtLocation(itemstack, this.getBbHeight()); -+ ret.add(itemstack); - } - } -+ -+ return ret; ++ if (world instanceof ServerLevel server) { ++ server.playSound(null, this, SoundEvents.BOGGED_SHEAR, SoundSource.PLAYERS, 1.0F, 1.0F); ++ this.setSheared(true); ++ var ret = new java.util.ArrayList(); ++ this.dropFromShearingLootTable(server, BuiltInLootTables.BOGGED_SHEAR, item, (slevel, stack) -> ret.add(stack)); ++ return ret; ++ } ++ return java.util.Collections.emptyList(); } - - @Override + } 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 b65b7d9697..c7b871fd8d 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -16,16 +16,16 @@ } @Override -@@ -210,7 +_,7 @@ +@@ -209,7 +_,7 @@ + } - boolean isLookingAtMe(Player p_32535_) { - ItemStack itemstack = p_32535_.getInventory().armor.get(3); -- if (itemstack.is(Blocks.CARVED_PUMPKIN.asItem())) { -+ if (net.minecraftforge.common.ForgeHooks.shouldSuppressEnderManAnger(this, p_32535_, itemstack)) { - return false; - } else { - Vec3 vec3 = p_32535_.getViewVector(1.0F).normalize(); -@@ -297,8 +_,10 @@ + boolean isBeingStaredBy(Player p_368759_) { +- return this.isLookingAtMe(p_368759_, 0.025, true, false, LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM, new DoubleSupplier[]{this::getEyeY}); ++ return this.isLookingAtMe(p_368759_, 0.025, true, false, net.minecraftforge.common.ForgeHooks.isNotDisguised(this), new DoubleSupplier[]{this::getEyeY}); + } + + @Override +@@ -287,8 +_,10 @@ boolean flag = blockstate.blocksMotion(); boolean flag1 = blockstate.getFluidState().is(FluidTags.WATER); if (flag && !flag1) { @@ -37,16 +37,16 @@ if (flag2) { this.level().gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(this)); if (!this.isSilent()) { -@@ -451,7 +_,7 @@ +@@ -441,7 +_,7 @@ if (this.enderman.getCarriedBlock() == null) { return false; } else { -- return !this.enderman.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(2000)) == 0; -+ return !net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.enderman.level(), this.enderman) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(2000)) == 0; +- return !getServerLevel(this.enderman).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(2000)) == 0; ++ return !net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(this.enderman), this.enderman) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(2000)) == 0; } } -@@ -469,7 +_,7 @@ +@@ -459,7 +_,7 @@ BlockState blockstate2 = this.enderman.getCarriedBlock(); if (blockstate2 != null) { blockstate2 = Block.updateFromNeighbourShapes(blockstate2, this.enderman.level(), blockpos); @@ -55,26 +55,20 @@ level.setBlock(blockpos, blockstate2, 3); level.gameEvent(GameEvent.BLOCK_PLACE, blockpos, GameEvent.Context.of(this.enderman, blockstate2)); this.enderman.setCarriedBlock(null); -@@ -478,12 +_,7 @@ - } - - private boolean canPlaceBlock(Level p_32559_, BlockPos p_32560_, BlockState p_32561_, BlockState p_32562_, BlockState p_32563_, BlockPos p_32564_) { -- return p_32562_.isAir() -- && !p_32563_.isAir() -- && !p_32563_.is(Blocks.BEDROCK) -- && p_32563_.isCollisionShapeFullBlock(p_32559_, p_32564_) -- && p_32561_.canSurvive(p_32559_, p_32560_) -- && p_32559_.getEntities(this.enderman, AABB.unitCubeFromLowerCorner(Vec3.atLowerCornerOf(p_32560_))).isEmpty(); -+ return p_32562_.isAir() && !p_32563_.isAir() && !p_32563_.is(Blocks.BEDROCK) && !p_32563_.is(net.minecraftforge.common.Tags.Blocks.ENDERMAN_PLACE_ON_BLACKLIST) && p_32563_.isCollisionShapeFullBlock(p_32559_, p_32564_) && p_32561_.canSurvive(p_32559_, p_32560_) && p_32559_.getEntities(this.enderman, AABB.unitCubeFromLowerCorner(Vec3.atLowerCornerOf(p_32560_))).isEmpty(); - } - } - -@@ -589,7 +_,7 @@ +@@ -471,6 +_,7 @@ + return p_32562_.isAir() + && !p_32563_.isAir() + && !p_32563_.is(Blocks.BEDROCK) ++ && !p_32563_.is(net.minecraftforge.common.Tags.Blocks.ENDERMAN_PLACE_ON_BLACKLIST) + && p_32563_.isCollisionShapeFullBlock(p_32559_, p_32564_) + && p_32561_.canSurvive(p_32559_, p_32560_) + && p_32559_.getEntities(this.enderman, AABB.unitCubeFromLowerCorner(Vec3.atLowerCornerOf(p_32560_))).isEmpty(); +@@ -580,7 +_,7 @@ if (this.enderman.getCarriedBlock() != null) { return false; } else { -- return !this.enderman.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(20)) == 0; -+ return !net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.enderman.level(), this.enderman) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(20)) == 0; +- return !getServerLevel(this.enderman).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(20)) == 0; ++ return !net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(this.enderman), this.enderman) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(20)) == 0; } } 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 7fc02da689..6e67393d92 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/Evoker.java +++ b/net/minecraft/world/entity/monster/Evoker.java -@@ -307,7 +_,7 @@ - return false; - } else if (Evoker.this.tickCount < this.nextAttackTickCount) { - return false; -- } else if (!Evoker.this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ } else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(Evoker.this.level(), Evoker.this)) { +@@ -308,7 +_,7 @@ return false; } else { - List list = Evoker.this.level().getNearbyEntities(Sheep.class, this.wololoTargeting, Evoker.this, Evoker.this.getBoundingBox().inflate(16.0, 4.0, 16.0)); + ServerLevel serverlevel = getServerLevel(Evoker.this.level()); +- if (!serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, Evoker.this)) { + return false; + } else { + List list = serverlevel.getNearbyEntities(Sheep.class, this.wololoTargeting, Evoker.this, Evoker.this.getBoundingBox().inflate(16.0, 4.0, 16.0)); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Husk.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Husk.java.patch index 1d70eedfc3..29b20e2df3 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Husk.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Husk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Husk.java +++ b/net/minecraft/world/entity/monster/Husk.java -@@ -69,6 +_,7 @@ +@@ -70,6 +_,7 @@ @Override protected void doUnderWaterConversion() { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Illusioner.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Illusioner.java.patch index 6cca9fb9ec..ab2a3a37ff 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Illusioner.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Illusioner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Illusioner.java +++ b/net/minecraft/world/entity/monster/Illusioner.java -@@ -173,9 +_,12 @@ +@@ -171,9 +_,12 @@ @Override public void performRangedAttack(LivingEntity p_32918_, float p_32919_) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Monster.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Monster.java.patch index 5fcded1daa..f3d9d62e08 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Monster.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Monster.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Monster.java +++ b/net/minecraft/world/entity/monster/Monster.java -@@ -138,9 +_,9 @@ +@@ -139,9 +_,9 @@ if (p_33038_.getItem() instanceof ProjectileWeaponItem) { Predicate predicate = ((ProjectileWeaponItem)p_33038_.getItem()).getSupportedHeldProjectiles(); ItemStack itemstack = ProjectileWeaponItem.getHeldProjectile(this, predicate); 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 f08cd904f2..ea74e23dd8 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 -@@ -116,7 +_,7 @@ +@@ -119,7 +_,7 @@ public AbstractIllager.IllagerArmPose getArmPose() { if (this.isChargingCrossbow()) { return AbstractIllager.IllagerArmPose.CROSSBOW_CHARGE; diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch index 5ebbda0380..6a7b9077cc 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/Ravager.java +++ b/net/minecraft/world/entity/monster/Ravager.java -@@ -134,7 +_,7 @@ +@@ -139,7 +_,7 @@ this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(Mth.lerp(0.1, d1, d0)); } -- if (this.horizontalCollision && this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (this.horizontalCollision && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level(), this)) { +- if (this.level() instanceof ServerLevel serverlevel && this.horizontalCollision && serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (this.level() instanceof ServerLevel serverlevel && this.horizontalCollision && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, this)) { boolean flag = false; AABB aabb = this.getBoundingBox().inflate(0.2); 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 89864dc705..8fd2873e51 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 -@@ -390,6 +_,12 @@ +@@ -391,6 +_,12 @@ && this.level().noCollision(this, new AABB(blockpos1).deflate(1.0E-6))) { Direction direction = this.findAttachableSurface(blockpos1); if (direction != null) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch index 3769ca904a..5f5c7eb560 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/entity/monster/Silverfish.java +++ b/net/minecraft/world/entity/monster/Silverfish.java -@@ -140,7 +_,7 @@ +@@ -143,7 +_,7 @@ return false; } else { RandomSource randomsource = this.mob.getRandom(); -- if (this.mob.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && randomsource.nextInt(reducedTickDelay(10)) == 0) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.mob.level(), this.mob) && randomsource.nextInt(reducedTickDelay(10)) == 0) { +- if (getServerLevel(this.mob).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && randomsource.nextInt(reducedTickDelay(10)) == 0) { ++ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(this.mob.level()), this.mob) && randomsource.nextInt(reducedTickDelay(10)) == 0) { this.selectedDirection = Direction.getRandom(randomsource); BlockPos blockpos = BlockPos.containing(this.mob.getX(), this.mob.getY() + 0.5, this.mob.getZ()) .relative(this.selectedDirection); -@@ -213,7 +_,7 @@ +@@ -216,7 +_,7 @@ BlockState blockstate = level.getBlockState(blockpos1); Block block = blockstate.getBlock(); if (block instanceof InfestedBlock) { -- if (level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(level, this.silverfish)) { +- if (getServerLevel(level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(level), this.silverfish)) { level.destroyBlock(blockpos1, true, this.silverfish); } else { level.setBlock(blockpos1, ((InfestedBlock)block).hostStateByInfested(level.getBlockState(blockpos1)), 3); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch index 8b9a7a9d01..4f358100c6 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch @@ -1,16 +1,10 @@ --- a/net/minecraft/world/entity/monster/Skeleton.java +++ b/net/minecraft/world/entity/monster/Skeleton.java -@@ -86,10 +_,12 @@ +@@ -89,6 +_,7 @@ } protected void doFreezeConversion() { -- this.convertTo(EntityType.STRAY, true); + if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.STRAY, (timer) -> this.conversionTime = timer)) return; -+ var result = this.convertTo(EntityType.STRAY, true); - if (!this.isSilent()) { - this.level().levelEvent(null, 1048, this.blockPosition(), 0); - } -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, result); - } - - @Override + this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), p_361572_ -> { + if (!this.isSilent()) { + this.level().levelEvent(null, 1048, this.blockPosition(), 0); 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 119b630625..b7cb2ca5de 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Slime.java +++ b/net/minecraft/world/entity/monster/Slime.java -@@ -141,13 +_,15 @@ +@@ -146,13 +_,15 @@ float f = this.getDimensions(this.getPose()).width() * 2.0F; float f1 = f / 2.0F; @@ -23,7 +23,7 @@ this.playSound(this.getSquishSound(), this.getSoundVolume(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F); this.targetSquish = -0.5F; -@@ -158,6 +_,12 @@ +@@ -163,6 +_,12 @@ this.wasOnGround = this.onGround(); this.decreaseSquish(); } 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 2bcd2e21d5..09c7f75a5e 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch @@ -1,75 +1,66 @@ --- a/net/minecraft/world/entity/monster/Zombie.java +++ b/net/minecraft/world/entity/monster/Zombie.java -@@ -257,6 +_,7 @@ +@@ -262,21 +_,28 @@ } - protected void doUnderWaterConversion() { -+ if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.DROWNED, (timer) -> this.conversionTime = timer)) return; - this.convertToZombieType(EntityType.DROWNED); - if (!this.isSilent()) { - this.level().levelEvent(null, 1040, this.blockPosition(), 0); -@@ -268,6 +_,7 @@ - if (zombie != null) { - zombie.handleAttributes(zombie.level().getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier()); - zombie.setCanBreakDoors(zombie.supportsBreakDoorGoal() && this.canBreakDoors()); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zombie); - } + protected void convertToZombieType(EntityType p_34311_) { ++ if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, p_34311_, timer -> this.conversionTime = timer)) return; + this.convertTo( + p_34311_, + ConversionParams.single(this, true, true), +- p_359259_ -> p_359259_.handleAttributes(p_359259_.level().getCurrentDifficultyAt(p_359259_.blockPosition()).getSpecialMultiplier()) ++ p_359259_ -> { ++ p_359259_.handleAttributes(p_359259_.level().getCurrentDifficultyAt(p_359259_.blockPosition()).getSpecialMultiplier()); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_359259_); ++ } + ); } -@@ -288,15 +_,25 @@ - livingentity = (LivingEntity)p_34288_.getEntity(); + @VisibleForTesting + public boolean convertVillagerToZombieVillager(ServerLevel p_369430_, Villager p_360910_) { ++ if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(p_360910_, EntityType.ZOMBIE_VILLAGER, (timer) -> {})) ++ return false; + ZombieVillager zombievillager = p_360910_.convertTo(EntityType.ZOMBIE_VILLAGER, ConversionParams.single(p_360910_, true, true), p_359258_ -> { + p_359258_.finalizeSpawn(p_369430_, p_369430_.getCurrentDifficultyAt(p_359258_.blockPosition()), EntitySpawnReason.CONVERSION, new Zombie.ZombieGroupData(false, true)); + p_359258_.setVillagerData(p_360910_.getVillagerData()); + p_359258_.setGossips(p_360910_.getGossips().store(NbtOps.INSTANCE)); + p_359258_.setTradeOffers(p_360910_.getOffers().copy()); + p_359258_.setVillagerXp(p_360910_.getVillagerXp()); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(p_360910_, p_359258_); + if (!this.isSilent()) { + p_369430_.levelEvent(null, 1026, this.blockPosition(), 0); + } +@@ -298,19 +_,26 @@ + livingentity = (LivingEntity)p_363403_.getEntity(); } - if (livingentity != null + var vanilla = (livingentity != null - && this.level().getDifficulty() == Difficulty.HARD + && p_363771_.getDifficulty() == Difficulty.HARD && (double)this.random.nextFloat() < this.getAttributeValue(Attributes.SPAWN_REINFORCEMENTS_CHANCE) -- && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { -+ && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)); -+ +- && p_363771_.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { ++ && p_363771_.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)); int i = Mth.floor(this.getX()); int j = Mth.floor(this.getY()); int k = Mth.floor(this.getZ()); -- Zombie zombie = new Zombie(this.level()); + EntityType entitytype = this.getType(); +- Zombie zombie = entitytype.create(p_363771_, EntitySpawnReason.REINFORCEMENT); +- if (zombie == null) { +- return true; +- } - + + var event = net.minecraftforge.event.ForgeEventFactory.fireZombieSummonAid(this, level(), i, j, k, livingentity, this.getAttributeValue(Attributes.SPAWN_REINFORCEMENTS_CHANCE)); + + Zombie zombie = null; -+ if (event.getResult().isAllowed()) { -+ zombie = event.getCustomSummonedAid() != null ? event.getCustomSummonedAid() : EntityType.ZOMBIE.create(this.level()); -+ } else if (vanilla && event.getResult().isDefault()) { -+ zombie = EntityType.ZOMBIE.create(this.level()); ++ if (event.getResult().isAllowed() || (vanilla && event.getResult().isDefault())) { ++ if (event.getCustomSummonedAid() != null) ++ zombie = event.getCustomSummonedAid(); ++ else ++ zombie = entitytype.create(this.level(), EntitySpawnReason.REINFORCEMENT); + } + + if (zombie != null) { for (int l = 0; l < 50; l++) { int i1 = i + Mth.nextInt(this.random, 7, 40) * Mth.nextInt(this.random, -1, 1); int j1 = j + Mth.nextInt(this.random, 7, 40) * Mth.nextInt(this.random, -1, 1); -@@ -310,6 +_,7 @@ - && this.level().isUnobstructed(zombie) - && this.level().noCollision(zombie) - && !this.level().containsAnyLiquid(zombie.getBoundingBox())) { -+ if (livingentity != null) - zombie.setTarget(livingentity); - zombie.finalizeSpawn(serverlevel, this.level().getCurrentDifficultyAt(zombie.blockPosition()), MobSpawnType.REINFORCEMENT, null); - serverlevel.addFreshEntityWithPassengers(zombie); -@@ -407,6 +_,10 @@ - return flag; - } - -+ if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(p_219161_, EntityType.ZOMBIE_VILLAGER, (timer) -> {})) { -+ return flag; -+ } -+ - ZombieVillager zombievillager = villager.convertTo(EntityType.ZOMBIE_VILLAGER, false); - if (zombievillager != null) { - zombievillager.finalizeSpawn( -@@ -416,6 +_,7 @@ - zombievillager.setGossips(villager.getGossips().store(NbtOps.INSTANCE)); - zombievillager.setTradeOffers(villager.getOffers().copy()); - zombievillager.setVillagerXp(villager.getVillagerXp()); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(p_219161_, zombievillager); - if (!this.isSilent()) { - p_219160_.levelEvent(null, 1026, this.blockPosition(), 0); - } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch index fa7cbe9171..29995ca1f2 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/ZombieVillager.java +++ b/net/minecraft/world/entity/monster/ZombieVillager.java -@@ -135,7 +_,7 @@ +@@ -137,7 +_,7 @@ if (!this.level().isClientSide && this.isAlive() && this.isConverting()) { int i = this.getConversionProgress(); this.villagerConversionTime -= i; @@ -9,11 +9,11 @@ this.finishConversion((ServerLevel)this.level()); } } -@@ -238,6 +_,7 @@ - if (!this.isSilent()) { - p_34399_.levelEvent(null, 1027, this.blockPosition(), 0); +@@ -244,6 +_,7 @@ + if (!this.isSilent()) { + p_34399_.levelEvent(null, 1027, this.blockPosition(), 0); + } ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_359261_); } -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, villager); - } + ); } - diff --git a/patches/minecraft/net/minecraft/world/entity/monster/creaking/Creaking.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/creaking/Creaking.java.patch new file mode 100644 index 0000000000..6bda4537b0 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/monster/creaking/Creaking.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/monster/creaking/Creaking.java ++++ b/net/minecraft/world/entity/monster/creaking/Creaking.java +@@ -230,7 +_,7 @@ + + return true; + } else { +- Predicate predicate = this.isActive() ? LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM : p_366417_ -> true; ++ Predicate predicate = this.isActive() ? net.minecraftforge.common.ForgeHooks.isNotDisguised(this) : p_366417_ -> true; + + for (Player player : list) { + if (!player.isCreative() diff --git a/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch index 19fd1c9e3f..aafb49dd92 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch @@ -1,19 +1,23 @@ --- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java +++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java -@@ -161,7 +_,7 @@ +@@ -166,7 +_,7 @@ HoglinAi.updateActivity(this); if (this.isConverting()) { this.timeInOverworld++; - if (this.timeInOverworld > 300) { + if (this.timeInOverworld > 300 && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.ZOGLIN, (timer) -> this.timeInOverworld = timer)) { this.makeSound(SoundEvents.HOGLIN_CONVERTED_TO_ZOMBIFIED); - this.finishConversion((ServerLevel)this.level()); + this.finishConversion(); } -@@ -257,6 +_,7 @@ - Zoglin zoglin = this.convertTo(EntityType.ZOGLIN, true); - if (zoglin != null) { - zoglin.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zoglin); - } +@@ -264,7 +_,10 @@ + this.convertTo( + EntityType.ZOGLIN, + ConversionParams.single(this, true, false), +- p_365626_ -> p_365626_.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)) ++ p_365626_ -> { ++ p_365626_.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_365626_); ++ } + ); } 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 844536bcf6..3d65b6811c 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,19 +1,23 @@ --- a/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java +++ b/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java -@@ -80,7 +_,7 @@ +@@ -82,7 +_,7 @@ this.timeInOverworld = 0; } - if (this.timeInOverworld > 300) { + if (this.timeInOverworld > 300 && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.ZOMBIFIED_PIGLIN, (timer) -> this.timeInOverworld = timer)) { this.playConvertedSound(); - this.finishConversion((ServerLevel)this.level()); - } -@@ -94,6 +_,7 @@ - ZombifiedPiglin zombifiedpiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, true); - if (zombifiedpiglin != null) { - zombifiedpiglin.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zombifiedpiglin); + this.finishConversion(p_360786_); } +@@ -101,7 +_,10 @@ + this.convertTo( + EntityType.ZOMBIFIED_PIGLIN, + ConversionParams.single(this, true, true), +- p_369673_ -> p_369673_.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)) ++ p_369673_ -> { ++ p_369673_.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_369673_); ++ } + ); } 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 c3e80cd74c..54814c5515 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,15 +1,15 @@ --- a/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/net/minecraft/world/entity/monster/piglin/Piglin.java -@@ -345,7 +_,7 @@ +@@ -351,7 +_,7 @@ } else if (this.isChargingCrossbow()) { return PiglinArmPose.CROSSBOW_CHARGE; } else { -- return this.isAggressive() && this.isHolding(Items.CROSSBOW) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT; -+ return this.isAggressive() && this.isHolding(is -> is.getItem() instanceof net.minecraft.world.item.CrossbowItem) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT; +- return this.isHolding(Items.CROSSBOW) && CrossbowItem.isCharged(this.getWeaponItem()) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT; ++ return this.isHolding(is -> is.getItem() instanceof net.minecraft.world.item.CrossbowItem) && CrossbowItem.isCharged(this.getWeaponItem()) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT; } } -@@ -386,7 +_,7 @@ +@@ -388,7 +_,7 @@ } protected void holdInOffHand(ItemStack p_34786_) { @@ -18,12 +18,12 @@ this.setItemSlot(EquipmentSlot.OFFHAND, p_34786_); this.setGuaranteedDrop(EquipmentSlot.OFFHAND); } else { -@@ -396,7 +_,7 @@ +@@ -398,7 +_,7 @@ @Override - public boolean wantsToPickUp(ItemStack p_34777_) { -- return this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && this.canPickUpLoot() && PiglinAi.wantsToPickup(this, p_34777_); -+ return net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level(), this) && this.canPickUpLoot() && PiglinAi.wantsToPickup(this, p_34777_); + public boolean wantsToPickUp(ServerLevel p_369934_, ItemStack p_34777_) { +- return p_369934_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && this.canPickUpLoot() && PiglinAi.wantsToPickup(this, p_34777_); ++ return net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_369934_, this) && this.canPickUpLoot() && PiglinAi.wantsToPickup(this, p_34777_); } protected boolean canReplaceCurrentItem(ItemStack p_34788_) { 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 f3a6c76df9..e2113d0edc 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,15 +1,15 @@ --- a/net/minecraft/world/entity/monster/piglin/PiglinAi.java +++ b/net/minecraft/world/entity/monster/piglin/PiglinAi.java -@@ -635,7 +_,7 @@ - public static boolean isWearingGold(LivingEntity p_34809_) { - for (ItemStack itemstack : p_34809_.getArmorAndBodyArmorSlots()) { - Item item = itemstack.getItem(); -- if (item instanceof ArmorItem && ((ArmorItem)item).getMaterial().is(ArmorMaterials.GOLD)) { -+ if (itemstack.makesPiglinsNeutral(p_34809_)) { +@@ -632,7 +_,7 @@ + + public static boolean isWearingSafeArmor(LivingEntity p_365495_) { + for (ItemStack itemstack : p_365495_.getArmorAndBodyArmorSlots()) { +- if (itemstack.is(ItemTags.PIGLIN_SAFE_ARMOR)) { ++ if (itemstack.makesPiglinsNeutral(p_365495_)) { return true; } } -@@ -779,7 +_,7 @@ +@@ -776,7 +_,7 @@ } private static boolean hasCrossbow(LivingEntity p_34919_) { @@ -18,7 +18,7 @@ } private static void admireGoldItem(LivingEntity p_34939_) { -@@ -791,7 +_,7 @@ +@@ -788,7 +_,7 @@ } private static boolean isBarterCurrency(ItemStack p_149968_) { 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 967441fdb6..c97dd00ccd 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 @@ -3,9 +3,9 @@ @@ -11,7 +_,7 @@ public static BehaviorControl create() { return BehaviorBuilder.create( - p_259197_ -> p_259197_.group(p_259197_.absent(MemoryModuleType.ADMIRING_ITEM)).apply(p_259197_, p_259512_ -> (p_341467_, p_341468_, p_341469_) -> { -- if (!p_341468_.getOffhandItem().isEmpty() && !p_341468_.getOffhandItem().is(Items.SHIELD)) { -+ if (!p_341468_.getOffhandItem().isEmpty() && !p_341468_.getOffhandItem().canPerformAction(net.minecraftforge.common.ToolActions.SHIELD_BLOCK)) { - PiglinAi.stopHoldingOffHandItem(p_341468_, true); + p_259197_ -> p_259197_.group(p_259197_.absent(MemoryModuleType.ADMIRING_ITEM)).apply(p_259197_, p_259512_ -> (p_359309_, p_359310_, p_359311_) -> { +- if (!p_359310_.getOffhandItem().isEmpty() && !p_359310_.getOffhandItem().is(Items.SHIELD)) { ++ if (!p_359310_.getOffhandItem().isEmpty() && !p_359310_.getOffhandItem().canPerformAction(net.minecraftforge.common.ToolActions.SHIELD_BLOCK)) { + PiglinAi.stopHoldingOffHandItem(p_359309_, p_359310_, true); return true; } else { diff --git a/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch index c0cbf518d6..f15338a740 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch @@ -5,7 +5,7 @@ return 0; } else { + cat.moveTo(p_35334_, 0.0F, 0.0F); // Fix MC-147659: Some witch huts spawn the incorrect cat - cat.finalizeSpawn(p_35335_, p_35335_.getCurrentDifficultyAt(p_35334_), MobSpawnType.NATURAL, null); + cat.finalizeSpawn(p_35335_, p_35335_.getCurrentDifficultyAt(p_35334_), EntitySpawnReason.NATURAL, null); - cat.moveTo(p_35334_, 0.0F, 0.0F); p_35335_.addFreshEntityWithPassengers(cat); return 1; 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 447f432d52..d18c0d9d5a 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/Villager.java +++ b/net/minecraft/world/entity/npc/Villager.java -@@ -314,7 +_,7 @@ +@@ -313,7 +_,7 @@ @Override public InteractionResult mobInteract(Player p_35472_, InteractionHand p_35473_) { ItemStack itemstack = p_35472_.getItemInHand(p_35473_); @@ -9,7 +9,7 @@ return super.mobInteract(p_35472_, p_35473_); } else if (this.isBaby()) { this.setUnhappy(); -@@ -727,7 +_,8 @@ +@@ -712,7 +_,8 @@ @Override protected Component getTypeName() { @@ -19,20 +19,12 @@ } @Override -@@ -782,7 +_,7 @@ +@@ -770,7 +_,7 @@ @Override public void thunderHit(ServerLevel p_35409_, LightningBolt p_35410_) { - if (p_35409_.getDifficulty() != Difficulty.PEACEFUL) { + if (p_35409_.getDifficulty() != Difficulty.PEACEFUL && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.WITCH, (timer) -> {})) { LOGGER.info("Villager {} was struck by lightning {}.", this, p_35410_); - Witch witch = EntityType.WITCH.create(p_35409_); - if (witch != null) { -@@ -795,6 +_,7 @@ - } - - witch.setPersistenceRequired(); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, witch); - p_35409_.addFreshEntityWithPassengers(witch); - this.releaseAllPois(); - this.discard(); + Witch witch = this.convertTo(EntityType.WITCH, ConversionParams.single(this, false, false), p_359315_ -> { + p_359315_.finalizeSpawn(p_35409_, p_35409_.getCurrentDifficultyAt(p_359315_.blockPosition()), EntitySpawnReason.CONVERSION, null); diff --git a/patches/minecraft/net/minecraft/world/entity/player/Input.java.patch b/patches/minecraft/net/minecraft/world/entity/player/Input.java.patch new file mode 100644 index 0000000000..11b0d3ca82 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/player/Input.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/player/Input.java ++++ b/net/minecraft/world/entity/player/Input.java +@@ -37,4 +_,8 @@ + } + }; + public static Input EMPTY = new Input(false, false, false, false, false, false, false); ++ ++ public Input jump(boolean value) { ++ return new Input(forward, backward, left, right, value, shift, sprint); ++ } + } diff --git a/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch b/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch index 70c4c4902b..a099624883 100644 --- a/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/Inventory.java +++ b/net/minecraft/world/entity/player/Inventory.java -@@ -130,7 +_,7 @@ +@@ -129,7 +_,7 @@ for (int k = 0; k < 9; k++) { int l = (this.selected + k) % 9; @@ -9,7 +9,7 @@ return l; } } -@@ -211,11 +_,13 @@ +@@ -201,11 +_,13 @@ } public void tick() { @@ -24,7 +24,7 @@ } } } -@@ -265,6 +_,8 @@ +@@ -255,6 +_,8 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Adding item to inventory"); CrashReportCategory crashreportcategory = crashreport.addCategory("Item being added"); 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 6aabd05d42..49a6116ed0 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 -@@ -113,7 +_,7 @@ +@@ -117,7 +_,7 @@ import net.minecraft.world.scores.Team; import org.slf4j.Logger; @@ -9,7 +9,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); public static final HumanoidArm DEFAULT_MAIN_HAND = HumanoidArm.RIGHT; public static final int DEFAULT_MODEL_CUSTOMIZATION = 0; -@@ -191,6 +_,9 @@ +@@ -195,6 +_,9 @@ public Entity currentExplosionCause; private boolean ignoreFallDamageFromCurrentImpulse; private int currentImpulseContextResetGraceTime; @@ -19,7 +19,7 @@ public Player(Level p_250508_, BlockPos p_250289_, float p_251702_, GameProfile p_252153_) { super(EntityType.PLAYER, p_250508_); -@@ -223,11 +_,12 @@ +@@ -227,11 +_,12 @@ .add(Attributes.LUCK) .add(Attributes.BLOCK_INTERACTION_RANGE, 4.5) .add(Attributes.ENTITY_INTERACTION_RANGE, 3.0) @@ -34,7 +34,7 @@ } @Override -@@ -243,6 +_,7 @@ +@@ -247,6 +_,7 @@ @Override public void tick() { @@ -42,7 +42,7 @@ this.noPhysics = this.isSpectator(); if (this.isSpectator()) { this.setOnGround(false); -@@ -258,7 +_,7 @@ +@@ -262,7 +_,7 @@ this.sleepCounter = 100; } @@ -51,7 +51,7 @@ this.stopSleepInBed(false, true); } } else if (this.sleepCounter > 0) { -@@ -316,6 +_,7 @@ +@@ -323,6 +_,7 @@ if (this.currentImpulseContextResetGraceTime > 0) { this.currentImpulseContextResetGraceTime--; } @@ -59,7 +59,7 @@ } @Override -@@ -395,6 +_,10 @@ +@@ -425,6 +_,10 @@ } protected void updatePlayerPose() { @@ -70,7 +70,7 @@ if (this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.SWIMMING)) { Pose pose; if (this.isFallFlying()) { -@@ -628,6 +_,7 @@ +@@ -652,6 +_,7 @@ @Override public void die(DamageSource p_36152_) { @@ -78,7 +78,7 @@ super.die(p_36152_); this.reapplyPosition(); if (!this.isSpectator() && this.level() instanceof ServerLevel serverlevel) { -@@ -682,7 +_,7 @@ +@@ -709,7 +_,7 @@ @Nullable public ItemEntity drop(ItemStack p_36177_, boolean p_36178_) { @@ -87,8 +87,8 @@ } @Nullable -@@ -724,7 +_,12 @@ - } +@@ -721,7 +_,12 @@ + return null; } + /** @deprecated Use {@link #getDestroySpeed(BlockState,BlockPos) */ @@ -100,7 +100,7 @@ float f = this.inventory.getDestroySpeed(p_36282_); if (f > 1.0F) { f += (float)this.getAttributeValue(Attributes.MINING_EFFICIENCY); -@@ -752,11 +_,14 @@ +@@ -750,11 +_,14 @@ f /= 5.0F; } @@ -116,24 +116,24 @@ } @Override -@@ -857,6 +_,7 @@ +@@ -855,6 +_,7 @@ @Override - public boolean hurt(DamageSource p_36154_, float p_36155_) { -+ if (!net.minecraftforge.common.ForgeHooks.onPlayerAttack(this, p_36154_, p_36155_)) return false; - if (this.isInvulnerableTo(p_36154_)) { + public boolean hurtServer(ServerLevel p_369360_, DamageSource p_364544_, float p_368576_) { ++ if (!net.minecraftforge.common.ForgeHooks.onPlayerAttack(this, p_364544_, p_368576_)) return false; + if (this.isInvulnerableTo(p_369360_, p_364544_)) { return false; - } else if (this.abilities.invulnerable && !p_36154_.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { -@@ -892,7 +_,7 @@ - @Override + } else if (this.abilities.invulnerable && !p_364544_.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { +@@ -888,7 +_,7 @@ protected void blockUsingShield(LivingEntity p_36295_) { super.blockUsingShield(p_36295_); -- if (p_36295_.canDisableShield()) { -+ if (p_36295_.getMainHandItem().canDisableShield(this.useItem, this, p_36295_)) { - this.disableShield(); + ItemStack itemstack = this.getItemBlockingWith(); +- if (p_36295_.canDisableShield() && itemstack != null) { ++ if (itemstack != null && itemstack.canDisableShield(this.useItem, this, p_36295_)) { + this.disableShield(itemstack); } } -@@ -924,7 +_,7 @@ +@@ -920,7 +_,7 @@ @Override protected void hurtCurrentlyUsedShield(float p_36383_) { @@ -142,10 +142,10 @@ if (!this.level().isClientSide) { this.awardStat(Stats.ITEM_USED.get(this.useItem.getItem())); } -@@ -950,10 +_,13 @@ +@@ -946,10 +_,13 @@ @Override - protected void actuallyHurt(DamageSource p_36312_, float p_36313_) { - if (!this.isInvulnerableTo(p_36312_)) { + protected void actuallyHurt(ServerLevel p_365751_, DamageSource p_36312_, float p_36313_) { + if (!this.isInvulnerableTo(p_365751_, p_36312_)) { + p_36313_ = net.minecraftforge.common.ForgeHooks.onLivingHurt(this, p_36312_, p_36313_); + if (p_36313_ <= 0) return; p_36313_ = this.getDamageAfterArmorAbsorb(p_36312_, p_36313_); @@ -156,7 +156,7 @@ float f = p_36313_ - f1; if (f > 0.0F && f < 3.4028235E37F) { this.awardStat(Stats.DAMAGE_ABSORBED, Math.round(f * 10.0F)); -@@ -1012,6 +_,10 @@ +@@ -1008,6 +_,10 @@ return InteractionResult.PASS; } else { @@ -167,7 +167,7 @@ ItemStack itemstack = this.getItemInHand(p_36159_); ItemStack itemstack1 = itemstack.copy(); InteractionResult interactionresult = p_36158_.interact(this, p_36159_); -@@ -1020,6 +_,10 @@ +@@ -1016,6 +_,10 @@ itemstack.setCount(itemstack1.getCount()); } @@ -178,7 +178,7 @@ return interactionresult; } else { if (!itemstack.isEmpty() && p_36158_ instanceof LivingEntity) { -@@ -1031,6 +_,7 @@ +@@ -1027,6 +_,7 @@ if (interactionresult1.consumesAction()) { this.level().gameEvent(GameEvent.ENTITY_INTERACT, p_36158_.position(), GameEvent.Context.of(this)); if (itemstack.isEmpty() && !this.abilities.instabuild) { @@ -186,7 +186,7 @@ this.setItemInHand(p_36159_, ItemStack.EMPTY); } -@@ -1130,6 +_,7 @@ +@@ -1126,6 +_,7 @@ } public void attack(Entity p_36347_) { @@ -194,7 +194,7 @@ if (p_36347_.isAttackable()) { if (!p_36347_.skipAttackInteraction(this)) { float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE); -@@ -1167,8 +_,10 @@ +@@ -1163,8 +_,10 @@ && !this.isPassenger() && p_36347_ instanceof LivingEntity && !this.isSprinting(); @@ -206,16 +206,16 @@ } float f3 = f + f1; -@@ -1176,7 +_,7 @@ - double d0 = (double)(this.walkDist - this.walkDistO); - if (flag4 && !flag1 && !flag && this.onGround() && d0 < (double)this.getSpeed()) { - ItemStack itemstack1 = this.getItemInHand(InteractionHand.MAIN_HAND); -- if (itemstack1.getItem() instanceof SwordItem) { -+ if (itemstack.canPerformAction(net.minecraftforge.common.ToolActions.SWORD_SWEEP)) { +@@ -1172,7 +_,7 @@ + if (flag3 && !flag1 && !flag && this.onGround()) { + double d0 = this.getKnownMovement().horizontalDistanceSqr(); + double d1 = (double)this.getSpeed() * 2.5; +- if (d0 < Mth.square(d1) && this.getItemInHand(InteractionHand.MAIN_HAND).is(ItemTags.SWORDS)) { ++ if (d0 < Mth.square(d1) && this.getItemInHand(InteractionHand.MAIN_HAND).canPerformAction(net.minecraftforge.common.ToolActions.SWORD_SWEEP)) { flag2 = true; } } -@@ -1212,7 +_,7 @@ +@@ -1208,7 +_,7 @@ if (flag2) { float f7 = 1.0F + (float)this.getAttributeValue(Attributes.SWEEPING_DAMAGE_RATIO) * f; @@ -224,7 +224,7 @@ if (livingentity2 != this && livingentity2 != p_36347_ && !this.isAlliedTo(livingentity2) -@@ -1262,8 +_,8 @@ +@@ -1258,8 +_,8 @@ this.setLastHurtMob(p_36347_); Entity entity = p_36347_; @@ -235,7 +235,7 @@ } boolean flag5 = false; -@@ -1304,6 +_,7 @@ +@@ -1300,6 +_,7 @@ this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); } } @@ -243,15 +243,6 @@ } } } -@@ -1318,7 +_,7 @@ - } - - public void disableShield() { -- this.getCooldowns().addCooldown(Items.SHIELD, 100); -+ this.getCooldowns().addCooldown(this.getUseItem().getItem(), 100); - this.stopUsingItem(); - this.level().broadcastEntityEvent(this, (byte)30); - } @@ -1384,6 +_,7 @@ } @@ -260,7 +251,7 @@ super.stopSleeping(); if (this.level() instanceof ServerLevel && p_36227_) { ((ServerLevel)this.level()).updateSleepingPlayerList(); -@@ -1497,6 +_,7 @@ +@@ -1492,6 +_,7 @@ @Override public boolean causeFallDamage(float p_150093_, float p_150094_, DamageSource p_150095_) { if (this.abilities.mayfly) { @@ -268,16 +259,7 @@ return false; } else { if (p_150093_ >= 2.0F) { -@@ -1528,7 +_,7 @@ - public boolean tryToStartFallFlying() { - if (!this.onGround() && !this.isFallFlying() && !this.isInWater() && !this.hasEffect(MobEffects.LEVITATION)) { - ItemStack itemstack = this.getItemBySlot(EquipmentSlot.CHEST); -- if (itemstack.is(Items.ELYTRA) && ElytraItem.isFlyEnabled(itemstack)) { -+ if (itemstack.canElytraFly(this)) { - this.startFallFlying(); - return true; - } -@@ -1557,13 +_,13 @@ +@@ -1550,13 +_,13 @@ protected void playStepSound(BlockPos p_282121_, BlockState p_282194_) { if (this.isInWater()) { this.waterSwimSound(); @@ -293,7 +275,7 @@ } else { super.playStepSound(blockpos, blockstate); } -@@ -1594,6 +_,12 @@ +@@ -1587,6 +_,12 @@ } public void giveExperiencePoints(int p_36291_) { @@ -306,7 +288,7 @@ this.increaseScore(p_36291_); this.experienceProgress = this.experienceProgress + (float)p_36291_ / (float)this.getXpNeededForNextLevel(); this.totalExperience = Mth.clamp(this.totalExperience + p_36291_, 0, Integer.MAX_VALUE); -@@ -1621,7 +_,7 @@ +@@ -1614,7 +_,7 @@ } public void onEnchantmentPerformed(ItemStack p_36172_, int p_36173_) { @@ -315,7 +297,7 @@ if (this.experienceLevel < 0) { this.experienceLevel = 0; this.experienceProgress = 0.0F; -@@ -1632,6 +_,12 @@ +@@ -1625,6 +_,12 @@ } public void giveExperienceLevels(int p_36276_) { @@ -325,10 +307,10 @@ + } + p_36276_ = event.getLevels(); + - this.experienceLevel += p_36276_; + this.experienceLevel = IntMath.saturatedAdd(this.experienceLevel, p_36276_); if (this.experienceLevel < 0) { this.experienceLevel = 0; -@@ -1840,7 +_,13 @@ +@@ -1828,7 +_,13 @@ @Override public Component getDisplayName() { @@ -343,7 +325,7 @@ return this.decorateDisplayNameComponent(mutablecomponent); } -@@ -2001,18 +_,19 @@ +@@ -1991,18 +_,19 @@ Predicate predicate = ((ProjectileWeaponItem)p_36349_.getItem()).getSupportedHeldProjectiles(); ItemStack itemstack = ProjectileWeaponItem.getHeldProjectile(this, predicate); if (!itemstack.isEmpty()) { @@ -366,7 +348,7 @@ } } } -@@ -2173,6 +_,65 @@ +@@ -2130,6 +_,65 @@ this.currentImpulseImpactPos = null; this.ignoreFallDamageFromCurrentImpulse = false; } @@ -430,5 +412,5 @@ + } + - public static enum BedSleepingProblem { - NOT_POSSIBLE_HERE, + public boolean shouldRotateWithMinecart() { + return false; 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 0d19ea642d..016f5342b0 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -8,7 +8,7 @@ protected AbstractArrow(EntityType p_332730_, Level p_335646_) { super(p_332730_, p_335646_); -@@ -188,7 +_,7 @@ +@@ -189,7 +_,7 @@ this.shakeTime--; } @@ -17,55 +17,12 @@ this.clearFire(); } -@@ -224,11 +_,27 @@ - } - } - -- if (hitresult != null && !flag) { -- ProjectileDeflection projectiledeflection = this.hitTargetOrDeflectSelf(hitresult); -- this.hasImpulse = true; -- if (projectiledeflection != ProjectileDeflection.NONE) { -- break; -+ if (hitresult != null && hitresult.getType() != HitResult.Type.MISS && !flag) { -+ switch (net.minecraftforge.event.ForgeEventFactory.onProjectileImpactResult(this, hitresult)) { -+ case SKIP_ENTITY: -+ if (hitresult.getType() != HitResult.Type.ENTITY) { // If there is no entity, we just return default behaviour -+ this.onHit(hitresult); -+ this.hasImpulse = true; -+ break; -+ } -+ ignoredEntities.add(entityhitresult.getEntity().getId()); -+ entityhitresult = null; // Don't process any further -+ break; -+ case STOP_AT_CURRENT_NO_DAMAGE: -+ this.discard(); -+ entityhitresult = null; // Don't process any further -+ break; -+ case STOP_AT_CURRENT: -+ this.setPierceLevel((byte) 0); -+ case DEFAULT: -+ this.onHit(hitresult); -+ this.hasImpulse = true; -+ break; - } - } - -@@ -239,6 +_,9 @@ - hitresult = null; - } - -+ if (this.isRemoved()) -+ return; -+ - vec3 = this.getDeltaMovement(); - double d5 = vec3.x; - double d6 = vec3.y; -@@ -504,7 +_,7 @@ - - @Override +@@ -541,7 +_,7 @@ protected boolean canHitEntity(Entity p_36743_) { -- return super.canHitEntity(p_36743_) && (this.piercingIgnoreEntityIds == null || !this.piercingIgnoreEntityIds.contains(p_36743_.getId())); -+ return super.canHitEntity(p_36743_) && (this.piercingIgnoreEntityIds == null || !this.piercingIgnoreEntityIds.contains(p_36743_.getId())) && !this.ignoredEntities.contains(p_36743_.getId()); + return p_36743_ instanceof Player && this.getOwner() instanceof Player player && !player.canHarmPlayer((Player)p_36743_) + ? false +- : super.canHitEntity(p_36743_) && (this.piercingIgnoreEntityIds == null || !this.piercingIgnoreEntityIds.contains(p_36743_.getId())); ++ : super.canHitEntity(p_36743_) && (this.piercingIgnoreEntityIds == null || !this.piercingIgnoreEntityIds.contains(p_36743_.getId())) && !this.ignoredEntities.contains(p_36743_.getId()); } @Override 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 693f0a5f5d..860193d65a 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java +++ b/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -@@ -78,7 +_,7 @@ +@@ -90,7 +_,7 @@ + this.igniteForSeconds(1.0F); } - HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity, this.getClipType()); -- if (hitresult.getType() != HitResult.Type.MISS) { -+ if (hitresult.getType() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { +- if (hitresult.getType() != HitResult.Type.MISS && this.isAlive()) { ++ if (hitresult.getType() != HitResult.Type.MISS && this.isAlive() && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { this.hitTargetOrDeflectSelf(hitresult); } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch index efe85a5e82..c4d1526934 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -305,6 +_,13 @@ +@@ -310,6 +_,13 @@ } @Override 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 7c454ac7d7..5dcc8c1f31 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 -@@ -239,8 +_,8 @@ +@@ -244,8 +_,8 @@ private boolean shouldStopFishing(Player p_37137_) { ItemStack itemstack = p_37137_.getMainHandItem(); ItemStack itemstack1 = p_37137_.getOffhandItem(); @@ -11,7 +11,7 @@ if (!p_37137_.isRemoved() && p_37137_.isAlive() && (flag || flag1) && !(this.distanceToSqr(p_37137_) > 1024.0)) { return false; } else { -@@ -251,6 +_,7 @@ +@@ -256,6 +_,7 @@ private void checkCollision() { HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); @@ -19,7 +19,7 @@ this.hitTargetOrDeflectSelf(hitresult); } -@@ -440,6 +_,7 @@ +@@ -445,6 +_,7 @@ Player player = this.getPlayerOwner(); if (!this.level().isClientSide && player != null && !this.shouldStopFishing(player)) { int i = 0; @@ -27,7 +27,7 @@ if (this.hookedIn != null) { this.pullEntity(this.hookedIn); CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer)player, p_37157_, this, Collections.emptyList()); -@@ -450,10 +_,16 @@ +@@ -455,10 +_,16 @@ .withParameter(LootContextParams.ORIGIN, this.position()) .withParameter(LootContextParams.TOOL, p_37157_) .withParameter(LootContextParams.THIS_ENTITY, this) @@ -44,7 +44,7 @@ CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer)player, p_37157_, this, list); for (ItemStack itemstack : list) { -@@ -483,7 +_,7 @@ +@@ -488,7 +_,7 @@ } this.discard(); 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 db33f94565..33c5d6b7fb 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch @@ -1,12 +1,11 @@ --- a/net/minecraft/world/entity/projectile/LargeFireball.java +++ b/net/minecraft/world/entity/projectile/LargeFireball.java -@@ -29,7 +_,8 @@ +@@ -29,7 +_,7 @@ protected void onHit(HitResult p_37218_) { super.onHit(p_37218_); - if (!this.level().isClientSide) { -- boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); -+ // 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.level(), this.getOwner()); + if (this.level() instanceof ServerLevel serverlevel) { +- boolean flag = serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); ++ boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, this.getOwner()); this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float)this.explosionPower, flag, Level.ExplosionInteraction.MOB); this.discard(); } 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 ab6ac32d38..9ddd84c0d8 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/Projectile.java +++ b/net/minecraft/world/entity/projectile/Projectile.java -@@ -278,7 +_,7 @@ +@@ -370,7 +_,7 @@ @Override - public boolean mayInteract(Level p_150167_, BlockPos p_150168_) { + public boolean mayInteract(ServerLevel p_364907_, BlockPos p_150168_) { Entity entity = this.getOwner(); -- return entity instanceof Player ? entity.mayInteract(p_150167_, p_150168_) : entity == null || p_150167_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); -+ return entity instanceof Player ? entity.mayInteract(p_150167_, p_150168_) : entity == null || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_150167_, entity); +- return entity instanceof Player ? entity.mayInteract(p_364907_, p_150168_) : entity == null || p_364907_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); ++ return entity instanceof Player ? entity.mayInteract(p_364907_, p_150168_) : entity == null || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_364907_, entity); } - public boolean mayBreak(Level p_313184_) { + public boolean mayBreak(ServerLevel p_361134_) { diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch index 1c7f9fae0b..b902272e87 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch @@ -9,7 +9,7 @@ if (d0 == 0.0) { entity = entity1; vec3 = vec31; -@@ -151,8 +_,13 @@ +@@ -153,8 +_,13 @@ } } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch index 7b03c487ab..f6985a6649 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/ShulkerBullet.java +++ b/net/minecraft/world/entity/projectile/ShulkerBullet.java -@@ -220,7 +_,7 @@ - } - - HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); -- if (hitresult.getType() != HitResult.Type.MISS) { -+ if (hitresult.getType() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { - this.hitTargetOrDeflectSelf(hitresult); - } +@@ -230,7 +_,7 @@ + this.handlePortal(); } + +- if (hitresult != null && this.isAlive() && hitresult.getType() != HitResult.Type.MISS) { ++ if (hitresult != null && this.isAlive() && hitresult.getType() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { + this.hitTargetOrDeflectSelf(hitresult); + } + diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/SmallFireball.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/SmallFireball.java.patch index 05623e54a3..7da181b8f2 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/SmallFireball.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/SmallFireball.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/world/entity/projectile/SmallFireball.java @@ -51,7 +_,7 @@ super.onHitBlock(p_37384_); - if (!this.level().isClientSide) { + if (this.level() instanceof ServerLevel serverlevel) { Entity entity = this.getOwner(); -- if (!(entity instanceof Mob) || this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (!(entity instanceof Mob) || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level(), entity)) { +- if (!(entity instanceof Mob) || serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!(entity instanceof Mob) || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, entity)) { BlockPos blockpos = p_37384_.getBlockPos().relative(p_37384_.getDirection()); if (this.level().isEmptyBlock(blockpos)) { this.level().setBlockAndUpdate(blockpos, BaseFireBlock.getState(this.level(), blockpos)); diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch index 77f5034762..42f244ae6d 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/ThrowableProjectile.java +++ b/net/minecraft/world/entity/projectile/ThrowableProjectile.java -@@ -42,7 +_,7 @@ - public void tick() { +@@ -58,7 +_,7 @@ + this.updateRotation(); + this.applyEffectsFromBlocks(); super.tick(); - HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); -- if (hitresult.getType() != HitResult.Type.MISS) { -+ if (hitresult.getType() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { +- if (hitresult.getType() != HitResult.Type.MISS && this.isAlive()) { ++ if (hitresult.getType() != HitResult.Type.MISS && this.isAlive() && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) { this.hitTargetOrDeflectSelf(hitresult); } - + } 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 49d20db00d..88101b1bf5 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +++ b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -@@ -66,6 +_,12 @@ - +@@ -126,6 +_,13 @@ + Vec3 vec3 = this.oldPosition(); if (entity instanceof ServerPlayer serverplayer) { if (serverplayer.connection.isAcceptingMessages()) { + var event = net.minecraftforge.event.ForgeEventFactory.onEnderPearlLand(serverplayer, this.getX(), this.getY(), this.getZ(), this, 5.0F, p_37504_); @@ -9,22 +9,17 @@ + this.discard(); + return; + } ++ vec3 = event.getTarget(); + if (this.random.nextFloat() < 0.05F && serverlevel.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { - Endermite endermite = EntityType.ENDERMITE.create(serverlevel); + Endermite endermite = EntityType.ENDERMITE.create(serverlevel, EntitySpawnReason.TRIGGERED); if (endermite != null) { -@@ -76,12 +_,12 @@ +@@ -152,7 +_,7 @@ + if (serverplayer1 != null) { + serverplayer1.resetFallDistance(); + serverplayer1.resetCurrentImpulseContext(); +- serverplayer1.hurtServer(serverplayer.serverLevel(), this.damageSources().enderPearl(), 5.0F); ++ serverplayer1.hurtServer(serverplayer.serverLevel(), this.damageSources().enderPearl(), event.getAttackDamage()); + } - entity.changeDimension( - new DimensionTransition( -- serverlevel, this.position(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING -+ serverlevel, event.getTarget(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING - ) - ); - entity.resetFallDistance(); - serverplayer.resetCurrentImpulseContext(); -- entity.hurt(this.damageSources().fall(), 5.0F); -+ entity.hurt(this.damageSources().fall(), event.getAttackDamage()); - this.playSound(serverlevel, this.position()); - } - } else { + this.playSound(serverlevel, vec3); 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 954302545e..4ec96972b2 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 -@@ -833,7 +_,7 @@ +@@ -827,7 +_,7 @@ } } @@ -9,7 +9,7 @@ VINDICATOR(EntityType.VINDICATOR, new int[]{0, 0, 2, 0, 1, 4, 2, 5}), EVOKER(EntityType.EVOKER, new int[]{0, 0, 0, 0, 0, 1, 1, 2}), PILLAGER(EntityType.PILLAGER, new int[]{0, 4, 3, 3, 4, 4, 4, 2}), -@@ -847,6 +_,20 @@ +@@ -841,6 +_,20 @@ private RaiderType(final EntityType p_37821_, final int[] p_37822_) { this.entityType = p_37821_; this.spawnsPerWaveBeforeBonus = p_37822_; diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch similarity index 60% rename from patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch rename to patches/minecraft/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch index c0be4dcaaa..8803bcf225 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch @@ -1,15 +1,15 @@ ---- a/net/minecraft/world/entity/vehicle/Boat.java -+++ b/net/minecraft/world/entity/vehicle/Boat.java -@@ -52,7 +_,7 @@ +--- a/net/minecraft/world/entity/vehicle/AbstractBoat.java ++++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java +@@ -45,7 +_,7 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; --public class Boat extends VehicleEntity implements Leashable, VariantHolder { -+public class Boat extends VehicleEntity implements Leashable, VariantHolder, net.minecraftforge.common.extensions.IForgeBoat { - private static final EntityDataAccessor DATA_ID_TYPE = SynchedEntityData.defineId(Boat.class, EntityDataSerializers.INT); - private static final EntityDataAccessor DATA_ID_PADDLE_LEFT = SynchedEntityData.defineId(Boat.class, EntityDataSerializers.BOOLEAN); - private static final EntityDataAccessor DATA_ID_PADDLE_RIGHT = SynchedEntityData.defineId(Boat.class, EntityDataSerializers.BOOLEAN); -@@ -498,7 +_,7 @@ +-public abstract class AbstractBoat extends VehicleEntity implements Leashable { ++public abstract class AbstractBoat extends VehicleEntity implements Leashable, net.minecraftforge.common.extensions.IForgeAbstractBoat { + private static final EntityDataAccessor DATA_ID_PADDLE_LEFT = SynchedEntityData.defineId(AbstractBoat.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor DATA_ID_PADDLE_RIGHT = SynchedEntityData.defineId(AbstractBoat.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor DATA_ID_BUBBLE_TIME = SynchedEntityData.defineId(AbstractBoat.class, EntityDataSerializers.INT); +@@ -476,7 +_,7 @@ for (int i2 = i1; i2 < j1; i2++) { blockpos$mutableblockpos.set(l1, k1, i2); FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); @@ -18,16 +18,7 @@ f = Math.max(f, fluidstate.getHeight(this.level(), blockpos$mutableblockpos)); } -@@ -544,7 +_,7 @@ - voxelshape, - BooleanOp.AND - )) { -- f += blockstate.getBlock().getFriction(); -+ f += blockstate.getFriction(this.level(), blockpos$mutableblockpos, this); - k1++; - } - } -@@ -573,7 +_,7 @@ +@@ -551,7 +_,7 @@ for (int i2 = i1; i2 < j1; i2++) { blockpos$mutableblockpos.set(k1, l1, i2); FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); @@ -36,7 +27,7 @@ float f = (float)l1 + fluidstate.getHeight(this.level(), blockpos$mutableblockpos); this.waterLevel = Math.max((double)f, this.waterLevel); flag |= aabb.minY < (double)f; -@@ -603,7 +_,7 @@ +@@ -581,7 +_,7 @@ for (int i2 = i1; i2 < j1; i2++) { blockpos$mutableblockpos.set(k1, l1, i2); FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); @@ -44,20 +35,20 @@ + if (this.canBoatInFluid(fluidstate) && d0 < (double)((float)blockpos$mutableblockpos.getY() + fluidstate.getHeight(this.level(), blockpos$mutableblockpos))) { if (!fluidstate.isSource()) { - return Boat.Status.UNDER_FLOWING_WATER; -@@ -839,7 +_,7 @@ - } - + return AbstractBoat.Status.UNDER_FLOWING_WATER; +@@ -786,7 +_,7 @@ + if (!this.isPassenger()) { + if (p_361999_) { this.resetFallDistance(); -- } else if (!this.level().getFluidState(this.blockPosition().below()).is(FluidTags.WATER) && p_38307_ < 0.0) { -+ } else if (!this.canBoatInFluid(this.level().getFluidState(this.blockPosition().below())) && p_38307_ < 0.0) { - this.fallDistance -= (float)p_38307_; +- } else if (!this.level().getFluidState(this.blockPosition().below()).is(FluidTags.WATER) && p_361830_ < 0.0) { ++ } else if (!this.canBoatInFluid(this.level().getFluidState(this.blockPosition().below())) && p_361830_ < 0.0) { + this.fallDistance -= (float)p_361830_; } } -@@ -871,7 +_,7 @@ +@@ -810,7 +_,7 @@ @Override - protected boolean canAddPassenger(Entity p_38390_) { + protected boolean canAddPassenger(Entity p_366021_) { - return this.getPassengers().size() < this.getMaxPassengers() && !this.isEyeInFluid(FluidTags.WATER); + return this.getPassengers().size() < this.getMaxPassengers() && !this.canBoatInFluid(this.getEyeInFluidType()); } 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 de8a55f201..05a6dad8b0 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 -@@ -45,7 +_,7 @@ +@@ -43,7 +_,7 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -9,7 +9,7 @@ private static final Vec3 LOWERED_PASSENGER_ATTACHMENT = new Vec3(0.0, 0.0, 0.0); private static final EntityDataAccessor DATA_ID_DISPLAY_BLOCK = SynchedEntityData.defineId(AbstractMinecart.class, EntityDataSerializers.INT); private static final EntityDataAccessor DATA_ID_DISPLAY_OFFSET = SynchedEntityData.defineId(AbstractMinecart.class, EntityDataSerializers.INT); -@@ -83,6 +_,7 @@ +@@ -75,15 +_,12 @@ p_38135_.put(RailShape.NORTH_WEST, Pair.of(vec3i2, vec3i)); p_38135_.put(RailShape.NORTH_EAST, Pair.of(vec3i2, vec3i1)); }); @@ -17,7 +17,17 @@ protected AbstractMinecart(EntityType p_38087_, Level p_38088_) { super(p_38087_, p_38088_); -@@ -139,7 +_,7 @@ + this.blocksBuilding = true; +- if (useExperimentalMovement(p_38088_)) { +- this.behavior = new NewMinecartBehavior(this); +- } else { +- this.behavior = new OldMinecartBehavior(this); +- } ++ this.behavior = behaviorFactory.apply(this, p_38088_); + } + + protected AbstractMinecart(EntityType p_38090_, Level p_38091_, double p_38092_, double p_38093_, double p_38094_) { +@@ -147,7 +_,7 @@ @Override public boolean isPushable() { @@ -26,47 +36,12 @@ } @Override -@@ -271,9 +_,9 @@ - BlockPos blockpos = new BlockPos(i, j, k); - BlockState blockstate = this.level().getBlockState(blockpos); - this.onRails = BaseRailBlock.isRail(blockstate); -- if (this.onRails) { -+ if (canUseRail() && this.onRails) { - this.moveAlongTrack(blockpos, blockstate); -- if (blockstate.is(Blocks.ACTIVATOR_RAIL)) { -+ if (blockstate.getBlock() instanceof PoweredRailBlock power && power.isActivatorRail()) { - this.activateMinecart(i, j, k, blockstate.getValue(PoweredRailBlock.POWERED)); - } - } else { -@@ -298,8 +_,11 @@ - } - - this.setRot(this.getYRot(), this.getXRot()); -- if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01) { -- List list = this.level().getEntities(this, this.getBoundingBox().inflate(0.2F, 0.0, 0.2F), EntitySelector.pushableBy(this)); -+ AABB box; -+ if (getCollisionHandler() != null) box = getCollisionHandler().getMinecartCollisionBox(this); -+ else box = this.getBoundingBox().inflate(0.2F, 0.0D, 0.2F); -+ if (canBeRidden() && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) { -+ List list = this.level().getEntities(this, box, EntitySelector.pushableBy(this)); - if (!list.isEmpty()) { - for (Entity entity1 : list) { - if (!(entity1 instanceof Player) -@@ -314,7 +_,7 @@ - } - } - } else { -- for (Entity entity : this.level().getEntities(this, this.getBoundingBox().inflate(0.2F, 0.0, 0.2F))) { -+ for (Entity entity : this.level().getEntities(this, box)) { - if (!this.hasPassenger(entity) && entity.isPushable() && entity instanceof AbstractMinecart) { - entity.push(this); - } -@@ -339,16 +_,24 @@ +@@ -366,16 +_,24 @@ } - protected void comeOffTrack() { -- double d0 = this.getMaxSpeed(); -+ double d0 = this.onGround() ? this.getMaxSpeed() : getMaxSpeedAirLateral(); + protected void comeOffTrack(ServerLevel p_365684_) { +- double d0 = this.getMaxSpeed(p_365684_); ++ double d0 = this.onGround() ? this.getMaxSpeed(p_365684_) : getMaxSpeedAirLateral(); Vec3 vec3 = this.getDeltaMovement(); this.setDeltaMovement(Mth.clamp(vec3.x, -d0, d0), vec3.y, Mth.clamp(vec3.z, -d0, d0)); if (this.onGround()) { @@ -88,126 +63,27 @@ } } -@@ -361,18 +_,19 @@ - d1 = (double)p_38156_.getY(); - boolean flag = false; - boolean flag1 = false; -- if (p_38157_.is(Blocks.POWERED_RAIL)) { -+ BaseRailBlock baserailblock = (BaseRailBlock) p_38157_.getBlock(); -+ if (baserailblock instanceof PoweredRailBlock power && !power.isActivatorRail()) { - flag = p_38157_.getValue(PoweredRailBlock.POWERED); - flag1 = !flag; - } - -- double d3 = 0.0078125; -+ double d3 = getSlopeAdjustment(); - if (this.isInWater()) { - d3 *= 0.2; - } - - Vec3 vec31 = this.getDeltaMovement(); -- RailShape railshape = p_38157_.getValue(((BaseRailBlock)p_38157_.getBlock()).getShapeProperty()); -+ RailShape railshape = baserailblock.getRailDirection(p_38157_, this.level(), p_38156_, this); - switch (railshape) { - case ASCENDING_EAST: - this.setDeltaMovement(vec31.add(-d3, 0.0, 0.0)); -@@ -418,7 +_,7 @@ - } - } - -- if (flag1) { -+ if (flag1 && shouldDoRailFunctions()) { - double d22 = this.getDeltaMovement().horizontalDistance(); - if (d22 < 0.03) { - this.setDeltaMovement(Vec3.ZERO); -@@ -447,10 +_,7 @@ - d0 = d23 + d4 * d14; - d2 = d10 + d5 * d14; - this.setPos(d0, d1, d2); -- double d24 = this.isVehicle() ? 0.75 : 1.0; -- double d25 = this.getMaxSpeed(); -- vec31 = this.getDeltaMovement(); -- this.move(MoverType.SELF, new Vec3(Mth.clamp(d24 * vec31.x, -d25, d25), 0.0, Mth.clamp(d24 * vec31.z, -d25, d25))); -+ this.moveMinecartOnRail(p_38156_); - if (vec3i.getY() != 0 - && Mth.floor(this.getX()) - p_38156_.getX() == vec3i.getX() - && Mth.floor(this.getZ()) - p_38156_.getZ() == vec3i.getZ()) { -@@ -482,7 +_,11 @@ - this.setDeltaMovement(d26 * (double)(j - p_38156_.getX()), vec35.y, d26 * (double)(i - p_38156_.getZ())); - } - -- if (flag) { -+ if (shouldDoRailFunctions()) { -+ baserailblock.onMinecartPass(p_38157_, level(), p_38156_, this); -+ } -+ -+ if (flag && shouldDoRailFunctions()) { - Vec3 vec36 = this.getDeltaMovement(); - double d27 = vec36.horizontalDistance(); - if (d27 > 0.01) { -@@ -546,7 +_,7 @@ - - BlockState blockstate = this.level().getBlockState(new BlockPos(i, j, k)); - if (BaseRailBlock.isRail(blockstate)) { +@@ -431,7 +_,7 @@ + public Vec3 getRedstoneDirection(BlockPos p_369874_) { + BlockState blockstate = this.level().getBlockState(p_369874_); + if (blockstate.is(Blocks.POWERED_RAIL) && blockstate.getValue(PoweredRailBlock.POWERED)) { - RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); -+ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), new BlockPos(i, j, k), this); - p_38098_ = (double)j; - if (railshape.isAscending()) { - p_38098_ = (double)(j + 1); -@@ -585,7 +_,7 @@ ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), p_369874_, this); + if (railshape == RailShape.EAST_WEST) { + if (this.isRedstoneConductor(p_369874_.west())) { + return new Vec3(1.0, 0.0, 0.0); +@@ -614,5 +_,42 @@ - BlockState blockstate = this.level().getBlockState(new BlockPos(i, j, k)); - if (BaseRailBlock.isRail(blockstate)) { -- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); -+ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), new BlockPos(i, j, k), this); - Pair pair = exits(railshape); - Vec3i vec3i = pair.getFirst(); - Vec3i vec3i1 = pair.getSecond(); -@@ -649,6 +_,10 @@ - - @Override - public void push(Entity p_38165_) { -+ if (getCollisionHandler() != null) { -+ getCollisionHandler().onEntityCollision(this, p_38165_); -+ return; -+ } - if (!this.level().isClientSide) { - if (!p_38165_.noPhysics && !this.noPhysics) { - if (!this.hasPassenger(p_38165_)) { -@@ -670,7 +_,7 @@ - d1 *= 0.1F; - d0 *= 0.5; - d1 *= 0.5; -- if (p_38165_ instanceof AbstractMinecart) { -+ if (p_38165_ instanceof AbstractMinecart oMinecart) { - double d4 = p_38165_.getX() - this.getX(); - double d5 = p_38165_.getZ() - this.getZ(); - Vec3 vec3 = new Vec3(d4, 0.0, d5).normalize(); -@@ -687,12 +_,11 @@ - - Vec3 vec32 = this.getDeltaMovement(); - Vec3 vec33 = p_38165_.getDeltaMovement(); -- if (((AbstractMinecart)p_38165_).getMinecartType() == AbstractMinecart.Type.FURNACE && this.getMinecartType() != AbstractMinecart.Type.FURNACE) { -+ if (oMinecart.isPoweredCart() && !this.isPoweredCart()) { - this.setDeltaMovement(vec32.multiply(0.2, 1.0, 0.2)); - this.push(vec33.x - d0, 0.0, vec33.z - d1); - p_38165_.setDeltaMovement(vec33.multiply(0.95, 1.0, 0.95)); -- } else if (((AbstractMinecart)p_38165_).getMinecartType() != AbstractMinecart.Type.FURNACE -- && this.getMinecartType() == AbstractMinecart.Type.FURNACE) { -+ } else if (!oMinecart.isPoweredCart() && this.isPoweredCart()) { - p_38165_.setDeltaMovement(vec33.multiply(0.2, 1.0, 0.2)); - p_38165_.push(vec32.x + d0, 0.0, vec32.z + d1); - this.setDeltaMovement(vec32.multiply(0.95, 1.0, 0.95)); -@@ -802,6 +_,50 @@ - case HOPPER -> Items.HOPPER_MINECART; - case COMMAND_BLOCK -> Items.COMMAND_BLOCK_MINECART; - }); + public boolean isFurnace() { + return false; + } + ++ private static java.util.function.BiFunction behaviorFactory = (cart, level) -> { ++ return useExperimentalMovement(level) ? new NewMinecartBehavior(cart) : new OldMinecartBehavior(cart); ++ }; ++ public static void setBehaviorFactory(java.util.function.BiFunction factory) { behaviorFactory = factory; } ++ public static java.util.function.BiFunction getBehaviorFactory() { return behaviorFactory; } + -+ private static net.minecraftforge.common.IMinecartCollisionHandler COLLISIONS = null; -+ public net.minecraftforge.common.IMinecartCollisionHandler getCollisionHandler() { return COLLISIONS; } -+ public static void registerCollisionHandler(@Nullable net.minecraftforge.common.IMinecartCollisionHandler handler) { COLLISIONS = handler; } + private boolean canUseRail = true; + @Override public boolean canUseRail() { return canUseRail; } + @Override public void setCanUseRail(boolean value) { this.canUseRail = value; } @@ -215,7 +91,7 @@ + @Override public float getCurrentCartSpeedCapOnRail() { return currentSpeedCapOnRail; } + @Override public void setCurrentCartSpeedCapOnRail(float value) { currentSpeedCapOnRail = Math.min(value, getMaxCartSpeedOnRail()); } + private Float maxSpeedAirLateral = null; -+ @Override public float getMaxSpeedAirLateral() { return maxSpeedAirLateral == null ? (float)this.getMaxSpeed() : maxSpeedAirLateral; } ++ @Override public float getMaxSpeedAirLateral() { return maxSpeedAirLateral == null ? (float)this.getMaxSpeed((ServerLevel)this.level()) : maxSpeedAirLateral; } + @Override public void setMaxSpeedAirLateral(float value) { maxSpeedAirLateral = value; } + private float maxSpeedAirVertical = DEFAULT_MAX_SPEED_AIR_VERTICAL; + @Override public float getMaxSpeedAirVertical() { return maxSpeedAirVertical; } @@ -226,26 +102,16 @@ + @Override + public double getMaxSpeedWithRail() { //Non-default because getMaximumSpeed is protected + if (!canUseRail()) { -+ return getMaxSpeed(); ++ return getMaxSpeed((ServerLevel)this.level()); + } + BlockPos pos = this.getCurrentRailPosition(); + BlockState state = this.level().getBlockState(pos); + + if (!state.is(BlockTags.RAILS)) { -+ return getMaxSpeed(); ++ return getMaxSpeed((ServerLevel)this.level()); + } + + float railMaxSpeed = ((BaseRailBlock)state.getBlock()).getRailMaxSpeed(state, this.level(), pos, this); + return Math.min(railMaxSpeed, getCurrentCartSpeedCapOnRail()); -+ } -+ -+ @Override -+ public void moveMinecartOnRail(BlockPos pos) { //Non-default because getMaximumSpeed is protected -+ AbstractMinecart mc = this; -+ double d24 = mc.isVehicle() ? 0.75D : 1.0D; -+ double d25 = mc.getMaxSpeedWithRail(); -+ Vec3 vec3d1 = mc.getDeltaMovement(); -+ mc.move(MoverType.SELF, new Vec3(Mth.clamp(d24 * vec3d1.x, -d25, d25), 0.0D, Mth.clamp(d24 * vec3d1.z, -d25, d25))); } - - public static enum Type { + } diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch index d02a4f38ba..f9f15bce97 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java +++ b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -@@ -95,6 +_,8 @@ +@@ -93,6 +_,8 @@ @Override public InteractionResult interact(Player p_38232_, InteractionHand p_38233_) { @@ -9,7 +9,7 @@ return this.interactWithContainerVehicle(p_38232_); } -@@ -165,5 +_,27 @@ +@@ -163,5 +_,27 @@ @Override public void clearItemStacks() { this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); 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 5aaa30ee1b..03227892c3 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/ChestBoat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/ChestBoat.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/vehicle/ChestBoat.java +++ b/net/minecraft/world/entity/vehicle/ChestBoat.java -@@ -220,4 +_,26 @@ - public void stopOpen(Player p_270286_) { - this.level().gameEvent(GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.Context.of(p_270286_)); +@@ -15,4 +_,26 @@ + protected double rideHeight(EntityDimensions p_362135_) { + return (double)(p_362135_.height() / 3.0F); } + + private net.minecraftforge.common.util.LazyOptional itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> new net.minecraftforge.items.wrapper.InvWrapper(this)); + + @Override -+ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable net.minecraft.core.Direction facing) { ++ public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @org.jetbrains.annotations.Nullable net.minecraft.core.Direction facing) { + if (capability == net.minecraftforge.common.capabilities.ForgeCapabilities.ITEM_HANDLER && this.isAlive()) { + return itemHandler.cast(); + } diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch index 3886463573..342d2413e8 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/vehicle/ContainerEntity.java +++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java -@@ -107,6 +_,9 @@ +@@ -105,6 +_,9 @@ - this.setLootTable(null); + this.setContainerLootTable(null); LootParams.Builder lootparams$builder = new LootParams.Builder((ServerLevel)this.level()).withParameter(LootContextParams.ORIGIN, this.position()); + // Forge: set the chest to killer_entity for loot context. + if (this instanceof AbstractMinecartContainer entityContainer) diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/Minecart.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/Minecart.java.patch deleted file mode 100644 index dcdbc9be2f..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/Minecart.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/vehicle/Minecart.java -+++ b/net/minecraft/world/entity/vehicle/Minecart.java -@@ -19,6 +_,8 @@ - - @Override - public InteractionResult interact(Player p_38483_, InteractionHand p_38484_) { -+ InteractionResult ret = super.interact(p_38483_, p_38484_); -+ if (ret.consumesAction()) return ret; - if (p_38483_.isSecondaryUseActive()) { - return InteractionResult.PASS; - } else if (this.isVehicle()) { diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch index fa2e6954e2..febb3543af 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java +++ b/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java -@@ -85,6 +_,8 @@ +@@ -82,6 +_,8 @@ @Override public InteractionResult interact(Player p_38522_, InteractionHand p_38523_) { diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch index 2f7d0ce506..483ff2ae1d 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch @@ -1,22 +1,12 @@ --- a/net/minecraft/world/entity/vehicle/MinecartFurnace.java +++ b/net/minecraft/world/entity/vehicle/MinecartFurnace.java -@@ -116,6 +_,8 @@ - - @Override - public InteractionResult interact(Player p_38562_, InteractionHand p_38563_) { -+ var ret = super.interact(p_38562_, p_38563_); -+ if (ret.consumesAction()) return ret; - ItemStack itemstack = p_38562_.getItemInHand(p_38563_); - if (INGREDIENT.test(itemstack) && this.fuel + 3600 <= 32000) { - itemstack.consume(1, p_38562_); -@@ -157,5 +_,10 @@ - @Override +@@ -146,4 +_,9 @@ public BlockState getDefaultDisplayBlockState() { return Blocks.FURNACE.defaultBlockState().setValue(FurnaceBlock.FACING, Direction.NORTH).setValue(FurnaceBlock.LIT, Boolean.valueOf(this.hasFuel())); -+ } + } + + @Override + public float getMaxCartSpeedOnRail() { + return 0.2f; - } ++ } } diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch index 9390a84e57..dbc06a596c 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/MinecartSpawner.java +++ b/net/minecraft/world/entity/vehicle/MinecartSpawner.java -@@ -17,6 +_,12 @@ +@@ -18,6 +_,12 @@ public void broadcastEvent(Level p_150342_, BlockPos p_150343_, int p_150344_) { p_150342_.broadcastEntityEvent(MinecartSpawner.this, (byte)p_150344_); } diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch new file mode 100644 index 0000000000..bd2ea5d75d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch @@ -0,0 +1,52 @@ +--- a/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java ++++ b/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java +@@ -170,7 +_,7 @@ + + public void adjustToRails(BlockPos p_367561_, BlockState p_368130_, boolean p_364585_) { + if (BaseRailBlock.isRail(p_368130_)) { +- RailShape railshape = p_368130_.getValue(((BaseRailBlock)p_368130_.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)p_368130_.getBlock()).getRailDirection(p_368130_, this.level(), p_367561_, this.minecart); + Pair pair = AbstractMinecart.exits(railshape); + Vec3 vec3 = new Vec3(pair.getFirst()).scale(0.5); + Vec3 vec31 = new Vec3(pair.getSecond()).scale(0.5); +@@ -262,11 +_,11 @@ + if (flag) { + this.minecart.resetFallDistance(); + this.minecart.setOldPosAndRot(); +- if (blockstate.is(Blocks.ACTIVATOR_RAIL)) { ++ if (blockstate.getBlock() instanceof PoweredRailBlock power && power.isActivatorRail()) { + this.minecart.activateMinecart(blockpos.getX(), blockpos.getY(), blockpos.getZ(), blockstate.getValue(PoweredRailBlock.POWERED)); + } + +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), blockpos, this.minecart); + Vec3 vec31 = this.calculateTrackSpeed(p_369629_, vec3.horizontal(), newminecartbehavior$trackiteration, blockpos, blockstate, railshape); + if (newminecartbehavior$trackiteration.firstIteration) { + newminecartbehavior$trackiteration.movementLeft = vec31.horizontalDistance(); +@@ -395,7 +_,7 @@ + } + + private Vec3 calculateHaltTrackSpeed(Vec3 p_364212_, BlockState p_362846_) { +- if (p_362846_.is(Blocks.POWERED_RAIL) && !p_362846_.getValue(PoweredRailBlock.POWERED)) { ++ if (p_362846_.getBlock() instanceof PoweredRailBlock && !p_362846_.getValue(PoweredRailBlock.POWERED)) { + return p_364212_.length() < 0.03 ? Vec3.ZERO : p_364212_.scale(0.5); + } else { + return p_364212_; +@@ -403,7 +_,7 @@ + } + + private Vec3 calculateBoostTrackSpeed(Vec3 p_366761_, BlockPos p_361866_, BlockState p_368734_) { +- if (p_368734_.is(Blocks.POWERED_RAIL) && p_368734_.getValue(PoweredRailBlock.POWERED)) { ++ if (p_368734_.getBlock() instanceof PoweredRailBlock && p_368734_.getValue(PoweredRailBlock.POWERED)) { + if (p_366761_.length() > 0.01) { + return p_366761_.normalize().scale(p_366761_.length() + 0.06); + } else { +@@ -455,7 +_,7 @@ + BlockState blockstate = this.level().getBlockState(BlockPos.containing(vec36)); + if (flag) { + if (BaseRailBlock.isRail(blockstate)) { +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), BlockPos.containing(vec36), this.minecart); + if (this.restAtVShape(p_363897_, railshape)) { + return 0.0; + } diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch new file mode 100644 index 0000000000..b2cef1abdc --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch @@ -0,0 +1,110 @@ +--- a/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java ++++ b/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java +@@ -95,9 +_,9 @@ + BlockState blockstate = this.level().getBlockState(blockpos); + boolean $$4 = BaseRailBlock.isRail(blockstate); + this.minecart.setOnRails($$4); +- if ($$4) { ++ if (this.minecart.canUseRail() && $$4) { + this.moveAlongTrack(serverlevel); +- if (blockstate.is(Blocks.ACTIVATOR_RAIL)) { ++ if (blockstate.getBlock() instanceof PoweredRailBlock power && power.isActivatorRail()) { + this.minecart.activateMinecart(blockpos.getX(), blockpos.getY(), blockpos.getZ(), blockstate.getValue(PoweredRailBlock.POWERED)); + } + } else { +@@ -148,18 +_,19 @@ + d1 = (double)blockpos.getY(); + boolean flag = false; + boolean flag1 = false; +- if (blockstate.is(Blocks.POWERED_RAIL)) { ++ BaseRailBlock baserailblock = (BaseRailBlock)blockstate.getBlock(); ++ if (blockstate.getBlock() instanceof PoweredRailBlock) { + flag = blockstate.getValue(PoweredRailBlock.POWERED); + flag1 = !flag; + } + +- double d3 = 0.0078125; ++ double d3 = getSlopeAdjustment(); + if (this.minecart.isInWater()) { + d3 *= 0.2; + } + + Vec3 vec31 = this.getDeltaMovement(); +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = baserailblock.getRailDirection(blockstate, this.level(), blockpos, this.minecart); + switch (railshape) { + case ASCENDING_EAST: + this.setDeltaMovement(vec31.add(-d3, 0.0, 0.0)); +@@ -211,7 +_,7 @@ + } + } + +- if (flag1) { ++ if (flag1 && shouldDoRailFunctions()) { + double d20 = this.getDeltaMovement().horizontalDistance(); + if (d20 < 0.03) { + this.setDeltaMovement(Vec3.ZERO); +@@ -240,10 +_,7 @@ + d0 = d21 + d4 * d12; + d2 = d9 + d5 * d12; + this.setPos(d0, d1, d2); +- double d23 = this.minecart.isVehicle() ? 0.75 : 1.0; +- double d24 = this.minecart.getMaxSpeed(p_366781_); +- vec31 = this.getDeltaMovement(); +- this.minecart.move(MoverType.SELF, new Vec3(Mth.clamp(d23 * vec31.x, -d24, d24), 0.0, Mth.clamp(d23 * vec31.z, -d24, d24))); ++ this.moveMinecartOnRail(p_366781_); + if (vec3i.getY() != 0 + && Mth.floor(this.minecart.getX()) - blockpos.getX() == vec3i.getX() + && Mth.floor(this.minecart.getZ()) - blockpos.getZ() == vec3i.getZ()) { +@@ -275,7 +_,11 @@ + this.setDeltaMovement(d25 * (double)(j - blockpos.getX()), vec36.y, d25 * (double)(i - blockpos.getZ())); + } + +- if (flag) { ++ if (shouldDoRailFunctions()) { ++ baserailblock.onMinecartPass(blockstate, level(), blockpos, this.minecart); ++ } ++ ++ if (flag && shouldDoRailFunctions()) { + Vec3 vec37 = this.getDeltaMovement(); + double d26 = vec37.horizontalDistance(); + if (d26 > 0.01) { +@@ -319,7 +_,7 @@ + + BlockState blockstate = this.level().getBlockState(new BlockPos(i, j, k)); + if (BaseRailBlock.isRail(blockstate)) { +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), new BlockPos(i, j, k), this.minecart); + p_364195_ = (double)j; + if (railshape.isSlope()) { + p_364195_ = (double)(j + 1); +@@ -358,7 +_,7 @@ + + BlockState blockstate = this.level().getBlockState(new BlockPos(i, j, k)); + if (BaseRailBlock.isRail(blockstate)) { +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), new BlockPos(i, j, k), this.minecart); + Pair pair = AbstractMinecart.exits(railshape); + Vec3i vec3i = pair.getFirst(); + Vec3i vec3i1 = pair.getSecond(); +@@ -449,5 +_,20 @@ + @Override + public double getSlowdownFactor() { + return this.minecart.isVehicle() ? 0.997 : 0.96; ++ } ++ ++ protected double getSlopeAdjustment() { ++ return 0.0078125D; ++ } ++ ++ protected boolean shouldDoRailFunctions() { ++ return true; ++ } ++ ++ protected void moveMinecartOnRail(ServerLevel level) { ++ double d23 = this.minecart.isVehicle() ? 0.75 : 1.0; ++ double d24 = this.minecart.getMaxSpeed(level); ++ var vec31 = this.getDeltaMovement(); ++ this.minecart.move(MoverType.SELF, new Vec3(Mth.clamp(d23 * vec31.x, -d24, d24), 0.0, Mth.clamp(d23 * vec31.z, -d24, d24))); + } + } diff --git a/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch index 5a650fd72b..573a4d5b18 100644 --- a/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -401,6 +_,7 @@ +@@ -433,6 +_,7 @@ ItemStack itemstack10 = this.getCarried(); p_150434_.updateTutorialInventoryAction(itemstack10, slot7.getItem(), clickaction); if (!this.tryItemClickBehaviourOverride(p_150434_, clickaction, slot7, itemstack9, itemstack10)) { @@ -8,7 +8,7 @@ if (itemstack9.isEmpty()) { if (!itemstack10.isEmpty()) { int i3 = clickaction == ClickAction.PRIMARY ? itemstack10.getCount() : 1; -@@ -598,7 +_,7 @@ +@@ -653,7 +_,7 @@ ItemStack itemstack = slot.getItem(); if (!itemstack.isEmpty() && ItemStack.isSameItemSameComponents(p_38904_, itemstack)) { int j = itemstack.getCount() + p_38904_.getCount(); diff --git a/patches/minecraft/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch deleted file mode 100644 index dfcc8d9f22..0000000000 --- a/patches/minecraft/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/inventory/AbstractFurnaceMenu.java -+++ b/net/minecraft/world/inventory/AbstractFurnaceMenu.java -@@ -167,7 +_,7 @@ - } - - protected boolean isFuel(ItemStack p_38989_) { -- return AbstractFurnaceBlockEntity.isFuel(p_38989_); -+ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_38989_, this.recipeType) > 0; - } - - public float getBurnProgress() { diff --git a/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch index 11ac3053a0..547166272e 100644 --- a/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch @@ -6,11 +6,11 @@ + float breakChance = net.minecraftforge.event.ForgeEventFactory.onAnvilRepair(p_150474_, p_150475_, AnvilMenu.this.inputSlots.getItem(0), AnvilMenu.this.inputSlots.getItem(1)).getBreakChance(); + - this.inputSlots.setItem(0, ItemStack.EMPTY); if (this.repairItemCountCost > 0) { ItemStack itemstack = this.inputSlots.getItem(1); + if (!itemstack.isEmpty() && itemstack.getCount() > this.repairItemCountCost) { @@ -95,7 +_,7 @@ - this.cost.set(0); + this.inputSlots.setItem(0, ItemStack.EMPTY); this.access.execute((p_150479_, p_150480_) -> { BlockState blockstate = p_150479_.getBlockState(p_150480_); - if (!p_150474_.hasInfiniteMaterials() && blockstate.is(BlockTags.ANVIL) && p_150474_.getRandom().nextFloat() < 0.12F) { @@ -18,7 +18,7 @@ BlockState blockstate1 = AnvilBlock.damage(blockstate); if (blockstate1 == null) { p_150479_.removeBlock(p_150480_, false); -@@ -124,8 +_,11 @@ +@@ -125,8 +_,11 @@ j += (long)itemstack.getOrDefault(DataComponents.REPAIR_COST, Integer.valueOf(0)).intValue() + (long)itemstack2.getOrDefault(DataComponents.REPAIR_COST, Integer.valueOf(0)).intValue(); this.repairItemCountCost = 0; @@ -28,10 +28,10 @@ if (!itemstack2.isEmpty()) { - boolean flag = itemstack2.has(DataComponents.STORED_ENCHANTMENTS); + flag = itemstack2.has(DataComponents.STORED_ENCHANTMENTS); - if (itemstack1.isDamageableItem() && itemstack1.getItem().isValidRepairItem(itemstack, itemstack2)) { + if (itemstack1.isDamageableItem() && itemstack.isValidRepairItem(itemstack2)) { int l2 = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4); if (l2 <= 0) { -@@ -229,6 +_,10 @@ +@@ -230,6 +_,10 @@ itemstack1.remove(DataComponents.CUSTOM_NAME); } @@ -39,10 +39,10 @@ + itemstack1 = ItemStack.EMPTY; + } + - int k2 = (int)Mth.clamp(j + (long)i, 0L, 2147483647L); + int k2 = i <= 0 ? 0 : (int)Mth.clamp(j + (long)i, 0L, 2147483647L); this.cost.set(k2); if (i <= 0) { -@@ -297,5 +_,9 @@ +@@ -302,5 +_,9 @@ public int getCost() { return this.cost.get(); diff --git a/patches/minecraft/net/minecraft/world/inventory/BeaconMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/BeaconMenu.java.patch index 8df10e8f26..9c42af6e5a 100644 --- a/patches/minecraft/net/minecraft/world/inventory/BeaconMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/BeaconMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/BeaconMenu.java +++ b/net/minecraft/world/inventory/BeaconMenu.java -@@ -98,10 +_,8 @@ +@@ -87,10 +_,8 @@ } slot.onQuickCraft(itemstack1, itemstack); diff --git a/patches/minecraft/net/minecraft/world/inventory/BrewingStandMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/BrewingStandMenu.java.patch index 70e03e6a56..8150b3d7df 100644 --- a/patches/minecraft/net/minecraft/world/inventory/BrewingStandMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/BrewingStandMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/BrewingStandMenu.java +++ b/net/minecraft/world/inventory/BrewingStandMenu.java -@@ -41,9 +_,9 @@ +@@ -42,9 +_,9 @@ this.brewingStand = p_39095_; this.brewingStandData = p_39096_; PotionBrewing potionbrewing = p_39094_.player.level().potionBrewing(); @@ -13,7 +13,7 @@ this.ingredientSlot = this.addSlot(new BrewingStandMenu.IngredientsSlot(potionbrewing, p_39095_, 3, 79, 17)); this.addSlot(new BrewingStandMenu.FuelSlot(p_39095_, 4, 17, 17)); this.addDataSlots(p_39096_); -@@ -80,7 +_,7 @@ +@@ -72,7 +_,7 @@ if (!this.moveItemStackTo(itemstack1, 3, 4, false)) { return ItemStack.EMPTY; } @@ -22,7 +22,7 @@ if (!this.moveItemStackTo(itemstack1, 0, 3, false)) { return ItemStack.EMPTY; } -@@ -157,12 +_,23 @@ +@@ -149,12 +_,23 @@ } public static class PotionSlot extends Slot { @@ -46,7 +46,7 @@ return mayPlaceItem(p_39132_); } -@@ -175,6 +_,7 @@ +@@ -167,6 +_,7 @@ public void onTake(Player p_150499_, ItemStack p_150500_) { Optional> optional = p_150500_.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY).potion(); if (optional.isPresent() && p_150499_ instanceof ServerPlayer serverplayer) { diff --git a/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch index 670ba8cad2..ccd659894a 100644 --- a/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch @@ -9,10 +9,10 @@ } @Override -@@ -101,23 +_,25 @@ +@@ -91,23 +_,25 @@ if (!itemstack.isEmpty() && itemstack.isEnchantable()) { this.access.execute((p_341515_, p_341516_) -> { - IdMap> idmap = p_341515_.registryAccess().registryOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); + IdMap> idmap = p_341515_.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); - int j = 0; + float j = 0; @@ -37,7 +37,7 @@ } for (int l = 0; l < 3; l++) { -@@ -244,7 +_,7 @@ +@@ -234,7 +_,7 @@ if (!this.moveItemStackTo(itemstack1, 2, 38, true)) { return ItemStack.EMPTY; } diff --git a/patches/minecraft/net/minecraft/world/inventory/GrindstoneMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/GrindstoneMenu.java.patch index af0967f779..d713f62597 100644 --- a/patches/minecraft/net/minecraft/world/inventory/GrindstoneMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/GrindstoneMenu.java.patch @@ -37,10 +37,10 @@ private int getExperienceAmount(Level p_39632_) { + if (xp > -1) return xp; - int l = 0; - l += this.getExperienceFromItem(GrindstoneMenu.this.repairSlots.getItem(0)); - l += this.getExperienceFromItem(GrindstoneMenu.this.repairSlots.getItem(1)); -@@ -130,6 +_,17 @@ + int i = 0; + i += this.getExperienceFromItem(GrindstoneMenu.this.repairSlots.getItem(0)); + i += this.getExperienceFromItem(GrindstoneMenu.this.repairSlots.getItem(1)); +@@ -121,6 +_,17 @@ } private ItemStack computeResult(ItemStack p_335167_, ItemStack p_329934_) { diff --git a/patches/minecraft/net/minecraft/world/inventory/RecipeBookMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/RecipeBookMenu.java.patch deleted file mode 100644 index 5c8a847c8b..0000000000 --- a/patches/minecraft/net/minecraft/world/inventory/RecipeBookMenu.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/inventory/RecipeBookMenu.java -+++ b/net/minecraft/world/inventory/RecipeBookMenu.java -@@ -46,4 +_,8 @@ - public abstract RecipeBookType getRecipeBookType(); - - public abstract boolean shouldMoveToInventory(int p_150635_); -+ -+ public java.util.List getRecipeBookCategories() { -+ return net.minecraft.client.RecipeBookCategories.getCategories(this.getRecipeBookType()); -+ } - } diff --git a/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch b/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch index daf6e8856b..5143d99708 100644 --- a/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ResultSlot.java +++ b/net/minecraft/world/inventory/ResultSlot.java -@@ -47,6 +_,7 @@ +@@ -51,6 +_,7 @@ protected void checkTakeAchievements(ItemStack p_40185_) { if (this.removeCount > 0) { p_40185_.onCraftedBy(this.player.level(), this.player, this.removeCount); @@ -8,12 +8,12 @@ } if (this.container instanceof RecipeCraftingHolder recipecraftingholder) { -@@ -63,7 +_,9 @@ +@@ -86,7 +_,9 @@ CraftingInput craftinginput = craftinginput$positioned.input(); int i = craftinginput$positioned.left(); int j = craftinginput$positioned.top(); + net.minecraftforge.common.ForgeHooks.setCraftingPlayer(p_150638_); - NonNullList nonnulllist = p_150638_.level().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, craftinginput, p_150638_.level()); + NonNullList nonnulllist = this.getRemainingItems(craftinginput, p_150638_.level()); + net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null); for (int k = 0; k < craftinginput.height(); k++) { diff --git a/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch b/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch index 18d6f4ba8a..a11d9ba593 100644 --- a/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch @@ -9,7 +9,7 @@ } public ItemStack remove(int p_40227_) { -@@ -158,5 +_,37 @@ +@@ -162,5 +_,37 @@ public boolean isFake() { return false; diff --git a/patches/minecraft/net/minecraft/world/item/AnimalArmorItem.java.patch b/patches/minecraft/net/minecraft/world/item/AnimalArmorItem.java.patch index f47af3d7e3..4cd44d3722 100644 --- a/patches/minecraft/net/minecraft/world/item/AnimalArmorItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/AnimalArmorItem.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/world/item/AnimalArmorItem.java +++ b/net/minecraft/world/item/AnimalArmorItem.java -@@ -48,7 +_,7 @@ - return false; +@@ -27,7 +_,7 @@ + return this.bodyType.breakingSound; } - public static enum BodyType { + public static enum BodyType implements net.minecraftforge.common.IExtensibleEnum { - EQUESTRIAN(p_331659_ -> p_331659_.withPath(p_329177_ -> "textures/entity/horse/armor/horse_armor_" + p_329177_), SoundEvents.ITEM_BREAK), - CANINE(p_333424_ -> p_333424_.withPath("textures/entity/wolf/wolf_armor"), SoundEvents.WOLF_ARMOR_BREAK); + EQUESTRIAN(SoundEvents.ITEM_BREAK, EntityType.HORSE), + CANINE(SoundEvents.WOLF_ARMOR_BREAK, EntityType.WOLF); -@@ -58,6 +_,10 @@ - private BodyType(final Function p_332420_, final SoundEvent p_335661_) { - this.textureLocator = p_332420_; +@@ -37,6 +_,10 @@ + private BodyType(final SoundEvent p_335661_, final EntityType... p_364750_) { this.breakingSound = p_335661_; + this.allowedEntities = HolderSet.direct(EntityType::builtInRegistryHolder, p_364750_); + } + -+ public static BodyType create(String name, final Function path, SoundEvent sound) { ++ public static BodyType create(String name, SoundEvent sound, EntityType... types) { + throw new IllegalStateException("Enum not extended"); } } diff --git a/patches/minecraft/net/minecraft/world/item/ArmorMaterial.java.patch b/patches/minecraft/net/minecraft/world/item/ArmorMaterial.java.patch deleted file mode 100644 index ee2a4546d3..0000000000 --- a/patches/minecraft/net/minecraft/world/item/ArmorMaterial.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/item/ArmorMaterial.java -+++ b/net/minecraft/world/item/ArmorMaterial.java -@@ -56,5 +_,9 @@ - public boolean dyeable() { - return this.dyeable; - } -+ -+ public String getSuffix() { -+ return this.suffix; -+ } - } - } diff --git a/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch b/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch index 25673edf13..744b70fda6 100644 --- a/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/AxeItem.java +++ b/net/minecraft/world/item/AxeItem.java -@@ -60,7 +_,8 @@ +@@ -62,7 +_,8 @@ if (playerHasShieldUseIntent(p_40529_)) { return InteractionResult.PASS; } else { @@ -10,10 +10,10 @@ if (optional.isEmpty()) { return InteractionResult.PASS; } else { -@@ -113,5 +_,16 @@ +@@ -115,5 +_,16 @@ private Optional getStripped(BlockState p_150691_) { return Optional.ofNullable(STRIPPABLES.get(p_150691_.getBlock())) - .map(p_150689_ -> p_150689_.defaultBlockState().setValue(RotatedPillarBlock.AXIS, p_150691_.getValue(RotatedPillarBlock.AXIS))); + .map(p_359378_ -> p_359378_.defaultBlockState().setValue(RotatedPillarBlock.AXIS, p_150691_.getValue(RotatedPillarBlock.AXIS))); + } + + @Override diff --git a/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch b/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch index 669da194d0..866ffd8e43 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 -@@ -82,9 +_,9 @@ +@@ -79,9 +_,9 @@ } } @@ -12,7 +12,7 @@ ); level.gameEvent(GameEvent.BLOCK_PLACE, blockpos, GameEvent.Context.of(player, blockstate1)); itemstack.consume(1, player); -@@ -94,10 +_,16 @@ +@@ -91,10 +_,16 @@ } } @@ -29,7 +29,7 @@ @Nullable public BlockPlaceContext updatePlacementContext(BlockPlaceContext p_40609_) { return p_40609_; -@@ -188,6 +_,10 @@ +@@ -180,6 +_,10 @@ public void registerBlocks(Map p_40607_, Item p_40608_) { p_40607_.put(this.getBlock(), p_40608_); diff --git a/patches/minecraft/net/minecraft/world/item/BowItem.java.patch b/patches/minecraft/net/minecraft/world/item/BowItem.java.patch index 3c40a05974..60e6b0ec66 100644 --- a/patches/minecraft/net/minecraft/world/item/BowItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BowItem.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/world/item/BowItem.java +++ b/net/minecraft/world/item/BowItem.java -@@ -28,6 +_,9 @@ - ItemStack itemstack = player.getProjectile(p_40667_); - if (!itemstack.isEmpty()) { +@@ -32,6 +_,9 @@ + return false; + } else { int i = this.getUseDuration(p_40667_, p_40669_) - p_40670_; + i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(p_40667_, p_40668_, player, i, true); -+ if (i < 0) return; ++ if (i < 0) return false; + float f = getPowerForTime(i); - if (!((double)f < 0.1)) { - List list = draw(p_40667_, itemstack, player); -@@ -82,6 +_,8 @@ - public InteractionResultHolder use(Level p_40672_, Player p_40673_, InteractionHand p_40674_) { + if ((double)f < 0.1) { + return false; +@@ -89,6 +_,8 @@ + public InteractionResult use(Level p_40672_, Player p_40673_, InteractionHand p_40674_) { ItemStack itemstack = p_40673_.getItemInHand(p_40674_); boolean flag = !p_40673_.getProjectile(itemstack).isEmpty(); + var ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(itemstack, p_40672_, p_40673_, p_40674_, flag); + if (ret != null) return ret; if (!p_40673_.hasInfiniteMaterials() && !flag) { - return InteractionResultHolder.fail(itemstack); + return InteractionResult.FAIL; } else { diff --git a/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch b/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch index 718371155a..739b92b946 100644 --- a/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch @@ -22,13 +22,13 @@ } @Override - public InteractionResultHolder use(Level p_40703_, Player p_40704_, InteractionHand p_40705_) { + public InteractionResult use(Level p_40703_, Player p_40704_, InteractionHand p_40705_) { ItemStack itemstack = p_40704_.getItemInHand(p_40705_); BlockHitResult blockhitresult = getPlayerPOVHitResult(p_40703_, p_40704_, this.content == Fluids.EMPTY ? ClipContext.Fluid.SOURCE_ONLY : ClipContext.Fluid.NONE); -+ InteractionResultHolder ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(p_40704_, p_40703_, itemstack, blockhitresult); ++ var ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(p_40704_, p_40703_, itemstack, blockhitresult); + if (ret != null) return ret; if (blockhitresult.getType() == HitResult.Type.MISS) { - return InteractionResultHolder.pass(itemstack); + return InteractionResult.PASS; } else if (blockhitresult.getType() != HitResult.Type.BLOCK) { @@ -56,7 +_,7 @@ ItemStack itemstack3 = bucketpickup.pickupBlock(p_40704_, p_40703_, blockpos, blockstate1); @@ -40,7 +40,7 @@ ItemStack itemstack2 = ItemUtils.createFilledResult(itemstack, p_40704_, itemstack3); if (!p_40703_.isClientSide) { @@ -70,8 +_,8 @@ - return InteractionResultHolder.fail(itemstack); + return InteractionResult.FAIL; } else { BlockState blockstate = p_40703_.getBlockState(blockpos); - BlockPos blockpos2 = blockstate.getBlock() instanceof LiquidBlockContainer && this.content == Fluids.WATER ? blockpos : blockpos1; diff --git a/patches/minecraft/net/minecraft/world/item/BundleItem.java.patch b/patches/minecraft/net/minecraft/world/item/BundleItem.java.patch index 82e8af93d8..e1c1329dcc 100644 --- a/patches/minecraft/net/minecraft/world/item/BundleItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BundleItem.java.patch @@ -1,19 +1,10 @@ --- a/net/minecraft/world/item/BundleItem.java +++ b/net/minecraft/world/item/BundleItem.java -@@ -38,7 +_,7 @@ - - @Override - public boolean overrideStackedOnOther(ItemStack p_150733_, Slot p_150734_, ClickAction p_150735_, Player p_150736_) { -- if (p_150735_ != ClickAction.SECONDARY) { -+ if (p_150733_.getCount() != 1 || p_150735_ != ClickAction.SECONDARY) { - return false; - } else { - BundleContents bundlecontents = p_150733_.get(DataComponents.BUNDLE_CONTENTS); -@@ -69,6 +_,7 @@ +@@ -98,6 +_,7 @@ @Override public boolean overrideOtherStackedOnMe(ItemStack p_150742_, ItemStack p_150743_, Slot p_150744_, ClickAction p_150745_, Player p_150746_, SlotAccess p_150747_) { + if (p_150742_.getCount() != 1) return false; - if (p_150745_ == ClickAction.SECONDARY && p_150744_.allowModification(p_150746_)) { - BundleContents bundlecontents = p_150742_.get(DataComponents.BUNDLE_CONTENTS); - if (bundlecontents == null) { + if (p_150745_ == ClickAction.PRIMARY && p_150743_.isEmpty()) { + toggleSelectedItem(p_150742_, -1); + return false; diff --git a/patches/minecraft/net/minecraft/world/item/ChorusFruitItem.java.patch b/patches/minecraft/net/minecraft/world/item/ChorusFruitItem.java.patch deleted file mode 100644 index 47e6611d82..0000000000 --- a/patches/minecraft/net/minecraft/world/item/ChorusFruitItem.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/world/item/ChorusFruitItem.java -+++ b/net/minecraft/world/item/ChorusFruitItem.java -@@ -34,7 +_,9 @@ - } - - Vec3 vec3 = p_40714_.position(); -- if (p_40714_.randomTeleport(d0, d1, d2, true)) { -+ var event = net.minecraftforge.event.ForgeEventFactory.onChorusFruitTeleport(p_40714_, d0, d1, d2); -+ if (event.isCanceled()) return itemstack; -+ if (p_40714_.randomTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true)) { - p_40713_.gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(p_40714_)); - SoundSource soundsource; - SoundEvent soundevent; diff --git a/patches/minecraft/net/minecraft/world/item/CrossbowItem.java.patch b/patches/minecraft/net/minecraft/world/item/CrossbowItem.java.patch index e2e42d0d9a..f2df8f9c1a 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 -@@ -182,6 +_,7 @@ +@@ -185,6 +_,7 @@ Level p_40888_, LivingEntity p_40889_, InteractionHand p_40890_, ItemStack p_40891_, float p_40892_, float p_40893_, @Nullable LivingEntity p_329478_ ) { if (p_40888_ instanceof ServerLevel serverlevel) { diff --git a/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch b/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch index 84b5e842d2..dd31f0012a 100644 --- a/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch +++ b/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch @@ -11,7 +11,7 @@ this.id = p_41046_; @@ -52,6 +_,8 @@ this.textColor = p_41051_; - this.textureDiffuseColor = FastColor.ARGB32.opaque(p_41048_); + this.textureDiffuseColor = ARGB.opaque(p_41048_); this.fireworkColor = p_41050_; + this.dyesTag = net.minecraft.tags.ItemTags.create("c", "dyes/" + p_41047_); + this.dyedTag = net.minecraft.tags.ItemTags.create("c", "dyed/" + p_41047_); diff --git a/patches/minecraft/net/minecraft/world/item/ElytraItem.java.patch b/patches/minecraft/net/minecraft/world/item/ElytraItem.java.patch deleted file mode 100644 index b35a4ca8b2..0000000000 --- a/patches/minecraft/net/minecraft/world/item/ElytraItem.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/world/item/ElytraItem.java -+++ b/net/minecraft/world/item/ElytraItem.java -@@ -39,4 +_,23 @@ - public EquipmentSlot getEquipmentSlot() { - return EquipmentSlot.CHEST; - } -+ -+ @Override -+ public boolean canElytraFly(ItemStack stack, net.minecraft.world.entity.LivingEntity entity) { -+ return ElytraItem.isFlyEnabled(stack); -+ } -+ -+ @Override -+ public boolean elytraFlightTick(ItemStack stack, net.minecraft.world.entity.LivingEntity entity, int flightTicks) { -+ if (!entity.level().isClientSide) { -+ int nextFlightTick = flightTicks + 1; -+ if (nextFlightTick % 10 == 0) { -+ if (nextFlightTick % 20 == 0) { -+ stack.hurtAndBreak(1, entity, net.minecraft.world.entity.EquipmentSlot.CHEST); -+ } -+ entity.gameEvent(net.minecraft.world.level.gameevent.GameEvent.ELYTRA_GLIDE); -+ } -+ } -+ return true; -+ } - } diff --git a/patches/minecraft/net/minecraft/world/item/FishingRodItem.java.patch b/patches/minecraft/net/minecraft/world/item/FishingRodItem.java.patch index 6b37f06006..4d87ab5e0c 100644 --- a/patches/minecraft/net/minecraft/world/item/FishingRodItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/FishingRodItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/FishingRodItem.java +++ b/net/minecraft/world/item/FishingRodItem.java -@@ -24,7 +_,11 @@ +@@ -25,7 +_,11 @@ if (p_41291_.fishing != null) { if (!p_41290_.isClientSide) { int i = p_41291_.fishing.retrieve(itemstack); @@ -12,10 +12,10 @@ } p_41290_.playSound( -@@ -65,5 +_,10 @@ - @Override - public int getEnchantmentValue() { - return 1; +@@ -61,5 +_,10 @@ + } + + return InteractionResult.SUCCESS; + } + + @Override diff --git a/patches/minecraft/net/minecraft/world/item/Item.java.patch b/patches/minecraft/net/minecraft/world/item/Item.java.patch index b84df1dc54..6e59375416 100644 --- a/patches/minecraft/net/minecraft/world/item/Item.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Item.java.patch @@ -1,21 +1,26 @@ --- a/net/minecraft/world/item/Item.java +++ b/net/minecraft/world/item/Item.java -@@ -56,9 +_,12 @@ +@@ -70,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import org.slf4j.Logger; -public class Item implements FeatureElement, ItemLike { +public class Item implements FeatureElement, ItemLike, net.minecraftforge.common.extensions.IForgeItem { + public static final Codec> CODEC = BuiltInRegistries.ITEM + .holderByNameCodec() + .validate( +@@ -79,7 +_,9 @@ + : DataResult.success(p_361655_) + ); private static final Logger LOGGER = LogUtils.getLogger(); - public static final Map BY_BLOCK = Maps.newHashMap(); -+ + public static final net.minecraft.network.codec.StreamCodec> STREAM_CODEC = + net.minecraft.network.codec.ByteBufCodecs.holderRegistry(net.minecraft.core.registries.Registries.ITEM); + public static final Map BY_BLOCK = net.minecraftforge.registries.GameData.ItemCallbacks.getBlockItemMap(); public static final ResourceLocation BASE_ATTACK_DAMAGE_ID = ResourceLocation.withDefaultNamespace("base_attack_damage"); public static final ResourceLocation BASE_ATTACK_SPEED_ID = ResourceLocation.withDefaultNamespace("base_attack_speed"); public static final int DEFAULT_MAX_STACK_SIZE = 64; -@@ -95,6 +_,7 @@ +@@ -116,6 +_,7 @@ LOGGER.error("Item classes should end with Item and {} doesn't.", s); } } @@ -23,7 +28,7 @@ } @Deprecated -@@ -102,17 +_,25 @@ +@@ -123,17 +_,25 @@ return this.builtInRegistryHolder; } @@ -51,36 +56,16 @@ public void onDestroyed(ItemEntity p_150887_) { } -@@ -238,10 +_,12 @@ +@@ -239,6 +_,8 @@ + return BuiltInRegistries.ITEM.wrapAsHolder(this).getRegisteredName(); } - @Nullable -+ @Deprecated // Use ItemStack sensitive version. - public final Item getCraftingRemainingItem() { - return this.craftingRemainingItem; ++ /** Forge: use {@link ItemStack#getCraftingRemainder()}. */ ++ @Deprecated + public final ItemStack getCraftingRemainder() { + return this.craftingRemainingItem == null ? ItemStack.EMPTY : new ItemStack(this.craftingRemainingItem); } - -+ @Deprecated // Use ItemStack sensitive version. - public boolean hasCraftingRemainingItem() { - return this.craftingRemainingItem != null; - } -@@ -297,6 +_,7 @@ - return p_41436_.clip(new ClipContext(vec3, vec31, ClipContext.Block.OUTLINE, p_41438_, p_41437_)); - } - -+ /** @deprecated in favor of {@link net.minecraftforge.common.extensions.IForgeItem#getEnchantmentValue(ItemStack)} */ - public int getEnchantmentValue() { - return 0; - } -@@ -305,6 +_,7 @@ - return false; - } - -+ /** @deprecated in favor of {@link net.minecraftforge.common.extensions.IForgeItem#getDefaultAttributeModifiers(ItemStack)} */ - @Deprecated - public ItemAttributeModifiers getDefaultAttributeModifiers() { - return ItemAttributeModifiers.EMPTY; -@@ -339,6 +_,30 @@ +@@ -318,6 +_,30 @@ return this.requiredFeatures; } @@ -109,9 +94,9 @@ + public void initializeClient(java.util.function.Consumer consumer) { } + public static class Properties { - private static final Interner COMPONENT_INTERNER = Interners.newStrongInterner(); - @Nullable -@@ -439,6 +_,11 @@ + private static final DependantName BLOCK_DESCRIPTION_ID = p_367498_ -> Util.makeDescriptionId("block", p_367498_.location()); + private static final DependantName ITEM_DESCRIPTION_ID = p_367603_ -> Util.makeDescriptionId("item", p_367603_.location()); +@@ -483,6 +_,11 @@ @Nullable MapItemSavedData mapData(MapId p_335695_); @@ -123,7 +108,7 @@ static Item.TooltipContext of(@Nullable final Level p_332083_) { return p_332083_ == null ? EMPTY : new Item.TooltipContext() { @Override -@@ -454,6 +_,11 @@ +@@ -498,6 +_,11 @@ @Override public MapItemSavedData mapData(MapId p_330171_) { return p_332083_.getMapData(p_330171_); diff --git a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch index 13a838be0f..a1e2aeca0d 100644 --- a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -92,7 +_,7 @@ +@@ -97,7 +_,7 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.slf4j.Logger; -public final class ItemStack implements DataComponentHolder { +public final class ItemStack implements DataComponentHolder, net.minecraftforge.common.extensions.IForgeItemStack { - public static final Codec> ITEM_NON_AIR_CODEC = BuiltInRegistries.ITEM - .holderByNameCodec() - .validate( -@@ -347,13 +_,22 @@ + public static final Codec CODEC = Codec.lazyInitialized( + () -> RecordCodecBuilder.create( + p_359412_ -> p_359412_.group( +@@ -348,13 +_,22 @@ } public InteractionResult useOn(UseOnContext p_41662_) { @@ -30,10 +30,10 @@ Item item = this.getItem(); - InteractionResult interactionresult = item.useOn(p_41662_); + InteractionResult interactionresult = callback.apply(p_41662_); - if (player != null && interactionresult.indicateItemUse()) { + if (player != null && interactionresult instanceof InteractionResult.Success interactionresult$success && interactionresult$success.wasItemInteraction()) { player.awardStat(Stats.ITEM_USED.get(item)); } -@@ -453,7 +_,13 @@ +@@ -507,7 +_,13 @@ p_41623_, serverlevel, p_41624_ instanceof ServerPlayer serverplayer ? serverplayer : null, @@ -48,7 +48,7 @@ ); } } -@@ -780,6 +_,8 @@ +@@ -856,6 +_,8 @@ list.add(DISABLED_ITEM_TOOLTIP); } @@ -57,25 +57,7 @@ return list; } } -@@ -923,7 +_,7 @@ - if (!itemattributemodifiers.modifiers().isEmpty()) { - itemattributemodifiers.forEach(p_344758_, p_342345_); - } else { -- this.getItem().getDefaultAttributeModifiers().forEach(p_344758_, p_342345_); -+ this.getDefaultAttributeModifiers().forEach(p_344758_, p_342345_); - } - - EnchantmentHelper.forEachModifier(this, p_344758_, p_342345_); -@@ -934,7 +_,7 @@ - if (!itemattributemodifiers.modifiers().isEmpty()) { - itemattributemodifiers.forEach(p_331036_, p_334430_); - } else { -- this.getItem().getDefaultAttributeModifiers().forEach(p_331036_, p_334430_); -+ this.getItem().getAttributeModifiers(p_331036_, this).forEach(p_331036_, p_334430_); - } - - EnchantmentHelper.forEachModifier(this, p_331036_, p_334430_); -@@ -1011,6 +_,7 @@ +@@ -1082,6 +_,7 @@ this.getItem().onUseTick(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 5d75d9610b..149d0da6f7 100644 --- a/patches/minecraft/net/minecraft/world/item/Items.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Items.java.patch @@ -1,38 +1,40 @@ --- a/net/minecraft/world/item/Items.java +++ b/net/minecraft/world/item/Items.java -@@ -1814,7 +_,23 @@ +@@ -2103,7 +_,25 @@ } public static Item registerBlock(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 registerBlocks(java.util.Map map, Item self) { -+ super.registerBlocks(map, self); -+ for (Block b : p_248886_) { -+ map.put(b, self); +- Item item = registerBlock(p_252092_); ++ Item item = registerBlock(p_252092_, (block_, prop_) -> { ++ return new BlockItem(block_, prop_) { ++ @Override ++ public void registerBlocks(java.util.Map map, Item self) { ++ super.registerBlocks(map, self); ++ for (var b : p_248886_) { ++ map.put(b, self); ++ } + } -+ } + -+ @Override -+ public void removeFromBlockToItemMap(java.util.Map map, Item self) { -+ super.removeFromBlockToItemMap(map, self); -+ for (Block b : p_248886_) { -+ map.remove(b); ++ @Override ++ public void removeFromBlockToItemMap(java.util.Map map, Item self) { ++ super.removeFromBlockToItemMap(map, self); ++ for (var b : p_248886_) { ++ map.remove(b); ++ } + } -+ } -+ }; ++ }; ++ }); for (Block block : p_248886_) { - Item.BY_BLOCK.put(block, blockitem); -@@ -1840,10 +_,6 @@ - } + Item.BY_BLOCK.put(block, item); +@@ -2142,10 +_,6 @@ - public static Item registerItem(ResourceKey p_281502_, Item p_283159_) { -- if (p_283159_ instanceof BlockItem) { -- ((BlockItem)p_283159_).registerBlocks(Item.BY_BLOCK, p_283159_); + public static Item registerItem(ResourceKey p_364577_, Function p_366144_, Item.Properties p_369845_) { + Item item = p_366144_.apply(p_369845_.setId(p_364577_)); +- if (item instanceof BlockItem blockitem) { +- blockitem.registerBlocks(Item.BY_BLOCK, item); - } - - return Registry.register(BuiltInRegistries.ITEM, p_281502_, p_283159_); + return Registry.register(BuiltInRegistries.ITEM, p_364577_, item); } } diff --git a/patches/minecraft/net/minecraft/world/item/MinecartItem.java.patch b/patches/minecraft/net/minecraft/world/item/MinecartItem.java.patch deleted file mode 100644 index 1bf03fac0d..0000000000 --- a/patches/minecraft/net/minecraft/world/item/MinecartItem.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/world/item/MinecartItem.java -+++ b/net/minecraft/world/item/MinecartItem.java -@@ -33,7 +_,7 @@ - BlockPos blockpos = p_42949_.pos().relative(direction); - BlockState blockstate = serverlevel.getBlockState(blockpos); - RailShape railshape = blockstate.getBlock() instanceof BaseRailBlock -- ? blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()) -+ ? ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, serverlevel, blockpos, null) - : RailShape.NORTH_SOUTH; - double d3; - if (blockstate.is(BlockTags.RAILS)) { -@@ -49,7 +_,7 @@ - - BlockState blockstate1 = serverlevel.getBlockState(blockpos.below()); - RailShape railshape1 = blockstate1.getBlock() instanceof BaseRailBlock -- ? blockstate1.getValue(((BaseRailBlock)blockstate1.getBlock()).getShapeProperty()) -+ ? ((BaseRailBlock)blockstate1.getBlock()).getRailDirection(blockstate, serverlevel, blockpos, null) - : RailShape.NORTH_SOUTH; - if (direction != Direction.DOWN && railshape1.isAscending()) { - d3 = -0.4; diff --git a/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch b/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch index 3ce487b630..c4062370c4 100644 --- a/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/MobBucketItem.java +++ b/net/minecraft/world/item/MobBucketItem.java -@@ -25,13 +_,18 @@ +@@ -26,13 +_,18 @@ public class MobBucketItem extends BucketItem { private static final MapCodec VARIANT_FIELD_CODEC = TropicalFish.Variant.CODEC.fieldOf("BucketVariantTag"); @@ -24,7 +24,7 @@ } @Override -@@ -44,11 +_,11 @@ +@@ -45,11 +_,11 @@ @Override protected void playEmptySound(@Nullable Player p_151151_, LevelAccessor p_151152_, BlockPos p_151153_) { @@ -33,12 +33,12 @@ } private void spawn(ServerLevel p_151142_, ItemStack p_151143_, BlockPos p_151144_) { -- if (this.type.spawn(p_151142_, p_151143_, null, p_151144_, MobSpawnType.BUCKET, true, false) instanceof Bucketable bucketable) { -+ if (this.getFishType().spawn(p_151142_, p_151143_, null, p_151144_, MobSpawnType.BUCKET, true, false) instanceof Bucketable bucketable) { +- Entity entity = this.type.create(p_151142_, EntityType.createDefaultStackConfig(p_151142_, p_151143_, null), p_151144_, EntitySpawnReason.BUCKET, true, false); ++ Entity entity = this.getFishType().create(p_151142_, EntityType.createDefaultStackConfig(p_151142_, p_151143_, null), p_151144_, EntitySpawnReason.BUCKET, true, false); + if (entity instanceof Bucketable bucketable) { CustomData customdata = p_151143_.getOrDefault(DataComponents.BUCKET_ENTITY_DATA, CustomData.EMPTY); bucketable.loadFromBucketTag(customdata.copyTag()); - bucketable.setFromBucket(true); -@@ -57,7 +_,7 @@ +@@ -63,7 +_,7 @@ @Override public void appendHoverText(ItemStack p_151155_, Item.TooltipContext p_329546_, List p_151157_, TooltipFlag p_151158_) { @@ -47,7 +47,7 @@ CustomData customdata = p_151155_.getOrDefault(DataComponents.BUCKET_ENTITY_DATA, CustomData.EMPTY); if (customdata.isEmpty()) { return; -@@ -85,5 +_,13 @@ +@@ -91,5 +_,13 @@ p_151157_.add(mutablecomponent); } } diff --git a/patches/minecraft/net/minecraft/world/item/PickaxeItem.java.patch b/patches/minecraft/net/minecraft/world/item/PickaxeItem.java.patch index ad70eb6979..c59bca667f 100644 --- a/patches/minecraft/net/minecraft/world/item/PickaxeItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/PickaxeItem.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/PickaxeItem.java +++ b/net/minecraft/world/item/PickaxeItem.java @@ -6,4 +_,9 @@ - public PickaxeItem(Tier p_42961_, Item.Properties p_42964_) { - super(p_42961_, BlockTags.MINEABLE_WITH_PICKAXE, p_42964_); + public PickaxeItem(ToolMaterial p_363941_, float p_367504_, float p_368380_, Item.Properties p_42964_) { + super(p_363941_, BlockTags.MINEABLE_WITH_PICKAXE, p_367504_, p_368380_, p_42964_); } + + @Override diff --git a/patches/minecraft/net/minecraft/world/item/ProjectileWeaponItem.java.patch b/patches/minecraft/net/minecraft/world/item/ProjectileWeaponItem.java.patch index dc120334cf..e7e46f7976 100644 --- a/patches/minecraft/net/minecraft/world/item/ProjectileWeaponItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ProjectileWeaponItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ProjectileWeaponItem.java +++ b/net/minecraft/world/item/ProjectileWeaponItem.java -@@ -88,6 +_,7 @@ +@@ -87,6 +_,7 @@ protected Projectile createProjectile(Level p_333069_, LivingEntity p_334736_, ItemStack p_333680_, ItemStack p_329118_, boolean p_336242_) { ArrowItem arrowitem = p_329118_.getItem() instanceof ArrowItem arrowitem1 ? arrowitem1 : (ArrowItem)Items.ARROW; AbstractArrow abstractarrow = arrowitem.createArrow(p_333069_, p_329118_, p_334736_, p_333680_); @@ -8,7 +8,7 @@ if (p_336242_) { abstractarrow.setCritArrow(true); } -@@ -102,9 +_,10 @@ +@@ -101,9 +_,10 @@ int i = p_335616_.level() instanceof ServerLevel serverlevel ? EnchantmentHelper.processProjectileCount(serverlevel, p_329054_, p_335616_, 1) : 1; List list = new ArrayList<>(i); ItemStack itemstack1 = p_328618_.copy(); @@ -20,7 +20,7 @@ if (!itemstack.isEmpty()) { list.add(itemstack); } -@@ -132,5 +_,9 @@ +@@ -131,5 +_,9 @@ return itemstack; } diff --git a/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch b/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch index f39ec25ba8..3f1301530d 100644 --- a/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ShearsItem.java +++ b/net/minecraft/world/item/ShearsItem.java -@@ -79,4 +_,33 @@ +@@ -84,4 +_,34 @@ return super.useOn(p_186371_); } @@ -11,16 +11,17 @@ + if (entity.level().isClientSide) { + return InteractionResult.SUCCESS; + } ++ var serverLevel = (net.minecraft.server.level.ServerLevel)entity.level(); + + BlockPos pos = BlockPos.containing(entity.position()); + if (target.isShearable(stack, entity.level(), pos)) { + var key = net.minecraft.world.item.enchantment.Enchantments.FORTUNE; + var drops = target.onSheared(playerIn, stack, entity.level(), pos, net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(entity.level().holderLookup(key.registryKey()).getOrThrow(key), stack)); + var rand = new java.util.Random(); -+ drops.forEach(d -> { -+ var ent = entity.spawnAtLocation(d, 1.0F); ++ for (var drop : drops) { ++ var ent = entity.spawnAtLocation(serverLevel, drop, 1.0F); + ent.setDeltaMovement(ent.getDeltaMovement().add((double)((rand.nextFloat() - rand.nextFloat()) * 0.1F), (double)(rand.nextFloat() * 0.05F), (double)((rand.nextFloat() - rand.nextFloat()) * 0.1F))); -+ }); ++ } + if (!drops.isEmpty()) + stack.hurtAndBreak(1, playerIn, LivingEntity.getSlotForHand(hand)); + } diff --git a/patches/minecraft/net/minecraft/world/item/ShieldItem.java.patch b/patches/minecraft/net/minecraft/world/item/ShieldItem.java.patch index 40a73be607..2b6300796f 100644 --- a/patches/minecraft/net/minecraft/world/item/ShieldItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ShieldItem.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/ShieldItem.java +++ b/net/minecraft/world/item/ShieldItem.java -@@ -58,4 +_,9 @@ - public EquipmentSlot getEquipmentSlot() { - return EquipmentSlot.OFFHAND; +@@ -43,4 +_,9 @@ + p_43100_.startUsingItem(p_43101_); + return InteractionResult.CONSUME; } + + @Override diff --git a/patches/minecraft/net/minecraft/world/item/SpawnEggItem.java.patch b/patches/minecraft/net/minecraft/world/item/SpawnEggItem.java.patch index bd9d58de00..40753ae515 100644 --- a/patches/minecraft/net/minecraft/world/item/SpawnEggItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/SpawnEggItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/SpawnEggItem.java +++ b/net/minecraft/world/item/SpawnEggItem.java -@@ -42,11 +_,13 @@ +@@ -41,11 +_,13 @@ private final int highlightColor; private final EntityType defaultType; @@ -14,7 +14,7 @@ BY_ID.put(p_43207_, this); } -@@ -132,6 +_,7 @@ +@@ -131,6 +_,7 @@ return p_43212_ == 0 ? this.backgroundColor : this.highlightColor; } @@ -22,7 +22,7 @@ @Nullable public static SpawnEggItem byId(@Nullable EntityType p_43214_) { return BY_ID.get(p_43214_); -@@ -143,12 +_,12 @@ +@@ -142,12 +_,12 @@ public EntityType getType(ItemStack p_334231_) { CustomData customdata = p_334231_.getOrDefault(DataComponents.ENTITY_DATA, CustomData.EMPTY); @@ -37,7 +37,7 @@ } public Optional spawnOffspringFromSpawnEgg(Player p_43216_, Mob p_43217_, EntityType p_43218_, ServerLevel p_43219_, Vec3 p_43220_, ItemStack p_43221_) { -@@ -177,5 +_,9 @@ +@@ -176,5 +_,9 @@ } } } diff --git a/patches/minecraft/net/minecraft/world/item/SwordItem.java.patch b/patches/minecraft/net/minecraft/world/item/SwordItem.java.patch index f87cf2f733..aeb5b8d150 100644 --- a/patches/minecraft/net/minecraft/world/item/SwordItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/SwordItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/SwordItem.java +++ b/net/minecraft/world/item/SwordItem.java -@@ -52,4 +_,9 @@ +@@ -26,4 +_,9 @@ public void postHurtEnemy(ItemStack p_342189_, LivingEntity p_344347_, LivingEntity p_343888_) { p_342189_.hurtAndBreak(1, p_343888_, EquipmentSlot.MAINHAND); } diff --git a/patches/minecraft/net/minecraft/world/item/UseAnim.java.patch b/patches/minecraft/net/minecraft/world/item/UseAnim.java.patch deleted file mode 100644 index 3f78819ea3..0000000000 --- a/patches/minecraft/net/minecraft/world/item/UseAnim.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/world/item/UseAnim.java -+++ b/net/minecraft/world/item/UseAnim.java -@@ -10,5 +_,10 @@ - CROSSBOW, - SPYGLASS, - TOOT_HORN, -- BRUSH; -+ BRUSH, -+ /** -+ * Items with custom arm animation should return this in `Item#getUseAnimation` -+ * to prevent vanilla from also trying to animate same item -+ */ -+ CUSTOM - } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch index c76d059412..5250195ea8 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch @@ -1,13 +1,11 @@ --- a/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java +++ b/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java -@@ -79,8 +_,8 @@ +@@ -84,7 +_,7 @@ for (int i = 0; i < nonnulllist.size(); i++) { ItemStack itemstack = p_342084_.getItem(i); if (!itemstack.isEmpty()) { -- if (itemstack.getItem().hasCraftingRemainingItem()) { -- nonnulllist.set(i, new ItemStack(itemstack.getItem().getCraftingRemainingItem())); -+ if (itemstack.hasCraftingRemainingItem()) { -+ nonnulllist.set(i, itemstack.getCraftingRemainingItem()); +- ItemStack itemstack1 = itemstack.getItem().getCraftingRemainder(); ++ ItemStack itemstack1 = itemstack.getCraftingRemainder(); + if (!itemstack1.isEmpty()) { + nonnulllist.set(i, itemstack1); } else if (!itemstack.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY).layers().isEmpty()) { - nonnulllist.set(i, itemstack.copyWithCount(1)); - } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch index b21d279457..f9eee67178 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch @@ -1,13 +1,11 @@ --- a/net/minecraft/world/item/crafting/BookCloningRecipe.java +++ b/net/minecraft/world/item/crafting/BookCloningRecipe.java -@@ -83,8 +_,8 @@ +@@ -88,7 +_,7 @@ for (int i = 0; i < nonnulllist.size(); i++) { ItemStack itemstack = p_344901_.getItem(i); -- if (itemstack.getItem().hasCraftingRemainingItem()) { -- nonnulllist.set(i, new ItemStack(itemstack.getItem().getCraftingRemainingItem())); -+ if (itemstack.hasCraftingRemainingItem()) { -+ nonnulllist.set(i, itemstack.getCraftingRemainingItem()); +- ItemStack itemstack1 = itemstack.getItem().getCraftingRemainder(); ++ ItemStack itemstack1 = itemstack.getCraftingRemainder(); + if (!itemstack1.isEmpty()) { + nonnulllist.set(i, itemstack1); } else if (itemstack.getItem() instanceof WrittenBookItem) { - nonnulllist.set(i, itemstack.copyWithCount(1)); - break; diff --git a/patches/minecraft/net/minecraft/world/item/crafting/CraftingRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/CraftingRecipe.java.patch new file mode 100644 index 0000000000..48caa1052d --- /dev/null +++ b/patches/minecraft/net/minecraft/world/item/crafting/CraftingRecipe.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/item/crafting/CraftingRecipe.java ++++ b/net/minecraft/world/item/crafting/CraftingRecipe.java +@@ -23,8 +_,7 @@ + NonNullList nonnulllist = NonNullList.withSize(p_368314_.size(), ItemStack.EMPTY); + + for (int i = 0; i < nonnulllist.size(); i++) { +- Item item = p_368314_.getItem(i).getItem(); +- nonnulllist.set(i, item.getCraftingRemainder()); ++ nonnulllist.set(i, p_368314_.getItem(i).getCraftingRemainder()); + } + + return nonnulllist; 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 59b03b0c5d..638930092f 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch @@ -1,74 +1,44 @@ --- a/net/minecraft/world/item/crafting/Ingredient.java +++ b/net/minecraft/world/item/crafting/Ingredient.java -@@ -28,16 +_,25 @@ +@@ -24,20 +_,28 @@ import net.minecraft.world.level.ItemLike; public class Ingredient implements Predicate { -+ //Because Mojang caches things... we need to invalidate them.. so... here we go.. -+ private static final java.util.concurrent.atomic.AtomicInteger INVALIDATION_COUNTER = new java.util.concurrent.atomic.AtomicInteger(); -+ public static void invalidateAll() { -+ INVALIDATION_COUNTER.incrementAndGet(); -+ } - public static final Ingredient EMPTY = new Ingredient(Stream.empty()); -- public static final StreamCodec CONTENTS_STREAM_CODEC = ItemStack.LIST_STREAM_CODEC -- .map(p_327193_ -> fromValues(p_327193_.stream().map(Ingredient.ItemValue::new)), p_327192_ -> Arrays.asList(p_327192_.getItems())); +- public static final StreamCodec CONTENTS_STREAM_CODEC = ByteBufCodecs.holderSet(Registries.ITEM) ++ private static final StreamCodec VANILLA_CONTENTS_STREAM_CODEC = ByteBufCodecs.holderSet(Registries.ITEM) + .map(Ingredient::new, p_359816_ -> p_359816_.values); +- public static final StreamCodec> OPTIONAL_CONTENTS_STREAM_CODEC = ByteBufCodecs.holderSet(Registries.ITEM) + public static final StreamCodec CONTENTS_STREAM_CODEC = net.minecraftforge.common.ForgeHooks.ingredientStreamCodec(); - private final Ingredient.Value[] values; ++ public static final StreamCodec> OPTIONAL_CONTENTS_STREAM_CODEC = CONTENTS_STREAM_CODEC + .map( +- p_359814_ -> p_359814_.size() == 0 ? Optional.empty() : Optional.of(new Ingredient((HolderSet)p_359814_)), +- p_359815_ -> p_359815_.>map(p_359810_ -> p_359810_.values).orElse(HolderSet.direct()) ++ ingredient -> ingredient.items().isEmpty() ? Optional.empty() : Optional.of(ingredient), ++ ingredient -> ingredient.orElseGet(() -> Ingredient.of()) + ); + public static final Codec> NON_AIR_HOLDER_SET_CODEC = HolderSetCodec.create(Registries.ITEM, Item.CODEC, false); +- public static final Codec CODEC = ExtraCodecs.nonEmptyHolderSet(NON_AIR_HOLDER_SET_CODEC).xmap(Ingredient::new, p_359811_ -> p_359811_.values); +- private final HolderSet values; ++ private static final Codec VANILLA_CODEC = ExtraCodecs.nonEmptyHolderSet(NON_AIR_HOLDER_SET_CODEC).xmap(Ingredient::new, p_359811_ -> p_359811_.values); ++ private static final com.mojang.serialization.MapCodec VANILLA_MAP_CODEC = VANILLA_CODEC.fieldOf("value"); ++ public static final Codec CODEC = net.minecraftforge.common.ForgeHooks.ingredientBaseCodec(VANILLA_CODEC); ++ protected final HolderSet values; @Nullable - private ItemStack[] itemStacks; - @Nullable - private IntList stackingIds; -- public static final Codec CODEC = codec(true); -- public static final Codec CODEC_NONEMPTY = codec(false); -+ /** The vanilla codec that doesn't support custom Ingredient types. */ -+ public static final Codec VANILLA_CODEC = codec(true); -+ public static final com.mojang.serialization.MapCodec VANILLA_MAP_CODEC = com.mojang.serialization.MapCodec.assumeMapUnsafe(VANILLA_CODEC); -+ public static final Codec CODEC = net.minecraftforge.common.ForgeHooks.enhanceIngredientCodec(VANILLA_CODEC); -+ private static final Codec VANILLA_CODEC_NONEMPTY = codec(false); -+ public static final Codec CODEC_NONEMPTY = net.minecraftforge.common.ForgeHooks.enhanceIngredientCodec(VANILLA_CODEC_NONEMPTY); -+ private int invalidationCounter; + private List> items; - protected Ingredient(Stream p_43907_) { - this.values = p_43907_.toArray(Ingredient.Value[]::new); -@@ -48,7 +_,7 @@ - } - - public ItemStack[] getItems() { -- if (this.itemStacks == null) { -+ if (this.itemStacks == null || checkInvalidation()) { - this.itemStacks = Arrays.stream(this.values).flatMap(p_43916_ -> p_43916_.getItems().stream()).distinct().toArray(ItemStack[]::new); + protected Ingredient(HolderSet p_368516_) { ++ this(p_368516_, true); ++ } ++ ++ protected Ingredient(HolderSet p_368516_, boolean validate) { ++ if (validate) + p_368516_.unwrap().ifRight(p_359817_ -> { + if (p_359817_.isEmpty()) { + throw new UnsupportedOperationException("Ingredients can't be empty"); +@@ -112,5 +_,50 @@ + } else { + return slotdisplay; } - -@@ -72,7 +_,8 @@ - } - - public IntList getStackingIds() { -- if (this.stackingIds == null) { -+ if (this.stackingIds == null || checkInvalidation()) { -+ this.markValid(); - ItemStack[] aitemstack = this.getItems(); - this.stackingIds = new IntArrayList(aitemstack.length); - -@@ -120,6 +_,56 @@ - return fromValues(Stream.of(new Ingredient.TagValue(p_204133_))); - } - -+ public final boolean checkInvalidation() { -+ int currentInvalidationCounter = INVALIDATION_COUNTER.get(); -+ if (this.invalidationCounter != currentInvalidationCounter) { -+ invalidate(); -+ return true; -+ } -+ return false; -+ } -+ -+ protected final void markValid() { -+ this.invalidationCounter = INVALIDATION_COUNTER.get(); -+ } -+ -+ protected void invalidate() { -+ this.itemStacks = null; -+ this.stackingIds = null; + } + + public boolean isSimple() { @@ -80,43 +50,39 @@ + return isVanilla; + } + ++ public static final net.minecraftforge.common.crafting.ingredients.IIngredientSerializer VANILLA_SERIALIZER = ++ new net.minecraftforge.common.crafting.ingredients.IIngredientSerializer() { ++ @Override ++ public com.mojang.serialization.MapCodec codec() { ++ return VANILLA_MAP_CODEC; ++ } ++ ++ @Override ++ public void write(RegistryFriendlyByteBuf buffer, Ingredient value) { ++ VANILLA_CONTENTS_STREAM_CODEC.encode(buffer, value); ++ } ++ ++ @Override ++ public Ingredient read(RegistryFriendlyByteBuf buffer) { ++ return VANILLA_CONTENTS_STREAM_CODEC.decode(buffer); ++ } ++ }; ++ + public net.minecraftforge.common.crafting.ingredients.IIngredientSerializer serializer() { + if (!isVanilla()) throw new IllegalStateException("Modders must implement Ingredient.codec in their custom Ingredients: " + getClass()); -+ return net.minecraftforge.common.crafting.ingredients.IIngredientSerializer.VANILLA; ++ return VANILLA_SERIALIZER; + } + + @Override + public String toString() { + var buf = new StringBuilder(); + buf.append("Ingredient["); -+ for (int x = 0; x < values.length; x++) { ++ for (int x = 0; x < values.size(); x++) { + if (x != 0) + buf.append(", "); -+ if (values[x] instanceof TagValue tag) -+ buf.append('#').append(tag.tag().location()); -+ else if (values[x] instanceof ItemValue item) -+ buf.append(item.item()); -+ else -+ buf.append(values[x]); ++ buf.append(values.get(x)); + } + buf.append(']'); + return buf.toString(); -+ } -+ - private static Codec codec(boolean p_298496_) { - Codec codec = Codec.list(Ingredient.Value.CODEC) - .comapFlatMap( -@@ -182,6 +_,13 @@ - - for (Holder holder : BuiltInRegistries.ITEM.getTagOrEmpty(this.tag)) { - list.add(new ItemStack(holder)); -+ } -+ -+ if (list.size() == 0) { -+ var marker = new ItemStack(net.minecraft.world.level.block.Blocks.BARRIER); -+ marker.set(net.minecraft.core.component.DataComponents.CUSTOM_NAME, -+ net.minecraft.network.chat.Component.literal("Empty Tag: " + this.tag.location())); -+ list.add(marker); - } - - return list; + } + } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/Recipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/Recipe.java.patch deleted file mode 100644 index 8865bea2c7..0000000000 --- a/patches/minecraft/net/minecraft/world/item/crafting/Recipe.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/world/item/crafting/Recipe.java -+++ b/net/minecraft/world/item/crafting/Recipe.java -@@ -30,9 +_,9 @@ - NonNullList nonnulllist = NonNullList.withSize(p_344178_.size(), ItemStack.EMPTY); - - for (int i = 0; i < nonnulllist.size(); i++) { -- Item item = p_344178_.getItem(i).getItem(); -+ ItemStack item = p_344178_.getItem(i); - if (item.hasCraftingRemainingItem()) { -- nonnulllist.set(i, new ItemStack(item.getCraftingRemainingItem())); -+ nonnulllist.set(i, item.getCraftingRemainingItem()); - } - } - -@@ -65,6 +_,6 @@ - - default boolean isIncomplete() { - NonNullList nonnulllist = this.getIngredients(); -- return nonnulllist.isEmpty() || nonnulllist.stream().anyMatch(p_151268_ -> p_151268_.getItems().length == 0); -+ return nonnulllist.isEmpty() || nonnulllist.stream().anyMatch(net.minecraftforge.common.ForgeHooks::hasNoElements); - } - } 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 6f8152b7aa..f4911a4ec4 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/crafting/RecipeManager.java +++ b/net/minecraft/world/item/crafting/RecipeManager.java -@@ -40,22 +_,35 @@ - private Multimap, RecipeHolder> byType = ImmutableMultimap.of(); - private Map> byName = ImmutableMap.of(); - private boolean hasErrors; +@@ -61,15 +_,24 @@ + private SelectableRecipe.SingleInputSet stonecutterRecipes = SelectableRecipe.SingleInputSet.empty(); + private List allDisplays = List.of(); + private Map>, List> recipeToDisplay = Map.of(); + private final net.minecraftforge.common.crafting.conditions.ICondition.IContext context; //Forge: add context + /** @deprecated Forge: use {@linkplain RecipeManager#RecipeManager(net.minecraftforge.common.crafting.conditions.ICondition.IContext) constructor with context}. */ @@ -12,28 +12,25 @@ + } + + public RecipeManager(HolderLookup.Provider p_330459_, net.minecraftforge.common.crafting.conditions.ICondition.IContext context) { - super(GSON, Registries.elementsDirPath(Registries.RECIPE)); this.registries = p_330459_; + this.context = context; } - protected void apply(Map p_44037_, ResourceManager p_44038_, ProfilerFiller p_44039_) { - this.hasErrors = false; - Builder, RecipeHolder> builder = ImmutableMultimap.builder(); - com.google.common.collect.ImmutableMap.Builder> builder1 = ImmutableMap.builder(); -- RegistryOps registryops = this.registries.createSerializationContext(JsonOps.INSTANCE); -+ RegistryOps registryops = this.registries.createSerializationContext(JsonOps.INSTANCE) -+ .withContext(net.minecraftforge.common.crafting.conditions.ICondition.IContext.KEY, this.context); + protected RecipeMap prepare(ResourceManager p_368640_, ProfilerFiller p_361102_) { + SortedMap> sortedmap = new TreeMap<>(); + SimpleJsonResourceReloadListener.scanDirectory( +- p_368640_, Registries.elementsDirPath(Registries.RECIPE), this.registries.createSerializationContext(JsonOps.INSTANCE), Recipe.CODEC, sortedmap ++ p_368640_, Registries.elementsDirPath(Registries.RECIPE), this.registries.createSerializationContext(JsonOps.INSTANCE) ++ .withContext(net.minecraftforge.common.crafting.conditions.ICondition.IContext.KEY, this.context), ++ Recipe.CODEC, sortedmap + ); + List> list = new ArrayList<>(sortedmap.size()); + sortedmap.forEach((p_359835_, p_359836_) -> { +@@ -86,6 +_,7 @@ + } - for (Entry entry : p_44037_.entrySet()) { - ResourceLocation resourcelocation = entry.getKey(); -+ if (resourcelocation.getPath().startsWith("_")) continue; //Forge: filter anything beginning with "_" as it's used for metadata. - - try { -+ if (entry.getValue().isJsonObject() && !net.minecraftforge.common.ForgeHooks.readAndTestCondition(registryops, entry.getValue().getAsJsonObject())) { -+ LOGGER.debug("Skipping loading recipe {} as it's conditions were not met", resourcelocation); -+ continue; -+ } - Recipe recipe = Recipe.CODEC.parse(registryops, entry.getValue()).getOrThrow(JsonParseException::new); - RecipeHolder recipeholder = new RecipeHolder<>(resourcelocation, recipe); - builder.put(recipe.getType(), recipeholder); + public void finalizeRecipeLoading(FeatureFlagSet p_360842_) { ++ //net.minecraftforge.event.ForgeEventFactory.onTagsUpdated(this.registries, false, false); + List> list = new ArrayList<>(); + List list1 = RECIPE_PROPERTY_SETS.entrySet() + .stream() 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 50ef9bc915..e6ce51556a 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/crafting/ShapedRecipe.java +++ b/net/minecraft/world/item/crafting/ShapedRecipe.java -@@ -11,7 +_,19 @@ - import net.minecraft.world.item.ItemStack; +@@ -18,7 +_,19 @@ + import net.minecraft.world.item.crafting.display.SlotDisplay; import net.minecraft.world.level.Level; -public class ShapedRecipe implements CraftingRecipe { @@ -21,10 +21,13 @@ final ShapedRecipePattern pattern; final ItemStack result; final String group; -@@ -82,9 +_,19 @@ - } +@@ -66,6 +_,16 @@ + } - @Override + return this.placementInfo; ++ } ++ ++ @Override + public int getRecipeWidth() { + return getWidth(); + } @@ -32,13 +35,6 @@ + @Override + public int getRecipeHeight() { + return getHeight(); -+ } -+ -+ @Override - public boolean isIncomplete() { - NonNullList nonnulllist = this.getIngredients(); -- return nonnulllist.isEmpty() || nonnulllist.stream().filter(p_151277_ -> !p_151277_.isEmpty()).anyMatch(p_151273_ -> p_151273_.getItems().length == 0); -+ return nonnulllist.isEmpty() || nonnulllist.stream().filter(p_151277_ -> !p_151277_.isEmpty()).anyMatch(net.minecraftforge.common.ForgeHooks::hasNoElements); } - public static class Serializer implements RecipeSerializer { + @Override diff --git a/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipePattern.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipePattern.java.patch index b894fe7240..9d5d1bcc46 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipePattern.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipePattern.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/ShapedRecipePattern.java +++ b/net/minecraft/world/item/crafting/ShapedRecipePattern.java -@@ -212,18 +_,22 @@ +@@ -204,18 +_,22 @@ return this.ingredients; } 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 afe043f6ba..987c8e6bf2 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,21 @@ --- a/net/minecraft/world/item/crafting/ShapelessRecipe.java +++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java -@@ -18,12 +_,14 @@ - final CraftingBookCategory category; - final ItemStack result; - final NonNullList ingredients; +@@ -24,12 +_,14 @@ + final List ingredients; + @Nullable + private PlacementInfo placementInfo; + private final boolean isSimple; - public ShapelessRecipe(String p_249640_, CraftingBookCategory p_249390_, ItemStack p_252071_, NonNullList p_250689_) { + public ShapelessRecipe(String p_249640_, CraftingBookCategory p_249390_, ItemStack p_252071_, List p_365863_) { this.group = p_249640_; this.category = p_249390_; this.result = p_252071_; - this.ingredients = p_250689_; -+ this.isSimple = p_250689_.stream().allMatch(Ingredient::isSimple); + this.ingredients = p_365863_; ++ this.isSimple = this.ingredients.stream().allMatch(Ingredient::isSimple); } @Override -@@ -54,10 +_,12 @@ +@@ -59,10 +_,12 @@ public boolean matches(CraftingInput p_345423_, Level p_44263_) { if (p_345423_.ingredientCount() != this.ingredients.size()) { return false; @@ -31,12 +31,12 @@ } } -@@ -85,7 +_,7 @@ - if (aingredient.length == 0) { - return DataResult.error(() -> "No ingredients for shapeless recipe"); - } else { -- return aingredient.length > 9 -+ return aingredient.length > ShapedRecipe.MAX_WIDTH * ShapedRecipe.MAX_HEIGHT - ? DataResult.error(() -> "Too many ingredients for shapeless recipe") - : DataResult.success(NonNullList.of(Ingredient.EMPTY, aingredient)); - } +@@ -87,7 +_,7 @@ + Codec.STRING.optionalFieldOf("group", "").forGetter(p_299460_ -> p_299460_.group), + CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(p_297437_ -> p_297437_.category), + ItemStack.STRICT_CODEC.fieldOf("result").forGetter(p_300770_ -> p_300770_.result), +- Ingredient.CODEC.listOf(1, 9).fieldOf("ingredients").forGetter(p_359857_ -> p_359857_.ingredients) ++ Ingredient.CODEC.listOf(/*1, 9 Forge: Make this usable for larger crafting windows*/).fieldOf("ingredients").forGetter(p_359857_ -> p_359857_.ingredients) + ) + .apply(p_359856_, ShapelessRecipe::new) + ); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch deleted file mode 100644 index c7fc575b40..0000000000 --- a/patches/minecraft/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/net/minecraft/world/item/crafting/ShulkerBoxColoring.java -+++ b/net/minecraft/world/item/crafting/ShulkerBoxColoring.java -@@ -24,7 +_,7 @@ - if (Block.byItem(itemstack.getItem()) instanceof ShulkerBoxBlock) { - i++; - } else { -- if (!(itemstack.getItem() instanceof DyeItem)) { -+ if (!itemstack.is(net.minecraftforge.common.Tags.Items.DYES)) { - return false; - } - -@@ -42,7 +_,7 @@ - - public ItemStack assemble(CraftingInput p_343576_, HolderLookup.Provider p_336251_) { - ItemStack itemstack = ItemStack.EMPTY; -- DyeItem dyeitem = (DyeItem)Items.WHITE_DYE; -+ var dyecolor = net.minecraft.world.item.DyeColor.WHITE; - - for (int i = 0; i < p_343576_.size(); i++) { - ItemStack itemstack1 = p_343576_.getItem(i); -@@ -51,12 +_,15 @@ - if (Block.byItem(item) instanceof ShulkerBoxBlock) { - itemstack = itemstack1; - } else if (item instanceof DyeItem) { -- dyeitem = (DyeItem)item; -+ var tmp = net.minecraft.world.item.DyeColor.getColor(itemstack1); -+ if (tmp != null) { -+ dyecolor = tmp; -+ } - } - } - } - -- Block block = ShulkerBoxBlock.getBlockByColor(dyeitem.getDyeColor()); -+ Block block = ShulkerBoxBlock.getBlockByColor(dyecolor); - return itemstack.transmuteCopy(block, 1); - } - diff --git a/patches/minecraft/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch deleted file mode 100644 index d883180d56..0000000000 --- a/patches/minecraft/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java -+++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java -@@ -60,7 +_,7 @@ - - @Override - public boolean isIncomplete() { -- return Stream.of(this.template, this.base, this.addition).anyMatch(Ingredient::isEmpty); -+ return Stream.of(this.template, this.base, this.addition).anyMatch(net.minecraftforge.common.ForgeHooks::hasNoElements); - } - - public static class Serializer implements RecipeSerializer { diff --git a/patches/minecraft/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch deleted file mode 100644 index 8dff334147..0000000000 --- a/patches/minecraft/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -+++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -@@ -89,7 +_,7 @@ - - @Override - public boolean isIncomplete() { -- return Stream.of(this.template, this.base, this.addition).anyMatch(Ingredient::isEmpty); -+ return Stream.of(this.template, this.base, this.addition).anyMatch(net.minecraftforge.common.ForgeHooks::hasNoElements); - } - - public static class Serializer implements RecipeSerializer { 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 2d6839caaa..d82727647d 100644 --- a/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch +++ b/patches/minecraft/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch @@ -1,24 +1,6 @@ --- a/net/minecraft/world/item/enchantment/EnchantmentHelper.java +++ b/net/minecraft/world/item/enchantment/EnchantmentHelper.java -@@ -462,7 +_,7 @@ - - public static int getEnchantmentCost(RandomSource p_220288_, int p_220289_, int p_220290_, ItemStack p_220291_) { - Item item = p_220291_.getItem(); -- int i = item.getEnchantmentValue(); -+ int i = p_220291_.getEnchantmentValue(); - if (i <= 0) { - return 0; - } else { -@@ -507,7 +_,7 @@ - public static List selectEnchantment(RandomSource p_220298_, ItemStack p_220299_, int p_220300_, Stream> p_342119_) { - List list = Lists.newArrayList(); - Item item = p_220299_.getItem(); -- int i = item.getEnchantmentValue(); -+ int i = p_220299_.getEnchantmentValue(); - if (i <= 0) { - return list; - } else { -@@ -553,7 +_,7 @@ +@@ -572,7 +_,7 @@ public static List getAvailableEnchantmentResults(int p_44818_, ItemStack p_44819_, Stream> p_342857_) { List list = Lists.newArrayList(); boolean flag = p_44819_.is(Items.BOOK); diff --git a/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch index efdfa56c0e..d764b19c6c 100644 --- a/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch @@ -4,18 +4,18 @@ entity.moveTo(entity.getX(), entity.getY(), entity.getZ(), randomsource.nextFloat() * 360.0F, 0.0F); if (entity instanceof Mob mob) { -- if (spawndata.getCustomSpawnRules().isEmpty() && !mob.checkSpawnRules(p_151312_, MobSpawnType.SPAWNER) || !mob.checkSpawnObstruction(p_151312_)) { -+ if (!net.minecraftforge.event.ForgeEventFactory.checkSpawnPositionSpawner(mob, p_151312_, MobSpawnType.SPAWNER, spawndata, this)) { +- if (spawndata.getCustomSpawnRules().isEmpty() && !mob.checkSpawnRules(p_151312_, EntitySpawnReason.SPAWNER) || !mob.checkSpawnObstruction(p_151312_)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.checkSpawnPositionSpawner(mob, p_151312_, EntitySpawnReason.SPAWNER, spawndata, this)) { continue; } boolean flag1 = spawndata.getEntityToSpawn().size() == 1 && spawndata.getEntityToSpawn().contains("id", 8); - if (flag1) { -- ((Mob)entity).finalizeSpawn(p_151312_, p_151312_.getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.SPAWNER, null); +- ((Mob)entity).finalizeSpawn(p_151312_, p_151312_.getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.SPAWNER, null); + // Forge: Patch in FinalizeSpawn for spawners so it may be fired unconditionally, instead of only when vanilla normally would trigger it. + var event = net.minecraftforge.event.ForgeEventFactory.onFinalizeSpawnSpawner(mob, p_151312_, p_151312_.getCurrentDifficultyAt(entity.blockPosition()), null, compoundtag, this); + if (!event.isCanceled() && flag1) { -+ ((Mob)entity).finalizeSpawn(p_151312_, event.getDifficulty(), MobSpawnType.SPAWNER, null); ++ ((Mob)entity).finalizeSpawn(p_151312_, event.getDifficulty(), EntitySpawnReason.SPAWNER, null); } spawndata.getEquipment().ifPresent(mob::equip); diff --git a/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch b/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch index 068f4f7cb2..bf152c3be5 100644 --- a/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch +++ b/patches/minecraft/net/minecraft/world/level/BlockGetter.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/BlockGetter.java +++ b/net/minecraft/world/level/BlockGetter.java -@@ -18,7 +_,7 @@ +@@ -20,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; -public interface BlockGetter extends LevelHeightAccessor { +public interface BlockGetter extends LevelHeightAccessor, net.minecraftforge.common.extensions.IForgeBlockGetter { - @Nullable - BlockEntity getBlockEntity(BlockPos p_45570_); + int MAX_BLOCK_ITERATIONS_ALONG_TRAVEL = 16; -@@ -32,7 +_,7 @@ + @Nullable +@@ -36,7 +_,7 @@ FluidState getFluidState(BlockPos p_45569_); default int getLightEmission(BlockPos p_45572_) { @@ -17,4 +17,4 @@ + return this.getBlockState(p_45572_).getLightEmission(this, p_45572_); } - default int getMaxLightLevel() { + default Stream getBlockStates(AABB p_45557_) { diff --git a/patches/minecraft/net/minecraft/world/level/Explosion.java.patch b/patches/minecraft/net/minecraft/world/level/Explosion.java.patch deleted file mode 100644 index 13bbb8d724..0000000000 --- a/patches/minecraft/net/minecraft/world/level/Explosion.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/world/level/Explosion.java -+++ b/net/minecraft/world/level/Explosion.java -@@ -257,6 +_,7 @@ - int j2 = Mth.floor(this.z - (double)f2 - 1.0); - int j1 = Mth.floor(this.z + (double)f2 + 1.0); - List list = this.level.getEntities(this.source, new AABB((double)k1, (double)i2, (double)j2, (double)l1, (double)i1, (double)j1)); -+ net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.level, this, list, f2); - Vec3 vec3 = new Vec3(this.x, this.y, this.z); - - for (Entity entity : list) { diff --git a/patches/minecraft/net/minecraft/world/level/Level.java.patch b/patches/minecraft/net/minecraft/world/level/Level.java.patch index 2b94ad2f90..2b967f294a 100644 --- a/patches/minecraft/net/minecraft/world/level/Level.java.patch +++ b/patches/minecraft/net/minecraft/world/level/Level.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -76,7 +_,7 @@ +@@ -78,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.scores.Scoreboard; @@ -9,7 +9,7 @@ public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("overworld")); public static final ResourceKey NETHER = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("the_nether")); -@@ -114,6 +_,11 @@ +@@ -115,6 +_,11 @@ private final RegistryAccess registryAccess; private final DamageSources damageSources; private long subTickCount; @@ -26,10 +26,10 @@ int p_270466_ ) { + super(Level.class); - this.profiler = p_270692_; this.levelData = p_270739_; this.dimensionTypeRegistration = p_270240_; -@@ -216,11 +_,39 @@ + final DimensionType dimensiontype = p_270240_.value(); +@@ -215,11 +_,35 @@ } else { LevelChunk levelchunk = this.getChunkAt(p_46605_); Block block = p_46606_.getBlock(); @@ -40,10 +40,6 @@ + blockSnapshot = net.minecraftforge.common.util.BlockSnapshot.create(this.dimension, this, p_46605_, p_46607_); + this.capturedBlockSnapshots.add(blockSnapshot); + } -+ -+ BlockState old = getBlockState(p_46605_); -+ int oldLight = old.getLightEmission(this, p_46605_); -+ int oldOpacity = old.getLightBlock(this, p_46605_); + BlockState blockstate = levelchunk.setBlockState(p_46605_, p_46606_, (p_46607_ & 64) != 0); if (blockstate == null) { @@ -69,7 +65,7 @@ if (blockstate1 == p_46606_) { if (blockstate != blockstate1) { this.setBlocksDirty(p_46605_, blockstate, blockstate1); -@@ -247,9 +_,8 @@ +@@ -246,9 +_,8 @@ } this.onBlockStateChange(p_46605_, blockstate, blockstate1); @@ -80,15 +76,7 @@ } } } -@@ -301,6 +_,7 @@ - } - - public void updateNeighborsAt(BlockPos p_46673_, Block p_46674_) { -+ net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(this, p_46673_, this.getBlockState(p_46673_), java.util.EnumSet.allOf(Direction.class), false).isCanceled(); - } - - public void updateNeighborsAtExceptFromFacing(BlockPos p_46591_, Block p_46592_, Direction p_46593_) { -@@ -488,10 +_,30 @@ +@@ -490,10 +_,30 @@ (this.tickingBlockEntities ? this.pendingBlockEntityTickers : this.blockEntityTickers).add(p_151526_); } @@ -101,7 +89,7 @@ + } + protected void tickBlockEntities() { - ProfilerFiller profilerfiller = this.getProfiler(); + ProfilerFiller profilerfiller = Profiler.get(); profilerfiller.push("blockEntities"); + + if (!this.pendingFreshBlockEntities.isEmpty()) { @@ -119,7 +107,7 @@ if (!this.pendingBlockEntityTickers.isEmpty()) { this.blockEntityTickers.addAll(this.pendingBlockEntityTickers); this.pendingBlockEntityTickers.clear(); -@@ -515,12 +_,19 @@ +@@ -517,12 +_,19 @@ public void guardEntityTick(Consumer p_46654_, T p_46655_) { try { @@ -139,26 +127,7 @@ } } -@@ -669,7 +_,7 @@ - Explosion.BlockInteraction explosion$blockinteraction = switch (p_310628_) { - case NONE -> Explosion.BlockInteraction.KEEP; - case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); -- case MOB -> this.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? this.getDestroyType(GameRules.RULE_MOB_EXPLOSION_DROP_DECAY) : Explosion.BlockInteraction.KEEP; -+ case MOB -> net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this, p_312521_) ? this.getDestroyType(GameRules.RULE_MOB_EXPLOSION_DROP_DECAY) : Explosion.BlockInteraction.KEEP; - case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY); - case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK; - }; -@@ -688,6 +_,9 @@ - p_311434_, - p_328498_ - ); -+ if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this, explosion)) { -+ return explosion; -+ } - explosion.explode(); - explosion.finalizeExplosion(p_309655_); - return explosion; -@@ -722,6 +_,7 @@ +@@ -674,6 +_,7 @@ if (!this.isOutsideBuildHeight(p_46748_)) { this.getChunkAt(p_46748_).removeBlockEntity(p_46748_); } @@ -166,7 +135,7 @@ } public boolean isLoaded(BlockPos p_46750_) { -@@ -798,8 +_,8 @@ +@@ -750,8 +_,8 @@ list.add(p_151522_); } @@ -177,7 +146,7 @@ if (p_151522_ != p_46536_ && p_46538_.test(enderdragonpart)) { list.add(enderdragonpart); } -@@ -832,8 +_,8 @@ +@@ -784,8 +_,8 @@ } } @@ -188,17 +157,17 @@ T t = p_261885_.tryCast(enderdragonpart); if (t != null && p_261688_.test(t)) { p_262071_.add(t); -@@ -972,16 +_,15 @@ +@@ -919,16 +_,15 @@ public abstract Scoreboard getScoreboard(); public void updateNeighbourForOutputSignal(BlockPos p_46718_, Block p_46719_) { - for (Direction direction : Direction.Plane.HORIZONTAL) { -+ for (Direction direction : Direction.values()) { ++ for (Direction direction : Direction.valuesView()) { BlockPos blockpos = p_46718_.relative(direction); if (this.hasChunkAt(blockpos)) { BlockState blockstate = this.getBlockState(blockpos); - if (blockstate.is(Blocks.COMPARATOR)) { -- this.neighborChanged(blockstate, blockpos, p_46719_, p_46718_, false); +- this.neighborChanged(blockstate, blockpos, p_46719_, null, false); - } else if (blockstate.isRedstoneConductor(this, blockpos)) { + blockstate.onNeighborChange(this, blockpos, p_46718_); + if (blockstate.isRedstoneConductor(this, blockpos)) { @@ -206,10 +175,10 @@ blockstate = this.getBlockState(blockpos); - if (blockstate.is(Blocks.COMPARATOR)) { + if (blockstate.getWeakChanges(this, blockpos)) { - this.neighborChanged(blockstate, blockpos, p_46719_, p_46718_, false); + this.neighborChanged(blockstate, blockpos, p_46719_, null, false); } } -@@ -1092,6 +_,20 @@ +@@ -1031,6 +_,20 @@ } public abstract PotionBrewing potionBrewing(); @@ -228,5 +197,5 @@ + return maxEntityRadius; + } - public static enum ExplosionInteraction implements StringRepresentable { - NONE("none"), + public abstract FuelValues fuelValues(); + diff --git a/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch b/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch index 75a28d7697..41e703c8f1 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 -@@ -173,6 +_,12 @@ +@@ -172,6 +_,12 @@ : 15; } diff --git a/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch b/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch index df2acb0360..f72cea454c 100644 --- a/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/LevelSettings.java.patch @@ -31,14 +31,14 @@ @@ -33,7 +_,8 @@ p_46925_.get("Difficulty").asNumber().map(p_46928_ -> Difficulty.byId(p_46928_.byteValue())).result().orElse(Difficulty.NORMAL), p_46925_.get("allowCommands").asBoolean(gametype == GameType.CREATIVE), - new GameRules(p_46925_.get("GameRules")), + new GameRules(p_251697_.enabledFeatures(), p_46925_.get("GameRules")), - p_251697_ + p_251697_, + net.minecraftforge.common.ForgeHooks.parseLifecycle(p_46925_.get("forgeLifecycle").asString("stable")) ); } -@@ -66,18 +_,26 @@ +@@ -66,20 +_,28 @@ } public LevelSettings withGameType(GameType p_46923_) { @@ -57,8 +57,10 @@ } public LevelSettings copy() { -- return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules.copy(), this.dataConfiguration); -+ return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules.copy(), this.dataConfiguration, this.lifecycle); + return new LevelSettings( +- this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules.copy(this.dataConfiguration.enabledFeatures()), this.dataConfiguration ++ this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules.copy(this.dataConfiguration.enabledFeatures()), this.dataConfiguration, this.lifecycle + ); + } + + public LevelSettings withLifecycle(com.mojang.serialization.Lifecycle lifecycle) { diff --git a/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch index e4d352c355..bee00b1db2 100644 --- a/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -67,7 +_,7 @@ +@@ -71,7 +_,7 @@ continue; } @@ -9,7 +9,7 @@ if (mobcategory != MobCategory.MISC) { BlockPos blockpos = entity.blockPosition(); p_186527_.query(ChunkPos.asLong(blockpos), p_275163_ -> { -@@ -187,7 +_,7 @@ +@@ -202,7 +_,7 @@ l1++; p_47040_.addFreshEntityWithPassengers(mob); p_47044_.run(mob, p_47041_); @@ -18,16 +18,16 @@ return; } -@@ -260,7 +_,7 @@ +@@ -275,7 +_,7 @@ private static boolean isValidPositionForMob(ServerLevel p_46992_, Mob p_46993_, double p_46994_) { return p_46994_ > (double)(p_46993_.getType().getCategory().getDespawnDistance() * p_46993_.getType().getCategory().getDespawnDistance()) && p_46993_.removeWhenFarAway(p_46994_) ? false -- : p_46993_.checkSpawnRules(p_46992_, MobSpawnType.NATURAL) && p_46993_.checkSpawnObstruction(p_46992_); -+ : net.minecraftforge.event.ForgeEventFactory.checkSpawnPosition(p_46993_, p_46992_, MobSpawnType.NATURAL); +- : p_46993_.checkSpawnRules(p_46992_, EntitySpawnReason.NATURAL) && p_46993_.checkSpawnObstruction(p_46992_); ++ : net.minecraftforge.event.ForgeEventFactory.checkSpawnPosition(p_46993_, p_46992_, EntitySpawnReason.NATURAL); } private static Optional getRandomSpawnMobAt( -@@ -291,9 +_,13 @@ +@@ -306,9 +_,13 @@ BlockPos p_220448_, @Nullable Holder p_220449_ ) { @@ -37,23 +37,23 @@ + // Forge: Add in potential spawns, and replace hardcoded nether fortress mob list + return net.minecraftforge.event.ForgeEventFactory.getPotentialSpawns(p_220444_, p_220447_, p_220448_, + isInNetherFortressBounds(p_220448_, p_220444_, p_220447_, p_220445_) -+ ? p_220445_.registryAccess().registryOrThrow(Registries.STRUCTURE).getOrThrow(BuiltinStructures.FORTRESS) -+ .spawnOverrides().get(MobCategory.MONSTER).spawns() ++ ? p_220445_.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(BuiltinStructures.FORTRESS) ++ .get().spawnOverrides().get(MobCategory.MONSTER).spawns() + : p_220446_.getMobsAt(p_220449_ != null ? p_220449_ : p_220444_.getBiome(p_220448_), p_220445_, p_220447_, p_220448_) + ); } public static boolean isInNetherFortressBounds(BlockPos p_220456_, ServerLevel p_220457_, MobCategory p_220458_, StructureManager p_220459_) { -@@ -379,7 +_,7 @@ +@@ -394,7 +_,7 @@ } entity.moveTo(d0, (double)blockpos.getY(), d1, p_220454_.nextFloat() * 360.0F, 0.0F); -- if (entity instanceof Mob mob && mob.checkSpawnRules(p_220451_, MobSpawnType.CHUNK_GENERATION) && mob.checkSpawnObstruction(p_220451_)) { -+ if (entity instanceof Mob mob && net.minecraftforge.event.ForgeEventFactory.checkSpawnPosition(mob, p_220451_, MobSpawnType.CHUNK_GENERATION)) { - spawngroupdata = mob.finalizeSpawn(p_220451_, p_220451_.getCurrentDifficultyAt(mob.blockPosition()), MobSpawnType.CHUNK_GENERATION, spawngroupdata); - p_220451_.addFreshEntityWithPassengers(mob); - flag = true; -@@ -483,7 +_,7 @@ +- if (entity instanceof Mob mob && mob.checkSpawnRules(p_220451_, EntitySpawnReason.CHUNK_GENERATION) && mob.checkSpawnObstruction(p_220451_)) { ++ if (entity instanceof Mob mob && net.minecraftforge.event.ForgeEventFactory.checkSpawnPosition(mob, p_220451_, EntitySpawnReason.CHUNK_GENERATION)) { + spawngroupdata = mob.finalizeSpawn( + p_220451_, p_220451_.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CHUNK_GENERATION, spawngroupdata + ); +@@ -500,7 +_,7 @@ } this.spawnPotential.addCharge(blockpos, d0); diff --git a/patches/minecraft/net/minecraft/world/level/ServerExplosion.java.patch b/patches/minecraft/net/minecraft/world/level/ServerExplosion.java.patch new file mode 100644 index 0000000000..b4b9d38fc3 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/ServerExplosion.java.patch @@ -0,0 +1,31 @@ +--- a/net/minecraft/world/level/ServerExplosion.java ++++ b/net/minecraft/world/level/ServerExplosion.java +@@ -167,7 +_,7 @@ + return new ObjectArrayList<>(set); + } + +- private void hurtEntities() { ++ private void hurtEntities(List blocks) { + float f = this.radius * 2.0F; + int i = Mth.floor(this.center.x - (double)f - 1.0); + int j = Mth.floor(this.center.x + (double)f + 1.0); +@@ -176,7 +_,9 @@ + int i1 = Mth.floor(this.center.z - (double)f - 1.0); + int j1 = Mth.floor(this.center.z + (double)f + 1.0); + +- for (Entity entity : this.level.getEntities(this.source, new AABB((double)i, (double)k, (double)i1, (double)j, (double)l, (double)j1))) { ++ var entities = this.level.getEntities(this.source, new AABB((double)i, (double)k, (double)i1, (double)j, (double)l, (double)j1)); ++ net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.level, this, blocks, entities, f); ++ for (Entity entity : entities) { + if (!entity.ignoreExplosion(this)) { + double d0 = Math.sqrt(entity.distanceToSqr(this.center)) / (double)f; + if (d0 <= 1.0) { +@@ -248,7 +_,7 @@ + public void explode() { + this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center); + List list = this.calculateExplodedPositions(); +- this.hurtEntities(); ++ this.hurtEntities(list); + if (this.interactsWithBlocks()) { + ProfilerFiller profilerfiller = Profiler.get(); + profilerfiller.push("explosion_blocks"); diff --git a/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch b/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch index 38428c9d93..59b415f331 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch @@ -46,7 +46,7 @@ } public boolean hasPrecipitation() { -@@ -189,7 +_,7 @@ +@@ -186,7 +_,7 @@ } public BiomeGenerationSettings getGenerationSettings() { @@ -55,7 +55,7 @@ } public int getFogColor() { -@@ -251,6 +_,31 @@ +@@ -248,6 +_,31 @@ public Optional getBackgroundMusic() { return this.specialEffects.getBackgroundMusic(); 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 6d5908f541..3a0ab5621a 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch @@ -1,29 +1,32 @@ --- a/net/minecraft/world/level/biome/BiomeGenerationSettings.java +++ b/net/minecraft/world/level/biome/BiomeGenerationSettings.java -@@ -50,6 +_,7 @@ - .apply(p_186655_, BiomeGenerationSettings::new) - ); - private final Map>> carvers; -+ private final java.util.Set carversView; - private final List> features; - private final Supplier>> flowerFeatures; - private final Supplier> featureSet; -@@ -66,6 +_,7 @@ - .collect(ImmutableList.toImmutableList()) - ); - this.featureSet = Suppliers.memoize(() -> p_186651_.stream().flatMap(HolderSet::stream).map(Holder::value).collect(Collectors.toSet())); -+ this.carversView = java.util.Collections.unmodifiableSet(carvers.keySet()); - } +@@ -99,6 +_,17 @@ + protected final List>> carvers = new ArrayList<>(); + protected final List>> features = new ArrayList<>(); - public Iterable>> getCarvers(GenerationStep.Carving p_204188_) { -@@ -82,6 +_,10 @@ - - public boolean hasFeature(PlacedFeature p_186659_) { - return this.featureSet.get().contains(p_186659_); -+ } ++ public BiomeGenerationSettings.PlainBuilder addFrom(BiomeGenerationSettings other) { ++ for (var carver : other.getCarvers()) ++ addCarver(carver); ++ var stages = other.features(); ++ for (int x = 0; x < stages.size(); x++) { ++ for (var feature : stages.get(x)) ++ addFeature(x, feature); ++ } ++ return this; ++ } + -+ public java.util.Set getCarvingStages() { -+ return this.carversView; - } + public BiomeGenerationSettings.PlainBuilder addFeature(GenerationStep.Decoration p_256360_, Holder p_256577_) { + return this.addFeature(p_256360_.ordinal(), p_256577_); + } +@@ -107,6 +_,11 @@ + this.addFeatureStepsUpTo(p_256305_); + this.features.get(p_256305_).add(p_255636_); + return this; ++ } ++ ++ public List> getFeatures(GenerationStep.Decoration stage) { ++ this.addFeatureStepsUpTo(stage.ordinal()); ++ return this.features.get(stage.ordinal()); + } - public static class Builder extends BiomeGenerationSettings.PlainBuilder { + public BiomeGenerationSettings.PlainBuilder addCarver(Holder> p_256082_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/BambooSaplingBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BambooSaplingBlock.java.patch index 7b2087683b..c2be990066 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BambooSaplingBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BambooSaplingBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BambooSaplingBlock.java +++ b/net/minecraft/world/level/block/BambooSaplingBlock.java -@@ -88,7 +_,7 @@ +@@ -95,7 +_,7 @@ @Override protected float getDestroyProgress(BlockState p_48981_, Player p_48982_, BlockGetter p_48983_, BlockPos p_48984_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/BambooStalkBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BambooStalkBlock.java.patch index d5daf07dae..7f5e4b451e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BambooStalkBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BambooStalkBlock.java.patch @@ -24,7 +24,7 @@ } } } -@@ -193,7 +_,7 @@ +@@ -198,7 +_,7 @@ @Override protected float getDestroyProgress(BlockState p_261691_, Player p_262171_, BlockGetter p_261621_, BlockPos p_261500_) { @@ -33,7 +33,7 @@ } protected void growBamboo(BlockState p_261855_, Level p_262076_, BlockPos p_262109_, RandomSource p_261633_, int p_261759_) { -@@ -240,5 +_,11 @@ +@@ -245,5 +_,11 @@ } return i; diff --git a/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch index 9dc40ef6dd..9752527feb 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/BaseFireBlock.java +++ b/net/minecraft/world/level/block/BaseFireBlock.java -@@ -141,6 +_,7 @@ +@@ -150,6 +_,7 @@ if (!p_49282_.is(p_49279_.getBlock())) { if (inPortalDimension(p_49280_)) { Optional optional = PortalShape.findEmptyPortalShape(p_49280_, p_49281_, Direction.Axis.X); + optional = net.minecraftforge.event.ForgeEventFactory.onTrySpawnPortal(p_49280_, p_49281_, optional); if (optional.isPresent()) { - optional.get().createPortalBlocks(); + optional.get().createPortalBlocks(p_49280_); return; -@@ -183,7 +_,7 @@ +@@ -192,7 +_,7 @@ boolean flag = false; for (Direction direction : Direction.values()) { diff --git a/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch index 0b211d3e56..24d89e2c7e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BaseRailBlock.java +++ b/net/minecraft/world/level/block/BaseRailBlock.java -@@ -20,7 +_,7 @@ +@@ -23,7 +_,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; @@ -9,33 +9,25 @@ protected static final VoxelShape FLAT_AABB = Block.box(0.0, 0.0, 0.0, 16.0, 2.0, 16.0); protected static final VoxelShape HALF_BLOCK_AABB = Block.box(0.0, 0.0, 0.0, 16.0, 8.0, 16.0); public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; -@@ -49,6 +_,7 @@ +@@ -79,7 +_,7 @@ @Override - protected VoxelShape getShape(BlockState p_49403_, BlockGetter p_49404_, BlockPos p_49405_, CollisionContext p_49406_) { - RailShape railshape = p_49403_.is(this) ? p_49403_.getValue(this.getShapeProperty()) : null; -+ //RailShape railShape2 = p_49403_.is(this) ? getRailDirection(p_49403_, p_49404_, p_49405_, null) : null; // seems unused in old patch, should it be wired up or removed? -Paint_Ninja - return railshape != null && railshape.isAscending() ? HALF_BLOCK_AABB : FLAT_AABB; - } - -@@ -76,7 +_,7 @@ - @Override - protected void neighborChanged(BlockState p_49377_, Level p_49378_, BlockPos p_49379_, Block p_49380_, BlockPos p_49381_, boolean p_49382_) { + protected void neighborChanged(BlockState p_49377_, Level p_49378_, BlockPos p_49379_, Block p_49380_, @Nullable Orientation p_362860_, boolean p_49382_) { if (!p_49378_.isClientSide && p_49378_.getBlockState(p_49379_).is(this)) { - RailShape railshape = p_49377_.getValue(this.getShapeProperty()); + RailShape railshape = getRailDirection(p_49377_, p_49378_, p_49379_, null); if (shouldBeRemoved(p_49379_, p_49378_, railshape)) { dropResources(p_49377_, p_49378_, p_49379_); p_49378_.removeBlock(p_49379_, p_49382_); -@@ -121,7 +_,7 @@ +@@ -124,7 +_,7 @@ protected void onRemove(BlockState p_49384_, Level p_49385_, BlockPos p_49386_, BlockState p_49387_, boolean p_49388_) { if (!p_49388_) { super.onRemove(p_49384_, p_49385_, p_49386_, p_49387_, p_49388_); -- if (p_49384_.getValue(this.getShapeProperty()).isAscending()) { -+ if (getRailDirection(p_49384_, p_49385_, p_49386_, null).isAscending()) { +- if (p_49384_.getValue(this.getShapeProperty()).isSlope()) { ++ if (getRailDirection(p_49384_, p_49385_, p_49386_, null).isSlope()) { p_49385_.updateNeighborsAt(p_49386_.above(), this); } -@@ -142,6 +_,11 @@ +@@ -145,6 +_,11 @@ return blockstate.setValue(this.getShapeProperty(), flag1 ? RailShape.EAST_WEST : RailShape.NORTH_SOUTH).setValue(WATERLOGGED, Boolean.valueOf(flag)); } @@ -47,7 +39,7 @@ public abstract Property getShapeProperty(); @Override -@@ -158,5 +_,15 @@ +@@ -168,5 +_,15 @@ @Override protected FluidState getFluidState(BlockState p_152158_) { return p_152158_.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(p_152158_); 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 d4e909cf35..9d5cf4b55a 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BeehiveBlock.java +++ b/net/minecraft/world/level/block/BeehiveBlock.java -@@ -126,7 +_,7 @@ +@@ -140,7 +_,7 @@ boolean flag = false; if (i >= 5) { Item item = p_331014_.getItem(); 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 f7a0053cdf..0b47838f31 100644 --- a/patches/minecraft/net/minecraft/world/level/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/Block.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -61,11 +_,12 @@ +@@ -60,11 +_,12 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.slf4j.Logger; @@ -15,7 +15,7 @@ private static final LoadingCache SHAPE_FULL_BLOCK_CACHE = CacheBuilder.newBuilder() .maximumSize(512L) .weakKeys() -@@ -190,6 +_,7 @@ +@@ -186,6 +_,7 @@ LOGGER.error("Block classes should end with Block and {} doesn't.", s); } } @@ -23,16 +23,27 @@ } public static boolean isExceptionForConnection(BlockState p_152464_) { -@@ -206,6 +_,8 @@ - BlockState blockstate = p_152446_.getBlockState(p_152449_); - if (p_152445_.skipRendering(blockstate, p_152448_)) { +@@ -198,12 +_,19 @@ + || p_152464_.is(BlockTags.SHULKER_BOXES); + } + ++ @Deprecated // FORGE: use shouldRenderFace with level and block pos instead + public static boolean shouldRenderFace(BlockState p_152445_, BlockState p_362730_, Direction p_152448_) { ++ return shouldRenderFace(net.minecraft.world.level.EmptyBlockGetter.INSTANCE, BlockPos.ZERO, p_152445_, p_362730_, p_152448_); ++ } ++ ++ public static boolean shouldRenderFace(BlockGetter level, BlockPos pos, BlockState p_152445_, BlockState p_362730_, Direction p_152448_) { + VoxelShape voxelshape = p_362730_.getFaceOcclusionShape(p_152448_.getOpposite()); + if (voxelshape == Shapes.block()) { return false; -+ } else if (p_152445_.supportsExternalFaceHiding() && blockstate.hidesNeighborFace(p_152446_, p_152449_, p_152445_, p_152448_.getOpposite())) { + } else if (p_152445_.skipRendering(p_362730_, p_152448_)) { + return false; ++ } else if (p_152445_.supportsExternalFaceHiding() && p_362730_.hidesNeighborFace(level, pos.relative(p_152448_), p_152445_, p_152448_.getOpposite())) { + return false; - } else if (blockstate.canOcclude()) { - Block.BlockStatePairKey block$blockstatepairkey = new Block.BlockStatePairKey(p_152445_, blockstate, p_152448_); - Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap = OCCLUSION_CACHE.get(); -@@ -294,9 +_,13 @@ + } else if (voxelshape == Shapes.empty()) { + return true; + } else { +@@ -291,9 +_,13 @@ public static void dropResources( BlockState p_49882_, Level p_49883_, BlockPos p_49884_, @Nullable BlockEntity p_49885_, @Nullable Entity p_49886_, ItemStack p_49887_ ) { @@ -47,16 +58,16 @@ } } -@@ -324,7 +_,7 @@ +@@ -321,7 +_,7 @@ } private static void popResource(Level p_152441_, Supplier p_152442_, ItemStack p_152443_) { -- if (!p_152441_.isClientSide && !p_152443_.isEmpty() && p_152441_.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { -+ if (!p_152441_.isClientSide && !p_152443_.isEmpty() && p_152441_.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS) && !p_152441_.restoringBlockSnapshots) { +- if (p_152441_ instanceof ServerLevel serverlevel && !p_152443_.isEmpty() && serverlevel.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { ++ if (p_152441_ instanceof ServerLevel serverlevel && !p_152443_.isEmpty() && serverlevel.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS) && !p_152441_.restoringBlockSnapshots) { ItemEntity itementity = p_152442_.get(); itementity.setDefaultPickUpDelay(); p_152441_.addFreshEntity(itementity); -@@ -332,11 +_,12 @@ +@@ -330,11 +_,12 @@ } public void popExperience(ServerLevel p_49806_, BlockPos p_49807_, int p_49808_) { @@ -70,7 +81,7 @@ public float getExplosionResistance() { return this.explosionResistance; } -@@ -355,7 +_,8 @@ +@@ -353,7 +_,8 @@ public void playerDestroy(Level p_49827_, Player p_49828_, BlockPos p_49829_, BlockState p_49830_, @Nullable BlockEntity p_49831_, ItemStack p_49832_) { p_49828_.awardStat(Stats.BLOCK_MINED.get(this)); p_49828_.causeFoodExhaustion(0.005F); @@ -80,7 +91,7 @@ } public void setPlacedBy(Level p_49847_, BlockPos p_49848_, BlockState p_49849_, @Nullable LivingEntity p_49850_, ItemStack p_49851_) { -@@ -385,6 +_,7 @@ +@@ -375,6 +_,7 @@ p_49822_.setDeltaMovement(p_49822_.getDeltaMovement().multiply(1.0, 0.0, 1.0)); } @@ -88,7 +99,7 @@ public ItemStack getCloneItemStack(LevelReader p_312699_, BlockPos p_49824_, BlockState p_49825_) { return new ItemStack(this); } -@@ -459,7 +_,7 @@ +@@ -449,7 +_,7 @@ this.item = Item.byBlock(this); } @@ -97,9 +108,9 @@ } public boolean hasDynamicShape() { -@@ -525,5 +_,74 @@ - i = 31 * i + this.second.hashCode(); - return 31 * i + this.direction.hashCode(); +@@ -501,5 +_,74 @@ + public int hashCode() { + return System.identityHashCode(this.first) * 31 + System.identityHashCode(this.second); } + } + 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 11797869cb..874b649b16 100644 --- a/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/level/block/Blocks.java +++ b/net/minecraft/world/level/block/Blocks.java -@@ -790,7 +_,7 @@ - public static final Block RED_BED = register("red_bed", bed(DyeColor.RED)); - public static final Block BLACK_BED = register("black_bed", bed(DyeColor.BLACK)); - public static final Block POWERED_RAIL = register( -- "powered_rail", new PoweredRailBlock(BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL)) -+ "powered_rail", new PoweredRailBlock(BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL), true) +@@ -2800,7 +_,7 @@ ); - public static final Block DETECTOR_RAIL = register( - "detector_rail", new DetectorRailBlock(BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL)) -@@ -7546,16 +_,5 @@ + public static final Block QUARTZ_STAIRS = registerLegacyStair("quartz_stairs", QUARTZ_BLOCK); + public static final Block ACTIVATOR_RAIL = register( +- "activator_rail", PoweredRailBlock::new, BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL) ++ "activator_rail", prop -> new PoweredRailBlock(prop, false), BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL) + ); + public static final Block DROPPER = register( + "dropper", +@@ -6552,14 +_,5 @@ - public static void rebuildCache() { - Block.BLOCK_STATE_REGISTRY.forEach(BlockBehaviour.BlockStateBase::initCache); + private static Block register(String p_50796_, BlockBehaviour.Properties p_362760_) { + return register(p_50796_, Block::new, p_362760_); - } - - static { @@ -21,8 +21,6 @@ - Block.BLOCK_STATE_REGISTRY.add(blockstate); - blockstate.initCache(); - } -- -- block.getLootTable(); - } } } diff --git a/patches/minecraft/net/minecraft/world/level/block/BushBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BushBlock.java.patch index 4a431d2d84..500a78172f 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BushBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BushBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BushBlock.java +++ b/net/minecraft/world/level/block/BushBlock.java -@@ -11,7 +_,7 @@ +@@ -12,7 +_,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.pathfinder.PathComputationType; @@ -9,7 +9,7 @@ protected BushBlock(BlockBehaviour.Properties p_51021_) { super(p_51021_); } -@@ -31,6 +_,9 @@ +@@ -43,6 +_,9 @@ @Override protected boolean canSurvive(BlockState p_51028_, LevelReader p_51029_, BlockPos p_51030_) { BlockPos blockpos = p_51030_.below(); @@ -19,7 +19,7 @@ return this.mayPlaceOn(p_51029_.getBlockState(blockpos), p_51029_, blockpos); } -@@ -42,5 +_,11 @@ +@@ -54,5 +_,11 @@ @Override protected boolean isPathfindable(BlockState p_51023_, PathComputationType p_51026_) { return p_51026_ == PathComputationType.AIR && !this.hasCollision ? true : super.isPathfindable(p_51023_, p_51026_); diff --git a/patches/minecraft/net/minecraft/world/level/block/CactusBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CactusBlock.java.patch index 2175804583..055dae677e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CactusBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CactusBlock.java.patch @@ -34,7 +34,7 @@ } } } -@@ -99,7 +_,7 @@ +@@ -108,7 +_,7 @@ } BlockState blockstate1 = p_51154_.getBlockState(p_51155_.below()); @@ -43,7 +43,7 @@ } @Override -@@ -115,5 +_,15 @@ +@@ -124,5 +_,15 @@ @Override protected boolean isPathfindable(BlockState p_51143_, PathComputationType p_51146_) { return false; diff --git a/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch index 17615ae821..927f77d8db 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CampfireBlock.java +++ b/net/minecraft/world/level/block/CampfireBlock.java -@@ -275,7 +_,7 @@ +@@ -292,7 +_,7 @@ return true; } diff --git a/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch index 99655a4e31..47e4ad187d 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ChestBlock.java +++ b/net/minecraft/world/level/block/ChestBlock.java -@@ -357,7 +_,8 @@ +@@ -365,7 +_,8 @@ @Override protected BlockState mirror(BlockState p_51549_, Mirror p_51550_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch index 42f89536d1..c1f016378b 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/ChorusFlowerBlock.java +++ b/net/minecraft/world/level/block/ChorusFlowerBlock.java -@@ -65,7 +_,7 @@ +@@ -66,7 +_,7 @@ BlockPos blockpos = p_220982_.above(); - if (p_220981_.isEmptyBlock(blockpos) && blockpos.getY() < p_220981_.getMaxBuildHeight()) { + if (p_220981_.isEmptyBlock(blockpos) && blockpos.getY() <= p_220981_.getMaxY()) { int i = p_220980_.getValue(AGE); - if (i < 5) { + if (i < 5 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_220981_, blockpos, p_220980_, true)) { boolean flag = false; boolean flag1 = false; BlockState blockstate = p_220981_.getBlockState(p_220982_.below()); -@@ -121,6 +_,7 @@ +@@ -122,6 +_,7 @@ } else { this.placeDeadFlower(p_220981_, p_220982_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch index 7d14e773c3..9e5c25509e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ComparatorBlock.java +++ b/net/minecraft/world/level/block/ComparatorBlock.java -@@ -197,4 +_,16 @@ +@@ -207,4 +_,16 @@ protected void createBlockStateDefinition(StateDefinition.Builder p_51887_) { p_51887_.add(FACING, MODE, POWERED); } @@ -13,7 +13,7 @@ + @Override + public void onNeighborChange(BlockState state, net.minecraft.world.level.LevelReader world, BlockPos pos, BlockPos neighbor) { + if (pos.getY() == neighbor.getY() && world instanceof Level level) { -+ level.neighborChanged(state, pos, world.getBlockState(neighbor).getBlock(), neighbor, false); ++ level.neighborChanged(state, pos, world.getBlockState(neighbor).getBlock(), null, false); + } + } } diff --git a/patches/minecraft/net/minecraft/world/level/block/ConcretePowderBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ConcretePowderBlock.java.patch index 29cb799e4c..2d470e1600 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ConcretePowderBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ConcretePowderBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ConcretePowderBlock.java +++ b/net/minecraft/world/level/block/ConcretePowderBlock.java -@@ -34,7 +_,7 @@ +@@ -36,7 +_,7 @@ @Override public void onLand(Level p_52068_, BlockPos p_52069_, BlockState p_52070_, BlockState p_52071_, FallingBlockEntity p_52072_) { @@ -9,7 +9,7 @@ p_52068_.setBlock(p_52069_, this.concrete.defaultBlockState(), 3); } } -@@ -47,20 +_,24 @@ +@@ -49,20 +_,24 @@ return shouldSolidify(blockgetter, blockpos, blockstate) ? this.concrete.defaultBlockState() : super.getStateForPlacement(p_52063_); } @@ -38,12 +38,12 @@ flag = true; break; } -@@ -76,7 +_,7 @@ - - @Override - protected BlockState updateShape(BlockState p_52074_, Direction p_52075_, BlockState p_52076_, LevelAccessor p_52077_, BlockPos p_52078_, BlockPos p_52079_) { -- return touchesLiquid(p_52077_, p_52078_) ? this.concrete.defaultBlockState() : super.updateShape(p_52074_, p_52075_, p_52076_, p_52077_, p_52078_, p_52079_); -+ return touchesLiquid(p_52077_, p_52078_, p_52074_) ? this.concrete.defaultBlockState() : super.updateShape(p_52074_, p_52075_, p_52076_, p_52077_, p_52078_, p_52079_); +@@ -87,7 +_,7 @@ + BlockState p_52076_, + RandomSource p_369257_ + ) { +- return touchesLiquid(p_361484_, p_52078_) ++ return touchesLiquid(p_361484_, p_52078_, p_52074_) + ? this.concrete.defaultBlockState() + : super.updateShape(p_52074_, p_361484_, p_362145_, p_52078_, p_52075_, p_52079_, p_52076_, p_369257_); } - - @Override diff --git a/patches/minecraft/net/minecraft/world/level/block/CoralBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CoralBlock.java.patch index 5a1ed63e3c..ea6a1bed14 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CoralBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CoralBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CoralBlock.java +++ b/net/minecraft/world/level/block/CoralBlock.java -@@ -51,9 +_,10 @@ +@@ -61,9 +_,10 @@ } protected boolean scanForWater(BlockGetter p_52135_, BlockPos p_52136_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch index 3489dcf4af..72095f6e91 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch @@ -36,8 +36,8 @@ @Override protected void entityInside(BlockState p_52277_, Level p_52278_, BlockPos p_52279_, Entity p_52280_) { -- if (p_52280_ instanceof Ravager && p_52278_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (p_52280_ instanceof Ravager && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_52278_, p_52280_)) { - p_52278_.destroyBlock(p_52279_, true, p_52280_); +- if (p_52278_ instanceof ServerLevel serverlevel && p_52280_ instanceof Ravager && serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (p_52278_ instanceof ServerLevel serverlevel && p_52280_ instanceof Ravager && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, p_52280_)) { + serverlevel.destroyBlock(p_52279_, true, p_52280_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch index 32480d060f..8f2c5ac067 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/block/DiodeBlock.java +++ b/net/minecraft/world/level/block/DiodeBlock.java -@@ -172,6 +_,9 @@ - protected void updateNeighborsInFront(Level p_52581_, BlockPos p_52582_, BlockState p_52583_) { +@@ -176,6 +_,9 @@ Direction direction = p_52583_.getValue(FACING); BlockPos blockpos = p_52582_.relative(direction.getOpposite()); -+ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(p_52581_, p_52582_, p_52581_.getBlockState(p_52582_), java.util.EnumSet.of(direction.getOpposite()), false).isCanceled()) { + Orientation orientation = ExperimentalRedstoneUtils.initialOrientation(p_52581_, direction.getOpposite(), Direction.UP); ++ if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(p_52581_, p_52582_, p_52581_.getBlockState(p_52582_), java.util.EnumSet.of(direction.getOpposite()), false)) { + return; + } - p_52581_.neighborChanged(blockpos, this, p_52582_); - p_52581_.updateNeighborsAtExceptFromFacing(blockpos, this, direction); + p_52581_.neighborChanged(blockpos, this, orientation); + p_52581_.updateNeighborsAtExceptFromFacing(blockpos, this, direction, orientation); } 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 34be88a048..b9261ddcd8 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 -@@ -69,6 +_,7 @@ +@@ -80,6 +_,7 @@ return super.canSurvive(p_52887_, p_52888_, p_52889_); } else { BlockState blockstate = p_52888_.getBlockState(p_52889_.below()); diff --git a/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch index f528073e8a..8a35a67562 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/level/block/FarmBlock.java +++ b/net/minecraft/world/level/block/FarmBlock.java -@@ -98,10 +_,7 @@ +@@ -107,10 +_,7 @@ @Override public void fallOn(Level p_153227_, BlockState p_153228_, BlockPos p_153229_, Entity p_153230_, float p_153231_) { - if (!p_153227_.isClientSide + if (p_153227_ instanceof ServerLevel serverlevel - && p_153227_.random.nextFloat() < p_153231_ - 0.5F - && p_153230_ instanceof LivingEntity -- && (p_153230_ instanceof Player || p_153227_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) +- && (p_153230_ instanceof Player || serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) - && p_153230_.getBbWidth() * p_153230_.getBbWidth() * p_153230_.getBbHeight() > 0.512F) { -+ && net.minecraftforge.common.ForgeHooks.onFarmlandTrample(p_153227_, p_153229_, Blocks.DIRT.defaultBlockState(), p_153231_, p_153230_)) { // Forge: Move logic to Entity#canTrample ++ && net.minecraftforge.common.ForgeHooks.onFarmlandTrample(serverlevel, p_153229_, Blocks.DIRT.defaultBlockState(), p_153231_, p_153230_)) { // Forge: Move logic to Entity#canTrample turnToDirt(p_153230_, p_153228_, p_153227_, p_153229_); } -@@ -115,17 +_,20 @@ +@@ -124,17 +_,20 @@ } private static boolean shouldMaintainFarmland(BlockGetter p_279219_, BlockPos p_279209_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/FenceGateBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FenceGateBlock.java.patch index ea10379f73..1e532e287e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FenceGateBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FenceGateBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FenceGateBlock.java +++ b/net/minecraft/world/level/block/FenceGateBlock.java -@@ -50,6 +_,8 @@ +@@ -55,6 +_,8 @@ protected static final VoxelShape Z_OCCLUSION_SHAPE_LOW = Shapes.or(Block.box(0.0, 2.0, 7.0, 2.0, 13.0, 9.0), Block.box(14.0, 2.0, 7.0, 16.0, 13.0, 9.0)); protected static final VoxelShape X_OCCLUSION_SHAPE_LOW = Shapes.or(Block.box(7.0, 2.0, 0.0, 9.0, 13.0, 2.0), Block.box(7.0, 2.0, 14.0, 9.0, 13.0, 16.0)); private final WoodType type; @@ -9,7 +9,7 @@ @Override public MapCodec codec() { -@@ -57,8 +_,14 @@ +@@ -62,8 +_,14 @@ } public FenceGateBlock(WoodType p_273340_, BlockBehaviour.Properties p_273352_) { @@ -26,7 +26,7 @@ this.registerDefaultState( this.stateDefinition .any() -@@ -169,7 +_,7 @@ +@@ -183,7 +_,7 @@ p_53366_.playSound( p_53368_, p_53367_, @@ -35,16 +35,16 @@ SoundSource.BLOCKS, 1.0F, p_53366_.getRandom().nextFloat() * 0.1F + 0.9F -@@ -186,7 +_,7 @@ - p_310915_.playSound( +@@ -200,7 +_,7 @@ + p_368190_.playSound( null, p_311232_, - flag ? this.type.fenceGateClose() : this.type.fenceGateOpen(), + flag ? this.closeSound : this.openSound, SoundSource.BLOCKS, 1.0F, - p_310915_.getRandom().nextFloat() * 0.1F + 0.9F -@@ -207,7 +_,7 @@ + p_368190_.getRandom().nextFloat() * 0.1F + 0.9F +@@ -221,7 +_,7 @@ p_53373_.playSound( null, p_53374_, diff --git a/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch index d40fd7aab9..12622a47ed 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FireBlock.java +++ b/net/minecraft/world/level/block/FireBlock.java -@@ -130,13 +_,13 @@ +@@ -139,13 +_,13 @@ protected BlockState getStateForPlacement(BlockGetter p_53471_, BlockPos p_53472_) { BlockPos blockpos = p_53472_.below(); BlockState blockstate = p_53471_.getBlockState(blockpos); @@ -16,7 +16,7 @@ } } -@@ -161,7 +_,7 @@ +@@ -170,7 +_,7 @@ } BlockState blockstate = p_221161_.getBlockState(p_221162_.below()); @@ -25,7 +25,7 @@ int i = p_221160_.getValue(AGE); if (!flag && p_221161_.isRaining() && this.isNearRain(p_221161_, p_221162_) && p_221163_.nextFloat() < 0.2F + (float)i * 0.03F) { p_221161_.removeBlock(p_221162_, false); -@@ -182,7 +_,7 @@ +@@ -191,7 +_,7 @@ return; } @@ -34,7 +34,7 @@ p_221161_.removeBlock(p_221162_, false); return; } -@@ -190,12 +_,12 @@ +@@ -199,12 +_,12 @@ boolean flag1 = p_221161_.getBiome(p_221162_).is(BiomeTags.INCREASED_FIRE_BURNOUT); int k = flag1 ? -50 : 0; @@ -53,7 +53,7 @@ BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int l = -1; l <= 1; l++) { -@@ -238,33 +_,31 @@ +@@ -247,33 +_,31 @@ || p_53429_.isRainingAt(p_53430_.south()); } @@ -92,7 +92,7 @@ } } -@@ -275,7 +_,7 @@ +@@ -284,7 +_,7 @@ private boolean isValidFireLocation(BlockGetter p_53486_, BlockPos p_53487_) { for (Direction direction : Direction.values()) { @@ -101,7 +101,7 @@ return true; } } -@@ -291,13 +_,14 @@ +@@ -300,13 +_,14 @@ for (Direction direction : Direction.values()) { BlockState blockstate = p_221157_.getBlockState(p_221158_.relative(direction)); @@ -117,7 +117,7 @@ @Override protected boolean canBurn(BlockState p_53489_) { return this.getIgniteOdds(p_53489_) > 0; -@@ -319,8 +_,21 @@ +@@ -328,8 +_,21 @@ } public void setFlammable(Block p_53445_, int p_53446_, int p_53447_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch index ddf177ad84..6644feaa44 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch @@ -51,9 +51,9 @@ - p_334489_.setBlock(p_330334_, Blocks.FLOWER_POT.defaultBlockState(), 3); + p_334489_.setBlock(p_330334_, getEmptyPot().defaultBlockState(), 3); p_334489_.gameEvent(p_333787_, GameEvent.BLOCK_CHANGE, p_330334_); - return InteractionResult.sidedSuccess(p_334489_.isClientSide); + return InteractionResult.SUCCESS; } -@@ -107,11 +_,30 @@ +@@ -116,11 +_,30 @@ } public Block getPotted() { diff --git a/patches/minecraft/net/minecraft/world/level/block/LeavesBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/LeavesBlock.java.patch index 8e6f4c0603..312a937551 100644 --- a/patches/minecraft/net/minecraft/world/level/block/LeavesBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/LeavesBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/LeavesBlock.java +++ b/net/minecraft/world/level/block/LeavesBlock.java -@@ -24,7 +_,7 @@ +@@ -26,7 +_,7 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; diff --git a/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch index d53a83a399..5713aaf3b8 100644 --- a/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/LiquidBlock.java +++ b/net/minecraft/world/level/block/LiquidBlock.java -@@ -50,7 +_,8 @@ - p_310157_ -> p_310157_.group(FLOWING_FLUID.fieldOf("fluid").forGetter(p_312827_ -> p_312827_.fluid), propertiesCodec()).apply(p_310157_, LiquidBlock::new) +@@ -53,7 +_,8 @@ + p_360438_ -> p_360438_.group(FLOWING_FLUID.fieldOf("fluid").forGetter(p_312827_ -> p_312827_.fluid), propertiesCodec()).apply(p_360438_, LiquidBlock::new) ); public static final IntegerProperty LEVEL = BlockStateProperties.LEVEL; - protected final FlowingFluid fluid; @@ -10,7 +10,7 @@ private final List stateCache; public static final VoxelShape STABLE_SHAPE = Block.box(0.0, 0.0, 0.0, 16.0, 8.0, 16.0); public static final ImmutableList POSSIBLE_FLOW_DIRECTIONS = ImmutableList.of(Direction.DOWN, Direction.SOUTH, Direction.NORTH, Direction.EAST, Direction.WEST); -@@ -60,6 +_,7 @@ +@@ -63,6 +_,7 @@ return CODEC; } @@ -18,7 +18,7 @@ public LiquidBlock(FlowingFluid p_54694_, BlockBehaviour.Properties p_54695_) { super(p_54695_); this.fluid = p_54694_; -@@ -72,6 +_,19 @@ +@@ -75,6 +_,19 @@ this.stateCache.add(p_54694_.getFlowing(8, true)); this.registerDefaultState(this.stateDefinition.any().setValue(LEVEL, Integer.valueOf(0))); @@ -38,7 +38,7 @@ } @Override -@@ -106,6 +_,7 @@ +@@ -109,6 +_,7 @@ @Override protected FluidState getFluidState(BlockState p_54765_) { int i = p_54765_.getValue(LEVEL); @@ -46,7 +46,7 @@ return this.stateCache.get(Math.min(i, 8)); } -@@ -131,7 +_,7 @@ +@@ -134,7 +_,7 @@ @Override protected void onPlace(BlockState p_54754_, Level p_54755_, BlockPos p_54756_, BlockState p_54757_, boolean p_54758_) { @@ -55,10 +55,10 @@ p_54755_.scheduleTick(p_54756_, p_54754_.getFluidState().getType(), this.fluid.getTickDelay(p_54755_)); } } -@@ -147,11 +_,12 @@ +@@ -159,11 +_,12 @@ @Override - protected void neighborChanged(BlockState p_54709_, Level p_54710_, BlockPos p_54711_, Block p_54712_, BlockPos p_54713_, boolean p_54714_) { + protected void neighborChanged(BlockState p_54709_, Level p_54710_, BlockPos p_54711_, Block p_54712_, @Nullable Orientation p_368724_, boolean p_54714_) { - if (this.shouldSpreadLiquid(p_54710_, p_54711_, p_54709_)) { + if (!net.minecraftforge.fluids.FluidInteractionRegistry.canInteract(p_54710_, p_54711_)) { p_54710_.scheduleTick(p_54711_, p_54709_.getFluidState().getType(), this.fluid.getTickDelay(p_54710_)); @@ -69,7 +69,7 @@ private boolean shouldSpreadLiquid(Level p_54697_, BlockPos p_54698_, BlockState p_54699_) { if (this.fluid.is(FluidTags.LAVA)) { boolean flag = p_54697_.getBlockState(p_54698_.below()).is(Blocks.SOUL_SOIL); -@@ -198,5 +_,24 @@ +@@ -210,5 +_,24 @@ @Override public Optional getPickupSound() { return this.fluid.getPickupSound(); 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 1eecf2fbef..691523a836 100644 --- a/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/NoteBlock.java +++ b/net/minecraft/world/level/block/NoteBlock.java -@@ -110,7 +_,9 @@ - if (p_332131_.isClientSide) { - return InteractionResult.SUCCESS; - } else { +@@ -121,7 +_,9 @@ + @Override + protected InteractionResult useWithoutItem(BlockState p_331116_, Level p_332131_, BlockPos p_333586_, Player p_329332_, BlockHitResult p_331978_) { + if (!p_332131_.isClientSide) { - p_331116_ = p_331116_.cycle(NOTE); + int _new = net.minecraftforge.common.ForgeHooks.onNoteChange(p_332131_, p_333586_, p_331116_, p_331116_.getValue(NOTE), p_331116_.cycle(NOTE).getValue(NOTE)); + if (_new == -1) return InteractionResult.FAIL; @@ -11,7 +11,7 @@ p_332131_.setBlock(p_333586_, p_331116_, 3); this.playNote(p_329332_, p_331116_, p_332131_, p_333586_); p_329332_.awardStat(Stats.TUNE_NOTEBLOCK); -@@ -132,6 +_,9 @@ +@@ -144,6 +_,9 @@ @Override protected boolean triggerEvent(BlockState p_55023_, Level p_55024_, BlockPos p_55025_, int p_55026_, int p_55027_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/PowderSnowBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/PowderSnowBlock.java.patch index 29c7e6ca18..923d5b94e6 100644 --- a/patches/minecraft/net/minecraft/world/level/block/PowderSnowBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/PowderSnowBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PowderSnowBlock.java +++ b/net/minecraft/world/level/block/PowderSnowBlock.java -@@ -130,7 +_,7 @@ +@@ -126,7 +_,7 @@ if (p_154256_.getType().is(EntityTypeTags.POWDER_SNOW_WALKABLE_MOBS)) { return true; } else { diff --git a/patches/minecraft/net/minecraft/world/level/block/PoweredRailBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/PoweredRailBlock.java.patch index 0f6a3b87b3..914f270ee4 100644 --- a/patches/minecraft/net/minecraft/world/level/block/PoweredRailBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/PoweredRailBlock.java.patch @@ -60,8 +60,8 @@ if (flag1 != flag) { p_55233_.setBlock(p_55234_, p_55232_.setValue(POWERED, Boolean.valueOf(flag1)), 3); p_55233_.updateNeighborsAt(p_55234_.below(), this); -- if (p_55232_.getValue(SHAPE).isAscending()) { -+ if (p_55232_.getValue(getShapeProperty()).isAscending()) { +- if (p_55232_.getValue(SHAPE).isSlope()) { ++ if (p_55232_.getValue(getShapeProperty()).isSlope()) { p_55233_.updateNeighborsAt(p_55234_.above(), this); } } diff --git a/patches/minecraft/net/minecraft/world/level/block/PumpkinBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/PumpkinBlock.java.patch index c449149a54..04e3829c08 100644 --- a/patches/minecraft/net/minecraft/world/level/block/PumpkinBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/PumpkinBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/PumpkinBlock.java +++ b/net/minecraft/world/level/block/PumpkinBlock.java @@ -35,7 +_,7 @@ - protected ItemInteractionResult useItemOn( + protected InteractionResult useItemOn( ItemStack p_330568_, BlockState p_330263_, Level p_327756_, BlockPos p_328675_, Player p_334049_, InteractionHand p_331851_, BlockHitResult p_329008_ ) { - if (!p_330568_.is(Items.SHEARS)) { + if (p_330568_.canPerformAction(net.minecraftforge.common.ToolActions.SHEARS_CARVE)) { return super.useItemOn(p_330568_, p_330263_, p_327756_, p_328675_, p_334049_, p_331851_, p_329008_); } else if (p_327756_.isClientSide) { - return ItemInteractionResult.sidedSuccess(p_327756_.isClientSide); + return InteractionResult.SUCCESS; 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 ab67d54b69..667adbd201 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 -@@ -249,7 +_,7 @@ +@@ -264,7 +_,7 @@ BlockState blockstate = p_55523_.getBlockState(blockpos); if (p_55526_) { boolean flag = blockstate.getBlock() instanceof TrapDoorBlock || this.canSurviveOn(p_55523_, blockpos, blockstate); @@ -9,7 +9,7 @@ if (blockstate.isFaceSturdy(p_55523_, blockpos, p_55525_.getOpposite())) { return RedstoneSide.UP; } -@@ -258,9 +_,14 @@ +@@ -273,9 +_,14 @@ } } 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 07d2f088ec..583f080f8a 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 -@@ -293,8 +_,13 @@ +@@ -301,8 +_,13 @@ @Override protected void spawnAfterBreak(BlockState p_222142_, ServerLevel p_222143_, BlockPos p_222144_, ItemStack p_222145_, boolean p_222146_) { super.spawnAfterBreak(p_222142_, p_222143_, p_222144_, p_222145_, p_222146_); diff --git a/patches/minecraft/net/minecraft/world/level/block/SculkShriekerBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SculkShriekerBlock.java.patch index e3eafbb8c3..f0db06e76a 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SculkShriekerBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SculkShriekerBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkShriekerBlock.java +++ b/net/minecraft/world/level/block/SculkShriekerBlock.java -@@ -140,7 +_,7 @@ +@@ -148,7 +_,7 @@ @Override protected void spawnAfterBreak(BlockState p_222192_, ServerLevel p_222193_, BlockPos p_222194_, ItemStack p_222195_, boolean p_222196_) { super.spawnAfterBreak(p_222192_, p_222193_, p_222194_, p_222195_, p_222196_); @@ -9,7 +9,7 @@ this.tryDropExperience(p_222193_, p_222194_, p_222195_, ConstantInt.of(5)); } } -@@ -155,5 +_,10 @@ +@@ -163,5 +_,10 @@ (p_281134_, p_281135_, p_281136_, p_281137_) -> VibrationSystem.Ticker.tick(p_281134_, p_281137_.getVibrationData(), p_281137_.getVibrationUser()) ) : null; 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 19577ef76e..a68fa05516 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 -@@ -22,7 +_,7 @@ +@@ -23,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 585d15c498..781848f3c9 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 -@@ -351,6 +_,7 @@ +@@ -357,6 +_,7 @@ private final SoundEvent hitSound; private final SoundEvent fallSound; diff --git a/patches/minecraft/net/minecraft/world/level/block/SpongeBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SpongeBlock.java.patch index 15599e6625..cb05f57fbb 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SpongeBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SpongeBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SpongeBlock.java +++ b/net/minecraft/world/level/block/SpongeBlock.java -@@ -49,6 +_,7 @@ +@@ -51,6 +_,7 @@ } private boolean removeWaterBreadthFirstSearch(Level p_56808_, BlockPos p_56809_) { @@ -8,7 +8,7 @@ return BlockPos.breadthFirstTraversal( p_56809_, 6, -@@ -64,7 +_,7 @@ +@@ -66,7 +_,7 @@ } else { BlockState blockstate = p_56808_.getBlockState(p_296944_); FluidState fluidstate = p_56808_.getFluidState(p_296944_); diff --git a/patches/minecraft/net/minecraft/world/level/block/SugarCaneBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SugarCaneBlock.java.patch index 12c5ed398b..dbacb3f45b 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SugarCaneBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SugarCaneBlock.java.patch @@ -25,7 +25,7 @@ } } } -@@ -79,6 +_,8 @@ +@@ -88,6 +_,8 @@ @Override protected boolean canSurvive(BlockState p_57175_, LevelReader p_57176_, BlockPos p_57177_) { @@ -34,7 +34,7 @@ BlockState blockstate = p_57176_.getBlockState(p_57177_.below()); if (blockstate.is(this)) { return true; -@@ -89,7 +_,7 @@ +@@ -98,7 +_,7 @@ for (Direction direction : Direction.Plane.HORIZONTAL) { BlockState blockstate1 = p_57176_.getBlockState(blockpos.relative(direction)); FluidState fluidstate = p_57176_.getFluidState(blockpos.relative(direction)); @@ -43,7 +43,7 @@ return true; } } -@@ -102,5 +_,15 @@ +@@ -111,5 +_,15 @@ @Override protected void createBlockStateDefinition(StateDefinition.Builder p_57186_) { p_57186_.add(AGE); 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 6bd43d3b94..c692e418f2 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 -@@ -69,10 +_,11 @@ +@@ -68,10 +_,11 @@ @Override protected void randomTick(BlockState p_222563_, ServerLevel p_222564_, BlockPos p_222565_, RandomSource p_222566_) { int i = p_222563_.getValue(AGE); diff --git a/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch index c5d779e5fd..695e350a2e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TntBlock.java +++ b/net/minecraft/world/level/block/TntBlock.java -@@ -44,7 +_,7 @@ +@@ -46,7 +_,7 @@ protected void onPlace(BlockState p_57466_, Level p_57467_, BlockPos p_57468_, BlockState p_57469_, boolean p_57470_) { if (!p_57469_.is(p_57466_.getBlock())) { if (p_57467_.hasNeighborSignal(p_57468_)) { @@ -9,16 +9,16 @@ p_57467_.removeBlock(p_57468_, false); } } -@@ -53,7 +_,7 @@ +@@ -55,7 +_,7 @@ @Override - protected void neighborChanged(BlockState p_57457_, Level p_57458_, BlockPos p_57459_, Block p_57460_, BlockPos p_57461_, boolean p_57462_) { + protected void neighborChanged(BlockState p_57457_, Level p_57458_, BlockPos p_57459_, Block p_57460_, @Nullable Orientation p_362896_, boolean p_57462_) { if (p_57458_.hasNeighborSignal(p_57459_)) { - explode(p_57458_, p_57459_); + onCaughtFire(p_57457_, p_57458_, p_57459_, null, null); p_57458_.removeBlock(p_57459_, false); } } -@@ -61,7 +_,7 @@ +@@ -63,7 +_,7 @@ @Override public BlockState playerWillDestroy(Level p_57445_, BlockPos p_57446_, BlockState p_57447_, Player p_57448_) { if (!p_57445_.isClientSide() && !p_57448_.isCreative() && p_57447_.getValue(UNSTABLE)) { @@ -28,7 +28,7 @@ return super.playerWillDestroy(p_57445_, p_57446_, p_57447_, p_57448_); @@ -79,10 +_,12 @@ - } + p_368198_.addFreshEntity(primedtnt); } + @Deprecated //Forge: Prefer using IForgeBlock#catchFire @@ -52,7 +52,7 @@ @@ -121,7 +_,7 @@ BlockPos blockpos = p_57431_.getBlockPos(); Entity entity = p_57432_.getOwner(); - if (p_57432_.isOnFire() && p_57432_.mayInteract(p_57429_, blockpos)) { + if (p_57432_.isOnFire() && p_57432_.mayInteract(serverlevel, blockpos)) { - explode(p_57429_, blockpos, entity instanceof LivingEntity ? (LivingEntity)entity : null); + onCaughtFire(p_57430_, p_57429_, blockpos, null, entity instanceof LivingEntity ? (LivingEntity)entity : null); p_57429_.removeBlock(blockpos, false); 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 b5d85d3815..4c07ac0e03 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 -@@ -202,4 +_,14 @@ +@@ -215,4 +_,14 @@ protected BlockSetType getType() { return this.type; } diff --git a/patches/minecraft/net/minecraft/world/level/block/TripWireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TripWireBlock.java.patch index 5b1c54e6c8..85e4570058 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TripWireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TripWireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TripWireBlock.java +++ b/net/minecraft/world/level/block/TripWireBlock.java -@@ -104,7 +_,7 @@ +@@ -114,7 +_,7 @@ @Override public BlockState playerWillDestroy(Level p_57615_, BlockPos p_57616_, BlockState p_57617_, Player p_57618_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/TripWireHookBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TripWireHookBlock.java.patch deleted file mode 100644 index a05968a164..0000000000 --- a/patches/minecraft/net/minecraft/world/level/block/TripWireHookBlock.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/level/block/TripWireHookBlock.java -+++ b/net/minecraft/world/level/block/TripWireHookBlock.java -@@ -176,8 +_,8 @@ - BlockPos blockpos2 = p_57687_.relative(direction, k); - BlockState blockstate2 = ablockstate[k]; - if (blockstate2 != null) { -+ if (!p_57686_.getBlockState(blockpos2).isAir()) { // FORGE: fix MC-129055 - p_57686_.setBlock(blockpos2, blockstate2.trySetValue(ATTACHED, Boolean.valueOf(flag2)), 3); -- if (!p_57686_.getBlockState(blockpos2).isAir()) { - } - } - } 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 e100c3c967..dd2d3624e4 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/TurtleEggBlock.java +++ b/net/minecraft/world/level/block/TurtleEggBlock.java -@@ -177,7 +_,7 @@ +@@ -179,7 +_,7 @@ if (p_57769_ instanceof Turtle || p_57769_ instanceof Bat) { return false; } else { -- return !(p_57769_ instanceof LivingEntity) ? false : p_57769_ instanceof Player || p_57768_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); -+ return !(p_57769_ instanceof LivingEntity) ? false : p_57769_ instanceof Player || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_57768_, p_57769_); +- return !(p_57769_ instanceof LivingEntity) ? false : p_57769_ instanceof Player || p_366354_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); ++ return !(p_57769_ instanceof LivingEntity) ? false : p_57769_ instanceof Player || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_366354_, p_57769_); } } } diff --git a/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch index 26a5f6474c..4d4a900f3b 100644 --- a/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch @@ -9,7 +9,7 @@ public static final MapCodec CODEC = simpleCodec(VineBlock::new); public static final BooleanProperty UP = PipeBlock.UP; public static final BooleanProperty NORTH = PipeBlock.NORTH; -@@ -181,7 +_,7 @@ +@@ -190,7 +_,7 @@ @Override protected void randomTick(BlockState p_222655_, ServerLevel p_222656_, BlockPos p_222657_, RandomSource p_222658_) { if (p_222656_.getGameRules().getBoolean(GameRules.RULE_DO_VINES_SPREAD)) { 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 6b13b03785..0a4cff8826 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 @@ -1,30 +1,22 @@ --- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -@@ -60,6 +_,7 @@ - public static final int NUM_DATA_VALUES = 4; +@@ -54,6 +_,7 @@ public static final int BURN_TIME_STANDARD = 200; public static final int BURN_COOL_SPEED = 2; + public static final int UNKNOWN_LIT_DURATION = 0; + private final RecipeType recipeType; protected NonNullList items = NonNullList.withSize(3, ItemStack.EMPTY); int litTime; - int litDuration; -@@ -114,12 +_,15 @@ + int litDuration = 0; +@@ -106,6 +_,7 @@ ) { super(p_154991_, p_154992_, p_154993_); this.quickCheck = RecipeManager.createCheck((RecipeType)p_154994_); + this.recipeType = p_154994_; } - public static void invalidateCache() { - fuelCache = null; - } - -+ /**@deprecated Forge: get burn times by calling ForgeHooks#getBurnTime(ItemStack)*/ -+ @Deprecated - public static Map getFuel() { - Map map = fuelCache; - if (map != null) { -@@ -226,9 +_,9 @@ + private boolean isLit() { +@@ -117,9 +_,9 @@ super.loadAdditional(p_335441_, p_330623_); this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); ContainerHelper.loadAllItems(p_335441_, this.items, p_330623_); @@ -34,10 +26,10 @@ + this.litTime = p_335441_.getInt("BurnTime"); + this.cookingProgress = p_335441_.getInt("CookTime"); + this.cookingTotalTime = p_335441_.getInt("CookTimeTotal"); - this.litDuration = this.getBurnDuration(this.items.get(1)); + this.litDuration = 0; CompoundTag compoundtag = p_335441_.getCompound("RecipesUsed"); -@@ -240,9 +_,9 @@ +@@ -131,9 +_,9 @@ @Override protected void saveAdditional(CompoundTag p_187452_, HolderLookup.Provider p_330192_) { super.saveAdditional(p_187452_, p_330192_); @@ -49,56 +41,53 @@ + p_187452_.putInt("CookTimeTotal", this.cookingTotalTime); ContainerHelper.saveAllItems(p_187452_, this.items, p_330192_); CompoundTag compoundtag = new CompoundTag(); - this.recipesUsed.forEach((p_187449_, p_187450_) -> compoundtag.putInt(p_187449_.toString(), p_187450_)); -@@ -269,28 +_,30 @@ + this.recipesUsed.forEach((p_360478_, p_360479_) -> compoundtag.putInt(p_360478_.location().toString(), p_360479_)); +@@ -165,27 +_,31 @@ } int i = p_155017_.getMaxStackSize(); -- if (!p_155017_.isLit() && canBurn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i)) { -+ if (!p_155017_.isLit() && p_155017_.canBurn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i)) { - p_155017_.litTime = p_155017_.getBurnDuration(itemstack); +- if (!p_155017_.isLit() && canBurn(p_364207_.registryAccess(), recipeholder, singlerecipeinput, p_155017_.items, i)) { ++ if (!p_155017_.isLit() && p_155017_.canBurn(p_364207_.registryAccess(), recipeholder, singlerecipeinput, p_155017_.items, i)) { + p_155017_.litTime = p_155017_.getBurnDuration(p_364207_.fuelValues(), itemstack); p_155017_.litDuration = p_155017_.litTime; if (p_155017_.isLit()) { flag1 = true; -+ if (itemstack.hasCraftingRemainingItem()) { -+ p_155017_.items.set(1, itemstack.getCraftingRemainingItem()); ++ var remainder = itemstack.getCraftingRemainder(); ++ if (!remainder.isEmpty()) { ++ p_155017_.items.set(1, remainder); + } else if (flag3) { Item item = itemstack.getItem(); itemstack.shrink(1); if (itemstack.isEmpty()) { -- Item item1 = item.getCraftingRemainingItem(); -- p_155017_.items.set(1, item1 == null ? ItemStack.EMPTY : new ItemStack(item1)); -+ p_155017_.items.set(1, itemstack.getCraftingRemainingItem()); +- p_155017_.items.set(1, item.getCraftingRemainder()); ++ p_155017_.items.set(1, remainder); } } } } -- if (p_155017_.isLit() && canBurn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i)) { -+ if (p_155017_.isLit() && p_155017_.canBurn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i)) { +- if (p_155017_.isLit() && canBurn(p_364207_.registryAccess(), recipeholder, singlerecipeinput, p_155017_.items, i)) { ++ if (p_155017_.isLit() && p_155017_.canBurn(p_364207_.registryAccess(), recipeholder, singlerecipeinput, p_155017_.items, i)) { p_155017_.cookingProgress++; if (p_155017_.cookingProgress == p_155017_.cookingTotalTime) { p_155017_.cookingProgress = 0; - p_155017_.cookingTotalTime = getTotalCookTime(p_155014_, p_155017_); -- if (burn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i)) { -+ if (p_155017_.burn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i)) { + p_155017_.cookingTotalTime = getTotalCookTime(p_364207_, p_155017_); +- if (burn(p_364207_.registryAccess(), recipeholder, singlerecipeinput, p_155017_.items, i)) { ++ if (p_155017_.burn(p_364207_.registryAccess(), recipeholder, singlerecipeinput, p_155017_.items, i)) { p_155017_.setRecipeUsed(recipeholder); } -@@ -314,9 +_,9 @@ +@@ -209,7 +_,7 @@ } } -- private static boolean canBurn(RegistryAccess p_266924_, @Nullable RecipeHolder p_299207_, NonNullList p_155007_, int p_155008_) { -+ private boolean canBurn(RegistryAccess p_266924_, @Nullable RecipeHolder p_299207_, NonNullList p_155007_, int p_155008_) { - if (!p_155007_.get(0).isEmpty() && p_299207_ != null) { -- ItemStack itemstack = p_299207_.value().getResultItem(p_266924_); -+ ItemStack itemstack = ((RecipeHolder>)p_299207_).value().assemble(new SingleRecipeInput(this.getItem(0)), p_266924_); - if (itemstack.isEmpty()) { - return false; - } else { -@@ -326,9 +_,9 @@ +- private static boolean canBurn( ++ private boolean canBurn( + RegistryAccess p_266924_, + @Nullable RecipeHolder p_299207_, + SingleRecipeInput p_364069_, +@@ -227,9 +_,9 @@ } else if (!ItemStack.isSameItemSameComponents(itemstack1, itemstack)) { return false; } else { @@ -110,17 +99,16 @@ } } } else { -@@ -336,15 +_,15 @@ +@@ -237,7 +_,7 @@ } } -- private static boolean burn(RegistryAccess p_266740_, @Nullable RecipeHolder p_299450_, NonNullList p_267073_, int p_267157_) { -+ private boolean burn(RegistryAccess p_266740_, @Nullable RecipeHolder p_299450_, NonNullList p_267073_, int p_267157_) { - if (p_299450_ != null && canBurn(p_266740_, p_299450_, p_267073_, p_267157_)) { - ItemStack itemstack = p_267073_.get(0); -- ItemStack itemstack1 = p_299450_.value().getResultItem(p_266740_); -+ ItemStack itemstack1 = ((RecipeHolder>)p_299450_).value().assemble(new SingleRecipeInput(this.getItem(0)), p_266740_); - ItemStack itemstack2 = p_267073_.get(2); +- private static boolean burn( ++ private boolean burn( + RegistryAccess p_266740_, + @Nullable RecipeHolder p_299450_, + SingleRecipeInput p_364092_, +@@ -251,7 +_,7 @@ if (itemstack2.isEmpty()) { p_267073_.set(2, itemstack1.copy()); } else if (ItemStack.isSameItemSameComponents(itemstack2, itemstack1)) { @@ -129,36 +117,9 @@ } if (itemstack.is(Blocks.WET_SPONGE.asItem()) && !p_267073_.get(1).isEmpty() && p_267073_.get(1).is(Items.BUCKET)) { -@@ -363,7 +_,7 @@ - return 0; - } else { - Item item = p_58343_.getItem(); -- return getFuel().getOrDefault(item, 0); -+ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_58343_, this.recipeType); - } - } - -@@ -373,7 +_,7 @@ - } - - public static boolean isFuel(ItemStack p_58400_) { -- return getFuel().containsKey(p_58400_.getItem()); -+ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_58400_, null) > 0; - } - - @Override -@@ -431,7 +_,7 @@ - return true; - } else { - ItemStack itemstack = this.items.get(1); -- return isFuel(p_58390_) || p_58390_.is(Items.BUCKET) && !itemstack.is(Items.BUCKET); -+ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_58390_, this.recipeType) > 0 || p_58390_.is(Items.BUCKET) && !itemstack.is(Items.BUCKET); - } - } - -@@ -494,5 +_,34 @@ +@@ -392,5 +_,34 @@ for (ItemStack itemstack : this.items) { - p_58342_.accountStack(itemstack); + p_363325_.accountStack(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 b47fa79d4a..3f6e5d5b07 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,7 +1,7 @@ --- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java @@ -166,4 +_,27 @@ - p_329140_.remove("Lock"); + p_329140_.remove("lock"); p_329140_.remove("Items"); } + diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch index bcc88fb298..097c53db37 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch @@ -47,7 +47,7 @@ } public final CompoundTag saveWithFullMetadata(HolderLookup.Provider p_331193_) { -@@ -216,6 +_,13 @@ +@@ -217,6 +_,13 @@ public void setRemoved() { this.remove = true; diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch index 11236bfad0..a230147e15 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch @@ -1,16 +1,15 @@ --- a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -@@ -170,15 +_,18 @@ +@@ -171,15 +_,18 @@ for (int i = 0; i < 3; i++) { p_155293_.set(i, potionbrewing.mix(itemstack, p_155293_.get(i))); } + net.minecraftforge.event.ForgeEventFactory.onPotionBrewed(p_155293_); - itemstack.shrink(1); -- if (itemstack.getItem().hasCraftingRemainingItem()) { -- ItemStack itemstack1 = new ItemStack(itemstack.getItem().getCraftingRemainingItem()); -+ if (itemstack.hasCraftingRemainingItem()) { -+ ItemStack itemstack1 = itemstack.getCraftingRemainingItem(); +- ItemStack itemstack1 = itemstack.getItem().getCraftingRemainder(); ++ ItemStack itemstack1 = itemstack.getCraftingRemainder(); + if (!itemstack1.isEmpty()) { + itemstack.shrink(1); if (itemstack.isEmpty()) { itemstack = itemstack1; @@ -22,7 +21,7 @@ } p_155293_.set(3, itemstack); -@@ -211,6 +_,9 @@ +@@ -212,6 +_,9 @@ if (p_59017_ == 3) { PotionBrewing potionbrewing = this.level != null ? this.level.potionBrewing() : PotionBrewing.EMPTY; return potionbrewing.isIngredient(p_59018_); @@ -31,8 +30,8 @@ + return this.getItem(p_59017_).isEmpty() && potionbrewing.isValidInput(p_59018_); } else { return p_59017_ == 4 - ? p_59018_.is(Items.BLAZE_POWDER) -@@ -246,5 +_,34 @@ + ? p_59018_.is(ItemTags.BREWING_FUEL) +@@ -247,5 +_,34 @@ @Override protected AbstractContainerMenu createMenu(int p_58990_, Inventory p_58991_) { return new BrewingStandMenu(p_58990_, p_58991_, this, this.dataAccess); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/FuelValues.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/FuelValues.java.patch new file mode 100644 index 0000000000..27435798a9 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/entity/FuelValues.java.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/world/level/block/entity/FuelValues.java ++++ b/net/minecraft/world/level/block/entity/FuelValues.java +@@ -25,7 +_,11 @@ + } + + public boolean isFuel(ItemStack p_369912_) { +- return this.values.containsKey(p_369912_.getItem()); ++ return isFuel(p_369912_, null); ++ } ++ ++ public boolean isFuel(ItemStack stack, @org.jetbrains.annotations.Nullable net.minecraft.world.item.crafting.RecipeType type) { ++ return burnDuration(stack, type) > 0; + } + + public SequencedSet fuelItems() { +@@ -33,7 +_,16 @@ + } + + public int burnDuration(ItemStack p_368393_) { +- return p_368393_.isEmpty() ? 0 : this.values.getInt(p_368393_.getItem()); ++ return burnDuration(p_368393_, null); ++ } ++ ++ public int burnDuration(ItemStack stack, @org.jetbrains.annotations.Nullable net.minecraft.world.item.crafting.RecipeType type) { ++ if (stack.isEmpty()) ++ return 0; ++ int ret = stack.getBurnTime(type); ++ if (ret == -1) ++ ret = this.values.getInt(stack.getItem()); ++ return net.minecraftforge.event.ForgeEventFactory.getItemBurnTime(stack, ret, type); + } + + public static FuelValues vanillaBurnTimes(HolderLookup.Provider p_363816_, FeatureFlagSet p_367705_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/grower/TreeGrower.java.patch b/patches/minecraft/net/minecraft/world/level/block/grower/TreeGrower.java.patch index 190dd2e943..0aebf31220 100644 --- a/patches/minecraft/net/minecraft/world/level/block/grower/TreeGrower.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/grower/TreeGrower.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/grower/TreeGrower.java +++ b/net/minecraft/world/level/block/grower/TreeGrower.java -@@ -129,6 +_,9 @@ +@@ -130,6 +_,9 @@ ResourceKey> resourcekey = this.getConfiguredMegaFeature(p_309951_); if (resourcekey != null) { - Holder> holder = p_309830_.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).getHolder(resourcekey).orElse(null); + Holder> holder = p_309830_.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).get(resourcekey).orElse(null); + var event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_309830_, p_309951_, p_310327_, holder); + holder = event.getFeature(); + if (event.getResult().isDenied()) return false; diff --git a/patches/minecraft/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch index 625d865187..3d0170a312 100644 --- a/patches/minecraft/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/net/minecraft/world/level/block/piston/PistonBaseBlock.java -@@ -186,6 +_,7 @@ +@@ -189,6 +_,7 @@ } if (p_60195_ == 0) { @@ -8,7 +8,7 @@ if (!this.moveBlocks(p_60193_, p_60194_, direction, true)) { return false; } -@@ -194,6 +_,7 @@ +@@ -197,6 +_,7 @@ p_60193_.playSound(null, p_60194_, SoundEvents.PISTON_EXTEND, SoundSource.BLOCKS, 0.5F, p_60193_.random.nextFloat() * 0.25F + 0.6F); p_60193_.gameEvent(GameEvent.BLOCK_ACTIVATE, p_60194_, GameEvent.Context.of(blockstate)); } else if (p_60195_ == 1 || p_60195_ == 2) { @@ -16,7 +16,7 @@ BlockEntity blockentity = p_60193_.getBlockEntity(p_60194_.relative(direction)); if (blockentity instanceof PistonMovingBlockEntity) { ((PistonMovingBlockEntity)blockentity).finalTick(); -@@ -241,6 +_,7 @@ +@@ -244,6 +_,7 @@ p_60193_.gameEvent(GameEvent.BLOCK_DEACTIVATE, p_60194_, GameEvent.Context.of(blockstate1)); } @@ -24,7 +24,7 @@ return true; } -@@ -380,6 +_,11 @@ +@@ -384,6 +_,11 @@ @Override protected BlockState rotate(BlockState p_60215_, Rotation p_60216_) { return p_60215_.setValue(FACING, p_60216_.rotate(p_60215_.getValue(FACING))); 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 94bcbb53d7..70dbd39e7d 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 -@@ -115,7 +_,7 @@ +@@ -116,7 +_,7 @@ List list = p_155911_.getEntities(null, PistonMath.getMovementArea(aabb, direction, d0).minmax(aabb)); if (!list.isEmpty()) { List list1 = voxelshape.toAabbs(); 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 d923d21113..d7a14f65bc 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,33 +1,6 @@ --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -96,6 +_,7 @@ - protected final boolean dynamicShape; - protected final FeatureFlagSet requiredFeatures; - protected final BlockBehaviour.Properties properties; -+ private final java.util.function.Supplier> lootTableSupplier; - @Nullable - protected ResourceKey drops; - -@@ -111,6 +_,18 @@ - this.dynamicShape = p_60452_.dynamicShape; - this.requiredFeatures = p_60452_.requiredFeatures; - this.properties = p_60452_; -+ -+ final ResourceKey lootTableCache = p_60452_.drops; -+ if (lootTableCache != null) { -+ this.lootTableSupplier = () -> lootTableCache; -+ } else if (p_60452_.lootTableSupplier != null) { -+ this.lootTableSupplier = p_60452_.lootTableSupplier; -+ } else { -+ this.lootTableSupplier = () -> { -+ ResourceLocation resourcelocation = BuiltInRegistries.BLOCK.getKey(this.asBlock()); -+ return ResourceKey.create(Registries.LOOT_TABLE, resourcelocation.withPrefix("blocks/")); -+ }; -+ } - } - - public BlockBehaviour.Properties properties() { -@@ -159,7 +_,7 @@ +@@ -171,7 +_,7 @@ } protected void onRemove(BlockState p_60515_, Level p_60516_, BlockPos p_60517_, BlockState p_60518_, boolean p_60519_) { @@ -36,26 +9,26 @@ p_60516_.removeBlockEntity(p_60517_); } } -@@ -168,7 +_,7 @@ +@@ -180,7 +_,7 @@ if (!p_310712_.isAir() && p_312709_.getBlockInteraction() != Explosion.BlockInteraction.TRIGGER_BLOCK) { Block block = p_310712_.getBlock(); boolean flag = p_312709_.getIndirectSourceEntity() instanceof Player; -- if (block.dropFromExplosion(p_312709_) && p_311693_ instanceof ServerLevel serverlevel) { -+ if (p_310712_.canDropFromExplosion(p_311693_, p_311490_, p_312709_) && p_311693_ instanceof ServerLevel serverlevel) { - BlockEntity blockentity = p_310712_.hasBlockEntity() ? p_311693_.getBlockEntity(p_311490_) : null; - LootParams.Builder lootparams$builder = new LootParams.Builder(serverlevel) +- if (block.dropFromExplosion(p_312709_)) { ++ if (p_310712_.canDropFromExplosion(p_367589_, p_311490_, p_312709_)) { + BlockEntity blockentity = p_310712_.hasBlockEntity() ? p_367589_.getBlockEntity(p_311490_) : null; + LootParams.Builder lootparams$builder = new LootParams.Builder(p_367589_) .withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(p_311490_)) -@@ -183,8 +_,7 @@ +@@ -195,8 +_,7 @@ p_310712_.getDrops(lootparams$builder).forEach(p_309419_ -> p_311277_.accept(p_309419_, p_311490_)); } -- p_311693_.setBlock(p_311490_, Blocks.AIR.defaultBlockState(), 3); -- block.wasExploded(p_311693_, p_311490_, p_312709_); -+ p_310712_.onBlockExploded(p_311693_, p_311490_, p_312709_); +- p_367589_.setBlock(p_311490_, Blocks.AIR.defaultBlockState(), 3); +- block.wasExploded(p_367589_, p_311490_, p_312709_); ++ p_310712_.onBlockExploded(p_367589_, p_311490_, p_312709_); } } -@@ -335,12 +_,15 @@ +@@ -342,12 +_,15 @@ if (f == -1.0F) { return 0.0F; } else { @@ -73,17 +46,7 @@ } protected void attack(BlockState p_60499_, Level p_60500_, BlockPos p_60501_, Player p_60502_) { -@@ -359,8 +_,7 @@ - - public final ResourceKey getLootTable() { - if (this.drops == null) { -- ResourceLocation resourcelocation = BuiltInRegistries.BLOCK.getKey(this.asBlock()); -- this.drops = ResourceKey.create(Registries.LOOT_TABLE, resourcelocation.withPrefix("blocks/")); -+ this.drops = this.lootTableSupplier.get(); - } - - return this.drops; -@@ -377,6 +_,7 @@ +@@ -387,6 +_,7 @@ return this.isRandomlyTicking; } @@ -91,7 +54,7 @@ protected SoundType getSoundType(BlockState p_328629_) { return this.soundType; } -@@ -393,6 +_,10 @@ +@@ -403,6 +_,10 @@ return this.properties.destroyTime; } @@ -100,9 +63,9 @@ + } + public abstract static class BlockStateBase extends StateHolder { - private final int lightEmission; - private final boolean useShapeForLightOcclusion; -@@ -523,12 +_,14 @@ + private static final Direction[] DIRECTIONS = Direction.values(); + private static final VoxelShape[] EMPTY_OCCLUSION_SHAPES = Util.make(new VoxelShape[DIRECTIONS.length], p_368402_ -> Arrays.fill(p_368402_, Shapes.empty())); +@@ -555,12 +_,14 @@ return this.useShapeForLightOcclusion; } @@ -118,7 +81,7 @@ } public boolean ignitedByLava() { -@@ -541,9 +_,11 @@ +@@ -573,9 +_,11 @@ } public MapColor getMapColor(BlockGetter p_285002_, BlockPos p_285293_) { @@ -131,7 +94,7 @@ public BlockState rotate(Rotation p_60718_) { return this.getBlock().rotate(this.asState(), p_60718_); } -@@ -597,6 +_,8 @@ +@@ -629,6 +_,8 @@ } public PushReaction getPistonPushReaction() { @@ -140,31 +103,12 @@ return this.pushReaction; } -@@ -960,10 +_,11 @@ - boolean spawnTerrainParticles = true; - NoteBlockInstrument instrument = NoteBlockInstrument.HARP; - boolean replaceable; -+ private java.util.function.Supplier> lootTableSupplier; - BlockBehaviour.StateArgumentPredicate> isValidSpawn = (p_284893_, p_284894_, p_284895_, p_284896_) -> p_284893_.isFaceSturdy( - p_284894_, p_284895_, Direction.UP +@@ -990,7 +_,7 @@ + BlockBehaviour.StateArgumentPredicate> isValidSpawn = (p_360542_, p_360543_, p_360544_, p_360545_) -> p_360542_.isFaceSturdy( + p_360543_, p_360544_, Direction.UP ) -- && p_284893_.getLightEmission() < 14; -+ && p_284893_.getLightEmission(p_284894_, p_284895_) < 14; - BlockBehaviour.StatePredicate isRedstoneConductor = (p_284888_, p_284889_, p_284890_) -> p_284888_.isCollisionShapeFullBlock(p_284889_, p_284890_); - BlockBehaviour.StatePredicate isSuffocating = (p_284885_, p_284886_, p_284887_) -> p_284885_.blocksMotion() && p_284885_.isCollisionShapeFullBlock(p_284886_, p_284887_); +- && p_360542_.getLightEmission() < 14; ++ && p_360542_.getLightEmission(p_360543_, p_360544_) < 14; + BlockBehaviour.StatePredicate isRedstoneConductor = (p_360546_, p_360547_, p_360548_) -> p_360546_.isCollisionShapeFullBlock(p_360547_, p_360548_); + BlockBehaviour.StatePredicate isSuffocating = (p_360539_, p_360540_, p_360541_) -> p_360539_.blocksMotion() && p_360539_.isCollisionShapeFullBlock(p_360540_, p_360541_); BlockBehaviour.StatePredicate isViewBlocking = this.isSuffocating; -@@ -1104,8 +_,14 @@ - return this; - } - -+ @Deprecated // FORGE: Use the variant that takes a Supplier below - public BlockBehaviour.Properties dropsLike(Block p_60917_) { - this.drops = p_60917_.getLootTable(); -+ return this; -+ } -+ -+ public BlockBehaviour.Properties lootFrom(java.util.function.Supplier blockIn) { -+ this.lootTableSupplier = () -> blockIn.get().getLootTable(); - return this; - } - diff --git a/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch index 4d3031882b..2c4df32839 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java -@@ -315,23 +_,28 @@ +@@ -324,23 +_,28 @@ @Override public final void findBlockLightSources(BiConsumer p_285269_) { -- this.findBlocks(p_284897_ -> p_284897_.getLightEmission() != 0, p_285269_); -+ this.findBlocks((p_284897_, pos) -> p_284897_.getLightEmission(this, pos) != 0, p_285269_); +- this.findBlocks(p_360555_ -> p_360555_.getLightEmission() != 0, p_285269_); ++ this.findBlocks((p_360555_, pos) -> p_360555_.getLightEmission(this, pos) != 0, p_285269_); } public void findBlocks(Predicate p_285343_, BiConsumer p_285030_) { @@ -15,7 +15,7 @@ + public void findBlocks(java.util.function.BiPredicate p_285343_, BiConsumer p_285030_) { BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); - for (int i = this.getMinSection(); i < this.getMaxSection(); i++) { + for (int i = this.getMinSectionY(); i <= this.getMaxSectionY(); i++) { LevelChunkSection levelchunksection = this.getSection(this.getSectionIndexFromSectionY(i)); - if (levelchunksection.maybeHas(p_285343_)) { + if (levelchunksection.maybeHas(state -> p_285343_.test(state, BlockPos.ZERO))) { @@ -33,10 +33,10 @@ } } } -@@ -475,5 +_,10 @@ +@@ -484,5 +_,10 @@ } - public static record TicksToSave(SerializableTickContainer blocks, SerializableTickContainer fluids) { + public static record PackedTicks(List> blocks, List> fluids) { + } + + @Nullable diff --git a/patches/minecraft/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch index b22128f7c4..3dcaa1b97b 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/ImposterProtoChunk.java +++ b/net/minecraft/world/level/chunk/ImposterProtoChunk.java -@@ -292,4 +_,9 @@ +@@ -291,4 +_,9 @@ public ChunkSkyLightSources getSkyLightSources() { return this.wrapped.getSkyLightSources(); } 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 48e6045e83..a218a5cc55 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -50,7 +_,7 @@ +@@ -51,7 +_,7 @@ import net.minecraft.world.ticks.TickContainerAccess; import org.slf4j.Logger; @@ -9,7 +9,7 @@ static final Logger LOGGER = LogUtils.getLogger(); private static final TickingBlockEntity NULL_TICKER = new TickingBlockEntity() { @Override -@@ -111,6 +_,7 @@ +@@ -114,6 +_,7 @@ this.postLoad = p_196861_; this.blockTicks = p_196857_; this.fluidTicks = p_196858_; @@ -17,7 +17,7 @@ } public LevelChunk(ServerLevel p_196850_, ProtoChunk p_196851_, @Nullable LevelChunk.PostLoadProcessor p_196852_) { -@@ -270,14 +_,14 @@ +@@ -290,14 +_,14 @@ boolean flag2 = blockstate.hasBlockEntity(); if (!this.level.isClientSide) { blockstate.onRemove(this.level, p_62865_, p_62866_, p_62867_); @@ -34,7 +34,7 @@ p_62866_.onPlace(this.level, p_62865_, blockstate, p_62867_); } -@@ -326,6 +_,12 @@ +@@ -352,6 +_,12 @@ @Nullable public BlockEntity getBlockEntity(BlockPos p_62868_, LevelChunk.EntityCreationType p_62869_) { BlockEntity blockentity = this.blockEntities.get(p_62868_); @@ -47,7 +47,7 @@ if (blockentity == null) { CompoundTag compoundtag = this.pendingBlockEntities.remove(p_62868_); if (compoundtag != null) { -@@ -343,9 +_,6 @@ +@@ -369,9 +_,6 @@ this.addAndRegisterBlockEntity(blockentity); } } @@ -57,7 +57,7 @@ } return blockentity; -@@ -359,6 +_,7 @@ +@@ -385,6 +_,7 @@ } this.updateBlockEntityTicker(p_156391_); @@ -65,7 +65,7 @@ } } -@@ -411,9 +_,14 @@ +@@ -437,9 +_,14 @@ public CompoundTag getBlockEntityNbtForSaving(BlockPos p_62932_, HolderLookup.Provider p_329605_) { BlockEntity blockentity = this.getBlockEntity(p_62932_); if (blockentity != null && !blockentity.isRemoved()) { @@ -80,7 +80,7 @@ } else { CompoundTag compoundtag = this.pendingBlockEntities.get(p_62932_); if (compoundtag != null) { -@@ -493,7 +_,7 @@ +@@ -519,7 +_,7 @@ p_187974_.accept((p_327409_, p_327410_, p_327411_) -> { BlockEntity blockentity = this.getBlockEntity(p_327409_, LevelChunk.EntityCreationType.IMMEDIATE); if (blockentity != null && p_327411_ != null && blockentity.getType() == p_327410_) { @@ -89,7 +89,7 @@ } }); } -@@ -601,6 +_,7 @@ +@@ -629,6 +_,7 @@ } public void clearAllBlockEntities() { @@ -97,7 +97,7 @@ this.blockEntities.values().forEach(BlockEntity::setRemoved); this.blockEntities.clear(); this.tickersInLevel.values().forEach(p_187966_ -> p_187966_.rebind(NULL_TICKER)); -@@ -608,6 +_,7 @@ +@@ -636,6 +_,7 @@ } public void registerAllBlockEntitiesAfterLevelLoad() { @@ -105,7 +105,7 @@ this.blockEntities.values().forEach(p_187988_ -> { if (this.level instanceof ServerLevel serverlevel) { this.addGameEventListener(p_187988_, serverlevel); -@@ -659,6 +_,24 @@ +@@ -687,6 +_,24 @@ return new LevelChunk.BoundTickingBlockEntity<>(p_156376_, p_156377_); } @@ -130,15 +130,15 @@ class BoundTickingBlockEntity implements TickingBlockEntity { private final T blockEntity; private final BlockEntityTicker ticker; -@@ -676,6 +_,7 @@ +@@ -704,6 +_,7 @@ if (LevelChunk.this.isTicking(blockpos)) { try { - ProfilerFiller profilerfiller = LevelChunk.this.level.getProfiler(); + ProfilerFiller profilerfiller = Profiler.get(); + net.minecraftforge.server.timings.TimeTracker.BLOCK_ENTITY_UPDATE.trackStart(blockEntity); profilerfiller.push(this::getType); BlockState blockstate = LevelChunk.this.getBlockState(blockpos); if (this.blockEntity.getType().isValid(blockstate)) { -@@ -697,6 +_,11 @@ +@@ -725,6 +_,11 @@ CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking block entity"); CrashReportCategory crashreportcategory = crashreport.addCategory("Block entity being ticked"); this.blockEntity.fillCrashReportCategory(crashreportcategory); @@ -150,7 +150,7 @@ throw new ReportedException(crashreport); } } -@@ -770,5 +_,32 @@ +@@ -798,6 +_,33 @@ public String toString() { return this.ticker + " "; } @@ -182,4 +182,5 @@ + public Level getWorldForge() { + return getLevel(); } - } + + @FunctionalInterface diff --git a/patches/minecraft/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch index 6e828d520f..11b806f115 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java +++ b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java -@@ -183,8 +_,14 @@ +@@ -181,9 +_,15 @@ levelchunk.setFullStatus(generationchunkholder::getFullStatus); levelchunk.runPostLoad(); levelchunk.setLoaded(true); @@ -8,10 +8,11 @@ + generationchunkholder.currentlyLoading = levelchunk; // Forge - bypass the future chain when getChunk is called, this prevents deadlocks. levelchunk.registerAllBlockEntitiesAfterLevelLoad(); levelchunk.registerTickContainerInLevel(serverlevel); + levelchunk.setUnsavedListener(p_342042_.unsavedListener()); + net.minecraftforge.event.ForgeEventFactory.onChunkLoad(levelchunk, !(protochunk instanceof ImposterProtoChunk)); + } finally { + generationchunkholder.currentlyLoading = null; // Forge - Stop bypassing the future chain. + } return levelchunk; - }, p_341879_ -> p_342042_.mainThreadMailBox().tell(ChunkTaskPriorityQueueSorter.message(p_341879_, chunkpos.toLong(), generationchunkholder::getTicketLevel))); + }, p_342042_.mainThreadExecutor()); } 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 deleted file mode 100644 index 57146a2f1d..0000000000 --- a/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch +++ /dev/null @@ -1,43 +0,0 @@ ---- a/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -+++ b/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -@@ -183,6 +_,9 @@ - postLoadChunk(p_188231_, p_188234_), - blendingdata - ); -+ if (p_188234_.contains("ForgeCaps")) { -+ ((LevelChunk)chunkaccess).readCapsFromNBT(p_188231_.registryAccess(), p_188234_.getCompound("ForgeCaps")); -+ } - } else { - ProtoChunkTicks protochunkticks = ProtoChunkTicks.load( - p_188234_.getList("block_ticks", 10), p_258992_ -> BuiltInRegistries.BLOCK.getOptional(ResourceLocation.tryParse(p_258992_)), p_188233_ -@@ -241,6 +_,7 @@ - } - - if (chunktype == ChunkType.LEVELCHUNK) { -+ net.minecraftforge.event.ForgeEventFactory.onChunkDataLoad(chunkaccess, p_188234_, chunktype); - return new ImposterProtoChunk((LevelChunk)chunkaccess, false); - } else { - ProtoChunk protochunk1 = (ProtoChunk)chunkaccess; -@@ -264,6 +_,7 @@ - protochunk1.setCarvingMask(generationstep$carving, new CarvingMask(compoundtag4.getLongArray(s1), chunkaccess.getMinBuildHeight())); - } - -+ net.minecraftforge.event.ForgeEventFactory.onChunkDataLoad(chunkaccess, p_188234_, chunktype); - return protochunk1; - } - } -@@ -373,6 +_,14 @@ - } - - compoundtag.put("CarvingMasks", compoundtag4); -+ } -+ else if (p_63456_ instanceof LevelChunk levelChunk){ -+ try { -+ final CompoundTag capTag = levelChunk.writeCapsToNBT(p_63455_.registryAccess()); -+ if (capTag != null) compoundtag.put("ForgeCaps", capTag); -+ } catch (Exception exception) { -+ LOGGER.error("A capability provider has thrown an exception trying to write state. It will not persist. Report this to the mod author", exception); -+ } - } - - saveTicks(p_63455_, compoundtag, p_63456_.getTicksForSerialization()); diff --git a/patches/minecraft/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch index 7cdba72d58..037905f5d5 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/storage/EntityStorage.java +++ b/net/minecraft/world/level/chunk/storage/EntityStorage.java -@@ -94,8 +_,12 @@ +@@ -95,8 +_,12 @@ ListTag listtag = new ListTag(); p_156559_.getEntities().forEach(p_156567_ -> { CompoundTag compoundtag1 = new CompoundTag(); 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 8fe44f5027..0d33c3dcf3 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/DebugLevelSource.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/DebugLevelSource.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/DebugLevelSource.java +++ b/net/minecraft/world/level/levelgen/DebugLevelSource.java -@@ -141,4 +_,10 @@ +@@ -135,4 +_,10 @@ public int getSeaLevel() { return 63; } 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 6fcd7d09ac..caf2754f6f 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch @@ -29,4 +29,4 @@ + int l = event.getPhantomsToSpawn(); for (int i1 = 0; i1 < l; i1++) { - Phantom phantom = EntityType.PHANTOM.create(p_64576_); + Phantom phantom = EntityType.PHANTOM.create(p_64576_, EntitySpawnReason.NATURAL); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/WorldDimensions.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/WorldDimensions.java.patch index 933d4c4197..76f5e91a99 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/WorldDimensions.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/WorldDimensions.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/WorldDimensions.java +++ b/net/minecraft/world/level/levelgen/WorldDimensions.java -@@ -36,7 +_,8 @@ +@@ -37,7 +_,8 @@ public record WorldDimensions(Map, LevelStem> dimensions) { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( p_327457_ -> p_327457_.group( 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 1b2ac4b713..63803d46c0 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/StructurePiece.java +++ b/net/minecraft/world/level/levelgen/structure/StructurePiece.java -@@ -91,6 +_,9 @@ +@@ -92,6 +_,9 @@ } public final CompoundTag createTag(StructurePieceSerializationContext p_192645_) { 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 7858491069..82e57865a9 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 @@ -4,9 +4,9 @@ public CompoundTag createTag(StructurePieceSerializationContext p_192661_, ChunkPos p_192662_) { CompoundTag compoundtag = new CompoundTag(); if (this.isValid()) { -+ if (p_192661_.registryAccess().registryOrThrow(Registries.STRUCTURE).getKey(this.getStructure()) == null) { // FORGE: This is just a more friendly error instead of the 'Null String' below ++ if (p_192661_.registryAccess().lookupOrThrow(Registries.STRUCTURE).getKey(this.getStructure()) == null) { // FORGE: This is just a more friendly error instead of the 'Null String' below + throw new RuntimeException("StructureStart \"" + this.getClass().getName() + "\": \"" + this.getStructure() + "\" unregistered, serializing impossible."); + } - compoundtag.putString("id", p_192661_.registryAccess().registryOrThrow(Registries.STRUCTURE).getKey(this.structure).toString()); + compoundtag.putString("id", p_192661_.registryAccess().lookupOrThrow(Registries.STRUCTURE).getKey(this.structure).toString()); compoundtag.putInt("ChunkX", p_192662_.x); compoundtag.putInt("ChunkZ", p_192662_.z); 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 0c9b6fc158..9ce0793b11 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 -@@ -226,6 +_,10 @@ +@@ -255,6 +_,10 @@ return transform(p_74565_, p_74564_.getMirror(), p_74564_.getRotation(), p_74564_.getRotationPivot()); } @@ -11,7 +11,7 @@ public boolean placeInWorld( ServerLevelAccessor p_230329_, BlockPos p_230330_, BlockPos p_230331_, StructurePlaceSettings p_230332_, RandomSource p_230333_, int p_230334_ ) { -@@ -248,7 +_,7 @@ +@@ -277,7 +_,7 @@ int i1 = Integer.MIN_VALUE; int j1 = Integer.MIN_VALUE; @@ -20,7 +20,7 @@ BlockPos blockpos = structuretemplate$structureblockinfo.pos; if (boundingbox == null || boundingbox.isInside(blockpos)) { FluidState fluidstate = p_230332_.shouldApplyWaterlogging() ? p_230329_.getFluidState(blockpos) : null; -@@ -360,7 +_,7 @@ +@@ -389,7 +_,7 @@ } if (!p_230332_.isIgnoreEntities()) { @@ -29,8 +29,8 @@ } return true; -@@ -394,12 +_,21 @@ - }); +@@ -429,12 +_,21 @@ + ); } + /** @@ -52,7 +52,7 @@ ) { List list = new ArrayList<>(); List list1 = new ArrayList<>(); -@@ -415,7 +_,7 @@ +@@ -450,7 +_,7 @@ while (structuretemplate$structureblockinfo1 != null && iterator.hasNext()) { structuretemplate$structureblockinfo1 = iterator.next() @@ -61,7 +61,7 @@ } if (structuretemplate$structureblockinfo1 != null) { -@@ -431,21 +_,27 @@ +@@ -466,21 +_,27 @@ return list1; } @@ -95,7 +95,7 @@ ListTag listtag = new ListTag(); listtag.add(DoubleTag.valueOf(vec31.x)); listtag.add(DoubleTag.valueOf(vec31.y)); -@@ -465,6 +_,24 @@ +@@ -500,6 +_,24 @@ } } } diff --git a/patches/minecraft/net/minecraft/world/level/lighting/BlockLightEngine.java.patch b/patches/minecraft/net/minecraft/world/level/lighting/BlockLightEngine.java.patch index 9d61520f29..2825019033 100644 --- a/patches/minecraft/net/minecraft/world/level/lighting/BlockLightEngine.java.patch +++ b/patches/minecraft/net/minecraft/world/level/lighting/BlockLightEngine.java.patch @@ -12,9 +12,9 @@ @@ -117,7 +_,7 @@ LightChunk lightchunk = this.chunkSource.getChunkForLighting(p_285274_.x, p_285274_.z); if (lightchunk != null) { - lightchunk.findBlockLightSources((p_285266_, p_285452_) -> { -- int i = p_285452_.getLightEmission(); -+ int i = p_285452_.getLightEmission(chunkSource.getLevel(), p_285266_); - this.enqueueIncrease(p_285266_.asLong(), LightEngine.QueueEntry.increaseLightFromEmission(i, isEmptyShape(p_285452_))); + lightchunk.findBlockLightSources((p_360638_, p_360639_) -> { +- int i = p_360639_.getLightEmission(); ++ int i = p_360639_.getLightEmission(chunkSource.getLevel(), p_360638_); + this.enqueueIncrease(p_360638_.asLong(), LightEngine.QueueEntry.increaseLightFromEmission(i, isEmptyShape(p_360639_))); }); } diff --git a/patches/minecraft/net/minecraft/world/level/lighting/LightEngine.java.patch b/patches/minecraft/net/minecraft/world/level/lighting/LightEngine.java.patch deleted file mode 100644 index 63adb6e17d..0000000000 --- a/patches/minecraft/net/minecraft/world/level/lighting/LightEngine.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/lighting/LightEngine.java -+++ b/net/minecraft/world/level/lighting/LightEngine.java -@@ -44,7 +_,7 @@ - return p_285372_ == p_285110_ - ? false - : p_285372_.getLightBlock(p_285159_, p_284985_) != p_285110_.getLightBlock(p_285159_, p_284985_) -- || p_285372_.getLightEmission() != p_285110_.getLightEmission() -+ || p_285372_.getLightEmission(p_285159_, p_284985_) != p_285110_.getLightEmission(p_285159_, p_284985_) - || p_285372_.useShapeForLightOcclusion() - || p_285110_.useShapeForLightOcclusion(); - } 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 527e97d609..f7e65a762b 100644 --- a/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch @@ -1,29 +1,29 @@ --- a/net/minecraft/world/level/material/FlowingFluid.java +++ b/net/minecraft/world/level/material/FlowingFluid.java -@@ -161,7 +_,7 @@ - BlockState blockstate = p_256464_.getBlockState(blockpos); +@@ -170,7 +_,7 @@ + BlockState blockstate = p_369574_.getBlockState(blockpos); FluidState fluidstate = blockstate.getFluidState(); - if (fluidstate.getType().isSame(this) && this.canPassThroughWall(direction, p_256464_, p_76037_, p_76038_, blockpos, blockstate)) { + if (fluidstate.getType().isSame(this) && canPassThroughWall(direction, p_369574_, p_76037_, p_76038_, blockpos, blockstate)) { - if (fluidstate.isSource()) { -+ if (fluidstate.isSource() && net.minecraftforge.event.ForgeEventFactory.canCreateFluidSource(p_256464_, blockpos, blockstate, fluidstate.canConvertToSource(p_256464_, blockpos))) { ++ if (fluidstate.isSource() && net.minecraftforge.event.ForgeEventFactory.canCreateFluidSource(p_369574_, blockpos, blockstate, fluidstate.canConvertToSource(p_369574_, blockpos))) { j++; } -@@ -169,7 +_,7 @@ +@@ -178,7 +_,7 @@ } } -- if (this.canConvertToSource(p_256464_) && j >= 2) { +- if (j >= 2 && this.canConvertToSource(p_369574_)) { + if (j >= 2) { - BlockState blockstate1 = p_256464_.getBlockState(p_76037_.below()); + BlockState blockstate1 = p_369574_.getBlockState(blockpos$mutableblockpos.setWithOffset(p_76037_, Direction.DOWN)); FluidState fluidstate1 = blockstate1.getFluidState(); if (blockstate1.isSolid() || this.isSourceBlockOfThisType(fluidstate1)) { -@@ -235,6 +_,15 @@ +@@ -252,6 +_,15 @@ return this.getSource().defaultFluidState().setValue(FALLING, Boolean.valueOf(p_76069_)); } + @Override -+ public boolean canConvertToSource(FluidState state, Level level, BlockPos pos) { ++ public boolean canConvertToSource(FluidState state, ServerLevel level, BlockPos pos) { + return this.canConvertToSource(level); + } + @@ -31,6 +31,6 @@ + * @deprecated Forge: Use {@link #canConvertToSource(FluidState, Level, BlockPos)} instead. + */ + @Deprecated - protected abstract boolean canConvertToSource(Level p_256009_); + protected abstract boolean canConvertToSource(ServerLevel p_369955_); protected void spreadTo(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/Fluid.java.patch b/patches/minecraft/net/minecraft/world/level/material/Fluid.java.patch index 57d3b725d1..a6dcfeeecb 100644 --- a/patches/minecraft/net/minecraft/world/level/material/Fluid.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/Fluid.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/Fluid.java +++ b/net/minecraft/world/level/material/Fluid.java -@@ -20,7 +_,7 @@ +@@ -21,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; @@ -9,7 +9,7 @@ public static final IdMapper FLUID_STATE_REGISTRY = new IdMapper<>(); protected final StateDefinition stateDefinition; private FluidState defaultFluidState; -@@ -108,5 +_,12 @@ +@@ -109,5 +_,12 @@ @Deprecated public Holder.Reference builtInRegistryHolder() { return this.builtInRegistryHolder; 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 c9b367c5a8..e5734d7dbb 100644 --- a/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/FluidState.java +++ b/net/minecraft/world/level/material/FluidState.java -@@ -21,7 +_,7 @@ +@@ -22,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; @@ -9,7 +9,7 @@ public static final Codec CODEC = codec(BuiltInRegistries.FLUID.byNameCodec(), Fluid::defaultFluidState).stable(); public static final int AMOUNT_MAX = 9; public static final int AMOUNT_FULL = 8; -@@ -113,6 +_,7 @@ +@@ -114,6 +_,7 @@ return this.getType() == p_192918_; } diff --git a/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch b/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch index da53eb696e..6c223f1836 100644 --- a/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java -@@ -87,7 +_,7 @@ - BlockState blockstate = p_230572_.getBlockState(blockpos); +@@ -88,7 +_,7 @@ + BlockState blockstate = p_367000_.getBlockState(blockpos); if (blockstate.isAir()) { - if (this.hasFlammableNeighbours(p_230572_, blockpos)) { -- p_230572_.setBlockAndUpdate(blockpos, BaseFireBlock.getState(p_230572_, blockpos)); -+ p_230572_.setBlockAndUpdate(blockpos, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_230572_, blockpos, p_230573_, Blocks.FIRE.defaultBlockState())); + if (this.hasFlammableNeighbours(p_367000_, blockpos)) { +- p_367000_.setBlockAndUpdate(blockpos, BaseFireBlock.getState(p_367000_, blockpos)); ++ p_367000_.setBlockAndUpdate(blockpos, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_367000_, blockpos, p_230573_, Blocks.FIRE.defaultBlockState())); return; } } else if (blockstate.blocksMotion()) { -@@ -101,8 +_,8 @@ +@@ -102,8 +_,8 @@ return; } -- if (p_230572_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_230572_, blockpos1)) { -- p_230572_.setBlockAndUpdate(blockpos1.above(), BaseFireBlock.getState(p_230572_, blockpos1)); -+ if (p_230572_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_230572_, blockpos1, Direction.UP)) { -+ p_230572_.setBlockAndUpdate(blockpos1.above(), net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_230572_, blockpos1.above(), p_230573_, Blocks.FIRE.defaultBlockState())); +- if (p_367000_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_367000_, blockpos1)) { +- p_367000_.setBlockAndUpdate(blockpos1.above(), BaseFireBlock.getState(p_367000_, blockpos1)); ++ if (p_367000_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_367000_, blockpos1, Direction.UP)) { ++ p_367000_.setBlockAndUpdate(blockpos1.above(), net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_367000_, blockpos1.above(), p_230573_, Blocks.FIRE.defaultBlockState())); } } } -@@ -111,7 +_,7 @@ +@@ -112,7 +_,7 @@ private boolean hasFlammableNeighbours(LevelReader p_76228_, BlockPos p_76229_) { for (Direction direction : Direction.values()) { @@ -29,19 +29,17 @@ return true; } } -@@ -119,12 +_,19 @@ +@@ -120,10 +_,17 @@ return false; } + /** @deprecated Forge: use {@link LavaFluid#isFlammable(LevelReader,BlockPos,Direction)} instead */ private boolean isFlammable(LevelReader p_76246_, BlockPos p_76247_) { - return p_76247_.getY() >= p_76246_.getMinBuildHeight() && p_76247_.getY() < p_76246_.getMaxBuildHeight() && !p_76246_.hasChunkAt(p_76247_) - ? false - : p_76246_.getBlockState(p_76247_).ignitedByLava(); + return p_76246_.isInsideBuildHeight(p_76247_.getY()) && !p_76246_.hasChunkAt(p_76247_) ? false : p_76246_.getBlockState(p_76247_).ignitedByLava(); } + private boolean isFlammable(LevelReader p_76246_, BlockPos p_76247_, Direction face) { -+ return p_76247_.getY() >= p_76246_.getMinBuildHeight() && p_76247_.getY() < p_76246_.getMaxBuildHeight() && !p_76246_.hasChunkAt(p_76247_) ++ return p_76246_.isInsideBuildHeight(p_76247_.getY()) && !p_76246_.hasChunkAt(p_76247_) + ? false + : p_76246_.getBlockState(p_76247_).ignitedByLava() && p_76246_.getBlockState(p_76247_).isFlammable(p_76246_, p_76247_, face); + } @@ -49,7 +47,7 @@ @Nullable @Override public ParticleOptions getDripParticle() { -@@ -196,7 +_,8 @@ +@@ -195,7 +_,8 @@ FluidState fluidstate = p_76220_.getFluidState(p_76221_); if (this.is(FluidTags.LAVA) && fluidstate.is(FluidTags.WATER)) { if (p_76222_.getBlock() instanceof LiquidBlock) { 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 56874b681d..eb09eeb89d 100644 --- a/patches/minecraft/net/minecraft/world/level/portal/PortalShape.java.patch +++ b/patches/minecraft/net/minecraft/world/level/portal/PortalShape.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/portal/PortalShape.java +++ b/net/minecraft/world/level/portal/PortalShape.java -@@ -27,7 +_,7 @@ +@@ -28,7 +_,7 @@ public static final int MAX_WIDTH = 21; private static final int MIN_HEIGHT = 3; public static final int MAX_HEIGHT = 21; @@ -8,4 +8,4 @@ + private static final BlockBehaviour.StatePredicate FRAME = (p_77720_, p_77721_, p_77722_) -> p_77720_.isPortalFrame(p_77721_, p_77722_); private static final float SAFE_TRAVEL_MAX_ENTITY_XY = 4.0F; private static final double SAFE_TRAVEL_MAX_VERTICAL_DELTA = 1.0; - private final LevelAccessor level; + private final Direction.Axis axis; diff --git a/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch b/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch index 0151bb6255..a06cfd27b5 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch @@ -1,20 +1,6 @@ --- a/net/minecraft/world/level/storage/DimensionDataStorage.java +++ b/net/minecraft/world/level/storage/DimensionDataStorage.java -@@ -54,9 +_,13 @@ - @Nullable - public T get(SavedData.Factory p_297465_, String p_164860_) { - SavedData saveddata = this.cache.get(p_164860_); -+ if (saveddata == net.minecraftforge.common.util.DummySavedData.DUMMY) return null; - if (saveddata == null && !this.cache.containsKey(p_164860_)) { - saveddata = this.readSavedData(p_297465_.deserializer(), p_297465_.type(), p_164860_); - this.cache.put(p_164860_, saveddata); -+ } else if (saveddata == null) { -+ this.cache.put(p_164860_, net.minecraftforge.common.util.DummySavedData.DUMMY); -+ return null; - } - - return (T)saveddata; -@@ -99,6 +_,10 @@ +@@ -104,6 +_,10 @@ } int i = NbtUtils.getDataVersion(compoundtag, 1343); diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/LootContext.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootContext.java.patch index 771bcdb712..c3a9c0e404 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootContext.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootContext.java.patch @@ -17,13 +17,24 @@ + this.queriedLootTableId = queriedLootTableId; } - public boolean hasParam(LootContextParam p_78937_) { + public boolean hasParameter(ContextKey p_368930_) { +@@ -75,6 +_,10 @@ + return this.params.getLevel(); + } + ++ public LootParams getParams() { ++ return this.params; ++ } ++ + public static LootContext.VisitedEntry createVisitedEntry(LootTable p_279327_) { + return new LootContext.VisitedEntry<>(LootDataType.TABLE, p_279327_); + } @@ -87,15 +_,34 @@ return new LootContext.VisitedEntry<>(LootDataType.MODIFIER, p_279163_); } + public int getLootingModifier() { -+ return net.minecraftforge.common.ForgeHooks.getLootingLevel(getParamOrNull(LootContextParams.THIS_ENTITY), getParamOrNull(LootContextParams.ATTACKING_ENTITY), getParamOrNull(LootContextParams.DAMAGE_SOURCE)); ++ return net.minecraftforge.common.ForgeHooks.getLootingLevel(getOptionalParameter(LootContextParams.THIS_ENTITY), getOptionalParameter(LootContextParams.ATTACKING_ENTITY), getOptionalParameter(LootContextParams.DAMAGE_SOURCE)); + } + + public void setQueriedLootTableId(ResourceLocation queriedLootTableId) { diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/LootDataType.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootDataType.java.patch index f05fe3928f..c793505791 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootDataType.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootDataType.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/level/storage/loot/LootDataType.java +++ b/net/minecraft/world/level/storage/loot/LootDataType.java -@@ -30,7 +_,12 @@ - DataResult dataresult = this.codec.parse(p_335939_, p_327740_); - dataresult.error() - .ifPresent(p_341974_ -> LOGGER.error("Couldn't parse element {}/{} - {}", this.registryKey.location(), p_279253_, p_341974_.message())); -- return dataresult.result(); -+ var ret = dataresult.result(); -+ if (ret.orElse(null) instanceof LootTable table) { -+ table.setLootTableId(p_279253_); -+ ret = Optional.ofNullable((T)net.minecraftforge.event.ForgeEventFactory.onLoadLootTable(p_279253_, table)); -+ } -+ return ret; +@@ -29,9 +_,12 @@ } - public static Stream> values() { + private static LootDataType.Validator createLootTableValidator() { +- return (p_327551_, p_327552_, p_327553_) -> p_327553_.validate( ++ return (p_327551_, p_327552_, p_327553_) -> { ++ p_327553_.setLootTableId(p_327552_.location()); ++ p_327553_.validate( + p_327551_.setContextKeySet(p_327553_.getParamSet()).enterElement("{" + p_327552_.registry() + "/" + p_327552_.location() + "}", p_327552_) + ); ++ }; + } + + @FunctionalInterface diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/LootParams.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootParams.java.patch index f2d7d0cb00..bae309e333 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootParams.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootParams.java.patch @@ -1,11 +1,29 @@ --- a/net/minecraft/world/level/storage/loot/LootParams.java +++ b/net/minecraft/world/level/storage/loot/LootParams.java -@@ -125,7 +_,7 @@ +@@ -53,6 +_,15 @@ + this.level = p_287594_; + } + ++ @SuppressWarnings("unchecked") ++ public Builder(LootParams parent) { ++ this.level = parent.getLevel(); ++ this.withLuck(parent.getLuck()); ++ parent.dynamicDrops.forEach(this::withDynamicDrop); ++ for (var key : parent.params.keySet()) ++ this.withParameter((ContextKey)key, (Object)parent.contextMap().getOptional(key)); ++ } ++ + public ServerLevel getLevel() { + return this.level; + } +@@ -93,6 +_,10 @@ + public LootParams create(ContextKeySet p_367827_) { + ContextMap contextmap = this.params.create(p_367827_); + return new LootParams(this.level, contextmap, this.dynamicDrops, this.luck); ++ } ++ ++ public LootParams create() { ++ return new LootParams(this.level, this.params.create(), this.dynamicDrops, this.luck); + } + } - public LootParams create(LootContextParamSet p_287701_) { - Set> set = Sets.difference(this.params.keySet(), p_287701_.getAllowed()); -- if (!set.isEmpty()) { -+ if (false && !set.isEmpty()) { // Forge: Allow mods to pass custom loot parameters (not part of the vanilla loot table) to the loot context. - throw new IllegalArgumentException("Parameters not allowed in this parameter set: " + set); - } else { - Set> set1 = Sets.difference(p_287701_.getRequired(), this.params.keySet()); 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 c54ed1b4d2..a77d8cb9fa 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 @@ -10,8 +10,8 @@ ) .apply(p_327557_, LootTable::new) @@ -53,7 +_,7 @@ - LootTable(LootContextParamSet p_287716_, Optional p_298628_, List p_298771_, List p_301234_) { - this.paramSet = p_287716_; + LootTable(ContextKeySet p_365565_, Optional p_298628_, List p_298771_, List p_301234_) { + this.paramSet = p_365565_; this.randomSequence = p_298628_; - this.pools = p_298771_; + this.pools = Lists.newArrayList(p_298771_); @@ -56,7 +56,7 @@ ObjectArrayList objectarraylist = new ObjectArrayList<>(); - this.getRandomItems(p_230923_, objectarraylist::add); + this.getRandomItemsRaw(p_230923_, createStackSplitter(p_230923_.getLevel(), objectarraylist::add)); -+ objectarraylist = net.minecraftforge.common.ForgeHooks.modifyLoot(this.getLootTableId(), objectarraylist, p_230923_); ++ objectarraylist = net.minecraftforge.common.ForgeHooks.modifyLoot(this, objectarraylist, p_230923_); return objectarraylist; } diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/functions/EnchantedCountIncreaseFunction.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/functions/EnchantedCountIncreaseFunction.java.patch index a20ae20c84..1b36a1be69 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/functions/EnchantedCountIncreaseFunction.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/functions/EnchantedCountIncreaseFunction.java.patch @@ -3,7 +3,7 @@ @@ -65,8 +_,12 @@ @Override public ItemStack run(ItemStack p_344964_, LootContext p_345394_) { - Entity entity = p_345394_.getParamOrNull(LootContextParams.ATTACKING_ENTITY); + Entity entity = p_345394_.getOptionalParameter(LootContextParams.ATTACKING_ENTITY); - if (entity instanceof LivingEntity livingentity) { - int i = EnchantmentHelper.getEnchantmentLevel(this.enchantment, livingentity); + int i = 0; diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/functions/SetAttributesFunction.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/functions/SetAttributesFunction.java.patch deleted file mode 100644 index acfafbc927..0000000000 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/functions/SetAttributesFunction.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/storage/loot/functions/SetAttributesFunction.java -+++ b/net/minecraft/world/level/storage/loot/functions/SetAttributesFunction.java -@@ -66,7 +_,7 @@ - p_80840_.update( - DataComponents.ATTRIBUTE_MODIFIERS, - ItemAttributeModifiers.EMPTY, -- p_327582_ -> p_327582_.modifiers().isEmpty() ? this.updateModifiers(p_80841_, p_80840_.getItem().getDefaultAttributeModifiers()) : this.updateModifiers(p_80841_, p_327582_) -+ p_327582_ -> p_327582_.modifiers().isEmpty() ? this.updateModifiers(p_80841_, p_80840_.getDefaultAttributeModifiers()) : this.updateModifiers(p_80841_, p_327582_) - ); - } - diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch index 22bb631d44..0851d8d1ab 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java +++ b/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java -@@ -41,7 +_,7 @@ +@@ -42,7 +_,7 @@ if (optional.isPresent()) { - ItemStack itemstack = optional.get().value().getResultItem(p_81269_.getLevel().registryAccess()); + ItemStack itemstack = optional.get().value().assemble(singlerecipeinput, p_81269_.getLevel().registryAccess()); if (!itemstack.isEmpty()) { - return itemstack.copyWithCount(p_81268_.getCount()); + return itemstack.copyWithCount(p_81268_.getCount() * itemstack.getCount()); // Forge: Support smelting returning multiple diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch index 00cef0bd8a..25b4d13d5a 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java +++ b/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java -@@ -20,7 +_,7 @@ - public static final LootContextParamSet EMPTY = register("empty", p_81454_ -> { +@@ -21,7 +_,7 @@ + public static final ContextKeySet EMPTY = register("empty", p_367081_ -> { }); - public static final LootContextParamSet CHEST = register( -- "chest", p_327636_ -> p_327636_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY) -+ "chest", p_327636_ -> p_327636_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY).optional(LootContextParams.ATTACKING_ENTITY) //Forge: Chest Minecarts can have killers. + public static final ContextKeySet CHEST = register( +- "chest", p_360697_ -> p_360697_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY) ++ "chest", p_360697_ -> p_360697_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY).optional(LootContextParams.ATTACKING_ENTITY) //Forge: Chest Minecarts can have killers. ); - public static final LootContextParamSet COMMAND = register( - "command", p_327634_ -> p_327634_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY) -@@ -29,7 +_,7 @@ - "selector", p_81442_ -> p_81442_.required(LootContextParams.ORIGIN).required(LootContextParams.THIS_ENTITY) + public static final ContextKeySet COMMAND = register( + "command", p_360688_ -> p_360688_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY) +@@ -30,7 +_,7 @@ + "selector", p_360687_ -> p_360687_.required(LootContextParams.ORIGIN).required(LootContextParams.THIS_ENTITY) ); - public static final LootContextParamSet FISHING = register( -- "fishing", p_81446_ -> p_81446_.required(LootContextParams.ORIGIN).required(LootContextParams.TOOL).optional(LootContextParams.THIS_ENTITY) -+ "fishing", p_81446_ -> p_81446_.required(LootContextParams.ORIGIN).required(LootContextParams.TOOL).optional(LootContextParams.THIS_ENTITY).optional(LootContextParams.ATTACKING_ENTITY).optional(LootContextParams.THIS_ENTITY) //Forge: Allow fisher, and bobber + public static final ContextKeySet FISHING = register( +- "fishing", p_360682_ -> p_360682_.required(LootContextParams.ORIGIN).required(LootContextParams.TOOL).optional(LootContextParams.THIS_ENTITY) ++ "fishing", p_360682_ -> p_360682_.required(LootContextParams.ORIGIN).required(LootContextParams.TOOL).optional(LootContextParams.THIS_ENTITY).optional(LootContextParams.ATTACKING_ENTITY).optional(LootContextParams.THIS_ENTITY) //Forge: Allow fisher, and bobber ); - public static final LootContextParamSet ENTITY = register( + public static final ContextKeySet ENTITY = register( "entity", diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithEnchantedBonusCondition.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithEnchantedBonusCondition.java.patch index 492bc9706d..0eb94cd445 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithEnchantedBonusCondition.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithEnchantedBonusCondition.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithEnchantedBonusCondition.java +++ b/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithEnchantedBonusCondition.java -@@ -42,7 +_,11 @@ +@@ -41,7 +_,11 @@ public boolean test(LootContext p_343845_) { - Entity entity = p_343845_.getParamOrNull(LootContextParams.ATTACKING_ENTITY); + Entity entity = p_343845_.getOptionalParameter(LootContextParams.ATTACKING_ENTITY); - int i = entity instanceof LivingEntity livingentity ? EnchantmentHelper.getEnchantmentLevel(this.enchantment, livingentity) : 0; + int i = 0; + if (this.enchantment.is(Enchantments.LOOTING)) diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch index 0f804d92a1..2235d284f0 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java +++ b/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java -@@ -60,7 +_,7 @@ +@@ -59,7 +_,7 @@ @Override public String getId() { diff --git a/src/main/generated/data/c/tags/entity_type/boats.json b/src/main/generated/data/c/tags/entity_type/boats.json index 5d453e0a99..1e97228009 100644 --- a/src/main/generated/data/c/tags/entity_type/boats.json +++ b/src/main/generated/data/c/tags/entity_type/boats.json @@ -1,6 +1,22 @@ { "values": [ - "minecraft:boat", - "minecraft:chest_boat" + "minecraft:acacia_boat", + "minecraft:acacia_chest_boat", + "minecraft:birch_boat", + "minecraft:birch_chest_boat", + "minecraft:cherry_boat", + "minecraft:cherry_chest_boat", + "minecraft:dark_oak_boat", + "minecraft:dark_oak_chest_boat", + "minecraft:jungle_boat", + "minecraft:jungle_chest_boat", + "minecraft:mangrove_boat", + "minecraft:mangrove_chest_boat", + "minecraft:oak_boat", + "minecraft:oak_chest_boat", + "minecraft:pale_oak_boat", + "minecraft:pale_oak_chest_boat", + "minecraft:spruce_boat", + "minecraft:spruce_chest_boat" ] } \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/acacia_chest_boat.json b/src/main/generated/data/minecraft/recipe/acacia_chest_boat.json index c677340129..8b2b099633 100644 --- a/src/main/generated/data/minecraft/recipe/acacia_chest_boat.json +++ b/src/main/generated/data/minecraft/recipe/acacia_chest_boat.json @@ -3,12 +3,8 @@ "category": "misc", "group": "chest_boat", "ingredients": [ - { - "tag": "c:chests/wooden" - }, - { - "item": "minecraft:acacia_boat" - } + "#c:chests/wooden", + "minecraft:acacia_boat" ], "result": { "count": 1, diff --git a/src/main/generated/data/minecraft/recipe/acacia_fence.json b/src/main/generated/data/minecraft/recipe/acacia_fence.json index 1df661b7b1..abc4d37cba 100644 --- a/src/main/generated/data/minecraft/recipe/acacia_fence.json +++ b/src/main/generated/data/minecraft/recipe/acacia_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:acacia_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:acacia_planks" }, "pattern": [ "W#W", diff --git a/src/main/generated/data/minecraft/recipe/acacia_fence_gate.json b/src/main/generated/data/minecraft/recipe/acacia_fence_gate.json index 01c8f1d461..af366bf332 100644 --- a/src/main/generated/data/minecraft/recipe/acacia_fence_gate.json +++ b/src/main/generated/data/minecraft/recipe/acacia_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:acacia_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:acacia_planks" }, "pattern": [ "#W#", diff --git a/src/main/generated/data/minecraft/recipe/acacia_sign.json b/src/main/generated/data/minecraft/recipe/acacia_sign.json index 8591a10c68..3232b1b89a 100644 --- a/src/main/generated/data/minecraft/recipe/acacia_sign.json +++ b/src/main/generated/data/minecraft/recipe/acacia_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:acacia_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:acacia_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/activator_rail.json b/src/main/generated/data/minecraft/recipe/activator_rail.json index f3e8a6d92a..555bb300db 100644 --- a/src/main/generated/data/minecraft/recipe/activator_rail.json +++ b/src/main/generated/data/minecraft/recipe/activator_rail.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:redstone_torch" - }, - "S": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "minecraft:redstone_torch", + "S": "#c:rods/wooden", + "X": "#c:ingots/iron" }, "pattern": [ "XSX", diff --git a/src/main/generated/data/minecraft/recipe/andesite.json b/src/main/generated/data/minecraft/recipe/andesite.json index 7e79c6d520..a73dac1c38 100644 --- a/src/main/generated/data/minecraft/recipe/andesite.json +++ b/src/main/generated/data/minecraft/recipe/andesite.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shapeless", "category": "building", "ingredients": [ - { - "item": "minecraft:diorite" - }, - { - "tag": "forge:cobblestone/normal" - } + "minecraft:diorite", + "#forge:cobblestone/normal" ], "result": { "count": 2, diff --git a/src/main/generated/data/minecraft/recipe/anvil.json b/src/main/generated/data/minecraft/recipe/anvil.json index 405668a7af..e50cd1febe 100644 --- a/src/main/generated/data/minecraft/recipe/anvil.json +++ b/src/main/generated/data/minecraft/recipe/anvil.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "I": { - "item": "minecraft:iron_block" - }, - "i": { - "tag": "c:ingots/iron" - } + "I": "minecraft:iron_block", + "i": "#c:ingots/iron" }, "pattern": [ "III", diff --git a/src/main/generated/data/minecraft/recipe/armor_stand.json b/src/main/generated/data/minecraft/recipe/armor_stand.json index 55e7dbeaff..a3ad60d12c 100644 --- a/src/main/generated/data/minecraft/recipe/armor_stand.json +++ b/src/main/generated/data/minecraft/recipe/armor_stand.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "/": { - "tag": "c:rods/wooden" - }, - "_": { - "item": "minecraft:smooth_stone_slab" - } + "/": "#c:rods/wooden", + "_": "minecraft:smooth_stone_slab" }, "pattern": [ "///", diff --git a/src/main/generated/data/minecraft/recipe/arrow.json b/src/main/generated/data/minecraft/recipe/arrow.json index 5b160e1c5a..8948fda6f2 100644 --- a/src/main/generated/data/minecraft/recipe/arrow.json +++ b/src/main/generated/data/minecraft/recipe/arrow.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "item": "minecraft:flint" - }, - "Y": { - "item": "minecraft:feather" - } + "#": "#c:rods/wooden", + "X": "minecraft:flint", + "Y": "minecraft:feather" }, "pattern": [ "X", diff --git a/src/main/generated/data/minecraft/recipe/bamboo_chest_raft.json b/src/main/generated/data/minecraft/recipe/bamboo_chest_raft.json index f50400493b..3715812774 100644 --- a/src/main/generated/data/minecraft/recipe/bamboo_chest_raft.json +++ b/src/main/generated/data/minecraft/recipe/bamboo_chest_raft.json @@ -3,12 +3,8 @@ "category": "misc", "group": "chest_boat", "ingredients": [ - { - "tag": "c:chests/wooden" - }, - { - "item": "minecraft:bamboo_raft" - } + "#c:chests/wooden", + "minecraft:bamboo_raft" ], "result": { "count": 1, diff --git a/src/main/generated/data/minecraft/recipe/bamboo_fence.json b/src/main/generated/data/minecraft/recipe/bamboo_fence.json index 190c83b690..d36413016a 100644 --- a/src/main/generated/data/minecraft/recipe/bamboo_fence.json +++ b/src/main/generated/data/minecraft/recipe/bamboo_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:bamboo_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:bamboo_planks" }, "pattern": [ "W#W", diff --git a/src/main/generated/data/minecraft/recipe/bamboo_fence_gate.json b/src/main/generated/data/minecraft/recipe/bamboo_fence_gate.json index 1d2e0f107b..444acda7be 100644 --- a/src/main/generated/data/minecraft/recipe/bamboo_fence_gate.json +++ b/src/main/generated/data/minecraft/recipe/bamboo_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:bamboo_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:bamboo_planks" }, "pattern": [ "#W#", diff --git a/src/main/generated/data/minecraft/recipe/bamboo_sign.json b/src/main/generated/data/minecraft/recipe/bamboo_sign.json index 2ea528857f..79d256d984 100644 --- a/src/main/generated/data/minecraft/recipe/bamboo_sign.json +++ b/src/main/generated/data/minecraft/recipe/bamboo_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:bamboo_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:bamboo_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/birch_chest_boat.json b/src/main/generated/data/minecraft/recipe/birch_chest_boat.json index 6d5286ebbe..8e41afa74c 100644 --- a/src/main/generated/data/minecraft/recipe/birch_chest_boat.json +++ b/src/main/generated/data/minecraft/recipe/birch_chest_boat.json @@ -3,12 +3,8 @@ "category": "misc", "group": "chest_boat", "ingredients": [ - { - "tag": "c:chests/wooden" - }, - { - "item": "minecraft:birch_boat" - } + "#c:chests/wooden", + "minecraft:birch_boat" ], "result": { "count": 1, diff --git a/src/main/generated/data/minecraft/recipe/birch_fence.json b/src/main/generated/data/minecraft/recipe/birch_fence.json index fef03a747d..f340e905c3 100644 --- a/src/main/generated/data/minecraft/recipe/birch_fence.json +++ b/src/main/generated/data/minecraft/recipe/birch_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:birch_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:birch_planks" }, "pattern": [ "W#W", diff --git a/src/main/generated/data/minecraft/recipe/birch_fence_gate.json b/src/main/generated/data/minecraft/recipe/birch_fence_gate.json index c0f380a750..55e6c5133a 100644 --- a/src/main/generated/data/minecraft/recipe/birch_fence_gate.json +++ b/src/main/generated/data/minecraft/recipe/birch_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:birch_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:birch_planks" }, "pattern": [ "#W#", diff --git a/src/main/generated/data/minecraft/recipe/birch_sign.json b/src/main/generated/data/minecraft/recipe/birch_sign.json index c7a1c36a77..94b286ed75 100644 --- a/src/main/generated/data/minecraft/recipe/birch_sign.json +++ b/src/main/generated/data/minecraft/recipe/birch_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:birch_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:birch_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/black_banner.json b/src/main/generated/data/minecraft/recipe/black_banner.json index 26cb29a877..7f67600216 100644 --- a/src/main/generated/data/minecraft/recipe/black_banner.json +++ b/src/main/generated/data/minecraft/recipe/black_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:black_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:black_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/blast_furnace.json b/src/main/generated/data/minecraft/recipe/blast_furnace.json index 6b73dce306..eb2c292aac 100644 --- a/src/main/generated/data/minecraft/recipe/blast_furnace.json +++ b/src/main/generated/data/minecraft/recipe/blast_furnace.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:smooth_stone" - }, - "I": { - "tag": "c:ingots/iron" - }, - "X": { - "item": "minecraft:furnace" - } + "#": "minecraft:smooth_stone", + "I": "#c:ingots/iron", + "X": "minecraft:furnace" }, "pattern": [ "III", diff --git a/src/main/generated/data/minecraft/recipe/blue_banner.json b/src/main/generated/data/minecraft/recipe/blue_banner.json index afb3cddb99..a98940c6b1 100644 --- a/src/main/generated/data/minecraft/recipe/blue_banner.json +++ b/src/main/generated/data/minecraft/recipe/blue_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:blue_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:blue_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/bolt_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/bolt_armor_trim_smithing_template.json index c7dcf7ebff..e5db16797d 100644 --- a/src/main/generated/data/minecraft/recipe/bolt_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/bolt_armor_trim_smithing_template.json @@ -2,20 +2,12 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, + "#": "#c:gems/diamond", "C": [ - { - "item": "minecraft:copper_block" - }, - { - "item": "minecraft:waxed_copper_block" - } + "minecraft:copper_block", + "minecraft:waxed_copper_block" ], - "S": { - "item": "minecraft:bolt_armor_trim_smithing_template" - } + "S": "minecraft:bolt_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/bow.json b/src/main/generated/data/minecraft/recipe/bow.json index b531f496f4..5831fc36f1 100644 --- a/src/main/generated/data/minecraft/recipe/bow.json +++ b/src/main/generated/data/minecraft/recipe/bow.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:strings" - } + "#": "#c:rods/wooden", + "X": "#c:strings" }, "pattern": [ " #X", diff --git a/src/main/generated/data/minecraft/recipe/brown_banner.json b/src/main/generated/data/minecraft/recipe/brown_banner.json index b3b8c24a19..5394a3d33c 100644 --- a/src/main/generated/data/minecraft/recipe/brown_banner.json +++ b/src/main/generated/data/minecraft/recipe/brown_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:brown_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:brown_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/brush.json b/src/main/generated/data/minecraft/recipe/brush.json index ff366537c6..4fc5863cee 100644 --- a/src/main/generated/data/minecraft/recipe/brush.json +++ b/src/main/generated/data/minecraft/recipe/brush.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:ingots/copper" - }, - "I": { - "tag": "c:rods/wooden" - }, - "X": { - "item": "minecraft:feather" - } + "#": "#c:ingots/copper", + "I": "#c:rods/wooden", + "X": "minecraft:feather" }, "pattern": [ "X", diff --git a/src/main/generated/data/minecraft/recipe/bucket.json b/src/main/generated/data/minecraft/recipe/bucket.json index 6da8ba3ded..692ea8b728 100644 --- a/src/main/generated/data/minecraft/recipe/bucket.json +++ b/src/main/generated/data/minecraft/recipe/bucket.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "# #", diff --git a/src/main/generated/data/minecraft/recipe/bundle.json b/src/main/generated/data/minecraft/recipe/bundle.json new file mode 100644 index 0000000000..fb9cad8657 --- /dev/null +++ b/src/main/generated/data/minecraft/recipe/bundle.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "#": "minecraft:leather", + "-": "#c:strings" + }, + "pattern": [ + "-", + "#" + ], + "result": { + "count": 1, + "id": "minecraft:bundle" + } +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/calibrated_sculk_sensor.json b/src/main/generated/data/minecraft/recipe/calibrated_sculk_sensor.json index 5cb919ad6c..7b748c17a2 100644 --- a/src/main/generated/data/minecraft/recipe/calibrated_sculk_sensor.json +++ b/src/main/generated/data/minecraft/recipe/calibrated_sculk_sensor.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:gems/amethyst" - }, - "X": { - "item": "minecraft:sculk_sensor" - } + "#": "#c:gems/amethyst", + "X": "minecraft:sculk_sensor" }, "pattern": [ " # ", diff --git a/src/main/generated/data/minecraft/recipe/campfire.json b/src/main/generated/data/minecraft/recipe/campfire.json index de8dffe49a..fd2f337523 100644 --- a/src/main/generated/data/minecraft/recipe/campfire.json +++ b/src/main/generated/data/minecraft/recipe/campfire.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "C": { - "tag": "minecraft:coals" - }, - "L": { - "tag": "minecraft:logs" - }, - "S": { - "tag": "c:rods/wooden" - } + "C": "#minecraft:coals", + "L": "#minecraft:logs", + "S": "#c:rods/wooden" }, "pattern": [ " S ", diff --git a/src/main/generated/data/minecraft/recipe/candle.json b/src/main/generated/data/minecraft/recipe/candle.json index c19d2b0e7b..6cb6864e6b 100644 --- a/src/main/generated/data/minecraft/recipe/candle.json +++ b/src/main/generated/data/minecraft/recipe/candle.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "H": { - "item": "minecraft:honeycomb" - }, - "S": { - "tag": "c:strings" - } + "H": "minecraft:honeycomb", + "S": "#c:strings" }, "pattern": [ "S", diff --git a/src/main/generated/data/minecraft/recipe/cauldron.json b/src/main/generated/data/minecraft/recipe/cauldron.json index 9fbb8b5af2..101a0b54d6 100644 --- a/src/main/generated/data/minecraft/recipe/cauldron.json +++ b/src/main/generated/data/minecraft/recipe/cauldron.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "# #", diff --git a/src/main/generated/data/minecraft/recipe/chain.json b/src/main/generated/data/minecraft/recipe/chain.json index f30618f0ba..bf70b9d5e3 100644 --- a/src/main/generated/data/minecraft/recipe/chain.json +++ b/src/main/generated/data/minecraft/recipe/chain.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "I": { - "tag": "c:ingots/iron" - }, - "N": { - "item": "minecraft:iron_nugget" - } + "I": "#c:ingots/iron", + "N": "minecraft:iron_nugget" }, "pattern": [ "N", diff --git a/src/main/generated/data/minecraft/recipe/cherry_chest_boat.json b/src/main/generated/data/minecraft/recipe/cherry_chest_boat.json index ee739ec5a2..df03568c18 100644 --- a/src/main/generated/data/minecraft/recipe/cherry_chest_boat.json +++ b/src/main/generated/data/minecraft/recipe/cherry_chest_boat.json @@ -3,12 +3,8 @@ "category": "misc", "group": "chest_boat", "ingredients": [ - { - "tag": "c:chests/wooden" - }, - { - "item": "minecraft:cherry_boat" - } + "#c:chests/wooden", + "minecraft:cherry_boat" ], "result": { "count": 1, diff --git a/src/main/generated/data/minecraft/recipe/cherry_fence.json b/src/main/generated/data/minecraft/recipe/cherry_fence.json index c199386881..9866480fe0 100644 --- a/src/main/generated/data/minecraft/recipe/cherry_fence.json +++ b/src/main/generated/data/minecraft/recipe/cherry_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:cherry_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:cherry_planks" }, "pattern": [ "W#W", diff --git a/src/main/generated/data/minecraft/recipe/cherry_fence_gate.json b/src/main/generated/data/minecraft/recipe/cherry_fence_gate.json index d3f7509557..7ad275d012 100644 --- a/src/main/generated/data/minecraft/recipe/cherry_fence_gate.json +++ b/src/main/generated/data/minecraft/recipe/cherry_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:cherry_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:cherry_planks" }, "pattern": [ "#W#", diff --git a/src/main/generated/data/minecraft/recipe/cherry_sign.json b/src/main/generated/data/minecraft/recipe/cherry_sign.json index fbd15b6ef9..000659bd4a 100644 --- a/src/main/generated/data/minecraft/recipe/cherry_sign.json +++ b/src/main/generated/data/minecraft/recipe/cherry_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:cherry_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:cherry_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/chest_minecart.json b/src/main/generated/data/minecraft/recipe/chest_minecart.json index bbf4896a30..9da9c5c21d 100644 --- a/src/main/generated/data/minecraft/recipe/chest_minecart.json +++ b/src/main/generated/data/minecraft/recipe/chest_minecart.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shapeless", "category": "misc", "ingredients": [ - { - "tag": "c:chests/wooden" - }, - { - "item": "minecraft:minecart" - } + "#c:chests/wooden", + "minecraft:minecart" ], "result": { "count": 1, diff --git a/src/main/generated/data/minecraft/recipe/clock.json b/src/main/generated/data/minecraft/recipe/clock.json index 276fe557ef..0ffa5dfe00 100644 --- a/src/main/generated/data/minecraft/recipe/clock.json +++ b/src/main/generated/data/minecraft/recipe/clock.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:ingots/gold" - }, - "X": { - "item": "minecraft:redstone" - } + "#": "#c:ingots/gold", + "X": "minecraft:redstone" }, "pattern": [ " # ", diff --git a/src/main/generated/data/minecraft/recipe/coast_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/coast_armor_trim_smithing_template.json index 14f50222b4..8064692610 100644 --- a/src/main/generated/data/minecraft/recipe/coast_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/coast_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "tag": "forge:cobblestone/normal" - }, - "S": { - "item": "minecraft:coast_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "#forge:cobblestone/normal", + "S": "minecraft:coast_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/compass.json b/src/main/generated/data/minecraft/recipe/compass.json index 3c7cbcb015..89310bdf95 100644 --- a/src/main/generated/data/minecraft/recipe/compass.json +++ b/src/main/generated/data/minecraft/recipe/compass.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:ingots/iron" - }, - "X": { - "item": "minecraft:redstone" - } + "#": "#c:ingots/iron", + "X": "minecraft:redstone" }, "pattern": [ " # ", diff --git a/src/main/generated/data/minecraft/recipe/copper_door.json b/src/main/generated/data/minecraft/recipe/copper_door.json index b4010399b8..544440c5c7 100644 --- a/src/main/generated/data/minecraft/recipe/copper_door.json +++ b/src/main/generated/data/minecraft/recipe/copper_door.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/copper" - } + "#": "#c:ingots/copper" }, "pattern": [ "##", diff --git a/src/main/generated/data/minecraft/recipe/copper_trapdoor.json b/src/main/generated/data/minecraft/recipe/copper_trapdoor.json index 2e8d8efe09..2a117e7c5b 100644 --- a/src/main/generated/data/minecraft/recipe/copper_trapdoor.json +++ b/src/main/generated/data/minecraft/recipe/copper_trapdoor.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/copper" - } + "#": "#c:ingots/copper" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/crafter.json b/src/main/generated/data/minecraft/recipe/crafter.json index b01e9c2509..8db88e0466 100644 --- a/src/main/generated/data/minecraft/recipe/crafter.json +++ b/src/main/generated/data/minecraft/recipe/crafter.json @@ -2,18 +2,10 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/iron" - }, - "C": { - "item": "minecraft:crafting_table" - }, - "D": { - "item": "minecraft:dropper" - }, - "R": { - "item": "minecraft:redstone" - } + "#": "#c:ingots/iron", + "C": "minecraft:crafting_table", + "D": "minecraft:dropper", + "R": "minecraft:redstone" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/crimson_fence.json b/src/main/generated/data/minecraft/recipe/crimson_fence.json index 7b9e174282..20e9d8a6e3 100644 --- a/src/main/generated/data/minecraft/recipe/crimson_fence.json +++ b/src/main/generated/data/minecraft/recipe/crimson_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:crimson_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:crimson_planks" }, "pattern": [ "W#W", diff --git a/src/main/generated/data/minecraft/recipe/crimson_fence_gate.json b/src/main/generated/data/minecraft/recipe/crimson_fence_gate.json index 6953799156..fdbdfa0f4b 100644 --- a/src/main/generated/data/minecraft/recipe/crimson_fence_gate.json +++ b/src/main/generated/data/minecraft/recipe/crimson_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:crimson_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:crimson_planks" }, "pattern": [ "#W#", diff --git a/src/main/generated/data/minecraft/recipe/crimson_sign.json b/src/main/generated/data/minecraft/recipe/crimson_sign.json index 3bb6d2cd40..b175242019 100644 --- a/src/main/generated/data/minecraft/recipe/crimson_sign.json +++ b/src/main/generated/data/minecraft/recipe/crimson_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:crimson_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:crimson_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/crossbow.json b/src/main/generated/data/minecraft/recipe/crossbow.json index 87d3fb5baf..96364225e1 100644 --- a/src/main/generated/data/minecraft/recipe/crossbow.json +++ b/src/main/generated/data/minecraft/recipe/crossbow.json @@ -2,18 +2,10 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "$": { - "item": "minecraft:tripwire_hook" - }, - "&": { - "tag": "c:ingots/iron" - }, - "~": { - "tag": "c:strings" - } + "#": "#c:rods/wooden", + "$": "minecraft:tripwire_hook", + "&": "#c:ingots/iron", + "~": "#c:strings" }, "pattern": [ "#&#", diff --git a/src/main/generated/data/minecraft/recipe/cyan_banner.json b/src/main/generated/data/minecraft/recipe/cyan_banner.json index 7c029672c6..2efc2367e5 100644 --- a/src/main/generated/data/minecraft/recipe/cyan_banner.json +++ b/src/main/generated/data/minecraft/recipe/cyan_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:cyan_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:cyan_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/dark_oak_chest_boat.json b/src/main/generated/data/minecraft/recipe/dark_oak_chest_boat.json index aae00295f7..dcdf6da42f 100644 --- a/src/main/generated/data/minecraft/recipe/dark_oak_chest_boat.json +++ b/src/main/generated/data/minecraft/recipe/dark_oak_chest_boat.json @@ -3,12 +3,8 @@ "category": "misc", "group": "chest_boat", "ingredients": [ - { - "tag": "c:chests/wooden" - }, - { - "item": "minecraft:dark_oak_boat" - } + "#c:chests/wooden", + "minecraft:dark_oak_boat" ], "result": { "count": 1, diff --git a/src/main/generated/data/minecraft/recipe/dark_oak_fence.json b/src/main/generated/data/minecraft/recipe/dark_oak_fence.json index ba37e3f888..d5c3933be8 100644 --- a/src/main/generated/data/minecraft/recipe/dark_oak_fence.json +++ b/src/main/generated/data/minecraft/recipe/dark_oak_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:dark_oak_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:dark_oak_planks" }, "pattern": [ "W#W", diff --git a/src/main/generated/data/minecraft/recipe/dark_oak_fence_gate.json b/src/main/generated/data/minecraft/recipe/dark_oak_fence_gate.json index b8365d4a28..d7db1861f2 100644 --- a/src/main/generated/data/minecraft/recipe/dark_oak_fence_gate.json +++ b/src/main/generated/data/minecraft/recipe/dark_oak_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:dark_oak_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:dark_oak_planks" }, "pattern": [ "#W#", diff --git a/src/main/generated/data/minecraft/recipe/dark_oak_sign.json b/src/main/generated/data/minecraft/recipe/dark_oak_sign.json index 4d53a6d24f..aeb6ace8bf 100644 --- a/src/main/generated/data/minecraft/recipe/dark_oak_sign.json +++ b/src/main/generated/data/minecraft/recipe/dark_oak_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:dark_oak_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:dark_oak_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/detector_rail.json b/src/main/generated/data/minecraft/recipe/detector_rail.json index 97238ca6e4..aa0d8b1f83 100644 --- a/src/main/generated/data/minecraft/recipe/detector_rail.json +++ b/src/main/generated/data/minecraft/recipe/detector_rail.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:stone_pressure_plate" - }, - "R": { - "item": "minecraft:redstone" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "minecraft:stone_pressure_plate", + "R": "minecraft:redstone", + "X": "#c:ingots/iron" }, "pattern": [ "X X", diff --git a/src/main/generated/data/minecraft/recipe/diamond_axe.json b/src/main/generated/data/minecraft/recipe/diamond_axe.json index 118f99e563..81cfd04879 100644 --- a/src/main/generated/data/minecraft/recipe/diamond_axe.json +++ b/src/main/generated/data/minecraft/recipe/diamond_axe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#c:rods/wooden", + "X": "#minecraft:diamond_tool_materials" }, "pattern": [ "XX", diff --git a/src/main/generated/data/minecraft/recipe/diamond_boots.json b/src/main/generated/data/minecraft/recipe/diamond_boots.json index 7d6ace85e7..38ea7f8e5d 100644 --- a/src/main/generated/data/minecraft/recipe/diamond_boots.json +++ b/src/main/generated/data/minecraft/recipe/diamond_boots.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:gems/diamond" - } + "X": "#c:gems/diamond" }, "pattern": [ "X X", diff --git a/src/main/generated/data/minecraft/recipe/diamond_chestplate.json b/src/main/generated/data/minecraft/recipe/diamond_chestplate.json index 46ad865dff..bace9a7d21 100644 --- a/src/main/generated/data/minecraft/recipe/diamond_chestplate.json +++ b/src/main/generated/data/minecraft/recipe/diamond_chestplate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:gems/diamond" - } + "X": "#c:gems/diamond" }, "pattern": [ "X X", diff --git a/src/main/generated/data/minecraft/recipe/diamond_helmet.json b/src/main/generated/data/minecraft/recipe/diamond_helmet.json index 50a88a0967..59067194a0 100644 --- a/src/main/generated/data/minecraft/recipe/diamond_helmet.json +++ b/src/main/generated/data/minecraft/recipe/diamond_helmet.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:gems/diamond" - } + "X": "#c:gems/diamond" }, "pattern": [ "XXX", diff --git a/src/main/generated/data/minecraft/recipe/diamond_hoe.json b/src/main/generated/data/minecraft/recipe/diamond_hoe.json index b2bf02dd07..6a770c0452 100644 --- a/src/main/generated/data/minecraft/recipe/diamond_hoe.json +++ b/src/main/generated/data/minecraft/recipe/diamond_hoe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#c:rods/wooden", + "X": "#minecraft:diamond_tool_materials" }, "pattern": [ "XX", diff --git a/src/main/generated/data/minecraft/recipe/diamond_leggings.json b/src/main/generated/data/minecraft/recipe/diamond_leggings.json index 5df5635836..7992a0d478 100644 --- a/src/main/generated/data/minecraft/recipe/diamond_leggings.json +++ b/src/main/generated/data/minecraft/recipe/diamond_leggings.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:gems/diamond" - } + "X": "#c:gems/diamond" }, "pattern": [ "XXX", diff --git a/src/main/generated/data/minecraft/recipe/diamond_pickaxe.json b/src/main/generated/data/minecraft/recipe/diamond_pickaxe.json index 3397993a01..bc06ce4af1 100644 --- a/src/main/generated/data/minecraft/recipe/diamond_pickaxe.json +++ b/src/main/generated/data/minecraft/recipe/diamond_pickaxe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#c:rods/wooden", + "X": "#minecraft:diamond_tool_materials" }, "pattern": [ "XXX", diff --git a/src/main/generated/data/minecraft/recipe/diamond_shovel.json b/src/main/generated/data/minecraft/recipe/diamond_shovel.json index ae4f9eb985..ff947a6fd7 100644 --- a/src/main/generated/data/minecraft/recipe/diamond_shovel.json +++ b/src/main/generated/data/minecraft/recipe/diamond_shovel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#c:rods/wooden", + "X": "#minecraft:diamond_tool_materials" }, "pattern": [ "X", diff --git a/src/main/generated/data/minecraft/recipe/diamond_sword.json b/src/main/generated/data/minecraft/recipe/diamond_sword.json index 338ca63240..cb872879e7 100644 --- a/src/main/generated/data/minecraft/recipe/diamond_sword.json +++ b/src/main/generated/data/minecraft/recipe/diamond_sword.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#c:rods/wooden", + "X": "#minecraft:diamond_tool_materials" }, "pattern": [ "X", diff --git a/src/main/generated/data/minecraft/recipe/diorite.json b/src/main/generated/data/minecraft/recipe/diorite.json index 94624af531..f26df80c2f 100644 --- a/src/main/generated/data/minecraft/recipe/diorite.json +++ b/src/main/generated/data/minecraft/recipe/diorite.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "building", "key": { - "C": { - "tag": "forge:cobblestone/normal" - }, - "Q": { - "item": "minecraft:quartz" - } + "C": "#forge:cobblestone/normal", + "Q": "minecraft:quartz" }, "pattern": [ "CQ", diff --git a/src/main/generated/data/minecraft/recipe/dispenser.json b/src/main/generated/data/minecraft/recipe/dispenser.json index 2b6bdb4d0d..bcffee112c 100644 --- a/src/main/generated/data/minecraft/recipe/dispenser.json +++ b/src/main/generated/data/minecraft/recipe/dispenser.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "forge:cobblestone/normal" - }, - "R": { - "item": "minecraft:redstone" - }, - "X": { - "item": "minecraft:bow" - } + "#": "#forge:cobblestone/normal", + "R": "minecraft:redstone", + "X": "minecraft:bow" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/dropper.json b/src/main/generated/data/minecraft/recipe/dropper.json index 79fb49ce4d..27ccdd1489 100644 --- a/src/main/generated/data/minecraft/recipe/dropper.json +++ b/src/main/generated/data/minecraft/recipe/dropper.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "forge:cobblestone/normal" - }, - "R": { - "item": "minecraft:redstone" - } + "#": "#forge:cobblestone/normal", + "R": "minecraft:redstone" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/dune_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/dune_armor_trim_smithing_template.json index 905e1f3f0d..a732119fe5 100644 --- a/src/main/generated/data/minecraft/recipe/dune_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/dune_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:sandstone" - }, - "S": { - "item": "minecraft:dune_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:sandstone", + "S": "minecraft:dune_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/enchanting_table.json b/src/main/generated/data/minecraft/recipe/enchanting_table.json index 0b202c954e..a18e62aa60 100644 --- a/src/main/generated/data/minecraft/recipe/enchanting_table.json +++ b/src/main/generated/data/minecraft/recipe/enchanting_table.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:obsidian" - }, - "B": { - "item": "minecraft:book" - }, - "D": { - "tag": "c:gems/diamond" - } + "#": "minecraft:obsidian", + "B": "minecraft:book", + "D": "#c:gems/diamond" }, "pattern": [ " B ", diff --git a/src/main/generated/data/minecraft/recipe/eye_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/eye_armor_trim_smithing_template.json index f4183152ba..24c0e2e4ad 100644 --- a/src/main/generated/data/minecraft/recipe/eye_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/eye_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:end_stone" - }, - "S": { - "item": "minecraft:eye_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:end_stone", + "S": "minecraft:eye_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/fishing_rod.json b/src/main/generated/data/minecraft/recipe/fishing_rod.json index 72690672d3..8308c1ef46 100644 --- a/src/main/generated/data/minecraft/recipe/fishing_rod.json +++ b/src/main/generated/data/minecraft/recipe/fishing_rod.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:strings" - } + "#": "#c:rods/wooden", + "X": "#c:strings" }, "pattern": [ " #", diff --git a/src/main/generated/data/minecraft/recipe/flint_and_steel.json b/src/main/generated/data/minecraft/recipe/flint_and_steel.json index c1ecbca55f..291b18605e 100644 --- a/src/main/generated/data/minecraft/recipe/flint_and_steel.json +++ b/src/main/generated/data/minecraft/recipe/flint_and_steel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shapeless", "category": "equipment", "ingredients": [ - { - "tag": "c:ingots/iron" - }, - { - "item": "minecraft:flint" - } + "#c:ingots/iron", + "minecraft:flint" ], "result": { "count": 1, diff --git a/src/main/generated/data/minecraft/recipe/flow_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/flow_armor_trim_smithing_template.json index 3b8d02a56d..958fdf6b4c 100644 --- a/src/main/generated/data/minecraft/recipe/flow_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/flow_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:breeze_rod" - }, - "S": { - "item": "minecraft:flow_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:breeze_rod", + "S": "minecraft:flow_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/golden_apple.json b/src/main/generated/data/minecraft/recipe/golden_apple.json index 6839d31d1e..0a029564aa 100644 --- a/src/main/generated/data/minecraft/recipe/golden_apple.json +++ b/src/main/generated/data/minecraft/recipe/golden_apple.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/gold" - }, - "X": { - "item": "minecraft:apple" - } + "#": "#c:ingots/gold", + "X": "minecraft:apple" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/golden_axe.json b/src/main/generated/data/minecraft/recipe/golden_axe.json index ed95ebdd0a..aad3355e76 100644 --- a/src/main/generated/data/minecraft/recipe/golden_axe.json +++ b/src/main/generated/data/minecraft/recipe/golden_axe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "X": "#minecraft:gold_tool_materials" }, "pattern": [ "XX", diff --git a/src/main/generated/data/minecraft/recipe/golden_boots.json b/src/main/generated/data/minecraft/recipe/golden_boots.json index 0b9010aa3c..baede9b2b0 100644 --- a/src/main/generated/data/minecraft/recipe/golden_boots.json +++ b/src/main/generated/data/minecraft/recipe/golden_boots.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/gold" - } + "X": "#c:ingots/gold" }, "pattern": [ "X X", diff --git a/src/main/generated/data/minecraft/recipe/golden_chestplate.json b/src/main/generated/data/minecraft/recipe/golden_chestplate.json index edd79c9908..44610c5b75 100644 --- a/src/main/generated/data/minecraft/recipe/golden_chestplate.json +++ b/src/main/generated/data/minecraft/recipe/golden_chestplate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/gold" - } + "X": "#c:ingots/gold" }, "pattern": [ "X X", diff --git a/src/main/generated/data/minecraft/recipe/golden_helmet.json b/src/main/generated/data/minecraft/recipe/golden_helmet.json index f275fa7514..77e0c12be8 100644 --- a/src/main/generated/data/minecraft/recipe/golden_helmet.json +++ b/src/main/generated/data/minecraft/recipe/golden_helmet.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/gold" - } + "X": "#c:ingots/gold" }, "pattern": [ "XXX", diff --git a/src/main/generated/data/minecraft/recipe/golden_hoe.json b/src/main/generated/data/minecraft/recipe/golden_hoe.json index 6a305f1b18..6a31db7ec1 100644 --- a/src/main/generated/data/minecraft/recipe/golden_hoe.json +++ b/src/main/generated/data/minecraft/recipe/golden_hoe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "X": "#minecraft:gold_tool_materials" }, "pattern": [ "XX", diff --git a/src/main/generated/data/minecraft/recipe/golden_leggings.json b/src/main/generated/data/minecraft/recipe/golden_leggings.json index 54c8ae061e..6ffc3edd1c 100644 --- a/src/main/generated/data/minecraft/recipe/golden_leggings.json +++ b/src/main/generated/data/minecraft/recipe/golden_leggings.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/gold" - } + "X": "#c:ingots/gold" }, "pattern": [ "XXX", diff --git a/src/main/generated/data/minecraft/recipe/golden_pickaxe.json b/src/main/generated/data/minecraft/recipe/golden_pickaxe.json index be94e94d06..7e88522f3e 100644 --- a/src/main/generated/data/minecraft/recipe/golden_pickaxe.json +++ b/src/main/generated/data/minecraft/recipe/golden_pickaxe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "X": "#minecraft:gold_tool_materials" }, "pattern": [ "XXX", diff --git a/src/main/generated/data/minecraft/recipe/golden_shovel.json b/src/main/generated/data/minecraft/recipe/golden_shovel.json index b71a44cb47..ed7b535236 100644 --- a/src/main/generated/data/minecraft/recipe/golden_shovel.json +++ b/src/main/generated/data/minecraft/recipe/golden_shovel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "X": "#minecraft:gold_tool_materials" }, "pattern": [ "X", diff --git a/src/main/generated/data/minecraft/recipe/golden_sword.json b/src/main/generated/data/minecraft/recipe/golden_sword.json index fdfc713b40..a400bb8117 100644 --- a/src/main/generated/data/minecraft/recipe/golden_sword.json +++ b/src/main/generated/data/minecraft/recipe/golden_sword.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "X": "#minecraft:gold_tool_materials" }, "pattern": [ "X", diff --git a/src/main/generated/data/minecraft/recipe/gray_banner.json b/src/main/generated/data/minecraft/recipe/gray_banner.json index 9a36e40aed..75e5ac3ebe 100644 --- a/src/main/generated/data/minecraft/recipe/gray_banner.json +++ b/src/main/generated/data/minecraft/recipe/gray_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:gray_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:gray_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/green_banner.json b/src/main/generated/data/minecraft/recipe/green_banner.json index 3960ffd83b..e18d67a1f3 100644 --- a/src/main/generated/data/minecraft/recipe/green_banner.json +++ b/src/main/generated/data/minecraft/recipe/green_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:green_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:green_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/grindstone.json b/src/main/generated/data/minecraft/recipe/grindstone.json index 234b5a8e4f..5edf22f750 100644 --- a/src/main/generated/data/minecraft/recipe/grindstone.json +++ b/src/main/generated/data/minecraft/recipe/grindstone.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "minecraft:planks" - }, - "-": { - "item": "minecraft:stone_slab" - }, - "I": { - "tag": "c:rods/wooden" - } + "#": "#minecraft:planks", + "-": "minecraft:stone_slab", + "I": "#c:rods/wooden" }, "pattern": [ "I-I", diff --git a/src/main/generated/data/minecraft/recipe/heavy_weighted_pressure_plate.json b/src/main/generated/data/minecraft/recipe/heavy_weighted_pressure_plate.json index ac9cd700dc..e4c401e38e 100644 --- a/src/main/generated/data/minecraft/recipe/heavy_weighted_pressure_plate.json +++ b/src/main/generated/data/minecraft/recipe/heavy_weighted_pressure_plate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "##" diff --git a/src/main/generated/data/minecraft/recipe/hopper.json b/src/main/generated/data/minecraft/recipe/hopper.json index 09424bfd07..7cbd773bf6 100644 --- a/src/main/generated/data/minecraft/recipe/hopper.json +++ b/src/main/generated/data/minecraft/recipe/hopper.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "C": { - "tag": "c:chests/wooden" - }, - "I": { - "tag": "c:ingots/iron" - } + "C": "#c:chests/wooden", + "I": "#c:ingots/iron" }, "pattern": [ "I I", diff --git a/src/main/generated/data/minecraft/recipe/host_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/host_armor_trim_smithing_template.json index f84de52ad6..ae84d48cc6 100644 --- a/src/main/generated/data/minecraft/recipe/host_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/host_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:terracotta" - }, - "S": { - "item": "minecraft:host_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:terracotta", + "S": "minecraft:host_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/iron_axe.json b/src/main/generated/data/minecraft/recipe/iron_axe.json index 950fa6ac7a..535479a2ba 100644 --- a/src/main/generated/data/minecraft/recipe/iron_axe.json +++ b/src/main/generated/data/minecraft/recipe/iron_axe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#minecraft:iron_tool_materials" }, "pattern": [ "XX", diff --git a/src/main/generated/data/minecraft/recipe/iron_bars.json b/src/main/generated/data/minecraft/recipe/iron_bars.json index 28be431fc6..e33ecdcc4f 100644 --- a/src/main/generated/data/minecraft/recipe/iron_bars.json +++ b/src/main/generated/data/minecraft/recipe/iron_bars.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/iron_boots.json b/src/main/generated/data/minecraft/recipe/iron_boots.json index f489f382e6..459f753384 100644 --- a/src/main/generated/data/minecraft/recipe/iron_boots.json +++ b/src/main/generated/data/minecraft/recipe/iron_boots.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/iron" - } + "X": "#c:ingots/iron" }, "pattern": [ "X X", diff --git a/src/main/generated/data/minecraft/recipe/iron_chestplate.json b/src/main/generated/data/minecraft/recipe/iron_chestplate.json index 67f70bc19c..42ac070a95 100644 --- a/src/main/generated/data/minecraft/recipe/iron_chestplate.json +++ b/src/main/generated/data/minecraft/recipe/iron_chestplate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/iron" - } + "X": "#c:ingots/iron" }, "pattern": [ "X X", diff --git a/src/main/generated/data/minecraft/recipe/iron_door.json b/src/main/generated/data/minecraft/recipe/iron_door.json index be3bbbf4da..2155da533f 100644 --- a/src/main/generated/data/minecraft/recipe/iron_door.json +++ b/src/main/generated/data/minecraft/recipe/iron_door.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "##", diff --git a/src/main/generated/data/minecraft/recipe/iron_helmet.json b/src/main/generated/data/minecraft/recipe/iron_helmet.json index 4b7326c79f..67b4fa7229 100644 --- a/src/main/generated/data/minecraft/recipe/iron_helmet.json +++ b/src/main/generated/data/minecraft/recipe/iron_helmet.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/iron" - } + "X": "#c:ingots/iron" }, "pattern": [ "XXX", diff --git a/src/main/generated/data/minecraft/recipe/iron_hoe.json b/src/main/generated/data/minecraft/recipe/iron_hoe.json index e175c35d0c..65fb6202de 100644 --- a/src/main/generated/data/minecraft/recipe/iron_hoe.json +++ b/src/main/generated/data/minecraft/recipe/iron_hoe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#minecraft:iron_tool_materials" }, "pattern": [ "XX", diff --git a/src/main/generated/data/minecraft/recipe/iron_leggings.json b/src/main/generated/data/minecraft/recipe/iron_leggings.json index db1ad0850c..ca4c45bc62 100644 --- a/src/main/generated/data/minecraft/recipe/iron_leggings.json +++ b/src/main/generated/data/minecraft/recipe/iron_leggings.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/iron" - } + "X": "#c:ingots/iron" }, "pattern": [ "XXX", diff --git a/src/main/generated/data/minecraft/recipe/iron_pickaxe.json b/src/main/generated/data/minecraft/recipe/iron_pickaxe.json index f829c9df56..169d8f7094 100644 --- a/src/main/generated/data/minecraft/recipe/iron_pickaxe.json +++ b/src/main/generated/data/minecraft/recipe/iron_pickaxe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#minecraft:iron_tool_materials" }, "pattern": [ "XXX", diff --git a/src/main/generated/data/minecraft/recipe/iron_shovel.json b/src/main/generated/data/minecraft/recipe/iron_shovel.json index 5a11203af5..b436766778 100644 --- a/src/main/generated/data/minecraft/recipe/iron_shovel.json +++ b/src/main/generated/data/minecraft/recipe/iron_shovel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#minecraft:iron_tool_materials" }, "pattern": [ "X", diff --git a/src/main/generated/data/minecraft/recipe/iron_sword.json b/src/main/generated/data/minecraft/recipe/iron_sword.json index 6f4c0a46cd..8c909bfa56 100644 --- a/src/main/generated/data/minecraft/recipe/iron_sword.json +++ b/src/main/generated/data/minecraft/recipe/iron_sword.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#minecraft:iron_tool_materials" }, "pattern": [ "X", diff --git a/src/main/generated/data/minecraft/recipe/iron_trapdoor.json b/src/main/generated/data/minecraft/recipe/iron_trapdoor.json index 45d3357442..a64774b455 100644 --- a/src/main/generated/data/minecraft/recipe/iron_trapdoor.json +++ b/src/main/generated/data/minecraft/recipe/iron_trapdoor.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "##", diff --git a/src/main/generated/data/minecraft/recipe/item_frame.json b/src/main/generated/data/minecraft/recipe/item_frame.json index f73e86feb5..9daf39f512 100644 --- a/src/main/generated/data/minecraft/recipe/item_frame.json +++ b/src/main/generated/data/minecraft/recipe/item_frame.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "item": "minecraft:leather" - } + "#": "#c:rods/wooden", + "X": "minecraft:leather" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/jukebox.json b/src/main/generated/data/minecraft/recipe/jukebox.json index 08f3d3b4d3..c7c109d95f 100644 --- a/src/main/generated/data/minecraft/recipe/jukebox.json +++ b/src/main/generated/data/minecraft/recipe/jukebox.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "minecraft:planks" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#minecraft:planks", + "X": "#c:gems/diamond" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/jungle_chest_boat.json b/src/main/generated/data/minecraft/recipe/jungle_chest_boat.json index 43b367f49d..cab5728082 100644 --- a/src/main/generated/data/minecraft/recipe/jungle_chest_boat.json +++ b/src/main/generated/data/minecraft/recipe/jungle_chest_boat.json @@ -3,12 +3,8 @@ "category": "misc", "group": "chest_boat", "ingredients": [ - { - "tag": "c:chests/wooden" - }, - { - "item": "minecraft:jungle_boat" - } + "#c:chests/wooden", + "minecraft:jungle_boat" ], "result": { "count": 1, diff --git a/src/main/generated/data/minecraft/recipe/jungle_fence.json b/src/main/generated/data/minecraft/recipe/jungle_fence.json index b49a38c19a..dc919dea44 100644 --- a/src/main/generated/data/minecraft/recipe/jungle_fence.json +++ b/src/main/generated/data/minecraft/recipe/jungle_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:jungle_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:jungle_planks" }, "pattern": [ "W#W", diff --git a/src/main/generated/data/minecraft/recipe/jungle_fence_gate.json b/src/main/generated/data/minecraft/recipe/jungle_fence_gate.json index a1dcfbde01..3f3ee533ed 100644 --- a/src/main/generated/data/minecraft/recipe/jungle_fence_gate.json +++ b/src/main/generated/data/minecraft/recipe/jungle_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:jungle_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:jungle_planks" }, "pattern": [ "#W#", diff --git a/src/main/generated/data/minecraft/recipe/jungle_sign.json b/src/main/generated/data/minecraft/recipe/jungle_sign.json index 713c47d1fa..9c22e2bcd1 100644 --- a/src/main/generated/data/minecraft/recipe/jungle_sign.json +++ b/src/main/generated/data/minecraft/recipe/jungle_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:jungle_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:jungle_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/ladder.json b/src/main/generated/data/minecraft/recipe/ladder.json index 8d64f336a8..0aefdd0268 100644 --- a/src/main/generated/data/minecraft/recipe/ladder.json +++ b/src/main/generated/data/minecraft/recipe/ladder.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - } + "#": "#c:rods/wooden" }, "pattern": [ "# #", diff --git a/src/main/generated/data/minecraft/recipe/lead.json b/src/main/generated/data/minecraft/recipe/lead.json index 57ca6d0bbc..a48100d61a 100644 --- a/src/main/generated/data/minecraft/recipe/lead.json +++ b/src/main/generated/data/minecraft/recipe/lead.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "O": { - "item": "minecraft:slime_ball" - }, - "~": { - "tag": "c:strings" - } + "O": "minecraft:slime_ball", + "~": "#c:strings" }, "pattern": [ "~~ ", diff --git a/src/main/generated/data/minecraft/recipe/lever.json b/src/main/generated/data/minecraft/recipe/lever.json index 1c3db9035f..f0cc6c54d5 100644 --- a/src/main/generated/data/minecraft/recipe/lever.json +++ b/src/main/generated/data/minecraft/recipe/lever.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "forge:cobblestone/normal" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "#forge:cobblestone/normal", + "X": "#c:rods/wooden" }, "pattern": [ "X", diff --git a/src/main/generated/data/minecraft/recipe/light_blue_banner.json b/src/main/generated/data/minecraft/recipe/light_blue_banner.json index 1fb0a66d80..b0fa080366 100644 --- a/src/main/generated/data/minecraft/recipe/light_blue_banner.json +++ b/src/main/generated/data/minecraft/recipe/light_blue_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:light_blue_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:light_blue_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/light_gray_banner.json b/src/main/generated/data/minecraft/recipe/light_gray_banner.json index 35d93c6693..7a16563cc0 100644 --- a/src/main/generated/data/minecraft/recipe/light_gray_banner.json +++ b/src/main/generated/data/minecraft/recipe/light_gray_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:light_gray_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:light_gray_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/light_weighted_pressure_plate.json b/src/main/generated/data/minecraft/recipe/light_weighted_pressure_plate.json index 0d6eec2360..ef08a13e3f 100644 --- a/src/main/generated/data/minecraft/recipe/light_weighted_pressure_plate.json +++ b/src/main/generated/data/minecraft/recipe/light_weighted_pressure_plate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/gold" - } + "#": "#c:ingots/gold" }, "pattern": [ "##" diff --git a/src/main/generated/data/minecraft/recipe/lightning_rod.json b/src/main/generated/data/minecraft/recipe/lightning_rod.json index 5a2186f659..614ed2737e 100644 --- a/src/main/generated/data/minecraft/recipe/lightning_rod.json +++ b/src/main/generated/data/minecraft/recipe/lightning_rod.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/copper" - } + "#": "#c:ingots/copper" }, "pattern": [ "#", diff --git a/src/main/generated/data/minecraft/recipe/lime_banner.json b/src/main/generated/data/minecraft/recipe/lime_banner.json index c076add05b..49b26aba09 100644 --- a/src/main/generated/data/minecraft/recipe/lime_banner.json +++ b/src/main/generated/data/minecraft/recipe/lime_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:lime_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:lime_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/lodestone.json b/src/main/generated/data/minecraft/recipe/lodestone.json index 5d1bc8a33a..aabb2183d5 100644 --- a/src/main/generated/data/minecraft/recipe/lodestone.json +++ b/src/main/generated/data/minecraft/recipe/lodestone.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/netherite" - }, - "S": { - "item": "minecraft:chiseled_stone_bricks" - } + "#": "#c:ingots/netherite", + "S": "minecraft:chiseled_stone_bricks" }, "pattern": [ "SSS", diff --git a/src/main/generated/data/minecraft/recipe/loom.json b/src/main/generated/data/minecraft/recipe/loom.json index 7fbb48dfe9..9b25eeb36f 100644 --- a/src/main/generated/data/minecraft/recipe/loom.json +++ b/src/main/generated/data/minecraft/recipe/loom.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "minecraft:planks" - }, - "@": { - "tag": "c:strings" - } + "#": "#minecraft:planks", + "@": "#c:strings" }, "pattern": [ "@@", diff --git a/src/main/generated/data/minecraft/recipe/magenta_banner.json b/src/main/generated/data/minecraft/recipe/magenta_banner.json index 5996580e8d..f09624c2ac 100644 --- a/src/main/generated/data/minecraft/recipe/magenta_banner.json +++ b/src/main/generated/data/minecraft/recipe/magenta_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:magenta_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:magenta_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/mangrove_chest_boat.json b/src/main/generated/data/minecraft/recipe/mangrove_chest_boat.json index 233473f202..e8bec29182 100644 --- a/src/main/generated/data/minecraft/recipe/mangrove_chest_boat.json +++ b/src/main/generated/data/minecraft/recipe/mangrove_chest_boat.json @@ -3,12 +3,8 @@ "category": "misc", "group": "chest_boat", "ingredients": [ - { - "tag": "c:chests/wooden" - }, - { - "item": "minecraft:mangrove_boat" - } + "#c:chests/wooden", + "minecraft:mangrove_boat" ], "result": { "count": 1, diff --git a/src/main/generated/data/minecraft/recipe/mangrove_fence.json b/src/main/generated/data/minecraft/recipe/mangrove_fence.json index 01d6d24181..f939810940 100644 --- a/src/main/generated/data/minecraft/recipe/mangrove_fence.json +++ b/src/main/generated/data/minecraft/recipe/mangrove_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:mangrove_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:mangrove_planks" }, "pattern": [ "W#W", diff --git a/src/main/generated/data/minecraft/recipe/mangrove_fence_gate.json b/src/main/generated/data/minecraft/recipe/mangrove_fence_gate.json index 3a0927be5e..8510a15d3f 100644 --- a/src/main/generated/data/minecraft/recipe/mangrove_fence_gate.json +++ b/src/main/generated/data/minecraft/recipe/mangrove_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:mangrove_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:mangrove_planks" }, "pattern": [ "#W#", diff --git a/src/main/generated/data/minecraft/recipe/mangrove_sign.json b/src/main/generated/data/minecraft/recipe/mangrove_sign.json index a55530fcd8..2c1eeab8a2 100644 --- a/src/main/generated/data/minecraft/recipe/mangrove_sign.json +++ b/src/main/generated/data/minecraft/recipe/mangrove_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:mangrove_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:mangrove_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/minecart.json b/src/main/generated/data/minecraft/recipe/minecart.json index 15fdd90d0e..3a407b046e 100644 --- a/src/main/generated/data/minecraft/recipe/minecart.json +++ b/src/main/generated/data/minecraft/recipe/minecart.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "# #", diff --git a/src/main/generated/data/minecraft/recipe/mossy_cobblestone_from_moss_block.json b/src/main/generated/data/minecraft/recipe/mossy_cobblestone_from_moss_block.json index 322539b081..4ee8e0a4c2 100644 --- a/src/main/generated/data/minecraft/recipe/mossy_cobblestone_from_moss_block.json +++ b/src/main/generated/data/minecraft/recipe/mossy_cobblestone_from_moss_block.json @@ -3,12 +3,8 @@ "category": "building", "group": "mossy_cobblestone", "ingredients": [ - { - "tag": "forge:cobblestone/normal" - }, - { - "item": "minecraft:moss_block" - } + "#forge:cobblestone/normal", + "minecraft:moss_block" ], "result": { "count": 1, diff --git a/src/main/generated/data/minecraft/recipe/mossy_cobblestone_from_vine.json b/src/main/generated/data/minecraft/recipe/mossy_cobblestone_from_vine.json index 51ade6cbcc..03cf0e01c5 100644 --- a/src/main/generated/data/minecraft/recipe/mossy_cobblestone_from_vine.json +++ b/src/main/generated/data/minecraft/recipe/mossy_cobblestone_from_vine.json @@ -3,12 +3,8 @@ "category": "building", "group": "mossy_cobblestone", "ingredients": [ - { - "tag": "forge:cobblestone/normal" - }, - { - "item": "minecraft:vine" - } + "#forge:cobblestone/normal", + "minecraft:vine" ], "result": { "count": 1, diff --git a/src/main/generated/data/minecraft/recipe/netherite_ingot.json b/src/main/generated/data/minecraft/recipe/netherite_ingot.json index ffa224998e..839b4ad4f5 100644 --- a/src/main/generated/data/minecraft/recipe/netherite_ingot.json +++ b/src/main/generated/data/minecraft/recipe/netherite_ingot.json @@ -3,30 +3,14 @@ "category": "misc", "group": "netherite_ingot", "ingredients": [ - { - "item": "minecraft:netherite_scrap" - }, - { - "item": "minecraft:netherite_scrap" - }, - { - "item": "minecraft:netherite_scrap" - }, - { - "item": "minecraft:netherite_scrap" - }, - { - "tag": "c:ingots/gold" - }, - { - "tag": "c:ingots/gold" - }, - { - "tag": "c:ingots/gold" - }, - { - "tag": "c:ingots/gold" - } + "minecraft:netherite_scrap", + "minecraft:netherite_scrap", + "minecraft:netherite_scrap", + "minecraft:netherite_scrap", + "#c:ingots/gold", + "#c:ingots/gold", + "#c:ingots/gold", + "#c:ingots/gold" ], "result": { "count": 1, diff --git a/src/main/generated/data/minecraft/recipe/netherite_upgrade_smithing_template.json b/src/main/generated/data/minecraft/recipe/netherite_upgrade_smithing_template.json index 44fc480189..aa03072c28 100644 --- a/src/main/generated/data/minecraft/recipe/netherite_upgrade_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/netherite_upgrade_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:netherrack" - }, - "S": { - "item": "minecraft:netherite_upgrade_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:netherrack", + "S": "minecraft:netherite_upgrade_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/oak_chest_boat.json b/src/main/generated/data/minecraft/recipe/oak_chest_boat.json index 9c1869540b..753ef643c4 100644 --- a/src/main/generated/data/minecraft/recipe/oak_chest_boat.json +++ b/src/main/generated/data/minecraft/recipe/oak_chest_boat.json @@ -3,12 +3,8 @@ "category": "misc", "group": "chest_boat", "ingredients": [ - { - "tag": "c:chests/wooden" - }, - { - "item": "minecraft:oak_boat" - } + "#c:chests/wooden", + "minecraft:oak_boat" ], "result": { "count": 1, diff --git a/src/main/generated/data/minecraft/recipe/oak_fence.json b/src/main/generated/data/minecraft/recipe/oak_fence.json index 3227fa2bc7..b3684fd871 100644 --- a/src/main/generated/data/minecraft/recipe/oak_fence.json +++ b/src/main/generated/data/minecraft/recipe/oak_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:oak_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:oak_planks" }, "pattern": [ "W#W", diff --git a/src/main/generated/data/minecraft/recipe/oak_fence_gate.json b/src/main/generated/data/minecraft/recipe/oak_fence_gate.json index 45923171d8..36941138d7 100644 --- a/src/main/generated/data/minecraft/recipe/oak_fence_gate.json +++ b/src/main/generated/data/minecraft/recipe/oak_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:oak_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:oak_planks" }, "pattern": [ "#W#", diff --git a/src/main/generated/data/minecraft/recipe/oak_sign.json b/src/main/generated/data/minecraft/recipe/oak_sign.json index 618d6d414a..1692e49e39 100644 --- a/src/main/generated/data/minecraft/recipe/oak_sign.json +++ b/src/main/generated/data/minecraft/recipe/oak_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:oak_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:oak_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/observer.json b/src/main/generated/data/minecraft/recipe/observer.json index 9f73b3a1c9..435f76840d 100644 --- a/src/main/generated/data/minecraft/recipe/observer.json +++ b/src/main/generated/data/minecraft/recipe/observer.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "forge:cobblestone/normal" - }, - "Q": { - "item": "minecraft:quartz" - }, - "R": { - "item": "minecraft:redstone" - } + "#": "#forge:cobblestone/normal", + "Q": "minecraft:quartz", + "R": "minecraft:redstone" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/orange_banner.json b/src/main/generated/data/minecraft/recipe/orange_banner.json index f2f3b03d6c..8bbc0dbf42 100644 --- a/src/main/generated/data/minecraft/recipe/orange_banner.json +++ b/src/main/generated/data/minecraft/recipe/orange_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:orange_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:orange_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/painting.json b/src/main/generated/data/minecraft/recipe/painting.json index df1b6d324d..64b32014dc 100644 --- a/src/main/generated/data/minecraft/recipe/painting.json +++ b/src/main/generated/data/minecraft/recipe/painting.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:wool" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wool" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/pink_banner.json b/src/main/generated/data/minecraft/recipe/pink_banner.json index 951e77cedd..4fd7901e5d 100644 --- a/src/main/generated/data/minecraft/recipe/pink_banner.json +++ b/src/main/generated/data/minecraft/recipe/pink_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:pink_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:pink_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/piston.json b/src/main/generated/data/minecraft/recipe/piston.json index 52bd6b7e15..5b7ddd117c 100644 --- a/src/main/generated/data/minecraft/recipe/piston.json +++ b/src/main/generated/data/minecraft/recipe/piston.json @@ -2,18 +2,10 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "forge:cobblestone/normal" - }, - "R": { - "item": "minecraft:redstone" - }, - "T": { - "tag": "minecraft:planks" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#forge:cobblestone/normal", + "R": "minecraft:redstone", + "T": "#minecraft:planks", + "X": "#c:ingots/iron" }, "pattern": [ "TTT", diff --git a/src/main/generated/data/minecraft/recipe/polished_deepslate.json b/src/main/generated/data/minecraft/recipe/polished_deepslate.json index 057b63d86e..3fb3c80730 100644 --- a/src/main/generated/data/minecraft/recipe/polished_deepslate.json +++ b/src/main/generated/data/minecraft/recipe/polished_deepslate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "building", "key": { - "S": { - "tag": "forge:cobblestone/deepslate" - } + "S": "#forge:cobblestone/deepslate" }, "pattern": [ "SS", diff --git a/src/main/generated/data/minecraft/recipe/powered_rail.json b/src/main/generated/data/minecraft/recipe/powered_rail.json index 97f3e17964..40d834f692 100644 --- a/src/main/generated/data/minecraft/recipe/powered_rail.json +++ b/src/main/generated/data/minecraft/recipe/powered_rail.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "R": { - "item": "minecraft:redstone" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "R": "minecraft:redstone", + "X": "#c:ingots/gold" }, "pattern": [ "X X", diff --git a/src/main/generated/data/minecraft/recipe/purple_banner.json b/src/main/generated/data/minecraft/recipe/purple_banner.json index 5475bffc70..ed4b36c136 100644 --- a/src/main/generated/data/minecraft/recipe/purple_banner.json +++ b/src/main/generated/data/minecraft/recipe/purple_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:purple_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:purple_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/rail.json b/src/main/generated/data/minecraft/recipe/rail.json index 481af10ee3..b9ed74f2f2 100644 --- a/src/main/generated/data/minecraft/recipe/rail.json +++ b/src/main/generated/data/minecraft/recipe/rail.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#c:ingots/iron" }, "pattern": [ "X X", diff --git a/src/main/generated/data/minecraft/recipe/raiser_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/raiser_armor_trim_smithing_template.json index 97a148d159..f49dd8b54a 100644 --- a/src/main/generated/data/minecraft/recipe/raiser_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/raiser_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:terracotta" - }, - "S": { - "item": "minecraft:raiser_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:terracotta", + "S": "minecraft:raiser_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/red_banner.json b/src/main/generated/data/minecraft/recipe/red_banner.json index 89b92a5470..9b0643110e 100644 --- a/src/main/generated/data/minecraft/recipe/red_banner.json +++ b/src/main/generated/data/minecraft/recipe/red_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:red_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:red_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/redstone_torch.json b/src/main/generated/data/minecraft/recipe/redstone_torch.json index 378c0d7b88..ea402cb6e4 100644 --- a/src/main/generated/data/minecraft/recipe/redstone_torch.json +++ b/src/main/generated/data/minecraft/recipe/redstone_torch.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "item": "minecraft:redstone" - } + "#": "#c:rods/wooden", + "X": "minecraft:redstone" }, "pattern": [ "X", diff --git a/src/main/generated/data/minecraft/recipe/rib_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/rib_armor_trim_smithing_template.json index 6ec72db0dd..f99a49c84f 100644 --- a/src/main/generated/data/minecraft/recipe/rib_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/rib_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:netherrack" - }, - "S": { - "item": "minecraft:rib_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:netherrack", + "S": "minecraft:rib_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/scaffolding.json b/src/main/generated/data/minecraft/recipe/scaffolding.json index c0290aba8c..1393f3b416 100644 --- a/src/main/generated/data/minecraft/recipe/scaffolding.json +++ b/src/main/generated/data/minecraft/recipe/scaffolding.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "I": { - "item": "minecraft:bamboo" - }, - "~": { - "tag": "c:strings" - } + "I": "minecraft:bamboo", + "~": "#c:strings" }, "pattern": [ "I~I", diff --git a/src/main/generated/data/minecraft/recipe/sentry_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/sentry_armor_trim_smithing_template.json index a10dc55eba..9619e872ce 100644 --- a/src/main/generated/data/minecraft/recipe/sentry_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/sentry_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "tag": "forge:cobblestone/normal" - }, - "S": { - "item": "minecraft:sentry_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "#forge:cobblestone/normal", + "S": "minecraft:sentry_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/shaper_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/shaper_armor_trim_smithing_template.json index 980b1d2108..e1f08a5ca1 100644 --- a/src/main/generated/data/minecraft/recipe/shaper_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/shaper_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:terracotta" - }, - "S": { - "item": "minecraft:shaper_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:terracotta", + "S": "minecraft:shaper_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/shears.json b/src/main/generated/data/minecraft/recipe/shears.json index cc526718eb..ca02dfb8aa 100644 --- a/src/main/generated/data/minecraft/recipe/shears.json +++ b/src/main/generated/data/minecraft/recipe/shears.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ " #", diff --git a/src/main/generated/data/minecraft/recipe/shield.json b/src/main/generated/data/minecraft/recipe/shield.json index 46aa8fbe7d..e0cc4be9a4 100644 --- a/src/main/generated/data/minecraft/recipe/shield.json +++ b/src/main/generated/data/minecraft/recipe/shield.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "W": { - "tag": "minecraft:planks" - }, - "o": { - "tag": "c:ingots/iron" - } + "W": "#minecraft:wooden_tool_materials", + "o": "#c:ingots/iron" }, "pattern": [ "WoW", diff --git a/src/main/generated/data/minecraft/recipe/shulker_box.json b/src/main/generated/data/minecraft/recipe/shulker_box.json index cfa4fed9ea..d95b64e916 100644 --- a/src/main/generated/data/minecraft/recipe/shulker_box.json +++ b/src/main/generated/data/minecraft/recipe/shulker_box.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:chests/wooden" - }, - "-": { - "item": "minecraft:shulker_shell" - } + "#": "#c:chests/wooden", + "-": "minecraft:shulker_shell" }, "pattern": [ "-", diff --git a/src/main/generated/data/minecraft/recipe/silence_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/silence_armor_trim_smithing_template.json index d13cf955b0..26ec6d761c 100644 --- a/src/main/generated/data/minecraft/recipe/silence_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/silence_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "tag": "forge:cobblestone/deepslate" - }, - "S": { - "item": "minecraft:silence_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "#forge:cobblestone/deepslate", + "S": "minecraft:silence_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/smithing_table.json b/src/main/generated/data/minecraft/recipe/smithing_table.json index e7dadd831c..cdf474dfc5 100644 --- a/src/main/generated/data/minecraft/recipe/smithing_table.json +++ b/src/main/generated/data/minecraft/recipe/smithing_table.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "minecraft:planks" - }, - "@": { - "tag": "c:ingots/iron" - } + "#": "#minecraft:planks", + "@": "#c:ingots/iron" }, "pattern": [ "@@", diff --git a/src/main/generated/data/minecraft/recipe/snout_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/snout_armor_trim_smithing_template.json index 8aa0dd55c1..8f24674fdd 100644 --- a/src/main/generated/data/minecraft/recipe/snout_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/snout_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:blackstone" - }, - "S": { - "item": "minecraft:snout_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:blackstone", + "S": "minecraft:snout_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/soul_campfire.json b/src/main/generated/data/minecraft/recipe/soul_campfire.json index e7459aa07d..8daec84a10 100644 --- a/src/main/generated/data/minecraft/recipe/soul_campfire.json +++ b/src/main/generated/data/minecraft/recipe/soul_campfire.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "minecraft:soul_fire_base_blocks" - }, - "L": { - "tag": "minecraft:logs" - }, - "S": { - "tag": "c:rods/wooden" - } + "#": "#minecraft:soul_fire_base_blocks", + "L": "#minecraft:logs", + "S": "#c:rods/wooden" }, "pattern": [ " S ", diff --git a/src/main/generated/data/minecraft/recipe/soul_torch.json b/src/main/generated/data/minecraft/recipe/soul_torch.json index fc57b7b0d3..89fba8cfe0 100644 --- a/src/main/generated/data/minecraft/recipe/soul_torch.json +++ b/src/main/generated/data/minecraft/recipe/soul_torch.json @@ -2,19 +2,11 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "S": { - "tag": "minecraft:soul_fire_base_blocks" - }, + "#": "#c:rods/wooden", + "S": "#minecraft:soul_fire_base_blocks", "X": [ - { - "item": "minecraft:coal" - }, - { - "item": "minecraft:charcoal" - } + "minecraft:coal", + "minecraft:charcoal" ] }, "pattern": [ diff --git a/src/main/generated/data/minecraft/recipe/spire_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/spire_armor_trim_smithing_template.json index 4cd59d3d03..a4f55cc155 100644 --- a/src/main/generated/data/minecraft/recipe/spire_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/spire_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:purpur_block" - }, - "S": { - "item": "minecraft:spire_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:purpur_block", + "S": "minecraft:spire_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/spruce_chest_boat.json b/src/main/generated/data/minecraft/recipe/spruce_chest_boat.json index f89eeea73e..ce964f8696 100644 --- a/src/main/generated/data/minecraft/recipe/spruce_chest_boat.json +++ b/src/main/generated/data/minecraft/recipe/spruce_chest_boat.json @@ -3,12 +3,8 @@ "category": "misc", "group": "chest_boat", "ingredients": [ - { - "tag": "c:chests/wooden" - }, - { - "item": "minecraft:spruce_boat" - } + "#c:chests/wooden", + "minecraft:spruce_boat" ], "result": { "count": 1, diff --git a/src/main/generated/data/minecraft/recipe/spruce_fence.json b/src/main/generated/data/minecraft/recipe/spruce_fence.json index d8790bce04..f84b63a72b 100644 --- a/src/main/generated/data/minecraft/recipe/spruce_fence.json +++ b/src/main/generated/data/minecraft/recipe/spruce_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:spruce_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:spruce_planks" }, "pattern": [ "W#W", diff --git a/src/main/generated/data/minecraft/recipe/spruce_fence_gate.json b/src/main/generated/data/minecraft/recipe/spruce_fence_gate.json index 61815e9606..ea1f612c1f 100644 --- a/src/main/generated/data/minecraft/recipe/spruce_fence_gate.json +++ b/src/main/generated/data/minecraft/recipe/spruce_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:spruce_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:spruce_planks" }, "pattern": [ "#W#", diff --git a/src/main/generated/data/minecraft/recipe/spruce_sign.json b/src/main/generated/data/minecraft/recipe/spruce_sign.json index 03fb28133e..58046b4828 100644 --- a/src/main/generated/data/minecraft/recipe/spruce_sign.json +++ b/src/main/generated/data/minecraft/recipe/spruce_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:spruce_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:spruce_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/spyglass.json b/src/main/generated/data/minecraft/recipe/spyglass.json index ea680e3fb9..d2caaad362 100644 --- a/src/main/generated/data/minecraft/recipe/spyglass.json +++ b/src/main/generated/data/minecraft/recipe/spyglass.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:gems/amethyst" - }, - "X": { - "tag": "c:ingots/copper" - } + "#": "#c:gems/amethyst", + "X": "#c:ingots/copper" }, "pattern": [ " # ", diff --git a/src/main/generated/data/minecraft/recipe/stone_axe.json b/src/main/generated/data/minecraft/recipe/stone_axe.json index 0bac2f1180..8d557557d6 100644 --- a/src/main/generated/data/minecraft/recipe/stone_axe.json +++ b/src/main/generated/data/minecraft/recipe/stone_axe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:stone_tool_materials" - } + "#": "#c:rods/wooden", + "X": "#minecraft:stone_tool_materials" }, "pattern": [ "XX", diff --git a/src/main/generated/data/minecraft/recipe/stone_hoe.json b/src/main/generated/data/minecraft/recipe/stone_hoe.json index 8c5b5eceee..8ed74421de 100644 --- a/src/main/generated/data/minecraft/recipe/stone_hoe.json +++ b/src/main/generated/data/minecraft/recipe/stone_hoe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:stone_tool_materials" - } + "#": "#c:rods/wooden", + "X": "#minecraft:stone_tool_materials" }, "pattern": [ "XX", diff --git a/src/main/generated/data/minecraft/recipe/stone_pickaxe.json b/src/main/generated/data/minecraft/recipe/stone_pickaxe.json index b366ac2065..cd245c22c4 100644 --- a/src/main/generated/data/minecraft/recipe/stone_pickaxe.json +++ b/src/main/generated/data/minecraft/recipe/stone_pickaxe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:stone_tool_materials" - } + "#": "#c:rods/wooden", + "X": "#minecraft:stone_tool_materials" }, "pattern": [ "XXX", diff --git a/src/main/generated/data/minecraft/recipe/stone_shovel.json b/src/main/generated/data/minecraft/recipe/stone_shovel.json index d1fbdebd22..bde9b0a8be 100644 --- a/src/main/generated/data/minecraft/recipe/stone_shovel.json +++ b/src/main/generated/data/minecraft/recipe/stone_shovel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:stone_tool_materials" - } + "#": "#c:rods/wooden", + "X": "#minecraft:stone_tool_materials" }, "pattern": [ "X", diff --git a/src/main/generated/data/minecraft/recipe/stone_sword.json b/src/main/generated/data/minecraft/recipe/stone_sword.json index 559caac73d..cdff3bf44e 100644 --- a/src/main/generated/data/minecraft/recipe/stone_sword.json +++ b/src/main/generated/data/minecraft/recipe/stone_sword.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:stone_tool_materials" - } + "#": "#c:rods/wooden", + "X": "#minecraft:stone_tool_materials" }, "pattern": [ "X", diff --git a/src/main/generated/data/minecraft/recipe/stonecutter.json b/src/main/generated/data/minecraft/recipe/stonecutter.json index e0820aeedb..e2f95eecf4 100644 --- a/src/main/generated/data/minecraft/recipe/stonecutter.json +++ b/src/main/generated/data/minecraft/recipe/stonecutter.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:stone" - }, - "I": { - "tag": "c:ingots/iron" - } + "#": "minecraft:stone", + "I": "#c:ingots/iron" }, "pattern": [ " I ", diff --git a/src/main/generated/data/minecraft/recipe/tide_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/tide_armor_trim_smithing_template.json index 8292dd0993..4f4f0feec4 100644 --- a/src/main/generated/data/minecraft/recipe/tide_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/tide_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:prismarine" - }, - "S": { - "item": "minecraft:tide_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:prismarine", + "S": "minecraft:tide_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/tinted_glass.json b/src/main/generated/data/minecraft/recipe/tinted_glass.json index 99d27ab3d3..899d357f7e 100644 --- a/src/main/generated/data/minecraft/recipe/tinted_glass.json +++ b/src/main/generated/data/minecraft/recipe/tinted_glass.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "building", "key": { - "G": { - "item": "minecraft:glass" - }, - "S": { - "tag": "c:gems/amethyst" - } + "G": "minecraft:glass", + "S": "#c:gems/amethyst" }, "pattern": [ " S ", diff --git a/src/main/generated/data/minecraft/recipe/torch.json b/src/main/generated/data/minecraft/recipe/torch.json index 031078faf0..442a61780e 100644 --- a/src/main/generated/data/minecraft/recipe/torch.json +++ b/src/main/generated/data/minecraft/recipe/torch.json @@ -2,16 +2,10 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, + "#": "#c:rods/wooden", "X": [ - { - "item": "minecraft:coal" - }, - { - "item": "minecraft:charcoal" - } + "minecraft:coal", + "minecraft:charcoal" ] }, "pattern": [ diff --git a/src/main/generated/data/minecraft/recipe/trapped_chest.json b/src/main/generated/data/minecraft/recipe/trapped_chest.json index 1cf84155e9..82cb55b53a 100644 --- a/src/main/generated/data/minecraft/recipe/trapped_chest.json +++ b/src/main/generated/data/minecraft/recipe/trapped_chest.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shapeless", "category": "redstone", "ingredients": [ - { - "tag": "c:chests/wooden" - }, - { - "item": "minecraft:tripwire_hook" - } + "#c:chests/wooden", + "minecraft:tripwire_hook" ], "result": { "count": 1, diff --git a/src/main/generated/data/minecraft/recipe/tripwire_hook.json b/src/main/generated/data/minecraft/recipe/tripwire_hook.json index b966ce7a63..9248d9973e 100644 --- a/src/main/generated/data/minecraft/recipe/tripwire_hook.json +++ b/src/main/generated/data/minecraft/recipe/tripwire_hook.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "minecraft:planks" - }, - "I": { - "tag": "c:ingots/iron" - }, - "S": { - "tag": "c:rods/wooden" - } + "#": "#minecraft:planks", + "I": "#c:ingots/iron", + "S": "#c:rods/wooden" }, "pattern": [ "I", diff --git a/src/main/generated/data/minecraft/recipe/vex_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/vex_armor_trim_smithing_template.json index 36b13fba54..a150f73101 100644 --- a/src/main/generated/data/minecraft/recipe/vex_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/vex_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "tag": "forge:cobblestone/normal" - }, - "S": { - "item": "minecraft:vex_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "#forge:cobblestone/normal", + "S": "minecraft:vex_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/ward_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/ward_armor_trim_smithing_template.json index 008583f234..e3a8c9db9d 100644 --- a/src/main/generated/data/minecraft/recipe/ward_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/ward_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "tag": "forge:cobblestone/deepslate" - }, - "S": { - "item": "minecraft:ward_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "#forge:cobblestone/deepslate", + "S": "minecraft:ward_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/warped_fence.json b/src/main/generated/data/minecraft/recipe/warped_fence.json index 715d558dd6..54684ffb50 100644 --- a/src/main/generated/data/minecraft/recipe/warped_fence.json +++ b/src/main/generated/data/minecraft/recipe/warped_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:warped_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:warped_planks" }, "pattern": [ "W#W", diff --git a/src/main/generated/data/minecraft/recipe/warped_fence_gate.json b/src/main/generated/data/minecraft/recipe/warped_fence_gate.json index 15dcad57d5..bd500ac089 100644 --- a/src/main/generated/data/minecraft/recipe/warped_fence_gate.json +++ b/src/main/generated/data/minecraft/recipe/warped_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:warped_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:warped_planks" }, "pattern": [ "#W#", diff --git a/src/main/generated/data/minecraft/recipe/warped_sign.json b/src/main/generated/data/minecraft/recipe/warped_sign.json index b0f4112a6d..fd63852c3b 100644 --- a/src/main/generated/data/minecraft/recipe/warped_sign.json +++ b/src/main/generated/data/minecraft/recipe/warped_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:warped_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:warped_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/wayfinder_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/wayfinder_armor_trim_smithing_template.json index 563776c2c5..3c93a650a0 100644 --- a/src/main/generated/data/minecraft/recipe/wayfinder_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/wayfinder_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:terracotta" - }, - "S": { - "item": "minecraft:wayfinder_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:terracotta", + "S": "minecraft:wayfinder_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/white_banner.json b/src/main/generated/data/minecraft/recipe/white_banner.json index 418906d5b9..0f87a1e878 100644 --- a/src/main/generated/data/minecraft/recipe/white_banner.json +++ b/src/main/generated/data/minecraft/recipe/white_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:white_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:white_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/data/minecraft/recipe/wild_armor_trim_smithing_template.json b/src/main/generated/data/minecraft/recipe/wild_armor_trim_smithing_template.json index 8eec0dc5e9..0048eb4531 100644 --- a/src/main/generated/data/minecraft/recipe/wild_armor_trim_smithing_template.json +++ b/src/main/generated/data/minecraft/recipe/wild_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:mossy_cobblestone" - }, - "S": { - "item": "minecraft:wild_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:mossy_cobblestone", + "S": "minecraft:wild_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/main/generated/data/minecraft/recipe/wooden_axe.json b/src/main/generated/data/minecraft/recipe/wooden_axe.json index 25cc73c46f..05fdaaad7e 100644 --- a/src/main/generated/data/minecraft/recipe/wooden_axe.json +++ b/src/main/generated/data/minecraft/recipe/wooden_axe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:planks" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wooden_tool_materials" }, "pattern": [ "XX", diff --git a/src/main/generated/data/minecraft/recipe/wooden_hoe.json b/src/main/generated/data/minecraft/recipe/wooden_hoe.json index a068c7fdc5..6fd2085dda 100644 --- a/src/main/generated/data/minecraft/recipe/wooden_hoe.json +++ b/src/main/generated/data/minecraft/recipe/wooden_hoe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:planks" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wooden_tool_materials" }, "pattern": [ "XX", diff --git a/src/main/generated/data/minecraft/recipe/wooden_pickaxe.json b/src/main/generated/data/minecraft/recipe/wooden_pickaxe.json index b09f9389ab..ff84e265b6 100644 --- a/src/main/generated/data/minecraft/recipe/wooden_pickaxe.json +++ b/src/main/generated/data/minecraft/recipe/wooden_pickaxe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:planks" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wooden_tool_materials" }, "pattern": [ "XXX", diff --git a/src/main/generated/data/minecraft/recipe/wooden_shovel.json b/src/main/generated/data/minecraft/recipe/wooden_shovel.json index dd2aa5e363..3aac8226a5 100644 --- a/src/main/generated/data/minecraft/recipe/wooden_shovel.json +++ b/src/main/generated/data/minecraft/recipe/wooden_shovel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:planks" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wooden_tool_materials" }, "pattern": [ "X", diff --git a/src/main/generated/data/minecraft/recipe/wooden_sword.json b/src/main/generated/data/minecraft/recipe/wooden_sword.json index 8906ea876f..35a7a42140 100644 --- a/src/main/generated/data/minecraft/recipe/wooden_sword.json +++ b/src/main/generated/data/minecraft/recipe/wooden_sword.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:planks" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wooden_tool_materials" }, "pattern": [ "X", diff --git a/src/main/generated/data/minecraft/recipe/yellow_banner.json b/src/main/generated/data/minecraft/recipe/yellow_banner.json index 5c1c07e88b..6228650872 100644 --- a/src/main/generated/data/minecraft/recipe/yellow_banner.json +++ b/src/main/generated/data/minecraft/recipe/yellow_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:yellow_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:yellow_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/main/generated/pack.mcmeta b/src/main/generated/pack.mcmeta index afba6dd03c..ac4f194926 100644 --- a/src/main/generated/pack.mcmeta +++ b/src/main/generated/pack.mcmeta @@ -3,6 +3,6 @@ "description": { "translate": "pack.forge.description" }, - "pack_format": 48 + "pack_format": 57 } } \ 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 071b671aaf..419ec568ed 100644 --- a/src/main/java/net/minecraftforge/client/ClientCommandHandler.java +++ b/src/main/java/net/minecraftforge/client/ClientCommandHandler.java @@ -18,6 +18,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.player.LocalPlayer; import net.minecraft.commands.CommandBuildContext; +import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.synchronization.SuggestionProviders; @@ -33,18 +34,15 @@ import org.jetbrains.annotations.ApiStatus; import java.util.IdentityHashMap; import java.util.Map; -public class ClientCommandHandler -{ +public class ClientCommandHandler { private static final Logger LOGGER = LogManager.getLogger(); private static CommandDispatcher commands = null; - public static void init() - { + public static void init() { MinecraftForge.EVENT_BUS.addListener(ClientCommandHandler::handleClientPlayerLogin); } - private static void handleClientPlayerLogin(ClientPlayerNetworkEvent.LoggingIn event) - { + private static void handleClientPlayerLogin(ClientPlayerNetworkEvent.LoggingIn event) { 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 @@ -58,8 +56,7 @@ public class ClientCommandHandler * with server commands in suggestions */ @ApiStatus.Internal - public static CommandDispatcher mergeServerCommands(CommandDispatcher serverCommands, CommandBuildContext buildContext) - { + public static CommandDispatcher mergeServerCommands(CommandDispatcher serverCommands, CommandBuildContext buildContext) { CommandDispatcher commandsTemp = new CommandDispatcher<>(); MinecraftForge.EVENT_BUS.post(new RegisterClientCommandsEvent(commandsTemp, buildContext)); @@ -74,17 +71,15 @@ public class ClientCommandHandler // Copies the client side commands into the server side commands to be used for suggestions CommandHelper.mergeCommandNode(commands.getRoot(), newServerCommands.getRoot(), new IdentityHashMap<>(), getSource(), (context) -> 0, (suggestions) -> { - SuggestionProvider suggestionProvider = SuggestionProviders - .safelySwap((SuggestionProvider) (SuggestionProvider) suggestions); - if (suggestionProvider == SuggestionProviders.ASK_SERVER) - { + @SuppressWarnings("unchecked") + var shared = (SuggestionProvider)(SuggestionProvider)suggestions; + var suggestionProvider = SuggestionProviders.safelySwap(shared); + if (suggestionProvider == SuggestionProviders.ASK_SERVER) { suggestionProvider = (context, builder) -> { ClientCommandSourceStack source = getSource(); StringReader reader = new StringReader(context.getInput()); if (reader.canRead() && reader.peek() == '/') - { reader.skip(); - } ParseResults parse = commands.parse(reader, source); return commands.getCompletionSuggestions(parse); @@ -99,19 +94,45 @@ public class ClientCommandHandler /** * @return The command dispatcher for client side commands */ - public static CommandDispatcher getDispatcher() - { + public static CommandDispatcher getDispatcher() { return commands; } /** * @return A {@link ClientCommandSourceStack} for the player in the current client */ - public static ClientCommandSourceStack getSource() - { - LocalPlayer player = Minecraft.getInstance().player; - return new ClientCommandSourceStack(player, player.position(), player.getRotationVector(), player.getPermissionLevel(), - player.getName().getString(), player.getDisplayName(), player); + public static ClientCommandSourceStack getSource() { + var mc = Minecraft.getInstance(); + LocalPlayer player = mc.player; + return new ClientCommandSourceStack( + new CommandSource() { + @Override + public void sendSystemMessage(Component message) { + mc.gui.getChat().addMessage(message); + } + + @Override + public boolean acceptsSuccess() { + return true; + } + + @Override + public boolean acceptsFailure() { + return true; + } + + @Override + public boolean shouldInformAdmins() { + return true; + } + }, + player.position(), + player.getRotationVector(), + player.getPermissionLevel(), + player.getName().getString(), + player.getDisplayName(), + player + ); } /** @@ -149,51 +170,49 @@ public class ClientCommandHandler * @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 */ - public static boolean runCommand(String command) - { + public static boolean runCommand(String command) { StringReader reader = new StringReader(command); ClientCommandSourceStack source = getSource(); + var mc = Minecraft.getInstance(); try { commands.execute(reader, source); //} catch (CommandRuntimeException execution) { // Probably thrown by the command // Minecraft.getInstance().player.sendSystemMessage(Component.literal("").append(execution.getComponent()).withStyle(ChatFormatting.RED)); } catch (CommandSyntaxException syntax) { - if (syntax.getType() == CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand() || syntax.getType() == CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownArgument()) - { + if (syntax.getType() == CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand() || + syntax.getType() == CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownArgument() + ) { // in case of unknown command, let the server try and handle it return false; } - Minecraft.getInstance().player.sendSystemMessage( - Component.literal("").append(ComponentUtils.fromMessage(syntax.getRawMessage())).withStyle(ChatFormatting.RED)); - if (syntax.getInput() != null && syntax.getCursor() >= 0) - { + mc.gui.getChat().addMessage( + Component.literal("").append(ComponentUtils.fromMessage(syntax.getRawMessage())).withStyle(ChatFormatting.RED) + ); + if (syntax.getInput() != null && syntax.getCursor() >= 0) { int position = Math.min(syntax.getInput().length(), syntax.getCursor()); MutableComponent details = Component.literal("") .withStyle(ChatFormatting.GRAY) .withStyle((style) -> style .withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, reader.getString()))); if (position > 10) - { details.append("..."); - } + details.append(syntax.getInput().substring(Math.max(0, position - 10), position)); if (position < syntax.getInput().length()) - { details.append(Component.literal(syntax.getInput().substring(position)).withStyle(ChatFormatting.RED, ChatFormatting.UNDERLINE)); - } + details.append(Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC)); - Minecraft.getInstance().player.sendSystemMessage(Component.literal("").append(details).withStyle(ChatFormatting.RED)); + mc.gui.getChat().addMessage(Component.literal("").append(details).withStyle(ChatFormatting.RED)); } - } - catch (Exception generic)// Probably thrown by the command - { + } catch (Exception generic) { // Probably thrown by the command{ MutableComponent message = Component.literal(generic.getMessage() == null ? generic.getClass().getName() : generic.getMessage()); - Minecraft.getInstance().player.sendSystemMessage(Component.translatable("command.failed") + mc.gui.getChat().addMessage( + Component.translatable("command.failed") .withStyle(ChatFormatting.RED) - .withStyle((style) -> style - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, message)))); + .withStyle(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, message))) + ); LOGGER.error("Error executing client command \"{}\"", command, generic); } return true; diff --git a/src/main/java/net/minecraftforge/client/ClientCommandSourceStack.java b/src/main/java/net/minecraftforge/client/ClientCommandSourceStack.java index 52fa692cc3..9f25195c69 100644 --- a/src/main/java/net/minecraftforge/client/ClientCommandSourceStack.java +++ b/src/main/java/net/minecraftforge/client/ClientCommandSourceStack.java @@ -16,7 +16,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; -import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; @@ -26,7 +25,6 @@ import java.util.Collection; import java.util.Set; import java.util.function.Supplier; import java.util.stream.Collectors; -import java.util.stream.Stream; /** * overrides for {@link CommandSourceStack} so that the methods will run successfully client side @@ -42,7 +40,7 @@ public class ClientCommandSourceStack extends CommandSourceStack { @SuppressWarnings("resource") @Override public void sendSuccess(Supplier message, boolean sendToAdmins) { - Minecraft.getInstance().player.sendSystemMessage(message.get()); + Minecraft.getInstance().gui.getChat().addMessage(message.get()); } /** @@ -62,14 +60,6 @@ public class ClientCommandSourceStack extends CommandSourceStack { return Minecraft.getInstance().getConnection().getOnlinePlayers().stream().map((player) -> player.getProfile().getName()).collect(Collectors.toList()); } - /** - * {@return a {@link Stream} of recipe ids that are available on the client} - */ - @Override - public Stream getRecipeNames() { - return Minecraft.getInstance().getConnection().getRecipeManager().getRecipeIds(); - } - /** * {@return a set of {@link ResourceKey} for levels from the client side} */ @@ -103,14 +93,6 @@ public class ClientCommandSourceStack extends CommandSourceStack { return Minecraft.getInstance().getConnection().getAdvancements().get(id); } - /** - * {@return the {@link RecipeManager} from the client side} - */ - @Override - public RecipeManager getRecipeManager() { - return Minecraft.getInstance().getConnection().getRecipeManager(); - } - /** * {@return the level from the client side} */ diff --git a/src/main/java/net/minecraftforge/client/ClientForgeMod.java b/src/main/java/net/minecraftforge/client/ClientForgeMod.java index 02d8d69bcf..57d2dc9688 100644 --- a/src/main/java/net/minecraftforge/client/ClientForgeMod.java +++ b/src/main/java/net/minecraftforge/client/ClientForgeMod.java @@ -21,11 +21,9 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @Mod.EventBusSubscriber(value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD, modid = "forge") -public class ClientForgeMod -{ +public class ClientForgeMod { @SubscribeEvent - public static void onRegisterGeometryLoaders(ModelEvent.RegisterGeometryLoaders event) - { + public static void onRegisterGeometryLoaders(ModelEvent.RegisterGeometryLoaders event) { event.register("empty", EmptyModel.LOADER); event.register("elements", ElementsModel.Loader.INSTANCE); event.register("obj", ObjLoader.INSTANCE); @@ -36,14 +34,12 @@ public class ClientForgeMod } @SubscribeEvent - public static void onRegisterReloadListeners(RegisterClientReloadListenersEvent event) - { + public static void onRegisterReloadListeners(RegisterClientReloadListenersEvent event) { event.registerReloadListener(ObjLoader.INSTANCE); } @SubscribeEvent - public static void onRegisterNamedRenderTypes(RegisterNamedRenderTypesEvent event) - { + public static void onRegisterNamedRenderTypes(RegisterNamedRenderTypesEvent event) { event.register("item_unlit", RenderType.translucent(), ForgeRenderTypes.ITEM_UNSORTED_UNLIT_TRANSLUCENT.get()); } } diff --git a/src/main/java/net/minecraftforge/client/DimensionSpecialEffectsManager.java b/src/main/java/net/minecraftforge/client/DimensionSpecialEffectsManager.java index f19c4b7b82..03abc83fd9 100644 --- a/src/main/java/net/minecraftforge/client/DimensionSpecialEffectsManager.java +++ b/src/main/java/net/minecraftforge/client/DimensionSpecialEffectsManager.java @@ -21,22 +21,19 @@ import java.util.Map; *

* Provides a lookup by dimension type. */ -public final class DimensionSpecialEffectsManager -{ +public final class DimensionSpecialEffectsManager { private static ImmutableMap EFFECTS; private static DimensionSpecialEffects DEFAULT_EFFECTS; /** * Finds the {@link DimensionSpecialEffects} for a given dimension type, or the default if none is registered. */ - public static DimensionSpecialEffects getForType(ResourceLocation type) - { + public static DimensionSpecialEffects getForType(ResourceLocation type) { return EFFECTS.getOrDefault(type, DEFAULT_EFFECTS); } @ApiStatus.Internal - public static void init() - { + public static void init() { var effects = new HashMap(); DEFAULT_EFFECTS = preRegisterVanillaEffects(effects); var event = new RegisterDimensionSpecialEffectsEvent(effects); @@ -49,8 +46,7 @@ public final class DimensionSpecialEffectsManager *

* Borrowed from {@link DimensionSpecialEffects#EFFECTS}. */ - private static DimensionSpecialEffects preRegisterVanillaEffects(Map effects) - { + private static DimensionSpecialEffects preRegisterVanillaEffects(Map effects) { var overworldEffects = new DimensionSpecialEffects.OverworldEffects(); effects.put(BuiltinDimensionTypes.OVERWORLD_EFFECTS, overworldEffects); effects.put(BuiltinDimensionTypes.NETHER_EFFECTS, new DimensionSpecialEffects.NetherEffects()); @@ -58,7 +54,5 @@ public final class DimensionSpecialEffectsManager return overworldEffects; } - private DimensionSpecialEffectsManager() - { - } + private DimensionSpecialEffectsManager() { } } diff --git a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java index 1cb705d9e6..48af06fb7a 100644 --- a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java +++ b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java @@ -5,6 +5,7 @@ package net.minecraftforge.client; +import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.mojang.blaze3d.platform.NativeImage; @@ -19,7 +20,9 @@ import com.mojang.math.Constants; import net.minecraft.ChatFormatting; import net.minecraft.FileUtil; +import net.minecraft.Util; import net.minecraft.client.Camera; +import net.minecraft.client.ClientRecipeBook; import net.minecraft.client.Minecraft; import net.minecraft.client.Options; import net.minecraft.client.color.block.BlockColors; @@ -44,15 +47,18 @@ import net.minecraft.client.multiplayer.PlayerInfo; import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.particle.ParticleEngine; import net.minecraft.client.particle.ParticleRenderType; -import net.minecraft.client.player.Input; +import net.minecraft.client.player.ClientInput; +import net.minecraft.client.renderer.FogParameters; import net.minecraft.client.renderer.FogRenderer; import net.minecraft.client.renderer.GameRenderer; 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.ShaderDefines; +import net.minecraft.client.renderer.ShaderProgram; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.culling.Frustum; +import net.minecraft.client.renderer.entity.state.HumanoidRenderState; import net.minecraft.client.renderer.texture.SpriteContents; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -87,8 +93,8 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.inventory.tooltip.TooltipComponent; -import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.world.level.BlockAndTintGetter; @@ -118,11 +124,9 @@ import net.minecraftforge.client.event.RegisterClientReloadListenersEvent; import net.minecraftforge.client.event.RegisterColorHandlersEvent; import net.minecraftforge.client.event.RegisterKeyMappingsEvent; import net.minecraftforge.client.event.RegisterParticleProvidersEvent; -import net.minecraftforge.client.event.RegisterShadersEvent; import net.minecraftforge.client.event.RenderBlockScreenEffectEvent; import net.minecraftforge.client.event.RenderHandEvent; import net.minecraftforge.client.event.RenderHighlightEvent; -import net.minecraftforge.client.event.RenderLevelStageEvent; import net.minecraftforge.client.event.RenderTooltipEvent; import net.minecraftforge.client.event.ScreenEvent; import net.minecraftforge.client.event.TextureStitchEvent; @@ -245,10 +249,12 @@ public class ForgeHooksClient { MinecraftForge.EVENT_BUS.post(new ClientPauseChangeEvent.Post(pause)); } + /* public static ResourceLocation getArmorTexture(Entity entity, ItemStack armor, EquipmentSlot slot, ArmorMaterial.Layer layer, boolean inner) { var result = armor.getItem().getArmorTexture(armor, entity, slot, layer, inner); return result != null ? result : layer.texture(inner); } + */ public static boolean onDrawHighlight(LevelRenderer context, Camera camera, HitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource) { switch (target.getType()) { @@ -263,12 +269,6 @@ public class ForgeHooksClient { } } - public static void dispatchRenderStage(RenderType renderType, LevelRenderer levelRenderer, Matrix4f poseStack, Matrix4f projectionMatrix, int renderTick, Camera camera, Frustum frustum) { - RenderLevelStageEvent.Stage stage = RenderLevelStageEvent.Stage.fromRenderType(renderType); - if (stage != null) - stage.dispatch(levelRenderer, poseStack, projectionMatrix, renderTick, camera, frustum); - } - public static boolean renderSpecificFirstPersonHand(InteractionHand hand, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, float partialTick, float interpPitch, float swingProgress, float equipProgress, ItemStack stack) { return MinecraftForge.EVENT_BUS.post(new RenderHandEvent(hand, poseStack, bufferSource, packedLight, partialTick, interpPitch, swingProgress, equipProgress, stack)); } @@ -285,13 +285,13 @@ public class ForgeHooksClient { ModLoader.get().postEvent(new RegisterColorHandlersEvent.Item(itemColors, blockColors)); } - public static Model getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot slot, HumanoidModel _default) { - return IClientItemExtensions.of(itemStack).getGenericArmorModel(entityLiving, itemStack, slot, _default); + public static Model getArmorModel(HumanoidRenderState state, ItemStack itemStack, EquipmentSlot slot, HumanoidModel _default) { + return IClientItemExtensions.of(itemStack).getGenericArmorModel(state, itemStack, slot, _default); } /** Copies humanoid model properties from the original model to another, used for armor models */ @SuppressWarnings("unchecked") - public static void copyModelProperties(HumanoidModel original, HumanoidModel replacement) { + public static void copyModelProperties(HumanoidModel original, HumanoidModel replacement) { // this function does not make use of the generic, so the unchecked cast should be safe original.copyPropertiesTo((HumanoidModel)replacement); replacement.head.visible = original.head.visible; @@ -318,10 +318,6 @@ public class ForgeHooksClient { } } - public static float getFieldOfViewModifier(Player entity, float fovModifier) { - return MinecraftForge.EVENT_BUS.fire(new ComputeFovModifierEvent(entity, fovModifier)).getNewFovModifier(); - } - /** * Initialization of Forge Renderers. */ @@ -400,18 +396,22 @@ public class ForgeHooksClient { return fluidFogColor; } - public static void onFogRender(FogRenderer.FogMode mode, FogType type, Camera camera, float partialTick, float renderDistance, float nearDistance, float farDistance, FogShape shape) { + public static FogParameters getFogParameters(FogRenderer.FogMode mode, FogType type, Camera camera, float partialTick, float renderDistance, FogParameters original) { + var ret = original; // Modify fog rendering depending on the fluid FluidState state = camera.getEntity().level().getFluidState(camera.getBlockPosition()); if (camera.getPosition().y < (double)((float)camera.getBlockPosition().getY() + state.getHeight(camera.getEntity().level(), camera.getBlockPosition()))) - IClientFluidTypeExtensions.of(state).modifyFogRender(camera, mode, renderDistance, partialTick, nearDistance, farDistance, shape); + ret = IClientFluidTypeExtensions.of(state).modifyFogRender(camera, mode, renderDistance, partialTick, ret); - ViewportEvent.RenderFog event = new ViewportEvent.RenderFog(mode, type, camera, partialTick, nearDistance, farDistance, shape); + var event = new ViewportEvent.RenderFog(mode, type, camera, partialTick, ret.start(), ret.end(), ret.shape()); if (MinecraftForge.EVENT_BUS.post(event)) { - RenderSystem.setShaderFogStart(event.getNearPlaneDistance()); - RenderSystem.setShaderFogEnd(event.getFarPlaneDistance()); - RenderSystem.setShaderFogShape(event.getFogShape()); + return new FogParameters( + event.getNearPlaneDistance(), event.getFarPlaneDistance(), event.getFogShape(), + ret.red(), ret.green(), ret.blue(), ret.alpha() + ); } + + return ret; } public static void onModifyBakingResult(Map models, ModelBakery modelBakery) { @@ -422,29 +422,28 @@ public class ForgeHooksClient { ModLoader.get().postEvent(new ModelEvent.BakingCompleted(modelManager, Collections.unmodifiableMap(models), modelBakery)); } - @SuppressWarnings("deprecation") public static TextureAtlasSprite[] getFluidSprites(BlockAndTintGetter level, BlockPos pos, FluidState fluidStateIn) { IClientFluidTypeExtensions props = IClientFluidTypeExtensions.of(fluidStateIn); ResourceLocation overlayTexture = props.getOverlayTexture(fluidStateIn, level, pos); return new TextureAtlasSprite[] { - Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(props.getStillTexture(fluidStateIn, level, pos)), - Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(props.getFlowingTexture(fluidStateIn, level, pos)), - overlayTexture == null ? null : Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(overlayTexture), + Minecraft.getInstance().getTextureAtlas(InventoryMenu.BLOCK_ATLAS).apply(props.getStillTexture(fluidStateIn, level, pos)), + Minecraft.getInstance().getTextureAtlas(InventoryMenu.BLOCK_ATLAS).apply(props.getFlowingTexture(fluidStateIn, level, pos)), + overlayTexture == null ? null : Minecraft.getInstance().getTextureAtlas(InventoryMenu.BLOCK_ATLAS).apply(overlayTexture), }; } - @SuppressWarnings("deprecation") public static Material getBlockMaterial(ResourceLocation loc) { - return new Material(TextureAtlas.LOCATION_BLOCKS, loc); + return new Material(InventoryMenu.BLOCK_ATLAS, loc); } + /* public static void fillNormal(int[] faceData, Direction facing) { fillNormal(faceData, facing, false); } /** * internal, relies on fixed format of FaceBakery - */ + * / // TODO Do we need this? public static void fillNormal(int[] faceData, Direction facing, boolean calculateNormals) { Vector3f v2; @@ -468,6 +467,7 @@ public class ForgeHooksClient { for(int i = 0; i < 4; i++) faceData[i * 8 + 7] = normal; } + */ private static Vector3f getVertexPos(int[] data, int vertex) { int idx = vertex * 8; @@ -490,14 +490,6 @@ public class ForgeHooksClient { return true; } - public static void loadEntityShader(Entity entity, GameRenderer entityRenderer) { - if (entity != null) { - ResourceLocation shader = EntitySpectatorShaderManager.get(entity.getType()); - if (shader != null) - entityRenderer.loadEffect(shader); - } - } - private static int slotMainHand = 0; public static boolean shouldCauseReequipAnimation(@NotNull ItemStack from, @NotNull ItemStack to, int slot) { @@ -517,22 +509,20 @@ public class ForgeHooksClient { public static CustomizeGuiOverlayEvent.BossEventProgress onCustomizeBossEventProgress(GuiGraphics guiGraphics, Window window, LerpingBossEvent bossInfo, int x, int y, int increment) { var evt = new CustomizeGuiOverlayEvent.BossEventProgress(window, guiGraphics, - Minecraft.getInstance().getTimer().getGameTimeDeltaPartialTick(false), bossInfo, x, y, increment); + Minecraft.getInstance().getDeltaTracker().getGameTimeDeltaPartialTick(false), bossInfo, x, y, increment); MinecraftForge.EVENT_BUS.post(evt); return evt; } public static void onCustomizeChatEvent(GuiGraphics guiGraphics, ChatComponent chat, Window window, int mouseX, int mouseY, int tickCount) { var minecraft = Minecraft.getInstance(); - minecraft.getProfiler().push("chat"); - var evt = new CustomizeGuiOverlayEvent.Chat(window, guiGraphics, minecraft.getTimer().getRealtimeDeltaTicks(), 0, chat.getHeight() - 40); + var evt = new CustomizeGuiOverlayEvent.Chat(window, guiGraphics, minecraft.getDeltaTracker().getRealtimeDeltaTicks(), 0, chat.getHeight() - 40); MinecraftForge.EVENT_BUS.post(evt); guiGraphics.pose().pushPose(); // We give the absolute Y position of the chat component in the event and account for the chat component's own offsetting here. guiGraphics.pose().translate(evt.getPosX(), (evt.getPosY() - chat.getHeight() + 40) / chat.getScale(), 0.0D); chat.render(guiGraphics, tickCount, mouseX, mouseY, false); guiGraphics.pose().popPose(); - minecraft.getProfiler().pop(); } public static void onCustomizeDebugEvent(GuiGraphics guiGraphics, Window window, float partialTick, List text, boolean isLeft) { @@ -547,18 +537,18 @@ public class ForgeHooksClient { } } - public static void onMovementInputUpdate(Player player, Input movementInput) { + public static void onMovementInputUpdate(Player player, ClientInput movementInput) { MinecraftForge.EVENT_BUS.post(new MovementInputUpdateEvent(player, movementInput)); } - public static void onScreenKeyPressed(boolean[] state, Screen screen, int keyCode, int scanCode, int modifiers) { - state[0] = ForgeEventFactoryClient.onScreenKeyPressedPre(screen, keyCode, scanCode, modifiers) + public static boolean onScreenKeyPressed(Screen screen, int keyCode, int scanCode, int modifiers) { + return ForgeEventFactoryClient.onScreenKeyPressedPre(screen, keyCode, scanCode, modifiers) || screen.keyPressed(keyCode, scanCode, modifiers) || ForgeEventFactoryClient.onScreenKeyPressedPost(screen, keyCode, scanCode, modifiers); } - public static void onScreenKeyReleased(boolean[] state, Screen screen, int keyCode, int scanCode, int modifiers) { - state[0] = ForgeEventFactoryClient.onScreenKeyReleasedPre(screen, keyCode, scanCode, modifiers) + public static boolean onScreenKeyReleased(Screen screen, int keyCode, int scanCode, int modifiers) { + return ForgeEventFactoryClient.onScreenKeyReleasedPre(screen, keyCode, scanCode, modifiers) || screen.keyReleased(keyCode, scanCode, modifiers) || ForgeEventFactoryClient.onScreenKeyReleasedPost(screen, keyCode, scanCode, modifiers); } @@ -569,10 +559,6 @@ public class ForgeHooksClient { || ForgeEventFactoryClient.onScreenCharTypedPost(screen, codePoint, modifiers); } - public static void onRecipesUpdated(RecipeManager mgr) { - MinecraftForge.EVENT_BUS.post(new RecipesUpdatedEvent(mgr)); - } - public static void onKeyInput(int key, int scanCode, int action, int modifiers) { MinecraftForge.EVENT_BUS.post(new InputEvent.Key(key, scanCode, action, modifiers)); } @@ -713,7 +699,7 @@ public class ForgeHooksClient { tooltip = ForgeI18n.parseMessage("fml.menu.multiplayer.unknown", target.forgeData.type()); } - guiGraphics.blit(ICON_SHEET, x + width - 18, y + 10, 16, 16, 0, idx, 16, 16, 256, 256); + guiGraphics.blit(RenderType::guiTextured, ICON_SHEET, x + width - 18, y + 10, 16, 16, 0, idx, 16, 16, 256, 256); if(relativeMouseX > width - 15 && relativeMouseX < width && relativeMouseY > 10 && relativeMouseY < 26) { //this is not the most proper way to do it, @@ -742,10 +728,6 @@ public class ForgeHooksClient { ModLoader.get().postEvent(new RegisterKeyMappingsEvent(options)); } - public static void onRegisterAdditionalModels(Set additionalModels) { - ModLoader.get().postEvent(new ModelEvent.RegisterAdditional(additionalModels)); - } - @Nullable public static Component onClientChat(ChatType.Bound boundChatType, Component message, UUID sender) { ClientChatReceivedEvent event = new ClientChatReceivedEvent(boundChatType, message, sender); @@ -771,31 +753,9 @@ public class ForgeHooksClient { return MinecraftForge.EVENT_BUS.post(event) ? "" : event.getMessage(); } - /** - * Mimics the behavior of {@link net.minecraft.client.renderer.ItemBlockRenderTypes#getRenderType(BlockState, boolean)} - * for the input {@link RenderType}. - */ - @NotNull - public static RenderType getEntityRenderType(RenderType chunkRenderType, boolean cull) { - return RenderTypeHelper.getEntityRenderType(chunkRenderType, cull); - } - - @Mod.EventBusSubscriber(value = Dist.CLIENT, modid="forge", bus= Mod.EventBusSubscriber.Bus.MOD) - public static class ClientEvents { - @Nullable - private static ShaderInstance rendertypeEntityTranslucentUnlitShader; - - public static ShaderInstance getEntityTranslucentUnlitShader() { - return Objects.requireNonNull(rendertypeEntityTranslucentUnlitShader, "Attempted to call getEntityTranslucentUnlitShader before shaders have finished loading."); - } - - @SubscribeEvent - public static void registerShaders(RegisterShadersEvent event) throws IOException { - event.registerShader(new ShaderInstance(event.getResourceProvider(), ResourceLocation.fromNamespaceAndPath("forge", "rendertype_entity_unlit_translucent"), DefaultVertexFormat.NEW_ENTITY), (p_172645_) -> { - rendertypeEntityTranslucentUnlitShader = p_172645_; - }); - } - } + public static final Supplier SHADER_UNLIT_TRANSLUCENT = Suppliers.memoize(() -> + new ShaderProgram(ResourceLocation.fromNamespaceAndPath("forge", "rendertype_entity_unlit_translucent"), DefaultVertexFormat.NEW_ENTITY, ShaderDefines.EMPTY) + ); public static Font getTooltipFont(@NotNull ItemStack stack, Font fallbackFont) { Font stackFont = IClientItemExtensions.of(stack).getFont(stack, IClientItemExtensions.FontContext.TOOLTIP); @@ -808,12 +768,6 @@ public class ForgeHooksClient { return preEvent; } - public static RenderTooltipEvent.Color onRenderTooltipColor(@NotNull ItemStack stack, GuiGraphics graphics, int x, int y, @NotNull Font font, @NotNull List components) { - var colorEvent = new RenderTooltipEvent.Color(stack, graphics, x, y, font, 0xf0100010, 0x505000FF, 0x5028007f, components); - MinecraftForge.EVENT_BUS.post(colorEvent); - return colorEvent; - } - public static List gatherTooltipComponents(ItemStack stack, List textElements, int mouseX, int screenWidth, int screenHeight, Font fallbackFont) { return gatherTooltipComponents(stack, textElements, Optional.empty(), mouseX, screenWidth, screenHeight, fallbackFont); } @@ -894,14 +848,6 @@ public class ForgeHooksClient { }; } - public static ScreenEvent.RenderInventoryMobEffects onScreenPotionSize(Screen screen, int availableSpace, boolean compact, int horizontalOffset) { - return MinecraftForge.EVENT_BUS.fire(new ScreenEvent.RenderInventoryMobEffects(screen, availableSpace, compact, horizontalOffset)); - } - - public static boolean onToastAdd(Toast toast) { - return MinecraftForge.EVENT_BUS.post(new ToastAddEvent(toast)); - } - public static boolean isBlockInSolidLayer(BlockState state) { var model = Minecraft.getInstance().getBlockRenderer().getBlockModel(state); return model.getRenderTypes(state, RandomSource.create(), ModelData.EMPTY).contains(RenderType.solid()); @@ -949,37 +895,6 @@ public class ForgeHooksClient { return loc.withPath(normalised); } - /** - * This function is a clone of {@link Direction#getNearest(float, float, float)} designed to return a consistent - * direction when the normal is at an inflection point (ie 45 degrees) rounding errors - * from associated matrix multiplication (such as during {@link SheetedDecalTextureGenerator#endVertex()} - * can cause the direction chosen to be unstable. - * - * The function will only take effect if the Forge Client config option "stabilizeDirectionGetNearest" is enabled. - * - * This is a port of the downstream changes from https://github.com/neoforged/NeoForge PR #26 - * - * @param nX X component of the normal - * @param nY Y component of the normal - * @param nZ Z component of the normal - * @return the nearest Direction to the passed in normal, biased slightly in favor of the order of declaration - */ - public static Direction getNearestStable(float nX, float nY, float nZ) { - if (ForgeConfig.CLIENT.stabilizeDirectionGetNearest.get()) { - Direction ret = Direction.NORTH; - float sum = Float.MIN_VALUE; - for(Direction dir : Direction.values()) { - float newSum = nX * (float)dir.getNormal().getX() + nY * (float)dir.getNormal().getY() + nZ * (float)dir.getNormal().getZ(); - if (newSum > sum + Constants.EPSILON) { - sum = newSum; - ret = dir; - } - } - return ret; - } else - return Direction.getNearest(nX, nY, nZ); - } - // Make sure the below method is only ever called once (by forge). private static boolean initializedClientHooks = false; // Runs during Minecraft construction, before initial resource loading. @@ -997,7 +912,6 @@ public class ForgeHooksClient { ClientTooltipComponentManager.init(); EntitySpectatorShaderManager.init(); ForgeHooksClient.onRegisterKeyMappings(mc.options); - RecipeBookManager.init(); //GuiOverlayManager.init(); DimensionSpecialEffectsManager.init(); NamedRenderTypeManager.init(); @@ -1014,11 +928,9 @@ public class ForgeHooksClient { return true; } - public static void onScreenMouseDrag(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { - if (ForgeEventFactoryClient.onScreenMouseDragPre(screen, mouseX, mouseY, mouseButton, dragX, dragY)) - return; - if (screen.mouseDragged(mouseX, mouseY, mouseButton, dragX, dragY)) - return; - ForgeEventFactoryClient.onScreenMouseDragPost(screen, mouseX, mouseY, mouseButton, dragX, dragY); + public static boolean onScreenMouseDrag(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { + return ForgeEventFactoryClient.onScreenMouseDragPre(screen, mouseX, mouseY, mouseButton, dragX, dragY) + || screen.mouseDragged(mouseX, mouseY, mouseButton, dragX, dragY) + || ForgeEventFactoryClient.onScreenMouseDragPost(screen, mouseX, mouseY, mouseButton, dragX, dragY); } } diff --git a/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java b/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java index 0ffa33e151..16aa68fe5c 100644 --- a/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java +++ b/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java @@ -8,72 +8,64 @@ package net.minecraftforge.client; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.Util; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderStateShard; import net.minecraft.client.renderer.RenderStateShard.TextureStateShard; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.texture.TextureAtlas; import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.VertexFormat; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.TriState; +import net.minecraft.world.inventory.InventoryMenu; import net.minecraftforge.common.util.NonNullLazy; import net.minecraftforge.common.util.NonNullSupplier; -import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Supplier; -@SuppressWarnings("deprecation") -public enum ForgeRenderTypes -{ - ITEM_LAYERED_SOLID(()-> getItemLayeredSolid(TextureAtlas.LOCATION_BLOCKS)), - ITEM_LAYERED_CUTOUT(()-> getItemLayeredCutout(TextureAtlas.LOCATION_BLOCKS)), - ITEM_LAYERED_CUTOUT_MIPPED(()-> getItemLayeredCutoutMipped(TextureAtlas.LOCATION_BLOCKS)), - ITEM_LAYERED_TRANSLUCENT(()-> getItemLayeredTranslucent(TextureAtlas.LOCATION_BLOCKS)), - ITEM_UNSORTED_TRANSLUCENT(()-> getUnsortedTranslucent(TextureAtlas.LOCATION_BLOCKS)), - ITEM_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(TextureAtlas.LOCATION_BLOCKS)), - ITEM_UNSORTED_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(TextureAtlas.LOCATION_BLOCKS, false)), - TRANSLUCENT_ON_PARTICLES_TARGET(() -> getTranslucentParticlesTarget(TextureAtlas.LOCATION_BLOCKS)); +public enum ForgeRenderTypes { + ITEM_LAYERED_SOLID(()-> getItemLayeredSolid(InventoryMenu.BLOCK_ATLAS)), + ITEM_LAYERED_CUTOUT(()-> getItemLayeredCutout(InventoryMenu.BLOCK_ATLAS)), + ITEM_LAYERED_CUTOUT_MIPPED(()-> getItemLayeredCutoutMipped(InventoryMenu.BLOCK_ATLAS)), + ITEM_LAYERED_TRANSLUCENT(()-> getItemLayeredTranslucent(InventoryMenu.BLOCK_ATLAS)), + ITEM_UNSORTED_TRANSLUCENT(()-> getUnsortedTranslucent(InventoryMenu.BLOCK_ATLAS)), + ITEM_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(InventoryMenu.BLOCK_ATLAS)), + ITEM_UNSORTED_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(InventoryMenu.BLOCK_ATLAS, false)), + TRANSLUCENT_ON_PARTICLES_TARGET(() -> getTranslucentParticlesTarget(InventoryMenu.BLOCK_ATLAS)); - public static boolean enableTextTextureLinearFiltering = false; + public static TriState enableTextTextureLinearFiltering = TriState.FALSE; /** * @return A RenderType fit for multi-layer solid item rendering. */ - public static RenderType getItemLayeredSolid(ResourceLocation textureLocation) - { + public static RenderType getItemLayeredSolid(ResourceLocation textureLocation) { return Internal.LAYERED_ITEM_SOLID.apply(textureLocation); } /** * @return A RenderType fit for multi-layer cutout item item rendering. */ - public static RenderType getItemLayeredCutout(ResourceLocation textureLocation) - { + public static RenderType getItemLayeredCutout(ResourceLocation textureLocation) { return Internal.LAYERED_ITEM_CUTOUT.apply(textureLocation); } /** * @return A RenderType fit for multi-layer cutout-mipped item rendering. */ - public static RenderType getItemLayeredCutoutMipped(ResourceLocation textureLocation) - { + public static RenderType getItemLayeredCutoutMipped(ResourceLocation textureLocation) { return Internal.LAYERED_ITEM_CUTOUT_MIPPED.apply(textureLocation); } /** * @return A RenderType fit for multi-layer translucent item rendering. */ - public static RenderType getItemLayeredTranslucent(ResourceLocation textureLocation) - { + public static RenderType getItemLayeredTranslucent(ResourceLocation textureLocation) { return Internal.LAYERED_ITEM_TRANSLUCENT.apply(textureLocation); } /** * @return A RenderType fit for translucent item/entity rendering, but with depth sorting disabled. */ - public static RenderType getUnsortedTranslucent(ResourceLocation textureLocation) - { + public static RenderType getUnsortedTranslucent(ResourceLocation textureLocation) { return Internal.UNSORTED_TRANSLUCENT.apply(textureLocation); } @@ -81,8 +73,7 @@ public enum ForgeRenderTypes * @return A RenderType fit for translucent item/entity rendering, but with diffuse lighting disabled * so that fullbright quads look correct. */ - public static RenderType getUnlitTranslucent(ResourceLocation textureLocation) - { + public static RenderType getUnlitTranslucent(ResourceLocation textureLocation) { return Internal.UNLIT_TRANSLUCENT_SORTED.apply(textureLocation); } @@ -91,72 +82,63 @@ public enum ForgeRenderTypes * so that fullbright quads look correct. * @param sortingEnabled If false, depth sorting will not be performed. */ - public static RenderType getUnlitTranslucent(ResourceLocation textureLocation, boolean sortingEnabled) - { + public static RenderType getUnlitTranslucent(ResourceLocation textureLocation, boolean sortingEnabled) { return (sortingEnabled ? Internal.UNLIT_TRANSLUCENT_SORTED : Internal.UNLIT_TRANSLUCENT_UNSORTED).apply(textureLocation); } /** * @return Same as {@link RenderType#entityCutout(ResourceLocation)}, but with mipmapping enabled. */ - public static RenderType getEntityCutoutMipped(ResourceLocation textureLocation) - { + public static RenderType getEntityCutoutMipped(ResourceLocation textureLocation) { return Internal.LAYERED_ITEM_CUTOUT_MIPPED.apply(textureLocation); } /** * @return Replacement of {@link RenderType#text(ResourceLocation)}, but with optional linear texture filtering. */ - public static RenderType getText(ResourceLocation locationIn) - { + public static RenderType getText(ResourceLocation locationIn) { return Internal.TEXT.apply(locationIn); } /** * @return Replacement of {@link RenderType#textIntensity(ResourceLocation)}, but with optional linear texture filtering. */ - public static RenderType getTextIntensity(ResourceLocation locationIn) - { + public static RenderType getTextIntensity(ResourceLocation locationIn) { return Internal.TEXT_INTENSITY.apply(locationIn); } /** * @return Replacement of {@link RenderType#textPolygonOffset(ResourceLocation)}, but with optional linear texture filtering. */ - public static RenderType getTextPolygonOffset(ResourceLocation locationIn) - { + public static RenderType getTextPolygonOffset(ResourceLocation locationIn) { return Internal.TEXT_POLYGON_OFFSET.apply(locationIn); } /** * @return Replacement of {@link RenderType#textIntensityPolygonOffset(ResourceLocation)}, but with optional linear texture filtering. */ - public static RenderType getTextIntensityPolygonOffset(ResourceLocation locationIn) - { + public static RenderType getTextIntensityPolygonOffset(ResourceLocation locationIn) { return Internal.TEXT_INTENSITY_POLYGON_OFFSET.apply(locationIn); } /** * @return Replacement of {@link RenderType#textSeeThrough(ResourceLocation)}, but with optional linear texture filtering. */ - public static RenderType getTextSeeThrough(ResourceLocation locationIn) - { + public static RenderType getTextSeeThrough(ResourceLocation locationIn) { return Internal.TEXT_SEETHROUGH.apply(locationIn); } /** * @return Replacement of {@link RenderType#textIntensitySeeThrough(ResourceLocation)}, but with optional linear texture filtering. */ - public static RenderType getTextIntensitySeeThrough(ResourceLocation locationIn) - { + public static RenderType getTextIntensitySeeThrough(ResourceLocation locationIn) { return Internal.TEXT_INTENSITY_SEETHROUGH.apply(locationIn); } /** - * @return A variation of {@link RenderType#translucent()} that uses {@link OutputStateShard#PARTICLES_TARGET} to allow fabulous transparency sorting when using {@link RenderLevelStageEvent} + * @return A variation of {@link RenderType#translucent()} that uses {@link OutputStateShard#PARTICLES_TARGET} */ - public static RenderType getTranslucentParticlesTarget(ResourceLocation locationIn) - { + public static RenderType getTranslucentParticlesTarget(ResourceLocation locationIn) { return Internal.TRANSLUCENT_PARTICLES_TARGET.apply(locationIn); } @@ -166,35 +148,29 @@ public enum ForgeRenderTypes private final NonNullSupplier renderTypeSupplier; - ForgeRenderTypes(NonNullSupplier renderTypeSupplier) - { + ForgeRenderTypes(NonNullSupplier renderTypeSupplier) { // Wrap in a Lazy<> to avoid running the supplier more than once. this.renderTypeSupplier = NonNullLazy.of(renderTypeSupplier); } - public RenderType get() - { + public RenderType get() { return renderTypeSupplier.get(); } + private static class Internal extends RenderType { + private static final ShaderStateShard RENDERTYPE_ENTITY_TRANSLUCENT_UNLIT_SHADER = new ShaderStateShard(ForgeHooksClient.SHADER_UNLIT_TRANSLUCENT.get()); - private static class Internal extends RenderType - { - private static final ShaderStateShard RENDERTYPE_ENTITY_TRANSLUCENT_UNLIT_SHADER = new ShaderStateShard(ForgeHooksClient.ClientEvents::getEntityTranslucentUnlitShader); - - private Internal(String name, VertexFormat fmt, VertexFormat.Mode glMode, int size, boolean doCrumbling, boolean depthSorting, Runnable onEnable, Runnable onDisable) - { + private Internal(String name, VertexFormat fmt, VertexFormat.Mode glMode, int size, boolean doCrumbling, boolean depthSorting, Runnable onEnable, Runnable onDisable) { super(name, fmt, glMode, size, doCrumbling, depthSorting, onEnable, onDisable); throw new IllegalStateException("This class must not be instantiated"); } public static Function UNSORTED_TRANSLUCENT = Util.memoize(Internal::unsortedTranslucent); - private static RenderType unsortedTranslucent(ResourceLocation textureLocation) - { + private static RenderType unsortedTranslucent(ResourceLocation textureLocation) { final boolean sortingEnabled = false; CompositeState renderState = CompositeState.builder() .setShaderState(RenderType.RENDERTYPE_ENTITY_TRANSLUCENT_SHADER) - .setTextureState(new TextureStateShard(textureLocation, false, false)) + .setTextureState(new TextureStateShard(textureLocation, TriState.FALSE, false)) .setTransparencyState(TRANSLUCENT_TRANSPARENCY) .setCullState(NO_CULL) .setLightmapState(LIGHTMAP) @@ -203,25 +179,26 @@ public enum ForgeRenderTypes return create("forge_entity_unsorted_translucent", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, sortingEnabled, renderState); } - private static final BiFunction ENTITY_TRANSLUCENT = Util.memoize((p_173227_, p_173228_) -> { + /* + private static final BiFunction ENTITY_TRANSLUCENT = Util.memoize((textureLocation, composite) -> { RenderType.CompositeState rendertype$compositestate = RenderType.CompositeState.builder() .setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_SHADER) - .setTextureState(new RenderStateShard.TextureStateShard(p_173227_, false, false)) + .setTextureState(new TextureStateShard(textureLocation, TriState.FALSE, false)) .setTransparencyState(TRANSLUCENT_TRANSPARENCY) .setCullState(NO_CULL) .setLightmapState(LIGHTMAP) .setOverlayState(OVERLAY) - .createCompositeState(p_173228_); + .createCompositeState(composite); return create("entity_translucent", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, rendertype$compositestate); }); + */ public static Function UNLIT_TRANSLUCENT_SORTED = Util.memoize(tex -> Internal.unlitTranslucent(tex, true)); public static Function UNLIT_TRANSLUCENT_UNSORTED = Util.memoize(tex -> Internal.unlitTranslucent(tex, false)); - private static RenderType unlitTranslucent(ResourceLocation textureLocation, boolean sortingEnabled) - { + private static RenderType unlitTranslucent(ResourceLocation textureLocation, boolean sortingEnabled) { CompositeState renderState = CompositeState.builder() .setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_UNLIT_SHADER) - .setTextureState(new TextureStateShard(textureLocation, false, false)) + .setTextureState(new TextureStateShard(textureLocation, TriState.FALSE, false)) .setTransparencyState(TRANSLUCENT_TRANSPARENCY) .setCullState(NO_CULL) .setLightmapState(LIGHTMAP) @@ -234,7 +211,7 @@ public enum ForgeRenderTypes private static RenderType layeredItemSolid(ResourceLocation locationIn) { RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() .setShaderState(RenderType.RENDERTYPE_ENTITY_SOLID_SHADER) - .setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, false)) + .setTextureState(new TextureStateShard(locationIn, TriState.FALSE, false)) .setTransparencyState(NO_TRANSPARENCY) .setLightmapState(LIGHTMAP) .setOverlayState(OVERLAY) @@ -246,7 +223,7 @@ public enum ForgeRenderTypes private static RenderType layeredItemCutout(ResourceLocation locationIn) { RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() .setShaderState(RenderType.RENDERTYPE_ENTITY_CUTOUT_SHADER) - .setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, false)) + .setTextureState(new TextureStateShard(locationIn, TriState.FALSE, false)) .setTransparencyState(NO_TRANSPARENCY) .setLightmapState(LIGHTMAP) .setOverlayState(OVERLAY) @@ -258,7 +235,7 @@ public enum ForgeRenderTypes private static RenderType layeredItemCutoutMipped(ResourceLocation locationIn) { RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() .setShaderState(RenderType.RENDERTYPE_ENTITY_SMOOTH_CUTOUT_SHADER) - .setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, true)) + .setTextureState(new TextureStateShard(locationIn, TriState.FALSE, true)) .setTransparencyState(NO_TRANSPARENCY) .setLightmapState(LIGHTMAP) .setOverlayState(OVERLAY) @@ -270,7 +247,7 @@ public enum ForgeRenderTypes private static RenderType layeredItemTranslucent(ResourceLocation locationIn) { RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() .setShaderState(RenderType.RENDERTYPE_ENTITY_TRANSLUCENT_SHADER) - .setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, false)) + .setTextureState(new TextureStateShard(locationIn, TriState.FALSE, false)) .setTransparencyState(TRANSLUCENT_TRANSPARENCY) .setLightmapState(LIGHTMAP) .setOverlayState(OVERLAY) @@ -354,7 +331,7 @@ public enum ForgeRenderTypes private static RenderType getTranslucentParticlesTarget(ResourceLocation locationIn) { RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() .setShaderState(RENDERTYPE_TRANSLUCENT_SHADER) - .setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, true)) + .setTextureState(new TextureStateShard(locationIn, TriState.FALSE, true)) .setTransparencyState(TRANSLUCENT_TRANSPARENCY) .setLightmapState(LIGHTMAP) .setOutputState(PARTICLES_TARGET) @@ -363,16 +340,15 @@ public enum ForgeRenderTypes } } - private static class CustomizableTextureState extends TextureStateShard - { - private CustomizableTextureState(ResourceLocation resLoc, Supplier blur, Supplier mipmap) - { + private static class CustomizableTextureState extends TextureStateShard { + private CustomizableTextureState(ResourceLocation resLoc, Supplier blur, Supplier mipmap) { super(resLoc, blur.get(), mipmap.get()); this.setupState = () -> { this.blur = blur.get(); this.mipmap = mipmap.get(); - TextureManager texturemanager = Minecraft.getInstance().getTextureManager(); - texturemanager.getTexture(resLoc).setFilter(this.blur, this.mipmap); + TextureManager manager = Minecraft.getInstance().getTextureManager(); + var texture = manager.getTexture(resLoc); + texture.setFilter(this.blur.toBoolean(texture.getDefaultBlur()), this.mipmap); RenderSystem.setShaderTexture(0, resLoc); }; } diff --git a/src/main/java/net/minecraftforge/client/IArmPoseTransformer.java b/src/main/java/net/minecraftforge/client/IArmPoseTransformer.java index 8dd32506a0..0205feef2f 100644 --- a/src/main/java/net/minecraftforge/client/IArmPoseTransformer.java +++ b/src/main/java/net/minecraftforge/client/IArmPoseTransformer.java @@ -6,6 +6,7 @@ package net.minecraftforge.client; import net.minecraft.client.model.HumanoidModel; +import net.minecraft.client.renderer.entity.state.HumanoidRenderState; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.LivingEntity; @@ -18,17 +19,16 @@ import net.minecraftforge.client.extensions.common.IClientItemExtensions; * and returning it in {@link IClientItemExtensions#getArmPose(LivingEntity, InteractionHand, ItemStack)}. */ @FunctionalInterface -public interface IArmPoseTransformer -{ +public interface IArmPoseTransformer { /** * This method should be used to apply all wanted transformations to the player when the ArmPose is active. * You can use {@link LivingEntity#getTicksUsingItem()} and {@link LivingEntity#getUseItemRemainingTicks()} for moving animations. * * @param model The humanoid model - * @param entity The humanoid entity + * @param state The humanoid state * @param arm Arm to pose */ - void applyTransform(HumanoidModel model, LivingEntity entity, HumanoidArm arm); + void applyTransform(HumanoidModel model, HumanoidRenderState state, HumanoidArm arm); } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/RecipeBookManager.java b/src/main/java/net/minecraftforge/client/RecipeBookManager.java deleted file mode 100644 index 00c1c4e809..0000000000 --- a/src/main/java/net/minecraftforge/client/RecipeBookManager.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client; - -import net.minecraft.client.RecipeBookCategories; -import net.minecraft.world.inventory.RecipeBookType; -import net.minecraft.world.item.crafting.Recipe; -import net.minecraft.world.item.crafting.RecipeHolder; -import net.minecraft.world.item.crafting.RecipeType; -import net.minecraftforge.client.event.RegisterRecipeBookCategoriesEvent; -import net.minecraftforge.fml.ModLoader; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - -/** - * Manager for {@link RecipeBookType recipe book types} and {@link RecipeBookCategories categories}. - *

- * Provides a recipe category lookup. - */ -public final class RecipeBookManager { - // Not using ConcurrentHashMap here because it's slower for lookups, so we only use it during init - private static final Map> AGGREGATE_CATEGORIES = new HashMap<>(); - private static final Map> TYPE_CATEGORIES = new HashMap<>(); - private static final Map, Function, RecipeBookCategories>> RECIPE_CATEGORY_LOOKUPS = new HashMap<>(); - private static final Map> AGGREGATE_CATEGORIES_VIEW = Collections.unmodifiableMap(AGGREGATE_CATEGORIES); - - /** - * Finds the category the specified recipe should display in, or null if none. - */ - @Nullable - public static > RecipeBookCategories findCategories(RecipeType type, RecipeHolder recipe) { - var lookup = RECIPE_CATEGORY_LOOKUPS.get(type); - return lookup != null ? lookup.apply(recipe.value()) : null; - } - - @ApiStatus.Internal - public static Map> getAggregateCategories(Map> vanilla) { - return AGGREGATE_CATEGORIES_VIEW; - } - - @ApiStatus.Internal - public static List getCustomCategoriesOrEmpty(RecipeBookType recipeBookType) { - return TYPE_CATEGORIES.getOrDefault(recipeBookType, List.of()); - } - - @ApiStatus.Internal - public static void init() { - // The ImmutableMap is the patched out value of AGGREGATE_CATEGORIES - var aggregateCategories = new HashMap<>(Map.of( - RecipeBookCategories.CRAFTING_SEARCH, List.of(RecipeBookCategories.CRAFTING_EQUIPMENT, RecipeBookCategories.CRAFTING_BUILDING_BLOCKS, RecipeBookCategories.CRAFTING_MISC, RecipeBookCategories.CRAFTING_REDSTONE), - RecipeBookCategories.FURNACE_SEARCH, List.of(RecipeBookCategories.FURNACE_FOOD, RecipeBookCategories.FURNACE_BLOCKS, RecipeBookCategories.FURNACE_MISC), - RecipeBookCategories.BLAST_FURNACE_SEARCH, List.of(RecipeBookCategories.BLAST_FURNACE_BLOCKS, RecipeBookCategories.BLAST_FURNACE_MISC), - RecipeBookCategories.SMOKER_SEARCH, List.of(RecipeBookCategories.SMOKER_FOOD) - )); - - var typeCategories = new HashMap>(); - var recipeCategoryLookups = new HashMap, Function, RecipeBookCategories>>(); - var event = new RegisterRecipeBookCategoriesEvent(aggregateCategories, typeCategories, recipeCategoryLookups); - ModLoader.get().postEventWrapContainerInModOrder(event); - AGGREGATE_CATEGORIES.putAll(aggregateCategories); - TYPE_CATEGORIES.putAll(typeCategories); - RECIPE_CATEGORY_LOOKUPS.putAll(recipeCategoryLookups); - } -} diff --git a/src/main/java/net/minecraftforge/client/RenderTypeHelper.java b/src/main/java/net/minecraftforge/client/RenderTypeHelper.java index 4ade29d0ec..f57ea1b87e 100644 --- a/src/main/java/net/minecraftforge/client/RenderTypeHelper.java +++ b/src/main/java/net/minecraftforge/client/RenderTypeHelper.java @@ -6,7 +6,6 @@ package net.minecraftforge.client; import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.Sheets; @@ -26,13 +25,11 @@ public final class RenderTypeHelper { * Provides a {@link RenderType} using {@link DefaultVertexFormat#NEW_ENTITY} for the given {@link DefaultVertexFormat#BLOCK} format. * This should be called for each {@link RenderType} returned by {@link BakedModel#getRenderTypes(BlockState, RandomSource, ModelData)}. *

- * Mimics the behavior of vanilla's {@link ItemBlockRenderTypes#getRenderType(BlockState, boolean)}. + * Mimics the behavior of vanilla's {@link ItemBlockRenderTypes#getRenderType(BlockState)}. */ @NotNull - public static RenderType getEntityRenderType(RenderType chunkRenderType, boolean cull) { - if (chunkRenderType != RenderType.translucent()) - return Sheets.cutoutBlockSheet(); - return cull || !Minecraft.useShaderTransparency() ? Sheets.translucentCullBlockSheet() : Sheets.translucentItemSheet(); + public static RenderType getEntityRenderType(RenderType chunkRenderType) { + return chunkRenderType == RenderType.translucent() ? Sheets.translucentItemSheet() : Sheets.cutoutBlockSheet(); } /** @@ -55,14 +52,14 @@ public final class RenderTypeHelper { * but removes the need to query the model again if the item is a {@link BlockItem}. */ @NotNull - public static RenderType getFallbackItemRenderType(ItemStack stack, BakedModel model, boolean cull) { + public static RenderType getFallbackItemRenderType(ItemStack stack, BakedModel model) { if (stack.getItem() instanceof BlockItem blockItem) { var renderTypes = model.getRenderTypes(blockItem.getBlock().defaultBlockState(), RandomSource.create(42), ModelData.EMPTY); if (renderTypes.contains(RenderType.translucent())) - return getEntityRenderType(RenderType.translucent(), cull); + return getEntityRenderType(RenderType.translucent()); return Sheets.cutoutBlockSheet(); } - return cull ? Sheets.translucentCullBlockSheet() : Sheets.translucentItemSheet(); + return Sheets.translucentItemSheet(); } private RenderTypeHelper() {} diff --git a/src/main/java/net/minecraftforge/client/event/ComputeFovModifierEvent.java b/src/main/java/net/minecraftforge/client/event/ComputeFovModifierEvent.java index 396ab73618..da21bede99 100644 --- a/src/main/java/net/minecraftforge/client/event/ComputeFovModifierEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ComputeFovModifierEvent.java @@ -24,41 +24,42 @@ import org.jetbrains.annotations.ApiStatus; * * @see ViewportEvent.ComputeFov */ -public class ComputeFovModifierEvent extends Event -{ +public class ComputeFovModifierEvent extends Event { private final Player player; private final float fovModifier; + private final float scale; private float newFovModifier; @ApiStatus.Internal - public ComputeFovModifierEvent(Player player, float fovModifier) - { + public ComputeFovModifierEvent(Player player, float fovModifier, float scale) { this.player = player; this.fovModifier = fovModifier; - this.setNewFovModifier((float) Mth.lerp(Minecraft.getInstance().options.fovEffectScale().get(), 1.0F, fovModifier)); + this.scale = scale; + this.newFovModifier = Mth.lerp(scale, 1.0F, fovModifier); } /** * {@return the player affected by this event} */ - public Player getPlayer() - { + public Player getPlayer() { return player; } /** * {@return the original field of vision (FOV) of the player, before any modifications or interpolation} */ - public float getFovModifier() - { + public float getFovModifier() { return fovModifier; } + public float getScale() { + return scale; + } + /** * {@return the current field of vision (FOV) of the player} */ - public float getNewFovModifier() - { + public float getNewFovModifier() { return newFovModifier; } @@ -67,8 +68,7 @@ public class ComputeFovModifierEvent extends Event * * @param newFovModifier the new field of vision (FOV) */ - public void setNewFovModifier(float newFovModifier) - { + public void setNewFovModifier(float newFovModifier) { this.newFovModifier = newFovModifier; } } diff --git a/src/main/java/net/minecraftforge/client/event/EntityRenderersEvent.java b/src/main/java/net/minecraftforge/client/event/EntityRenderersEvent.java index 3bf0989043..04f84e9fb0 100644 --- a/src/main/java/net/minecraftforge/client/event/EntityRenderersEvent.java +++ b/src/main/java/net/minecraftforge/client/event/EntityRenderersEvent.java @@ -6,7 +6,6 @@ package net.minecraftforge.client.event; import com.google.common.collect.ImmutableMap; -import net.minecraft.client.model.EntityModel; import net.minecraft.client.model.SkullModel; import net.minecraft.client.model.SkullModelBase; import net.minecraft.client.model.geom.EntityModelSet; @@ -18,8 +17,8 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.EntityRenderers; -import net.minecraft.client.renderer.entity.LivingEntityRenderer; import net.minecraft.client.renderer.entity.player.PlayerRenderer; +import net.minecraft.client.renderer.entity.state.EntityRenderState; import net.minecraft.client.resources.PlayerSkin; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -128,12 +127,12 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ public static class AddLayers extends EntityRenderersEvent { - private final Map, EntityRenderer> renderers; - private final Map> skinMap; + private final Map, EntityRenderer> renderers; + private final Map> skinMap; private final EntityRendererProvider.Context context; @ApiStatus.Internal - public AddLayers(Map, EntityRenderer> renderers, Map> playerRenderers, EntityRendererProvider.Context context) { + public AddLayers(Map, EntityRenderer> renderers, Map> playerRenderers, EntityRendererProvider.Context context) { this.renderers = renderers; this.skinMap = playerRenderers; this.context = context; @@ -160,7 +159,7 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent */ @Nullable @SuppressWarnings("unchecked") - public > R getPlayerSkin(PlayerSkin.Model skinName) { + public > R getPlayerSkin(PlayerSkin.Model skinName) { return (R)skinMap.get(skinName); } @@ -174,7 +173,7 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent */ @Nullable @SuppressWarnings("unchecked") - public > R getEntityRenderer(EntityType entityType) { + public > R getEntityRenderer(EntityType entityType) { return (R)renderers.get(entityType); } diff --git a/src/main/java/net/minecraftforge/client/event/ForgeEventFactoryClient.java b/src/main/java/net/minecraftforge/client/event/ForgeEventFactoryClient.java index 727e01bb38..4296b9678a 100644 --- a/src/main/java/net/minecraftforge/client/event/ForgeEventFactoryClient.java +++ b/src/main/java/net/minecraftforge/client/event/ForgeEventFactoryClient.java @@ -8,53 +8,55 @@ package net.minecraftforge.client.event; import java.io.File; import java.util.List; import java.util.Map; -import java.util.function.Consumer; - import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.fml.ModLoader; import net.minecraftforge.fml.event.IModBusEvent; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import com.mojang.blaze3d.audio.Channel; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.datafixers.util.Pair; - import net.minecraft.client.Camera; +import net.minecraft.client.ClientRecipeBook; import net.minecraft.client.DeltaTracker; import net.minecraft.client.KeyMapping; import net.minecraft.client.MouseHandler; +import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.toasts.Toast; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.client.model.EntityModel; import net.minecraft.client.multiplayer.MultiPlayerGameMode; -import net.minecraft.client.player.AbstractClientPlayer; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.ShaderInstance; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider.Context; import net.minecraft.client.renderer.entity.ItemFrameRenderer; import net.minecraft.client.renderer.entity.LivingEntityRenderer; import net.minecraft.client.renderer.entity.player.PlayerRenderer; +import net.minecraft.client.renderer.entity.state.EntityRenderState; +import net.minecraft.client.renderer.entity.state.ItemFrameRenderState; +import net.minecraft.client.renderer.entity.state.LivingEntityRenderState; +import net.minecraft.client.renderer.entity.state.PlayerRenderState; import net.minecraft.client.resources.PlayerSkin.Model; import net.minecraft.client.resources.sounds.SoundInstance; import net.minecraft.client.sounds.SoundEngine; import net.minecraft.network.Connection; import net.minecraft.network.chat.Component; -import net.minecraft.server.packs.resources.ResourceProvider; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionHand; -import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.decoration.ItemFrame; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.client.event.sound.PlaySoundSourceEvent; import net.minecraftforge.client.event.sound.PlayStreamingSourceEvent; import net.minecraftforge.eventbus.api.Event; @@ -88,33 +90,27 @@ public final class ForgeEventFactoryClient { ML.postEvent(e); } - public static void onGatherLayers(Map, EntityRenderer> renderers, Map> playerRenderers, Context context) { + public static void onGatherLayers(Map, EntityRenderer> renderers, Map> playerRenderers, Context context) { // TODO: Why is this a ModLoader event... postModBus(new EntityRenderersEvent.AddLayers(renderers, playerRenderers, context)); } - public static void onRegisterShaders(ResourceProvider resourceProvider, List>> shaderList) { - // TODO: Why is this a ModLoader event... - postModBus(new RegisterShadersEvent(resourceProvider, shaderList)); + public static boolean onScreenMouseReleased(Screen screen, double mouseX, double mouseY, int button) { + if (post(new ScreenEvent.MouseButtonReleased.Pre(screen, mouseX, mouseY, button))) + return true; + + var ret = screen.mouseReleased(mouseX, mouseY, button); + var result = fire(new ScreenEvent.MouseButtonReleased.Post(screen, mouseX, mouseY, button, ret)).getResult(); + return result == Event.Result.DEFAULT ? ret : result == Event.Result.ALLOW; } - public static void onScreenMouseReleased(boolean[] state, Screen screen, double mouseX, double mouseY, int button) { - state[0] = post(new ScreenEvent.MouseButtonReleased.Pre(screen, mouseX, mouseY, button)); - if (!state[0]) { - state[0] = screen.mouseReleased(mouseX, mouseY, button); - var result = fire(new ScreenEvent.MouseButtonReleased.Post(screen, mouseX, mouseY, button, state[0])).getResult(); - state[0] = result == Event.Result.DEFAULT ? state[0] : result == Event.Result.ALLOW; - } - } + public static boolean onScreenMouseClicked(Screen screen, double mouseX, double mouseY, int button) { + var ret = post(new ScreenEvent.MouseButtonPressed.Pre(screen, mouseX, mouseY, button)); + if (!ret) + ret = screen.mouseClicked(mouseX, mouseY, button); - public static void onScreenMouseClicked(boolean[] state, Screen screen, double mouseX, double mouseY, int button) { - state[0] = post(new ScreenEvent.MouseButtonPressed.Pre(screen, mouseX, mouseY, button)); - if (!state[0]) { - state[0] = screen.mouseClicked(mouseX, mouseY, button); - } - - var result = fire(new ScreenEvent.MouseButtonPressed.Post(screen, mouseX, mouseY, button, state[0])).getResult(); - state[0] = result == Event.Result.DEFAULT ? state[0] : result == Event.Result.ALLOW; + var result = fire(new ScreenEvent.MouseButtonPressed.Post(screen, mouseX, mouseY, button, ret)).getResult(); + return result == Event.Result.DEFAULT ? ret : result == Event.Result.ALLOW; } public static boolean onMouseButtonPre(int button, int action, int mods) { @@ -141,8 +137,8 @@ public final class ForgeEventFactoryClient { return post(new ScreenEvent.MouseDragged.Pre(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY)); } - public static void onScreenMouseDragPost(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { - post(new ScreenEvent.MouseDragged.Post(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY)); + public static boolean onScreenMouseDragPost(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { + return post(new ScreenEvent.MouseDragged.Post(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY)); } public static @Nullable Screen onScreenOpening(Screen old, Screen screen) { @@ -216,7 +212,7 @@ public final class ForgeEventFactoryClient { post(new ClientPlayerNetworkEvent.Clone(pc, oldPlayer, newPlayer, networkManager)); } - public static ViewportEvent.ComputeFov fireComputeFov(GameRenderer renderer, Camera camera, double partialTick, double fov, boolean usedConfiguredFov) { + public static ViewportEvent.ComputeFov fireComputeFov(GameRenderer renderer, Camera camera, double partialTick, float fov, boolean usedConfiguredFov) { return fire(new ViewportEvent.ComputeFov(renderer, camera, partialTick, fov, usedConfiguredFov)); } @@ -224,32 +220,32 @@ public final class ForgeEventFactoryClient { return fire(new ViewportEvent.ComputeCameraAngles(renderer, camera, partial, camera.getYRot(), camera.getXRot(), 0)); } - public static > boolean onRenderLivingPre(LivingEntity entity, LivingEntityRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - return post(new RenderLivingEvent.Pre(entity, renderer, partialTick, poseStack, multiBufferSource, packedLight)); + public static > boolean onRenderLivingPre(S state, LivingEntityRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + return post(new RenderLivingEvent.Pre(state, renderer, poseStack, multiBufferSource, packedLight)); } - public static > boolean onRenderLivingPost(LivingEntity entity, LivingEntityRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - return post(new RenderLivingEvent.Post(entity, renderer, partialTick, poseStack, multiBufferSource, packedLight)); + public static > boolean onRenderLivingPost(S state, LivingEntityRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + return post(new RenderLivingEvent.Post(state, renderer, poseStack, multiBufferSource, packedLight)); } - public static boolean onRenderPlayerPre(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - return post(new RenderPlayerEvent.Pre(player, renderer, partialTick, poseStack, multiBufferSource, packedLight)); + public static boolean onRenderPlayerPre(PlayerRenderState player, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + return post(new RenderPlayerEvent.Pre(player, renderer, poseStack, multiBufferSource, packedLight)); } - public static boolean onRenderPlayerPost(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - return post(new RenderPlayerEvent.Post(player, renderer, partialTick, poseStack, multiBufferSource, packedLight)); + public static boolean onRenderPlayerPost(PlayerRenderState player, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + return post(new RenderPlayerEvent.Post(player, renderer, poseStack, multiBufferSource, packedLight)); } - public static boolean onRenderArm(PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, AbstractClientPlayer player, HumanoidArm arm) { - return post(new RenderArmEvent(poseStack, multiBufferSource, packedLight, player, arm)); + public static boolean onRenderArm(PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, HumanoidArm arm) { + return post(new RenderArmEvent(poseStack, multiBufferSource, packedLight, arm)); } - public static boolean onRenderItemInFrame(ItemFrame itemFrame, ItemFrameRenderer renderItemFrame, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - return post(new RenderItemInFrameEvent(itemFrame, renderItemFrame, poseStack, multiBufferSource, packedLight)); + public static boolean onRenderItemInFrame(ItemFrameRenderState state, ItemFrameRenderer renderItemFrame, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + return post(new RenderItemInFrameEvent(state, renderItemFrame, poseStack, multiBufferSource, packedLight)); } - public static RenderNameTagEvent fireRenderNameTagEvent(Entity entity, Component content, EntityRenderer entityRenderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, float partialTick) { - return fire(new RenderNameTagEvent(entity, content, entityRenderer, poseStack, multiBufferSource, packedLight, partialTick)); + public static RenderNameTagEvent fireRenderNameTagEvent(EntityRenderState state, Component content, EntityRenderer entityRenderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + return fire(new RenderNameTagEvent(state, content, entityRenderer, poseStack, multiBufferSource, packedLight)); } public static void onRenderScreenBackground(Screen screen, GuiGraphics guiGraphics) { @@ -263,4 +259,24 @@ public final class ForgeEventFactoryClient { public static void onRenderTickEnd(DeltaTracker timer) { post(new TickEvent.RenderTickEvent.Post(timer)); } + + public static RenderTooltipEvent.Background onRenderTooltipBackground(@NotNull ItemStack stack, GuiGraphics graphics, int x, int y, @NotNull Font font, @NotNull List components, @Nullable ResourceLocation backgroundPrefix) { + return fire(new RenderTooltipEvent.Background(stack, graphics, x, y, font, components, backgroundPrefix)); + } + + public static boolean onToastAdd(Toast toast) { + return post(new ToastAddEvent(toast)); + } + + public static ScreenEvent.RenderInventoryMobEffects onScreenEffectSize(Screen screen, int availableSpace, boolean compact, int horizontalOffset) { + return fire(new ScreenEvent.RenderInventoryMobEffects(screen, availableSpace, compact, horizontalOffset)); + } + + public static void onRecipesUpdated(ClientRecipeBook book) { + post(new RecipesUpdatedEvent(book)); + } + + public static ComputeFovModifierEvent fireFovModifierEvent(Player entity, float modifier, float scale) { + return fire(new ComputeFovModifierEvent(entity, modifier, scale)); + } } diff --git a/src/main/java/net/minecraftforge/client/event/ModelEvent.java b/src/main/java/net/minecraftforge/client/event/ModelEvent.java index 507f3040a1..962c882f93 100644 --- a/src/main/java/net/minecraftforge/client/event/ModelEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ModelEvent.java @@ -21,7 +21,6 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.jetbrains.annotations.ApiStatus; import java.util.Map; -import java.util.Set; /** * Houses events related to models. @@ -116,31 +115,6 @@ public abstract class ModelEvent extends Event { } } - /** - * Fired when the {@link net.minecraft.client.resources.model.ModelBakery} is notified of the resource manager reloading. - * Allows developers to register models to be loaded, along with their dependencies. - * - *

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 RegisterAdditional extends ModelEvent implements IModBusEvent { - private final Set models; - - @ApiStatus.Internal - public RegisterAdditional(Set models) { - this.models = models; - } - - /** - * Registers a model to be loaded, along with its dependencies. - */ - public void register(ModelResourceLocation model) { - models.add(model); - } - } - /** * Allows users to register their own {@link IGeometryLoader geometry loaders} for use in block/item models. * diff --git a/src/main/java/net/minecraftforge/client/event/MovementInputUpdateEvent.java b/src/main/java/net/minecraftforge/client/event/MovementInputUpdateEvent.java index a1d8a5f233..422ba3d3fc 100644 --- a/src/main/java/net/minecraftforge/client/event/MovementInputUpdateEvent.java +++ b/src/main/java/net/minecraftforge/client/event/MovementInputUpdateEvent.java @@ -5,7 +5,7 @@ package net.minecraftforge.client.event; -import net.minecraft.client.player.Input; +import net.minecraft.client.player.ClientInput; import net.minecraft.world.entity.player.Player; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerEvent; @@ -21,13 +21,11 @@ import org.jetbrains.annotations.ApiStatus; *

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

*/ -public class MovementInputUpdateEvent extends PlayerEvent -{ - private final Input input; +public class MovementInputUpdateEvent extends PlayerEvent { + private final ClientInput input; @ApiStatus.Internal - public MovementInputUpdateEvent(Player player, Input input) - { + public MovementInputUpdateEvent(Player player, ClientInput input) { super(player); this.input = input; } @@ -35,8 +33,7 @@ public class MovementInputUpdateEvent extends PlayerEvent /** * {@return the player's movement inputs} */ - public Input getInput() - { + public ClientInput getInput() { return input; } } diff --git a/src/main/java/net/minecraftforge/client/event/RecipesUpdatedEvent.java b/src/main/java/net/minecraftforge/client/event/RecipesUpdatedEvent.java index 0337d6c4ac..1e4d5ad032 100644 --- a/src/main/java/net/minecraftforge/client/event/RecipesUpdatedEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RecipesUpdatedEvent.java @@ -5,6 +5,7 @@ package net.minecraftforge.client.event; +import net.minecraft.client.ClientRecipeBook; import net.minecraft.world.item.crafting.RecipeManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; @@ -13,28 +14,25 @@ import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; /** - * Fired when the {@link RecipeManager} has received and synced the recipes from the server to the client. + * Fired when the {@link ClientRecipeBook} has updated information about recipes from the server to the client. * *

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}.

*/ -public class RecipesUpdatedEvent extends Event -{ - private final RecipeManager recipeManager; +public class RecipesUpdatedEvent extends Event { + private final ClientRecipeBook recipeBook; @ApiStatus.Internal - public RecipesUpdatedEvent(RecipeManager recipeManager) - { - this.recipeManager = recipeManager; + public RecipesUpdatedEvent(ClientRecipeBook recipeBook) { + this.recipeBook = recipeBook; } /** * {@return the recipe manager} */ - public RecipeManager getRecipeManager() - { - return recipeManager; + public ClientRecipeBook getRecipeBook() { + return recipeBook; } } diff --git a/src/main/java/net/minecraftforge/client/event/RegisterRecipeBookCategoriesEvent.java b/src/main/java/net/minecraftforge/client/event/RegisterRecipeBookCategoriesEvent.java deleted file mode 100644 index f39eb7c3b3..0000000000 --- a/src/main/java/net/minecraftforge/client/event/RegisterRecipeBookCategoriesEvent.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.event; - -import net.minecraft.client.RecipeBookCategories; -import net.minecraft.world.inventory.RecipeBookType; -import net.minecraft.world.item.crafting.Recipe; -import net.minecraft.world.item.crafting.RecipeType; -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 java.util.List; -import java.util.Map; -import java.util.function.Function; - -/** - * Allows users to register custom categories for the vanilla recipe book, making it usable in modded GUIs. - * - *

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 class RegisterRecipeBookCategoriesEvent extends Event implements IModBusEvent -{ - private final Map> aggregateCategories; - private final Map> typeCategories; - private final Map, Function, RecipeBookCategories>> recipeCategoryLookups; - - @ApiStatus.Internal - public RegisterRecipeBookCategoriesEvent( - Map> aggregateCategories, - Map> typeCategories, - Map, Function, RecipeBookCategories>> recipeCategoryLookups) - { - this.aggregateCategories = aggregateCategories; - this.typeCategories = typeCategories; - this.recipeCategoryLookups = recipeCategoryLookups; - } - - /** - * Registers the list of categories that compose an aggregate category. - */ - public void registerAggregateCategory(RecipeBookCategories category, List others) - { - aggregateCategories.put(category, List.copyOf(others)); - } - - /** - * Registers the list of categories that compose a recipe book. - */ - public void registerBookCategories(RecipeBookType type, List categories) - { - typeCategories.put(type, List.copyOf(categories)); - } - - /** - * Registers a category lookup for a certain recipe type. - */ - public void registerRecipeCategoryFinder(RecipeType type, Function, RecipeBookCategories> lookup) - { - recipeCategoryLookups.put(type, lookup); - } -} diff --git a/src/main/java/net/minecraftforge/client/event/RegisterShadersEvent.java b/src/main/java/net/minecraftforge/client/event/RegisterShadersEvent.java deleted file mode 100644 index f4cea57042..0000000000 --- a/src/main/java/net/minecraftforge/client/event/RegisterShadersEvent.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.event; - -import com.mojang.datafixers.util.Pair; -import net.minecraft.client.renderer.ShaderInstance; -import net.minecraft.server.packs.resources.ResourceProvider; -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 java.util.List; -import java.util.function.Consumer; - -/** - * Fired to allow mods to register custom {@linkplain ShaderInstance shaders}. - * This event is fired after the default Minecraft shaders have been 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}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

- */ -public class RegisterShadersEvent extends Event implements IModBusEvent { - private final ResourceProvider resourceProvider; - private final List>> shaderList; - - @ApiStatus.Internal - public RegisterShadersEvent(ResourceProvider resourceProvider, List>> shaderList) { - this.resourceProvider = resourceProvider; - this.shaderList = shaderList; - } - - /** - * {@return the client-side resource provider} - */ - public ResourceProvider getResourceProvider() { - return resourceProvider; - } - - /** - * Registers a shader, and a callback for when the shader is loaded. - * - *

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.

- * - * @param shaderInstance a shader - * @param onLoaded a callback for when the shader is loaded - */ - public void registerShader(ShaderInstance shaderInstance, Consumer onLoaded) { - shaderList.add(Pair.of(shaderInstance, onLoaded)); - } -} diff --git a/src/main/java/net/minecraftforge/client/event/RenderArmEvent.java b/src/main/java/net/minecraftforge/client/event/RenderArmEvent.java index 2ec47314f6..c75ece2aa6 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderArmEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderArmEvent.java @@ -32,15 +32,13 @@ public class RenderArmEvent extends Event { private final PoseStack poseStack; private final MultiBufferSource multiBufferSource; private final int packedLight; - private final AbstractClientPlayer player; private final HumanoidArm arm; @ApiStatus.Internal - public RenderArmEvent(PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, AbstractClientPlayer player, HumanoidArm arm) { + public RenderArmEvent(PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, HumanoidArm arm) { this.poseStack = poseStack; this.multiBufferSource = multiBufferSource; this.packedLight = packedLight; - this.player = player; this.arm = arm; } @@ -73,12 +71,4 @@ public class RenderArmEvent extends Event { public int getPackedLight() { return packedLight; } - - /** - * {@return the client player that is having their arm rendered} In general, this will be the same as - * {@link net.minecraft.client.Minecraft#player}. - */ - public AbstractClientPlayer getPlayer() { - return player; - } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java b/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java index 289aea55e6..67375e94c5 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java @@ -9,7 +9,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.ItemFrameRenderer; -import net.minecraft.world.entity.decoration.ItemFrame; +import net.minecraft.client.renderer.entity.state.ItemFrameRenderState; import net.minecraft.world.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; @@ -31,18 +31,16 @@ import org.jetbrains.annotations.ApiStatus; */ @Cancelable public class RenderItemInFrameEvent extends Event { - private final ItemStack itemStack; - private final ItemFrame itemFrameEntity; + private final ItemFrameRenderState state; private final ItemFrameRenderer renderer; private final PoseStack poseStack; private final MultiBufferSource multiBufferSource; private final int packedLight; @ApiStatus.Internal - public RenderItemInFrameEvent(ItemFrame itemFrame, ItemFrameRenderer renderItemFrame, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - itemStack = itemFrame.getItem(); - itemFrameEntity = itemFrame; - renderer = renderItemFrame; + public RenderItemInFrameEvent(ItemFrameRenderState state, ItemFrameRenderer renderItemFrame, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + this.state = state; + this.renderer = renderItemFrame; this.poseStack = poseStack; this.multiBufferSource = multiBufferSource; this.packedLight = packedLight; @@ -52,14 +50,14 @@ public class RenderItemInFrameEvent extends Event { * {@return the item stack being rendered} */ public ItemStack getItemStack() { - return itemStack; + return getItemFrameState().itemStack; } /** * {@return the item frame entity} */ - public ItemFrame getItemFrameEntity() { - return itemFrameEntity; + public ItemFrameRenderState getItemFrameState() { + return state; } /** diff --git a/src/main/java/net/minecraftforge/client/event/RenderLevelStageEvent.java b/src/main/java/net/minecraftforge/client/event/RenderLevelStageEvent.java deleted file mode 100644 index e69c8c085d..0000000000 --- a/src/main/java/net/minecraftforge/client/event/RenderLevelStageEvent.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.event; - -import java.util.HashMap; -import java.util.Map; - -import javax.annotation.Nullable; - -import com.mojang.blaze3d.vertex.PoseStack; - -import net.minecraft.client.Camera; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.culling.Frustum; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.client.ForgeRenderTypes; -import net.minecraftforge.common.MinecraftForge; -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.joml.Matrix4f; - -/** - * 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}.

- */ -public class RenderLevelStageEvent extends Event { - private final Stage stage; - private final LevelRenderer levelRenderer; - private final Matrix4f poseStack; - private final Matrix4f projectionMatrix; - private final int renderTick; - private final float partialTick; - private final Camera camera; - private final Frustum frustum; - - public RenderLevelStageEvent(Stage stage, LevelRenderer levelRenderer, Matrix4f poseStack, Matrix4f projectionMatrix, int renderTick, float partialTick, Camera camera, Frustum frustum) { - this.stage = stage; - this.levelRenderer = levelRenderer; - this.poseStack = poseStack; - this.projectionMatrix = projectionMatrix; - this.renderTick = renderTick; - this.partialTick = partialTick; - this.camera = camera; - this.frustum = frustum; - } - - /** - * {@return the current {@linkplain Stage stage} that is being rendered. Check this before doing rendering to ensure - * that rendering happens at the appropriate time.} - */ - public Stage getStage() { - return stage; - } - - /** - * {@return the level renderer} - */ - public LevelRenderer getLevelRenderer() { - return levelRenderer; - } - - /** - * @deprecated Mojang has stopped passing around PosStacks. getProjectionMatrix should be enough. - */ - @Deprecated(forRemoval = true, since = "1.21") - public Matrix4f getPoseStack() { - return poseStack; - } - - /** - * {@return the projection matrix} - */ - public Matrix4f getProjectionMatrix() { - return projectionMatrix; - } - - /** - * {@return the current "ticks" value in the {@linkplain LevelRenderer level renderer}} - */ - public int getRenderTick() { - return renderTick; - } - - /** - * {@return the current partialTick value used for rendering} - */ - public float getPartialTick() { - return partialTick; - } - - /** - * {@return the camera} - */ - public Camera getCamera() { - return camera; - } - - /** - * {@return the frustum} - */ - public Frustum getFrustum() { - return frustum; - } - - /** - * 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}.

- */ - public static class RegisterStageEvent extends Event implements IModBusEvent { - /** - * @param name The name of your Stage. - * @param renderType - * If not null, called automatically by LevelRenderer.renderChunkLayer if the RenderType passed into it matches this one. - * If null, needs to be called manually by whoever implements it. - * - * @throws IllegalArgumentException if the RenderType passed is already mapped to a Stage. - */ - public Stage register(ResourceLocation name, @Nullable RenderType renderType) throws IllegalArgumentException { - return Stage.register(name, renderType); - } - } - - /** - * A time during level rendering for you to render custom things into the world. - * @see RegisterStageEvent - */ - public static class Stage { - private static final Map RENDER_TYPE_STAGES = new HashMap<>(); - - /** - * Use this to render custom objects into the skybox. - * Called regardless of if they sky actually renders or not. - */ - public static final Stage AFTER_SKY = register("after_sky", null); - /** - * Use this to render custom block-like geometry into the world. - */ - public static final Stage AFTER_SOLID_BLOCKS = register("after_solid_blocks", RenderType.solid()); - /** - * Use this to render custom block-like geometry into the world. - */ - public static final Stage AFTER_CUTOUT_MIPPED_BLOCKS_BLOCKS = register("after_cutout_mipped_blocks", RenderType.cutoutMipped()); - /** - * Use this to render custom block-like geometry into the world. - */ - public static final Stage AFTER_CUTOUT_BLOCKS = register("after_cutout_blocks", RenderType.cutout()); - /** - * Use this to render custom block-like geometry into the world. - */ - public static final Stage AFTER_ENTITIES = register("after_entities", null); - /** - * Use this to render custom block-like geometry into the world. - */ - public static final Stage AFTER_BLOCK_ENTITIES = register("after_block_entities", null); - /** - * Use this to render custom block-like geometry into the world. - * Due to how transparency sorting works, this stage may not work properly with translucency. If you intend to render translucency, - * try using {@link #AFTER_TRIPWIRE_BLOCKS} or {@link #AFTER_PARTICLES}. - * Although this is called within a fabulous graphics target, it does not function properly in many cases. - */ - public static final Stage AFTER_TRANSLUCENT_BLOCKS = register("after_translucent_blocks", RenderType.translucent()); - /** - * Use this to render custom block-like geometry into the world. - */ - public static final Stage AFTER_TRIPWIRE_BLOCKS = register("after_tripwire_blocks", RenderType.tripwire()); - /** - * 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); - /** - * Use this to render custom weather effects into the world. - * Called within a fabulous graphics target. - */ - public static final Stage AFTER_WEATHER = register("after_weather", null); - /** - * Use this to render after everything in the level has been rendered. - * Called after {@link LevelRenderer#renderLevel(PoseStack, float, long, boolean, Camera, GameRenderer, LightTexture, Matrix4f)} finishes. - */ - public static final Stage AFTER_LEVEL = register("after_level", null); - - private final String name; - - private Stage(String name) { - this.name = name; - } - - private static Stage register(ResourceLocation name, @Nullable RenderType renderType) throws IllegalArgumentException { - Stage stage = new Stage(name.toString()); - if (renderType != null && RENDER_TYPE_STAGES.putIfAbsent(renderType, stage) != null) - throw new IllegalArgumentException("Attempted to replace an existing RenderLevelStageEvent.Stage for a RenderType: Stage = " + stage + ", RenderType = " + renderType); - return stage; - } - - private static Stage register(String name, @Nullable RenderType renderType) throws IllegalArgumentException { - return register(ResourceLocation.parse(name), renderType); - } - - @Override - public String toString() { - return this.name; - } - - /** - * {@return the {@linkplain Stage stage} bound to the {@linkplain RenderType render type}, or null if no value is present} - */ - @Nullable - public static Stage fromRenderType(RenderType renderType) { - return RENDER_TYPE_STAGES.get(renderType); - } - - /** Internal just to make our patch smaller, it just fires the event. If you have good reason for this to be external, ask. */ - @ApiStatus.Internal - public void dispatch(LevelRenderer levelRenderer, Matrix4f poseStack, Matrix4f projectionMatrix, int renderTick, Camera camera, Frustum frustum) { - var mc = Minecraft.getInstance(); - var profiler = mc.getProfiler(); - profiler.push(this.toString()); - MinecraftForge.EVENT_BUS.post(new RenderLevelStageEvent(this, levelRenderer, poseStack, projectionMatrix, renderTick, mc.getTimer().getRealtimeDeltaTicks(), camera, frustum)); - profiler.pop(); - } - } -} diff --git a/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java b/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java index fbf6e06ad9..e5b11fab56 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java @@ -10,6 +10,7 @@ import net.minecraft.client.model.EntityModel; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.LivingEntityRenderer; +import net.minecraft.client.renderer.entity.state.LivingEntityRenderState; import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; @@ -31,19 +32,17 @@ import org.jetbrains.annotations.ApiStatus; * @see RenderPlayerEvent * @see LivingEntityRenderer */ -public abstract class RenderLivingEvent> extends Event { - private final LivingEntity entity; - private final LivingEntityRenderer renderer; - private final float partialTick; +public abstract class RenderLivingEvent> extends Event { + private final S state; + private final LivingEntityRenderer renderer; private final PoseStack poseStack; private final MultiBufferSource multiBufferSource; private final int packedLight; @ApiStatus.Internal - protected RenderLivingEvent(LivingEntity entity, LivingEntityRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - this.entity = entity; + protected RenderLivingEvent(S state, LivingEntityRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + this.state = state; this.renderer = renderer; - this.partialTick = partialTick; this.poseStack = poseStack; this.multiBufferSource = multiBufferSource; this.packedLight = packedLight; @@ -52,24 +51,17 @@ public abstract class RenderLivingEvent getRenderer() { + public LivingEntityRenderer getRenderer() { return renderer; } - /** - * {@return the partial tick} - */ - public float getPartialTick() { - return partialTick; - } - /** * {@return the pose stack used for rendering} */ @@ -108,10 +100,10 @@ public abstract class RenderLivingEvent the model for the living entity */ @Cancelable - public static class Pre> extends RenderLivingEvent { + public static class Pre> extends RenderLivingEvent { @ApiStatus.Internal - public Pre(LivingEntity entity, LivingEntityRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - super(entity, renderer, partialTick, poseStack, multiBufferSource, packedLight); + public Pre(S state, LivingEntityRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + super(state, renderer, poseStack, multiBufferSource, packedLight); } } @@ -126,10 +118,10 @@ public abstract class RenderLivingEvent the living entity that was rendered * @param the model for the living entity */ - public static class Post> extends RenderLivingEvent { + public static class Post> extends RenderLivingEvent { @ApiStatus.Internal - public Post(LivingEntity entity, LivingEntityRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - super(entity, renderer, partialTick, poseStack, multiBufferSource, packedLight); + public Post(S state, LivingEntityRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + super(state, renderer, poseStack, multiBufferSource, packedLight); } } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderNameTagEvent.java b/src/main/java/net/minecraftforge/client/event/RenderNameTagEvent.java index 27df85a2c7..aba8031de2 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderNameTagEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderNameTagEvent.java @@ -8,10 +8,9 @@ package net.minecraftforge.client.event; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.EntityRenderer; +import net.minecraft.client.renderer.entity.state.EntityRenderState; import net.minecraft.network.chat.Component; -import net.minecraft.world.entity.Entity; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.LogicalSide; @@ -33,25 +32,29 @@ import org.jetbrains.annotations.ApiStatus; * @see EntityRenderer */ @Event.HasResult -public class RenderNameTagEvent extends EntityEvent { +public class RenderNameTagEvent extends Event { private Component nameplateContent; + private final EntityRenderState state; private final Component originalContent; - private final EntityRenderer entityRenderer; + private final EntityRenderer entityRenderer; private final PoseStack poseStack; private final MultiBufferSource multiBufferSource; private final int packedLight; - private final float partialTick; @ApiStatus.Internal - public RenderNameTagEvent(Entity entity, Component content, EntityRenderer entityRenderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, float partialTick) { - super(entity); + public RenderNameTagEvent(EntityRenderState state, Component content, EntityRenderer entityRenderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + this.state = state; this.originalContent = content; this.setContent(this.originalContent); this.entityRenderer = entityRenderer; this.poseStack = poseStack; this.multiBufferSource = multiBufferSource; this.packedLight = packedLight; - this.partialTick = partialTick; + } + + @SuppressWarnings("unchecked") + public T getState() { + return (T)state; } /** @@ -80,7 +83,7 @@ public class RenderNameTagEvent extends EntityEvent { /** * {@return the entity renderer rendering the nameplate} */ - public EntityRenderer getEntityRenderer() { + public EntityRenderer getEntityRenderer() { return this.entityRenderer; } @@ -106,11 +109,4 @@ public class RenderNameTagEvent extends EntityEvent { public int getPackedLight() { return this.packedLight; } - - /** - * {@return the partial tick} - */ - public float getPartialTick() { - return this.partialTick; - } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java b/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java index 3d754dbf24..15b0342faf 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java @@ -9,10 +9,10 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.player.PlayerRenderer; -import net.minecraft.world.entity.player.Player; +import net.minecraft.client.renderer.entity.state.PlayerRenderState; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; @@ -24,23 +24,26 @@ import org.jetbrains.annotations.ApiStatus; * @see RenderPlayerEvent.Post * @see PlayerRenderer */ -public abstract class RenderPlayerEvent extends PlayerEvent { +public abstract class RenderPlayerEvent extends Event { + private final PlayerRenderState state; private final PlayerRenderer renderer; - private final float partialTick; private final PoseStack poseStack; private final MultiBufferSource multiBufferSource; private final int packedLight; @ApiStatus.Internal - protected RenderPlayerEvent(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - super(player); + protected RenderPlayerEvent(PlayerRenderState state, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + this.state = state; this.renderer = renderer; - this.partialTick = partialTick; this.poseStack = poseStack; this.multiBufferSource = multiBufferSource; this.packedLight = packedLight; } + public PlayerRenderState getState() { + return this.state; + } + /** * {@return the player entity renderer} */ @@ -48,13 +51,6 @@ public abstract class RenderPlayerEvent extends PlayerEvent { return renderer; } - /** - * {@return the partial tick} - */ - public float getPartialTick() { - return partialTick; - } - /** * {@return the pose stack used for rendering} */ @@ -92,8 +88,8 @@ public abstract class RenderPlayerEvent extends PlayerEvent { @Cancelable public static class Pre extends RenderPlayerEvent { @ApiStatus.Internal - public Pre(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - super(player, renderer, partialTick, poseStack, multiBufferSource, packedLight); + public Pre(PlayerRenderState state, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + super(state, renderer, poseStack, multiBufferSource, packedLight); } } @@ -107,8 +103,8 @@ public abstract class RenderPlayerEvent extends PlayerEvent { */ public static class Post extends RenderPlayerEvent { @ApiStatus.Internal - public Post(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - super(player, renderer, partialTick, poseStack, multiBufferSource, packedLight); + public Post(PlayerRenderState state, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + super(state, renderer, poseStack, multiBufferSource, packedLight); } } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java b/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java index c9eea0e0c8..d158d094cb 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java @@ -11,6 +11,7 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner; import net.minecraft.network.chat.FormattedText; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.tooltip.TooltipComponent; import net.minecraft.world.item.ItemStack; import net.minecraftforge.common.MinecraftForge; @@ -20,6 +21,7 @@ import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.List; @@ -30,7 +32,7 @@ import java.util.List; * * @see RenderTooltipEvent.GatherComponents * @see RenderTooltipEvent.Pre - * @see RenderTooltipEvent.Color + * @see RenderTooltipEvent.Background */ public abstract class RenderTooltipEvent extends Event { @@ -113,7 +115,7 @@ public abstract class RenderTooltipEvent extends Event * *

This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. * If this event is cancelled, then the list of components will be empty, causing the tooltip to not be rendered and - * the corresponding {@link RenderTooltipEvent.Pre} and {@link RenderTooltipEvent.Color} to not be fired.

+ * the corresponding {@link RenderTooltipEvent.Pre} and {@link RenderTooltipEvent.Background} to not be fired.

* *

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

@@ -202,7 +204,7 @@ public abstract class RenderTooltipEvent extends Event * *

This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. * If this event is cancelled, then the tooltip will not be rendered and the corresponding - * {@link RenderTooltipEvent.Color} will not be fired.

+ * {@link RenderTooltipEvent.Background} will not be fired.

* *

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

@@ -279,151 +281,44 @@ public abstract class RenderTooltipEvent extends Event } /** - * Fired when the colours for the tooltip background are determined. - * This can be used to modify the background color and the border's gradient colors. + * Fired when the tooltip background prefix is determined. + * This can be used to modify the textures to be used for the tooltip background. * *

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}.

*/ - public static class Color extends RenderTooltipEvent - { - private final int originalBackground; - private final int originalBorderStart; - private final int originalBorderEnd; - private int backgroundStart; - private int backgroundEnd; - private int borderStart; - private int borderEnd; + public static class Background extends RenderTooltipEvent { + private final ResourceLocation originalBackground; + private ResourceLocation background; @ApiStatus.Internal - public Color(@NotNull ItemStack stack, GuiGraphics graphics, int x, int y, @NotNull Font fr, int background, int borderStart, int borderEnd, @NotNull List components) - { + public Background(@NotNull ItemStack stack, GuiGraphics graphics, int x, int y, @NotNull Font fr, @NotNull List components, @Nullable ResourceLocation background) { super(stack, graphics, x, y, fr, components); this.originalBackground = background; - this.originalBorderStart = borderStart; - this.originalBorderEnd = borderEnd; - this.backgroundStart = background; - this.backgroundEnd = background; - this.borderStart = borderStart; - this.borderEnd = borderEnd; + this.background = background; } /** - * {@return the gradient start color for the tooltip background (top edge)} + * Sets the new prefix for the background texture */ - public int getBackgroundStart() - { - return backgroundStart; + public void setBackground(ResourceLocation background) { + this.background = background; } /** - * {@return the gradient end color for the tooltip background (bottom edge)} + * @return the potentially modified background's prefix, can be null for default */ - public int getBackgroundEnd() - { - return backgroundEnd; + public ResourceLocation getBackground() { + return this.background; } /** - * Sets the new color for the tooltip background. This sets both the gradient start and end color for the - * background to this color. - * - * @param background the new color for the tooltip background + * @return the original tooltip background's prefix, can be null for default */ - public void setBackground(int background) - { - this.backgroundStart = background; - this.backgroundEnd = background; - } - - /** - * Sets the new start color for the gradient of the tooltip background (top edge). - * - * @param backgroundStart the new start color for the tooltip background - */ - public void setBackgroundStart(int backgroundStart) - { - this.backgroundStart = backgroundStart; - } - - /** - * Sets the new end color for the gradient of the tooltip background (bottom edge). - * - * @param backgroundEnd the new end color for the tooltip background - */ - public void setBackgroundEnd(int backgroundEnd) - { - this.backgroundEnd = backgroundEnd; - } - - /** - * {@return the gradient start color for the tooltip border (top edge)} - */ - public int getBorderStart() - { - return borderStart; - } - - /** - * Sets the new start color for the gradient of the tooltip border (top edge). - * - * @param borderStart the new start color for the tooltip border - */ - public void setBorderStart(int borderStart) - { - this.borderStart = borderStart; - } - - /** - * {@return the gradient end color for the tooltip border (bottom edge)} - */ - public int getBorderEnd() - { - return borderEnd; - } - - /** - * Sets the new end color for the gradient of the tooltip border (bottom edge). - * - * @param borderEnd the new end color for the tooltip border - */ - public void setBorderEnd(int borderEnd) - { - this.borderEnd = borderEnd; - } - - /** - * {@return the original tooltip background's gradient start color (top edge)} - */ - public int getOriginalBackgroundStart() - { + public ResourceLocation getOriginalBackground() { return originalBackground; } - - /** - * {@return the original tooltip background's gradient end color (bottom edge)} - */ - public int getOriginalBackgroundEnd() - { - return originalBackground; - } - - /** - * {@return the original tooltip border's gradient start color (top edge)} - */ - public int getOriginalBorderStart() - { - return originalBorderStart; - } - - /** - * {@return the original tooltip border's gradient end color (bottom edge)} - */ - public int getOriginalBorderEnd() - { - return originalBorderEnd; - } } } diff --git a/src/main/java/net/minecraftforge/client/event/ScreenEvent.java b/src/main/java/net/minecraftforge/client/event/ScreenEvent.java index 3f0e5c4bc0..8331d668a7 100644 --- a/src/main/java/net/minecraftforge/client/event/ScreenEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ScreenEvent.java @@ -9,7 +9,6 @@ import com.mojang.blaze3d.platform.InputConstants; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; @@ -248,7 +247,7 @@ public abstract class ScreenEvent extends Event { } /** - * Fired ahead of rendering any active mob effects in the {@link EffectRenderingInventoryScreen inventory screen}. + * Fired ahead of rendering any active mob effects in the {@link EffectsInInventory inventory screen}. * Can be used to select the size of the effects display (full or compact) or even hide or replace vanilla's rendering entirely. * This event can also be used to modify the horizontal position of the stack of effects being rendered. * diff --git a/src/main/java/net/minecraftforge/client/event/ToastAddEvent.java b/src/main/java/net/minecraftforge/client/event/ToastAddEvent.java index d562f1a599..9f77796ee0 100644 --- a/src/main/java/net/minecraftforge/client/event/ToastAddEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ToastAddEvent.java @@ -22,17 +22,14 @@ import net.minecraftforge.fml.LogicalSide; * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @Cancelable -public class ToastAddEvent extends Event -{ +public class ToastAddEvent extends Event { private final Toast toast; - public ToastAddEvent(Toast toast) - { + public ToastAddEvent(Toast toast) { this.toast = toast; } - public Toast getToast() - { + public Toast getToast() { return toast; } } diff --git a/src/main/java/net/minecraftforge/client/event/ViewportEvent.java b/src/main/java/net/minecraftforge/client/event/ViewportEvent.java index 4cd977dc58..a10cfd6a13 100644 --- a/src/main/java/net/minecraftforge/client/event/ViewportEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ViewportEvent.java @@ -80,6 +80,7 @@ public abstract class ViewportEvent extends Event { private float nearPlaneDistance; private FogShape fogShape; + @SuppressWarnings("resource") @ApiStatus.Internal public RenderFog(FogMode mode, FogType type, Camera camera, float partialTicks, float nearPlaneDistance, float farPlaneDistance, FogShape fogShape) { super(Minecraft.getInstance().gameRenderer, camera, partialTicks); @@ -186,6 +187,7 @@ public abstract class ViewportEvent extends Event { private float green; private float blue; + @SuppressWarnings("resource") @ApiStatus.Internal public ComputeFogColor(Camera camera, float partialTicks, float red, float green, float blue) { super(Minecraft.getInstance().gameRenderer, camera, partialTicks); @@ -327,10 +329,10 @@ public abstract class ViewportEvent extends Event { */ public static class ComputeFov extends ViewportEvent { private final boolean usedConfiguredFov; - private double fov; + private float fov; @ApiStatus.Internal - public ComputeFov(GameRenderer renderer, Camera camera, double renderPartialTicks, double fov, boolean usedConfiguredFov) { + public ComputeFov(GameRenderer renderer, Camera camera, double renderPartialTicks, float fov, boolean usedConfiguredFov) { super(renderer, camera, renderPartialTicks); this.usedConfiguredFov = usedConfiguredFov; this.setFOV(fov); @@ -339,7 +341,7 @@ public abstract class ViewportEvent extends Event { /** * {@return the raw field of view value} */ - public double getFOV() { + public float getFOV() { return fov; } @@ -348,7 +350,7 @@ public abstract class ViewportEvent extends Event { * * @param fov the new FOV value */ - public void setFOV(double fov) { + public void setFOV(float fov) { this.fov = fov; } diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeBakedModel.java b/src/main/java/net/minecraftforge/client/extensions/IForgeBakedModel.java index 4db1bd5df8..a4e014374a 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeBakedModel.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeBakedModel.java @@ -30,6 +30,7 @@ import java.util.List; /** * Extension interface for {@link IForgeBakedModel}. */ +@SuppressWarnings("deprecation") public interface IForgeBakedModel { private BakedModel self() { return (BakedModel)this; @@ -89,7 +90,7 @@ public interface IForgeBakedModel { * @see #getRenderPasses(ItemStack, boolean) */ default List getRenderTypes(ItemStack itemStack, boolean fabulous) { - return List.of(RenderTypeHelper.getFallbackItemRenderType(itemStack, self(), fabulous)); + return List.of(RenderTypeHelper.getFallbackItemRenderType(itemStack, self())); } /** diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeBlockAndTintGetter.java b/src/main/java/net/minecraftforge/client/extensions/IForgeBlockAndTintGetter.java index 23d9d27345..f001231d91 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeBlockAndTintGetter.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeBlockAndTintGetter.java @@ -11,19 +11,16 @@ import net.minecraft.world.level.BlockAndTintGetter; /** * Extension interface for {@link BlockAndTintGetter}. */ -public interface IForgeBlockAndTintGetter -{ - private BlockAndTintGetter self() - { - return (BlockAndTintGetter) this; +public interface IForgeBlockAndTintGetter { + private BlockAndTintGetter self() { + return (BlockAndTintGetter)this; } /** * Computes the shade for a given normal. * Alternate version of the vanilla method taking in a {@link Direction}. */ - default float getShade(float normalX, float normalY, float normalZ, boolean shade) - { - return self().getShade(Direction.getNearest(normalX, normalY, normalZ), shade); + default float getShade(float normalX, float normalY, float normalZ, boolean shade) { + return self().getShade(Direction.getApproximateNearest(normalX, normalY, normalZ), shade); } } diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeDimensionSpecialEffects.java b/src/main/java/net/minecraftforge/client/extensions/IForgeDimensionSpecialEffects.java deleted file mode 100644 index df064208b9..0000000000 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeDimensionSpecialEffects.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.extensions; - -import com.mojang.blaze3d.vertex.PoseStack; -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}. - */ -public interface IForgeDimensionSpecialEffects { - private DimensionSpecialEffects self() { - return (DimensionSpecialEffects)this; - } - - /** - * Renders the clouds of this dimension. - * - * @return true to prevent vanilla cloud rendering - */ - default boolean renderClouds(ClientLevel level, int ticks, float partialTick, PoseStack poseStack, double camX, double camY, double camZ, Matrix4f projectionMatrix) { - return false; - } - - /** - * Renders the sky of this dimension. - * - * @return true to prevent vanilla sky rendering - */ - default boolean renderSky(ClientLevel level, int ticks, float partialTick, Camera camera, Matrix4f projectionMatrix, boolean isFoggy, Runnable setupFog) { - return false; - } - - /** - * Renders the snow and rain effects of this dimension. - * - * @return true to prevent vanilla snow and rain rendering - */ - default boolean renderSnowAndRain(ClientLevel level, int ticks, float partialTick, LightTexture lightTexture, double camX, double camY, double camZ) { - return false; - } - - /** - * Ticks the rain of this dimension. - * - * @return true to prevent vanilla rain ticking - */ - default boolean tickRain(ClientLevel level, int ticks, Camera camera) { - return false; - } - - /** - * Allows for manipulating the coloring of the lightmap texture. - * Will be called for each 16*16 combination of sky/block light values. - * - * @param level The current level (client-side). - * @param partialTicks Progress between ticks. - * @param skyDarken Current darkness of the sky (can be used to calculate sky light). - * @param blockLightRedFlicker Block light flicker factor (red color) (can be used to calculate block light). - * @param skyLight Sky light brightness (accounting for sky darkness). - * @param pixelX X-coordinate of the lightmap texture (block). - * @param pixelY Y-coordinate of the lightmap texture (sky). - * @param colors The color values that will be used: [r, g, b]. - * @see LightTexture#updateLightTexture(float) - */ - default void adjustLightmapColors(ClientLevel level, float partialTicks, float skyDarken, float blockLightRedFlicker, float skyLight, int pixelX, int pixelY, Vector3f colors) {} -} diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeElytraLayer.java b/src/main/java/net/minecraftforge/client/extensions/IForgeElytraLayer.java deleted file mode 100644 index ab8fbbdf6a..0000000000 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeElytraLayer.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.extensions; - -import net.minecraft.client.renderer.entity.layers.ElytraLayer; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; - -public interface IForgeElytraLayer { - /** - * Determines if the ElytraLayer should render. - * ItemStack and Entity are provided for modder convenience, - * For example, using the same ElytraLayer for multiple custom Elytra. - * - * @param stack The Elytra ItemStack - * @param entity The entity being rendered. - * @return If the ElytraLayer should render. - */ - default boolean shouldRender(ItemStack stack, T entity) { - return stack.getItem() == Items.ELYTRA; - } - - /** - * Gets the texture to use with this ElytraLayer. - * This assumes the vanilla Elytra model. - * - * @param stack The Elytra ItemStack. - * @param entity The entity being rendered. - * @return The texture. - */ - default ResourceLocation getElytraTexture(ItemStack stack, T entity) { - return ElytraLayer.WINGS_LOCATION; - } -} diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeFont.java b/src/main/java/net/minecraftforge/client/extensions/IForgeFont.java index 4d865bfb67..630ca24e64 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeFont.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeFont.java @@ -11,11 +11,12 @@ import net.minecraft.network.chat.FormattedText; /** * Extension interface for {@link Font}. */ -public interface IForgeFont -{ +public interface IForgeFont { FormattedText ELLIPSIS = FormattedText.of("..."); - Font self(); + default Font self() { + return (Font)this; + } /** * If the width of the text exceeds {@code maxWidth}, an ellipse is added and the text is substringed. @@ -24,17 +25,16 @@ public interface IForgeFont * @param maxWidth the maximum width of the text * @return the ellipsized text */ - default FormattedText ellipsize(FormattedText text, int maxWidth) - { + default FormattedText ellipsize(FormattedText text, int maxWidth) { final Font self = self(); final int strWidth = self.width(text); final int ellipsisWidth = self.width(ELLIPSIS); - if (strWidth > maxWidth) - { - if (ellipsisWidth >= maxWidth) return self.substrByWidth(text, maxWidth); + if (strWidth > maxWidth) { + if (ellipsisWidth >= maxWidth) + return self.substrByWidth(text, maxWidth); return FormattedText.composite( - self.substrByWidth(text, maxWidth - ellipsisWidth), - ELLIPSIS + self.substrByWidth(text, maxWidth - ellipsisWidth), + ELLIPSIS ); } return text; diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeGuiGraphics.java b/src/main/java/net/minecraftforge/client/extensions/IForgeGuiGraphics.java index 8831e62027..846bffe623 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeGuiGraphics.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeGuiGraphics.java @@ -6,16 +6,15 @@ package net.minecraftforge.client.extensions; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.renderer.RenderType; import net.minecraft.resources.ResourceLocation; /** * Extension interface for {@link GuiGraphics}. */ -public interface IForgeGuiGraphics -{ - private GuiGraphics self() - { - return (GuiGraphics) this; +public interface IForgeGuiGraphics { + private GuiGraphics self() { + return (GuiGraphics)this; } int DEFAULT_BACKGROUND_COLOR = 0xF0100010; @@ -28,8 +27,7 @@ public interface IForgeGuiGraphics int[] TEXT_COLOR_CODES = new int[] { 0, 170, 43520, 43690, 11141120, 11141290, 16755200, 11184810, 5592405, 5592575, 5635925, 5636095, 16733525, 16733695, 16777045, 16777215, 0, 42, 10752, 10794, 2752512, 2752554, 2763264, 2763306, 1381653, 1381695, 1392405, 1392447, 4134165, 4134207, 4144917, 4144959 }; - default int getColorFromFormattingCharacter(char c, boolean isLighter) - { + default int getColorFromFormattingCharacter(char c, boolean isLighter) { return TEXT_COLOR_CODES[isLighter ? "0123456789abcdef".indexOf(c) : "0123456789abcdef".indexOf(c) + 16]; } @@ -48,8 +46,7 @@ public interface IForgeGuiGraphics * @param textureHeight the height of the box texture in the resource location image * @param borderSize the size of the box's borders */ - default void blitWithBorder(ResourceLocation texture, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize) - { + default void blitWithBorder(ResourceLocation texture, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize) { this.blitWithBorder(texture, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize); } @@ -71,8 +68,7 @@ public interface IForgeGuiGraphics * @param leftBorder the size of the box's left border * @param rightBorder the size of the box's right border */ - default void blitWithBorder(ResourceLocation texture, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder) - { + default void blitWithBorder(ResourceLocation texture, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder) { int fillerWidth = textureWidth - leftBorder - rightBorder; int fillerHeight = textureHeight - topBorder - bottomBorder; int canvasWidth = width - leftBorder - rightBorder; @@ -84,56 +80,50 @@ public interface IForgeGuiGraphics // Draw Border // Top Left - self().blit(texture, x, y, u, v, leftBorder, topBorder); + self().blit(RenderType::guiTextured, texture, x, y, 0, u, v, leftBorder, topBorder, 256, 256); // Top Right - self().blit(texture, x + leftBorder + canvasWidth, y, u + leftBorder + fillerWidth, v, rightBorder, topBorder); + self().blit(RenderType::guiTextured, texture, x + leftBorder + canvasWidth, y, 0, u + leftBorder + fillerWidth, v, rightBorder, topBorder, 256, 256); // Bottom Left - self().blit(texture, x, y + topBorder + canvasHeight, u, v + topBorder + fillerHeight, leftBorder, bottomBorder); + self().blit(RenderType::guiTextured, texture, x, y + topBorder + canvasHeight, 0, u, v + topBorder + fillerHeight, leftBorder, bottomBorder, 256, 256); // Bottom Right - self().blit(texture, x + leftBorder + canvasWidth, y + topBorder + canvasHeight, u + leftBorder + fillerWidth, v + topBorder + fillerHeight, rightBorder, bottomBorder); + self().blit(RenderType::guiTextured, texture, x + leftBorder + canvasWidth, y + topBorder + canvasHeight, 0, u + leftBorder + fillerWidth, v + topBorder + fillerHeight, rightBorder, bottomBorder, 256, 256); - for (int i = 0; i < xPasses + (remainderWidth > 0 ? 1 : 0); i++) - { + for (int i = 0; i < xPasses + (remainderWidth > 0 ? 1 : 0); i++) { // Top Border - self().blit(texture, x + leftBorder + (i * fillerWidth), y, u + leftBorder, v, (i == xPasses ? remainderWidth : fillerWidth), topBorder); + self().blit(RenderType::guiTextured, texture, x + leftBorder + (i * fillerWidth), y, 0, u + leftBorder, v, (i == xPasses ? remainderWidth : fillerWidth), topBorder, 256, 256); // Bottom Border - self().blit(texture, x + leftBorder + (i * fillerWidth), y + topBorder + canvasHeight, u + leftBorder, v + topBorder + fillerHeight, (i == xPasses ? remainderWidth : fillerWidth), bottomBorder); + self().blit(RenderType::guiTextured, texture, x + leftBorder + (i * fillerWidth), y + topBorder + canvasHeight, 0, u + leftBorder, v + topBorder + fillerHeight, (i == xPasses ? remainderWidth : fillerWidth), bottomBorder, 256, 256); // Throw in some filler for good measure for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++) - self().blit(texture, x + leftBorder + (i * fillerWidth), y + topBorder + (j * fillerHeight), u + leftBorder, v + topBorder, (i == xPasses ? remainderWidth : fillerWidth), (j == yPasses ? remainderHeight : fillerHeight)); + self().blit(RenderType::guiTextured, texture, x + leftBorder + (i * fillerWidth), y + topBorder + (j * fillerHeight), 0, u + leftBorder, v + topBorder, (i == xPasses ? remainderWidth : fillerWidth), (j == yPasses ? remainderHeight : fillerHeight), 256, 256); } // Side Borders - for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++) - { + for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++) { // Left Border - self().blit(texture, x, y + topBorder + (j * fillerHeight), u, v + topBorder, leftBorder, (j == yPasses ? remainderHeight : fillerHeight)); + self().blit(RenderType::guiTextured, texture, x, y + topBorder + (j * fillerHeight), 0, u, v + topBorder, leftBorder, (j == yPasses ? remainderHeight : fillerHeight), 256, 256); // Right Border - self().blit(texture, x + leftBorder + canvasWidth, y + topBorder + (j * fillerHeight), u + leftBorder + fillerWidth, v + topBorder, rightBorder, (j == yPasses ? remainderHeight : fillerHeight)); + self().blit(RenderType::guiTextured, texture, x + leftBorder + canvasWidth, y + topBorder + (j * fillerHeight), 0, u + leftBorder + fillerWidth, v + topBorder, rightBorder, (j == yPasses ? remainderHeight : fillerHeight), 256, 256); } } - default void blitInscribed(ResourceLocation texture, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight) - { + default void blitInscribed(ResourceLocation texture, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight) { this.blitInscribed(texture, x, y, boundsWidth, boundsHeight, rectWidth, rectHeight, true, true); } - default void blitInscribed(ResourceLocation texture, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY) - { - if (rectWidth * boundsHeight > rectHeight * boundsWidth) - { + default void blitInscribed(ResourceLocation texture, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY) { + if (rectWidth * boundsHeight > rectHeight * boundsWidth) { int h = boundsHeight; boundsHeight = (int) (boundsWidth * ((double) rectHeight / rectWidth)); if (centerY) y += (h - boundsHeight) / 2; - } - else - { + } else { int w = boundsWidth; boundsWidth = (int) (boundsHeight * ((double) rectWidth / rectHeight)); if (centerX) x += (w - boundsWidth) / 2; } - self().blit(texture, x, y, boundsWidth, boundsHeight, 0.0f,0.0f, rectWidth, rectHeight, rectWidth, rectHeight); + //self().blit(RenderType::guiTextured, texture, x, y, boundsWidth, boundsHeight, 0.0f,0.0f, rectWidth, rectHeight, rectWidth, rectHeight); + self().blit(RenderType::guiTextured, texture, x, y, 0.0f, 0.0f, boundsWidth, boundsHeight, boundsWidth, boundsHeight); } } 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 cee69a2cac..66cdf2f8dc 100644 --- a/src/main/java/net/minecraftforge/client/extensions/common/IClientFluidTypeExtensions.java +++ b/src/main/java/net/minecraftforge/client/extensions/common/IClientFluidTypeExtensions.java @@ -13,6 +13,7 @@ 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.FogParameters; import net.minecraft.client.renderer.FogRenderer; import net.minecraft.client.renderer.ScreenEffectRenderer; import net.minecraft.core.BlockPos; @@ -33,22 +34,18 @@ import org.joml.Vector3f; * * @see FluidType#initializeClient(Consumer) */ -public interface IClientFluidTypeExtensions -{ +public interface IClientFluidTypeExtensions { IClientFluidTypeExtensions DEFAULT = new IClientFluidTypeExtensions() { }; - static IClientFluidTypeExtensions of(FluidState state) - { + static IClientFluidTypeExtensions of(FluidState state) { return of(state.getFluidType()); } - static IClientFluidTypeExtensions of(Fluid fluid) - { + static IClientFluidTypeExtensions of(Fluid fluid) { return of(fluid.getFluidType()); } - static IClientFluidTypeExtensions of(FluidType type) - { + static IClientFluidTypeExtensions of(FluidType type) { return type.getRenderPropertiesInternal() instanceof IClientFluidTypeExtensions props ? props : DEFAULT; } @@ -62,8 +59,7 @@ public interface IClientFluidTypeExtensions * * @return the tint applied to the fluid's textures in ARGB format */ - default int getTintColor() - { + default int getTintColor() { return 0xFFFFFFFF; } @@ -79,8 +75,7 @@ public interface IClientFluidTypeExtensions * * @return the reference of the texture to apply to a source fluid */ - default ResourceLocation getStillTexture() - { + default ResourceLocation getStillTexture() { return null; } @@ -96,8 +91,7 @@ public interface IClientFluidTypeExtensions * * @return the reference of the texture to apply to a flowing fluid */ - default ResourceLocation getFlowingTexture() - { + default ResourceLocation getFlowingTexture() { return null; } @@ -115,26 +109,10 @@ public interface IClientFluidTypeExtensions * a non-opaque block */ @Nullable - default ResourceLocation getOverlayTexture() - { + default ResourceLocation getOverlayTexture() { return null; } - // 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 * within the fluid. If no location is specified, no overlay will be applied. @@ -148,8 +126,7 @@ public interface IClientFluidTypeExtensions * within the fluid */ @Nullable - default ResourceLocation getRenderOverlayTexture(Minecraft mc) - { + default ResourceLocation getRenderOverlayTexture(Minecraft mc) { return null; } @@ -160,8 +137,7 @@ public interface IClientFluidTypeExtensions * @param mc the client instance * @param poseStack the transformations representing the current rendering position */ - default void renderOverlay(Minecraft mc, PoseStack poseStack) - { + default void renderOverlay(Minecraft mc, PoseStack poseStack) { ResourceLocation texture = this.getRenderOverlayTexture(mc); if (texture != null) ScreenEffectRenderer.renderFluid(mc, poseStack, texture); @@ -182,8 +158,7 @@ public interface IClientFluidTypeExtensions * @return the color of the fog */ @NotNull - default Vector3f modifyFogColor(Camera camera, float partialTick, ClientLevel level, int renderDistance, float darkenWorldAmount, Vector3f fluidFogColor) - { + default Vector3f modifyFogColor(Camera camera, float partialTick, ClientLevel level, int renderDistance, float darkenWorldAmount, Vector3f fluidFogColor) { return fluidFogColor; } @@ -195,12 +170,9 @@ public interface IClientFluidTypeExtensions * @param mode the type of fog being rendered * @param renderDistance the render distance of the client * @param partialTick the delta time of where the current frame is within a tick - * @param nearDistance the near plane of where the fog starts to render - * @param farDistance the far plane of where the fog ends rendering - * @param shape the shape of the fog being rendered */ - default void modifyFogRender(Camera camera, FogRenderer.FogMode mode, float renderDistance, float partialTick, float nearDistance, float farDistance, FogShape shape) - { + default FogParameters modifyFogRender(Camera camera, FogRenderer.FogMode mode, float renderDistance, float partialTick, FogParameters original) { + return original; } /* Level-Based Accessors */ @@ -220,8 +192,7 @@ public interface IClientFluidTypeExtensions * @param pos the position of the fluid * @return the reference of the texture to apply to a source fluid */ - default ResourceLocation getStillTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos) - { + default ResourceLocation getStillTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos) { return this.getStillTexture(); } @@ -240,8 +211,7 @@ public interface IClientFluidTypeExtensions * @param pos the position of the fluid * @return the reference of the texture to apply to a flowing fluid */ - default ResourceLocation getFlowingTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos) - { + default ResourceLocation getFlowingTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos) { return this.getFlowingTexture(); } @@ -261,8 +231,7 @@ public interface IClientFluidTypeExtensions * @return the reference of the texture to apply to a fluid directly touching * a non-opaque block */ - default ResourceLocation getOverlayTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos) - { + default ResourceLocation getOverlayTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos) { return this.getOverlayTexture(); } @@ -277,8 +246,7 @@ public interface IClientFluidTypeExtensions * @param pos the position of the fluid * @return the tint applied to the fluid's textures in ARGB format */ - default int getTintColor(FluidState state, BlockAndTintGetter getter, BlockPos pos) - { + default int getTintColor(FluidState state, BlockAndTintGetter getter, BlockPos pos) { return this.getTintColor(); } @@ -293,8 +261,7 @@ public interface IClientFluidTypeExtensions * @param stack the stack the fluid is in * @return the tint applied to the fluid's textures in ARGB format */ - default int getTintColor(FluidStack stack) - { + default int getTintColor(FluidStack stack) { return this.getTintColor(); } @@ -311,8 +278,7 @@ public interface IClientFluidTypeExtensions * @param stack the stack the fluid is in * @return the reference of the texture to apply to a source fluid */ - default ResourceLocation getStillTexture(FluidStack stack) - { + default ResourceLocation getStillTexture(FluidStack stack) { return this.getStillTexture(); } @@ -329,8 +295,7 @@ public interface IClientFluidTypeExtensions * @param stack the stack the fluid is in * @return the reference of the texture to apply to a flowing fluid */ - default ResourceLocation getFlowingTexture(FluidStack stack) - { + default ResourceLocation getFlowingTexture(FluidStack stack) { return this.getFlowingTexture(); } @@ -348,8 +313,7 @@ public interface IClientFluidTypeExtensions * @return the reference of the texture to apply to a fluid directly touching * a non-opaque block */ - default ResourceLocation getOverlayTexture(FluidStack stack) - { + default ResourceLocation getOverlayTexture(FluidStack stack) { return this.getOverlayTexture(); } } diff --git a/src/main/java/net/minecraftforge/client/extensions/common/IClientItemExtensions.java b/src/main/java/net/minecraftforge/client/extensions/common/IClientItemExtensions.java index 5e28a83e12..f6a62543db 100644 --- a/src/main/java/net/minecraftforge/client/extensions/common/IClientItemExtensions.java +++ b/src/main/java/net/minecraftforge/client/extensions/common/IClientItemExtensions.java @@ -12,6 +12,8 @@ import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.Model; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; +import net.minecraft.client.renderer.entity.state.HumanoidRenderState; +import net.minecraft.client.renderer.entity.state.LivingEntityRenderState; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.EquipmentSlot; @@ -34,17 +36,14 @@ import java.util.function.Consumer; * * @see Item#initializeClient(Consumer) */ -public interface IClientItemExtensions -{ +public interface IClientItemExtensions { IClientItemExtensions DEFAULT = new IClientItemExtensions() { }; - static IClientItemExtensions of(ItemStack stack) - { + static IClientItemExtensions of(ItemStack stack) { return of(stack.getItem()); } - static IClientItemExtensions of(Item item) - { + static IClientItemExtensions of(Item item) { return item.getRenderPropertiesInternal() instanceof IClientItemExtensions e ? e : DEFAULT; } @@ -57,8 +56,7 @@ public interface IClientItemExtensions * @return A {@link Font} or null to use the default */ @Nullable - default Font getFont(ItemStack stack, FontContext context) - { + default Font getFont(ItemStack stack, FontContext context) { return null; } @@ -72,8 +70,7 @@ public interface IClientItemExtensions * @return A custom ArmPose that can be used to define movement of the arm */ @Nullable - default HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack itemStack) - { + default HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack itemStack) { return null; } @@ -96,7 +93,7 @@ public interface IClientItemExtensions /** * Queries the humanoid armor model for this item when it's equipped. * - * @param livingEntity The entity wearing the armor + * @param state The entity wearing the armor * @param itemStack The item stack * @param equipmentSlot The slot the item is in * @param original The original armor model. Will have attributes set. @@ -104,14 +101,13 @@ public interface IClientItemExtensions * @see #getGenericArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel) */ @NotNull - default HumanoidModel getHumanoidArmorModel(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel original) - { + default HumanoidModel getHumanoidArmorModel(LivingEntityRenderState state, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel original) { return original; } /** * Queries the armor model for this item when it's equipped. Useful in place of - * {@link #getHumanoidArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel)} for wrapping the original + * {@link #getHumanoidArmorModel(LivingEntityRenderState, ItemStack, EquipmentSlot, HumanoidModel)} for wrapping the original * model or returning anything non-standard. *

* If you override this method you are responsible for copying any properties you care about from the original model. @@ -121,14 +117,12 @@ public interface IClientItemExtensions * @param equipmentSlot The slot the item is in * @param original The original armor model. Will have attributes set. * @return A Model to be rendered. Relevant properties must be copied over manually. - * @see #getHumanoidArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel) + * @see #getHumanoidArmorModel(LivingEntityRenderState, ItemStack, EquipmentSlot, HumanoidModel) */ @NotNull - default Model getGenericArmorModel(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel original) - { - HumanoidModel replacement = getHumanoidArmorModel(livingEntity, itemStack, equipmentSlot, original); - if (replacement != original) - { + default Model getGenericArmorModel(HumanoidRenderState state, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel original) { + HumanoidModel replacement = getHumanoidArmorModel(state, itemStack, equipmentSlot, original); + if (replacement != original) { ForgeHooksClient.copyModelProperties(original, replacement); return replacement; } @@ -146,9 +140,7 @@ public interface IClientItemExtensions * @param height Viewport height * @param partialTick Partial tick time, useful for interpolation */ - default void renderHelmetOverlay(ItemStack stack, Player player, int width, int height, float partialTick) - { - } + default void renderHelmetOverlay(ItemStack stack, Player player, int width, int height, float partialTick) { } /** * Queries this item's renderer. @@ -158,13 +150,11 @@ public interface IClientItemExtensions *

* By default, returns vanilla's block entity renderer. */ - default BlockEntityWithoutLevelRenderer getCustomRenderer() - { + default BlockEntityWithoutLevelRenderer getCustomRenderer() { return Minecraft.getInstance().getItemRenderer().getBlockEntityRenderer(); } - enum FontContext - { + enum FontContext { /** * Used to display the amount of items in the {@link ItemStack}. */ diff --git a/src/main/java/net/minecraftforge/client/extensions/common/IClientMobEffectExtensions.java b/src/main/java/net/minecraftforge/client/extensions/common/IClientMobEffectExtensions.java index 8a00f73b49..a4082e8f38 100644 --- a/src/main/java/net/minecraftforge/client/extensions/common/IClientMobEffectExtensions.java +++ b/src/main/java/net/minecraftforge/client/extensions/common/IClientMobEffectExtensions.java @@ -7,7 +7,7 @@ package net.minecraftforge.client.extensions.common; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen; +import net.minecraft.client.gui.screens.inventory.EffectsInInventory; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; import net.minecraftforge.fml.LogicalSide; @@ -53,14 +53,14 @@ public interface IClientMobEffectExtensions { * This can be used to render icons from your own texture sheet. * * @param instance The effect instance - * @param screen The effect-rendering screen + * @param effects The effect-rendering screen * @param guiGraphics The gui graphics * @param x The x coordinate * @param y The y coordinate * @param blitOffset The blit offset * @return true to prevent default rendering, false otherwise */ - default boolean renderInventoryIcon(MobEffectInstance instance, EffectRenderingInventoryScreen screen, GuiGraphics guiGraphics, int x, int y, int blitOffset) { + default boolean renderInventoryIcon(MobEffectInstance instance, EffectsInInventory effects, GuiGraphics guiGraphics, int x, int y, int blitOffset) { return false; } @@ -68,14 +68,14 @@ public interface IClientMobEffectExtensions { * Renders the text of the specified effect in the player's inventory. * * @param instance The effect instance - * @param screen The effect-rendering screen + * @param effects The effect-rendering screen * @param guiGraphics The gui graphics * @param x The x coordinate * @param y The y coordinate * @param blitOffset The blit offset * @return true to prevent default rendering, false otherwise */ - default boolean renderInventoryText(MobEffectInstance instance, EffectRenderingInventoryScreen screen, GuiGraphics guiGraphics, int x, int y, int blitOffset) { + default boolean renderInventoryText(MobEffectInstance instance, EffectsInInventory effects, GuiGraphics guiGraphics, int x, int y, int blitOffset) { return false; } diff --git a/src/main/java/net/minecraftforge/client/gui/ClientTooltipComponentManager.java b/src/main/java/net/minecraftforge/client/gui/ClientTooltipComponentManager.java index 8fe35de80e..2f8c8d6016 100644 --- a/src/main/java/net/minecraftforge/client/gui/ClientTooltipComponentManager.java +++ b/src/main/java/net/minecraftforge/client/gui/ClientTooltipComponentManager.java @@ -21,30 +21,28 @@ import java.util.function.Function; *

* Provides a lookup. */ -public final class ClientTooltipComponentManager -{ +public final class ClientTooltipComponentManager { private static ImmutableMap, Function> FACTORIES; /** * Creates a client component for the given argument, or null if unsupported. */ @Nullable - public static ClientTooltipComponent createClientTooltipComponent(TooltipComponent component) - { + public static ClientTooltipComponent createClientTooltipComponent(TooltipComponent component) { var factory = FACTORIES.get(component.getClass()); - return factory != null ? factory.apply(component) : null; + var ret = factory != null ? factory.apply(component) : null; + if (ret == null) + throw new IllegalArgumentException("Unknown TooltipComponent"); + return ret; } @ApiStatus.Internal - public static void init() - { + public static void init() { var factories = new HashMap, Function>(); var event = new RegisterClientTooltipComponentFactoriesEvent(factories); ModLoader.get().postEventWrapContainerInModOrder(event); FACTORIES = ImmutableMap.copyOf(factories); } - private ClientTooltipComponentManager() - { - } + private ClientTooltipComponentManager() { } } diff --git a/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java b/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java index 25af8904be..876beadd3e 100644 --- a/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java @@ -21,9 +21,6 @@ import net.minecraftforge.fml.ModLoadingException; import net.minecraftforge.fml.ModLoadingWarning; import net.minecraftforge.client.gui.widget.ExtendedButton; import net.minecraftforge.fml.loading.FMLPaths; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; @@ -32,7 +29,6 @@ import java.util.List; import java.util.Objects; public class LoadingErrorScreen extends ErrorScreen { - private static final Logger LOGGER = LogManager.getLogger(); private final Path modsDir; private final Path logFile; private final List modLoadErrors; @@ -137,7 +133,8 @@ public class LoadingErrorScreen extends ErrorScreen { @Override public void render(GuiGraphics guiGraphics, int entryIdx, int top, int left, final int entryWidth, final int entryHeight, final int mouseX, final int mouseY, final boolean p_194999_5_, final float partialTick) { - Font font = Minecraft.getInstance().font; + var mc = Minecraft.getInstance(); + Font font = mc.font; var strings = font.split(message, LoadingEntryList.this.width - 20); int y = top + 2; for (var string : strings) { diff --git a/src/main/java/net/minecraftforge/client/gui/TitleScreenModUpdateIndicator.java b/src/main/java/net/minecraftforge/client/gui/TitleScreenModUpdateIndicator.java index a2d8771dc5..539d616c2d 100644 --- a/src/main/java/net/minecraftforge/client/gui/TitleScreenModUpdateIndicator.java +++ b/src/main/java/net/minecraftforge/client/gui/TitleScreenModUpdateIndicator.java @@ -8,6 +8,7 @@ package net.minecraftforge.client.gui; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.TitleScreen; +import net.minecraft.client.renderer.RenderType; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -51,7 +52,7 @@ public class TitleScreenModUpdateIndicator extends Screen { int w = modButton.getWidth(); int h = modButton.getHeight(); - guiGraphics.blit(VERSION_CHECK_ICONS, x + w - (h / 2 + 4), y + (h / 2 - 4), showNotification.getSheetOffset() * 8, (showNotification.isAnimated() && ((System.currentTimeMillis() / 800 & 1) == 1)) ? 8 : 0, 8, 8, 64, 16); + guiGraphics.blit(RenderType::guiTextured, VERSION_CHECK_ICONS, x + w - (h / 2 + 4), y + (h / 2 - 4), showNotification.getSheetOffset() * 8, (showNotification.isAnimated() && ((System.currentTimeMillis() / 800 & 1) == 1)) ? 8 : 0, 8, 8, 64, 16); } public static TitleScreenModUpdateIndicator init(TitleScreen guiMainMenu, Button modButton) { 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 5e2f9ca05c..93cea39850 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java @@ -8,6 +8,7 @@ package net.minecraftforge.client.gui.widget; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; +import net.minecraft.client.renderer.RenderType; import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; @@ -19,23 +20,17 @@ import net.minecraft.network.chat.FormattedText; * trimming the end of the string and adding an ellipsis.

* * The code that handles drawing the button is in GuiUtils. - * - * @author bspkrs */ -public class ExtendedButton extends Button -{ - public ExtendedButton(int xPos, int yPos, int width, int height, Component displayString, OnPress handler) - { +public class ExtendedButton extends Button { + public ExtendedButton(int xPos, int yPos, int width, int height, Component displayString, OnPress 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) - { + public ExtendedButton(int xPos, int yPos, int width, int height, Component displayString, OnPress handler, CreateNarration createNarration) { super(xPos, yPos, width, height, displayString, handler, createNarration); } - public ExtendedButton(Button.Builder builder) - { + public ExtendedButton(Button.Builder builder) { super(builder); } @@ -43,11 +38,9 @@ public class ExtendedButton extends Button * Draws this button to the screen. */ @Override - public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) - { + public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { Minecraft mc = Minecraft.getInstance(); - int k = !this.active ? 0 : (this.isHoveredOrFocused() ? 2 : 1); - guiGraphics.blitSprite(SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight()); + guiGraphics.blitSprite(RenderType::guiTextured, SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight()); final FormattedText buttonText = mc.font.ellipsize(this.getMessage(), this.width - 6); // Remove 6 pixels so that the text is always contained within the button's borders guiGraphics.drawCenteredString(mc.font, Language.getInstance().getVisualOrder(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 ba1c598b76..31483e4d94 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ForgeSlider.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ForgeSlider.java @@ -8,6 +8,7 @@ package net.minecraftforge.client.gui.widget; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractSliderButton; +import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; import org.lwjgl.glfw.GLFW; @@ -193,8 +194,8 @@ public class ForgeSlider extends AbstractSliderButton { @Override public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { final Minecraft mc = Minecraft.getInstance(); - guiGraphics.blitSprite(this.getSprite(), this.getX(), this.getY(), this.getWidth(), this.getHeight()); - guiGraphics.blitSprite(this.getHandleSprite(), this.getX() + (int)(this.value * (double)(this.width - 8)), this.getY(), 8, this.getHeight()); + guiGraphics.blitSprite(RenderType::guiTextured, this.getSprite(), this.getX(), this.getY(), this.getWidth(), this.getHeight()); + guiGraphics.blitSprite(RenderType::guiTextured, this.getHandleSprite(), this.getX() + (int)(this.value * (double)(this.width - 8)), this.getY(), 8, this.getHeight()); renderScrollingString(guiGraphics, mc.font, 2, getFGColor() | Mth.ceil(this.alpha * 255.0F) << 24); } diff --git a/src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java b/src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java index f1afc60255..204a4dc771 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java @@ -8,6 +8,7 @@ package net.minecraftforge.client.gui.widget; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.ObjectSelectionList; +import net.minecraft.client.renderer.RenderType; import net.minecraft.resources.ResourceLocation; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; @@ -20,16 +21,14 @@ import net.minecraftforge.forgespi.language.IModInfo; import com.mojang.blaze3d.systems.RenderSystem; -public class ModListWidget extends ObjectSelectionList -{ +public class ModListWidget extends ObjectSelectionList { private static String stripControlCodes(String value) { return net.minecraft.util.StringUtil.stripColor(value); } private static final ResourceLocation VERSION_CHECK_ICONS = ResourceLocation.fromNamespaceAndPath(ForgeVersion.MOD_ID, "textures/gui/version_check_icons.png"); private final int listWidth; private final ModListScreen parent; - public ModListWidget(ModListScreen parent, int listWidth, int top, int bottom) - { + public ModListWidget(ModListScreen parent, int listWidth, int top, int bottom) { super(parent.getMinecraftInstance(), listWidth, bottom, top, parent.getFontRenderer().lineHeight * 2 + 8); this.parent = parent; this.listWidth = listWidth; @@ -37,14 +36,12 @@ public class ModListWidget extends ObjectSelectionList } @Override - protected int getScrollbarPosition() - { + protected int getScrollbarPosition() { return this.listWidth; } @Override - public int getRowWidth() - { + public int getRowWidth() { return this.listWidth; } @@ -84,26 +81,23 @@ public class ModListWidget extends ObjectSelectionList Font font = this.parent.getFontRenderer(); guiGraphics.drawString(font, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(name, listWidth))), left + 3, top + 2, 0xFFFFFF, false); guiGraphics.drawString(font, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(version, listWidth))), left + 3, top + 2 + font.lineHeight, 0xCCCCCC, false); - if (vercheck.status().shouldDraw()) - { + if (vercheck.status().shouldDraw()) { //TODO: Consider adding more icons for visualization RenderSystem.setShaderColor(1, 1, 1, 1); guiGraphics.pose().pushPose(); - guiGraphics.blit(VERSION_CHECK_ICONS, getX() + width - 12, top + entryHeight / 4, vercheck.status().getSheetOffset() * 8, (vercheck.status().isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16); + guiGraphics.blit(RenderType::guiTextured, VERSION_CHECK_ICONS, getX() + width - 12, top + entryHeight / 4, vercheck.status().getSheetOffset() * 8, (vercheck.status().isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16); guiGraphics.pose().popPose(); } } @Override - public boolean mouseClicked(double p_mouseClicked_1_, double p_mouseClicked_3_, int p_mouseClicked_5_) - { + public boolean mouseClicked(double p_mouseClicked_1_, double p_mouseClicked_3_, int p_mouseClicked_5_) { parent.setSelected(this); ModListWidget.this.setSelected(this); return false; } - public IModInfo getInfo() - { + public IModInfo getInfo() { return modInfo; } } 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 3a230e1f19..4249afc102 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java @@ -13,9 +13,7 @@ import net.minecraft.client.gui.components.Renderable; import net.minecraft.client.gui.components.events.AbstractContainerEventHandler; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarratableEntry; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.renderer.GameRenderer; - +import net.minecraft.client.renderer.CoreShaders; import java.util.Collections; import java.util.List; @@ -290,7 +288,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen int barBgGreen = this.barBgColor >> 8 & 0xff; int barBgBlue = this.barBgColor & 0xff; - RenderSystem.setShader(GameRenderer::getPositionColorShader); + RenderSystem.setShader(CoreShaders.POSITION_COLOR); BufferBuilder worldr = tess.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); worldr.addVertex(barLeft, this.bottom, 0.0F).setColor(barBgRed, barBgGreen, barBgBlue, barBgAlpha); worldr.addVertex(barLeft + barWidth, this.bottom, 0.0F).setColor(barBgRed, barBgGreen, barBgBlue, barBgAlpha); diff --git a/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java b/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java index dbb9f41174..13d9aeefc2 100644 --- a/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java +++ b/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java @@ -23,7 +23,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import net.minecraft.client.Minecraft; -import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.server.packs.PackType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -59,7 +58,7 @@ public class ClientModLoader { } } - private static CompletableFuture onResourceReload(final PreparableReloadListener.PreparationBarrier stage, final ResourceManager resourceManager, final ProfilerFiller prepareProfiler, final ProfilerFiller executeProfiler, final Executor asyncExecutor, final Executor syncExecutor) { + private static CompletableFuture onResourceReload(final PreparableReloadListener.PreparationBarrier stage, final ResourceManager resourceManager, final Executor asyncExecutor, final Executor syncExecutor) { return CompletableFuture.runAsync(createRunnableWithCatch(() -> startModLoading(ModWorkManager.wrappedExecutor(syncExecutor), asyncExecutor)), ModWorkManager.parallelExecutor()) .thenCompose(stage::wait) .thenRunAsync(() -> finishModLoading(ModWorkManager.wrappedExecutor(syncExecutor), asyncExecutor), ModWorkManager.parallelExecutor()); diff --git a/src/main/java/net/minecraftforge/client/loading/ForgeLoadingOverlay.java b/src/main/java/net/minecraftforge/client/loading/ForgeLoadingOverlay.java index a943a5777a..7daf985c5e 100644 --- a/src/main/java/net/minecraftforge/client/loading/ForgeLoadingOverlay.java +++ b/src/main/java/net/minecraftforge/client/loading/ForgeLoadingOverlay.java @@ -6,24 +6,19 @@ package net.minecraftforge.client.loading; import com.mojang.blaze3d.platform.GlConst; -import com.mojang.blaze3d.platform.GlStateManager; 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.Tesselator; import com.mojang.blaze3d.vertex.VertexFormat; -import com.mojang.blaze3d.vertex.VertexSorting; -import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.LoadingOverlay; -import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.client.renderer.CoreShaders; +import net.minecraft.client.renderer.RenderType; import net.minecraft.server.packs.resources.ReloadInstance; import net.minecraft.util.Mth; import net.minecraftforge.fml.StartupMessageManager; -import net.minecraftforge.fml.earlydisplay.ColourScheme; import net.minecraftforge.fml.earlydisplay.DisplayWindow; import net.minecraftforge.fml.loading.progress.ProgressMeter; import org.jetbrains.annotations.NotNull; @@ -43,19 +38,15 @@ import java.util.function.Supplier; * It is somewhat a copy of the superclass render method. */ public class ForgeLoadingOverlay extends LoadingOverlay { - private static final ResourceLocation MOJANG_STUDIOS_LOGO_LOCATION = ResourceLocation.withDefaultNamespace("textures/gui/title/mojangstudios.png"); private final Minecraft minecraft; private final ReloadInstance reload; - private final Consumer> onFinish; private final DisplayWindow displayWindow; private final ProgressMeter progress; - private long fadeOutStart = -1L; public ForgeLoadingOverlay(final Minecraft mc, final ReloadInstance reloader, final Consumer> errorConsumer, DisplayWindow displayWindow) { super(mc, reloader, errorConsumer, false); this.minecraft = mc; this.reload = reloader; - this.onFinish = errorConsumer; this.displayWindow = displayWindow; displayWindow.addMojangTexture(mc.getTextureManager().getTexture(MOJANG_STUDIOS_LOGO_LOCATION).getId()); this.progress = StartupMessageManager.prependProgressBar("Minecraft Progress", 100); @@ -66,98 +57,48 @@ public class ForgeLoadingOverlay extends LoadingOverlay { } @Override - public void render(final @NotNull GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTick) { - long millis = Util.getMillis(); - float fadeouttimer = this.fadeOutStart > -1L ? (float)(millis - this.fadeOutStart) / 1000.0F : -1.0F; + protected boolean renderContents(GuiGraphics gui, float fade) { progress.setAbsolute(Mth.clamp((int)(this.reload.getActualProgress() * 100f), 0, 100)); - var fade = 1.0F - Mth.clamp(fadeouttimer - 1.0F, 0.0F, 1.0F); - var colour = this.displayWindow.context().colourScheme().background(); - RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, fade); - if (fadeouttimer >= 1.0F) { - if (this.minecraft.screen != null) { - this.minecraft.screen.render(graphics, 0, 0, partialTick); - } - displayWindow.render(0xff); - } else { - GlStateManager._clearColor(colour.redf(), colour.greenf(), colour.bluef(), 1f); - GlStateManager._clear(GlConst.GL_COLOR_BUFFER_BIT, Minecraft.ON_OSX); - displayWindow.render(0xFF); - } - RenderSystem.enableBlend(); - RenderSystem.blendFunc(GlConst.GL_SRC_ALPHA, GlConst.GL_ONE_MINUS_SRC_ALPHA); + + int alpha = (int)(fade * 255); + this.displayWindow.render(alpha); + + int width = gui.guiWidth(); + int height = gui.guiHeight(); + var fbWidth = this.minecraft.getWindow().getWidth(); var fbHeight = this.minecraft.getWindow().getHeight(); GL30C.glViewport(0, 0, fbWidth, fbHeight); - final var twidth = this.displayWindow.context().width(); - final var theight = this.displayWindow.context().height(); - var wscale = (float)fbWidth / twidth; - var hscale = (float)fbHeight / theight; - var scale = this.displayWindow.context().scale() * Math.min(wscale, hscale) / 2f; - var wleft = Mth.clamp(fbWidth * 0.5f - scale * twidth, 0, fbWidth); - var wtop = Mth.clamp(fbHeight * 0.5f - scale * theight, 0, fbHeight); - var wright = Mth.clamp(fbWidth * 0.5f + scale * twidth, 0, fbWidth); - var wbottom = Mth.clamp(fbHeight * 0.5f + scale * theight, 0, fbHeight); - GlStateManager.glActiveTexture(GlConst.GL_TEXTURE0); - RenderSystem.disableCull(); - BufferBuilder bufferbuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, fade); - RenderSystem.getModelViewMatrix().identity(); - RenderSystem.setProjectionMatrix(new Matrix4f().setOrtho(0.0F, fbWidth, 0.0F, fbHeight, 0.1f, -0.1f), VertexSorting.ORTHOGRAPHIC_Z); - RenderSystem.setShader(GameRenderer::getPositionColorShader); - // This is fill in around the edges - it's empty solid colour - - // top box from hpos - addQuad(bufferbuilder, 0, fbWidth, wtop, fbHeight, colour, fade); - // bottom box to hpos - addQuad(bufferbuilder, 0, fbWidth, 0, wtop, colour, fade); - // left box to wpos - addQuad(bufferbuilder, 0, wleft, wtop, wbottom, colour, fade); - // right box from wpos - addQuad(bufferbuilder, wright, fbWidth, wtop, wbottom, colour, fade); - BufferUploader.drawWithShader(bufferbuilder.buildOrThrow()); - - // This is the actual screen data from the loading screen + Matrix4f pos = gui.pose().last().pose(); RenderSystem.enableBlend(); RenderSystem.blendFunc(GlConst.GL_SRC_ALPHA, GlConst.GL_ONE_MINUS_SRC_ALPHA); - RenderSystem.setShader(GameRenderer::getPositionTexColorShader); + RenderSystem.setShader(CoreShaders.POSITION_TEX_COLOR); RenderSystem.setShaderTexture(0, displayWindow.getFramebufferTextureId()); - bufferbuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); - bufferbuilder.addVertex(wleft, wbottom, 0f).setUv(0, 0).setColor(1f, 1f, 1f, fade); - bufferbuilder.addVertex(wright, wbottom, 0f).setUv(1, 0).setColor(1f, 1f, 1f, fade); - bufferbuilder.addVertex(wright, wtop, 0f).setUv(1, 1).setColor(1f, 1f, 1f, fade); - bufferbuilder.addVertex(wleft, wtop, 0f).setUv(0, 1).setColor(1f, 1f, 1f, fade); GL30C.glTexParameterIi(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_MIN_FILTER, GlConst.GL_NEAREST); GL30C.glTexParameterIi(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_MAG_FILTER, GlConst.GL_NEAREST); - BufferUploader.drawWithShader(bufferbuilder.buildOrThrow()); + + var buf = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + buf.addVertex(pos, 0, 0, 0f).setUv(0, 0).setColor(1f, 1f, 1f, fade); + buf.addVertex(pos, 0, height, 0f).setUv(0, 1).setColor(1f, 1f, 1f, fade); + buf.addVertex(pos, width, height, 0f).setUv(1, 1).setColor(1f, 1f, 1f, fade); + buf.addVertex(pos, width, 0, 0f).setUv(1, 0).setColor(1f, 1f, 1f, fade); + BufferUploader.drawWithShader(buf.buildOrThrow()); + + // I dont know what exactly this does, but without it the screen flickers black. + // So as a hack we just render the mojang logo as a 0x0 cube + // TODO: Remove this when early screen is re-written to not be a texture based renderer + var logo = gui.getBufferSource().getBuffer(RenderType.mojangLogo()); + logo.addVertex(pos, 0, 0, 0f).setUv(0, 0).setColor(1f, 1f, 1f, fade); + logo.addVertex(pos, 0, 0, 0f).setUv(0, 1).setColor(1f, 1f, 1f, fade); + logo.addVertex(pos, 0, 0, 0f).setUv(1, 1).setColor(1f, 1f, 1f, fade); + logo.addVertex(pos, 0, 0, 0f).setUv(1, 0).setColor(1f, 1f, 1f, fade); + RenderSystem.defaultBlendFunc(); RenderSystem.disableBlend(); RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1f); - if (fadeouttimer >= 2.0F) { - this.minecraft.setOverlay(null); - this.displayWindow.close(); - } - - if (this.fadeOutStart == -1L && this.reload.isDone()) { - progress.complete(); - this.fadeOutStart = Util.getMillis(); - try { - this.reload.checkExceptions(); - this.onFinish.accept(Optional.empty()); - } catch (Throwable throwable) { - this.onFinish.accept(Optional.of(throwable)); - } - - if (this.minecraft.screen != null) { - this.minecraft.screen.init(this.minecraft, this.minecraft.getWindow().getGuiScaledWidth(), this.minecraft.getWindow().getGuiScaledHeight()); - } - } - } - - private static void addQuad(BufferBuilder bufferbuilder, float x0, float x1, float y0, float y1, ColourScheme.Colour colour, float fade) { - bufferbuilder.addVertex(x0, y0, 0f).setColor(colour.redf(), colour.greenf(), colour.bluef(), fade); - bufferbuilder.addVertex(x0, y1, 0f).setColor(colour.redf(), colour.greenf(), colour.bluef(), fade); - bufferbuilder.addVertex(x1, y1, 0f).setColor(colour.redf(), colour.greenf(), colour.bluef(), fade); - bufferbuilder.addVertex(x1, y0, 0f).setColor(colour.redf(), colour.greenf(), colour.bluef(), fade); + return false; } } diff --git a/src/main/java/net/minecraftforge/client/model/BakedModelWrapper.java b/src/main/java/net/minecraftforge/client/model/BakedModelWrapper.java index 7f639087db..7365831ac9 100644 --- a/src/main/java/net/minecraftforge/client/model/BakedModelWrapper.java +++ b/src/main/java/net/minecraftforge/client/model/BakedModelWrapper.java @@ -7,8 +7,8 @@ package net.minecraftforge.client.model; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.block.model.BakedOverrides; import net.minecraft.client.renderer.block.model.BakedQuad; -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; @@ -31,116 +31,97 @@ import java.util.List; *

* Useful for creating wrapper baked models which only override certain properties. */ -public abstract class BakedModelWrapper implements BakedModel -{ +public abstract class BakedModelWrapper implements BakedModel { protected final T originalModel; - public BakedModelWrapper(T originalModel) - { + public BakedModelWrapper(T originalModel) { this.originalModel = originalModel; } @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand) - { + public List getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand) { return originalModel.getQuads(state, side, rand); } @Override - public boolean useAmbientOcclusion() - { + public boolean useAmbientOcclusion() { return originalModel.useAmbientOcclusion(); } @Override - public boolean useAmbientOcclusion(BlockState state) - { + public boolean useAmbientOcclusion(BlockState state) { return originalModel.useAmbientOcclusion(state); } @Override - public boolean useAmbientOcclusion(BlockState state, RenderType renderType) - { + public boolean useAmbientOcclusion(BlockState state, RenderType renderType) { return originalModel.useAmbientOcclusion(state, renderType); } @Override - public boolean isGui3d() - { + public boolean isGui3d() { return originalModel.isGui3d(); } @Override - public boolean usesBlockLight() - { + public boolean usesBlockLight() { return originalModel.usesBlockLight(); } @Override - public boolean isCustomRenderer() - { + public boolean isCustomRenderer() { return originalModel.isCustomRenderer(); } @Override - public TextureAtlasSprite getParticleIcon() - { + public TextureAtlasSprite getParticleIcon() { return originalModel.getParticleIcon(); } @Override - public ItemTransforms getTransforms() - { + public ItemTransforms getTransforms() { return originalModel.getTransforms(); } @Override - public ItemOverrides getOverrides() - { - return originalModel.getOverrides(); + public BakedOverrides overrides() { + return originalModel.overrides(); } @Override - public BakedModel applyTransform(ItemDisplayContext cameraTransformType, PoseStack poseStack, boolean applyLeftHandTransform) - { + public BakedModel applyTransform(ItemDisplayContext cameraTransformType, PoseStack poseStack, boolean applyLeftHandTransform) { return originalModel.applyTransform(cameraTransformType, poseStack, applyLeftHandTransform); } @Override - public TextureAtlasSprite getParticleIcon(@NotNull ModelData data) - { + public TextureAtlasSprite getParticleIcon(@NotNull ModelData data) { return originalModel.getParticleIcon(data); } @NotNull @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull ModelData extraData, @Nullable RenderType renderType) - { + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull ModelData extraData, @Nullable RenderType renderType) { return originalModel.getQuads(state, side, rand, extraData, renderType); } @NotNull @Override - public ModelData getModelData(@NotNull BlockAndTintGetter level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ModelData modelData) - { + public ModelData getModelData(@NotNull BlockAndTintGetter level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ModelData modelData) { return originalModel.getModelData(level, pos, state, modelData); } @Override - public ChunkRenderTypeSet getRenderTypes(@NotNull BlockState state, @NotNull RandomSource rand, @NotNull ModelData data) - { + public ChunkRenderTypeSet getRenderTypes(@NotNull BlockState state, @NotNull RandomSource rand, @NotNull ModelData data) { return originalModel.getRenderTypes(state, rand, data); } @Override - public List getRenderTypes(ItemStack itemStack, boolean fabulous) - { + public List getRenderTypes(ItemStack itemStack, boolean fabulous) { return originalModel.getRenderTypes(itemStack, fabulous); } @Override - public List getRenderPasses(ItemStack itemStack, boolean fabulous) - { + public List getRenderPasses(ItemStack itemStack, boolean fabulous) { return originalModel.getRenderPasses(itemStack, fabulous); } } diff --git a/src/main/java/net/minecraftforge/client/model/CompositeModel.java b/src/main/java/net/minecraftforge/client/model/CompositeModel.java index 3212c4fa06..806734bd6d 100644 --- a/src/main/java/net/minecraftforge/client/model/CompositeModel.java +++ b/src/main/java/net/minecraftforge/client/model/CompositeModel.java @@ -23,7 +23,6 @@ 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; -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; @@ -33,7 +32,6 @@ 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; import net.minecraft.util.RandomSource; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockAndTintGetter; @@ -56,20 +54,17 @@ import org.jetbrains.annotations.Nullable; * These respect component visibility as specified in {@link IGeometryBakingContext} and can additionally be provided * with an item-specific render ordering, for multi-pass arrangements. */ -public class CompositeModel implements IUnbakedGeometry -{ +public class CompositeModel implements IUnbakedGeometry { private final ImmutableMap children; private final ImmutableList itemPasses; - public CompositeModel(ImmutableMap children, ImmutableList itemPasses) - { + public CompositeModel(ImmutableMap children, ImmutableList itemPasses) { this.children = children; this.itemPasses = itemPasses; } @Override - public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides) - { + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState) { Material particleLocation = context.getMaterial("particle"); TextureAtlasSprite particle = spriteGetter.apply(particleLocation); @@ -78,13 +73,12 @@ public class CompositeModel implements IUnbakedGeometry modelState = UnbakedGeometryHelper.composeRootTransformIntoModelState(modelState, rootTransform); var bakedPartsBuilder = ImmutableMap.builder(); - for (var entry : children.entrySet()) - { + for (var entry : children.entrySet()) { var name = entry.getKey(); if (!context.isComponentVisible(name, true)) continue; var model = entry.getValue(); - bakedPartsBuilder.put(name, model.bake(baker, model, spriteGetter, modelState, true)); + bakedPartsBuilder.put(name, model.bake(baker, spriteGetter, modelState)); } var bakedParts = bakedPartsBuilder.build(); @@ -97,53 +91,44 @@ public class CompositeModel implements IUnbakedGeometry itemPassesBuilder.add(model); } - return new Baked(context.isGui3d(), context.useBlockLight(), context.useAmbientOcclusion(), particle, context.getTransforms(), overrides, bakedParts, itemPassesBuilder.build()); + return new Baked(context.isGui3d(), context.useBlockLight(), context.useAmbientOcclusion(), particle, context.getTransforms(), bakedParts, itemPassesBuilder.build()); } @Override - public void resolveParents(Function modelGetter, IGeometryBakingContext context) - { - children.values().forEach(child -> child.resolveParents(modelGetter)); + public void resolveDependencies(UnbakedModel.Resolver resolver, IGeometryBakingContext context) { + children.values().forEach(child -> child.resolveDependencies(resolver)); } @Override - public Set getConfigurableComponentNames() - { + public Set getConfigurableComponentNames() { return children.keySet(); } - public static class Baked implements IDynamicBakedModel - { + public static class Baked implements IDynamicBakedModel { private final boolean isAmbientOcclusion; private final boolean isGui3d; private final boolean isSideLit; private final TextureAtlasSprite particle; - private final ItemOverrides overrides; private final ItemTransforms transforms; private final ImmutableMap children; private final ImmutableList itemPasses; - public Baked(boolean isGui3d, boolean isSideLit, boolean isAmbientOcclusion, TextureAtlasSprite particle, ItemTransforms transforms, ItemOverrides overrides, ImmutableMap children, ImmutableList itemPasses) - { + public Baked(boolean isGui3d, boolean isSideLit, boolean isAmbientOcclusion, TextureAtlasSprite particle, ItemTransforms transforms, ImmutableMap children, ImmutableList itemPasses) { this.children = children; this.isAmbientOcclusion = isAmbientOcclusion; this.isGui3d = isGui3d; this.isSideLit = isSideLit; this.particle = particle; - this.overrides = overrides; this.transforms = transforms; this.itemPasses = itemPasses; } @NotNull @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull ModelData data, @Nullable RenderType renderType) - { + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull ModelData data, @Nullable RenderType renderType) { List> quadLists = new ArrayList<>(); - for (Map.Entry entry : children.entrySet()) - { - if (renderType == null || (state != null && entry.getValue().getRenderTypes(state, rand, data).contains(renderType))) - { + for (Map.Entry entry : children.entrySet()) { + if (renderType == null || (state != null && entry.getValue().getRenderTypes(state, rand, data).contains(renderType))) { quadLists.add(entry.getValue().getQuads(state, side, rand, CompositeModel.Data.resolve(data, entry.getKey()), renderType)); } } @@ -151,8 +136,7 @@ public class CompositeModel implements IUnbakedGeometry } @Override - public @NotNull ModelData getModelData(@NotNull BlockAndTintGetter level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ModelData modelData) - { + public @NotNull ModelData getModelData(@NotNull BlockAndTintGetter level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ModelData modelData) { var builder = Data.builder(); for (var entry : children.entrySet()) builder.with(entry.getKey(), entry.getValue().getModelData(level, pos, state, Data.resolve(modelData, entry.getKey()))); @@ -160,50 +144,37 @@ public class CompositeModel implements IUnbakedGeometry } @Override - public boolean useAmbientOcclusion() - { + public boolean useAmbientOcclusion() { return isAmbientOcclusion; } @Override - public boolean isGui3d() - { + public boolean isGui3d() { return isGui3d; } @Override - public boolean usesBlockLight() - { + public boolean usesBlockLight() { return isSideLit; } @Override - public boolean isCustomRenderer() - { + public boolean isCustomRenderer() { return false; } @Override - public TextureAtlasSprite getParticleIcon() - { + public TextureAtlasSprite getParticleIcon() { return particle; } @Override - public ItemOverrides getOverrides() - { - return overrides; - } - - @Override - public ItemTransforms getTransforms() - { + public ItemTransforms getTransforms() { return transforms; } @Override - public ChunkRenderTypeSet getRenderTypes(@NotNull BlockState state, @NotNull RandomSource rand, @NotNull ModelData data) - { + public ChunkRenderTypeSet getRenderTypes(@NotNull BlockState state, @NotNull RandomSource rand, @NotNull ModelData data) { var sets = new ArrayList(); for (Map.Entry entry : children.entrySet()) sets.add(entry.getValue().getRenderTypes(state, rand, CompositeModel.Data.resolve(data, entry.getKey()))); @@ -211,68 +182,55 @@ public class CompositeModel implements IUnbakedGeometry } @Override - public List getRenderPasses(ItemStack itemStack, boolean fabulous) - { + public List getRenderPasses(ItemStack itemStack, boolean fabulous) { return itemPasses; } @Nullable - public BakedModel getPart(String name) - { + public BakedModel getPart(String name) { return children.get(name); } - public static Builder builder(IGeometryBakingContext owner, TextureAtlasSprite particle, ItemOverrides overrides, ItemTransforms cameraTransforms) - { - return builder(owner.useAmbientOcclusion(), owner.isGui3d(), owner.useBlockLight(), particle, overrides, cameraTransforms); + public static Builder builder(IGeometryBakingContext owner, TextureAtlasSprite particle, ItemTransforms cameraTransforms) { + return builder(owner.useAmbientOcclusion(), owner.isGui3d(), owner.useBlockLight(), particle, cameraTransforms); } - public static Builder builder(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemOverrides overrides, ItemTransforms cameraTransforms) - { - return new Builder(isAmbientOcclusion, isGui3d, isSideLit, particle, overrides, cameraTransforms); + public static Builder builder(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemTransforms cameraTransforms) { + return new Builder(isAmbientOcclusion, isGui3d, isSideLit, particle, cameraTransforms); } - public static class Builder - { + public static class Builder { private final boolean isAmbientOcclusion; private final boolean isGui3d; private final boolean isSideLit; private final List children = new ArrayList<>(); private final List quads = new ArrayList<>(); - private final ItemOverrides overrides; private final ItemTransforms transforms; private TextureAtlasSprite particle; private RenderTypeGroup lastRenderTypes = RenderTypeGroup.EMPTY; - private Builder(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemOverrides overrides, ItemTransforms transforms) - { + private Builder(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemTransforms transforms) { this.isAmbientOcclusion = isAmbientOcclusion; this.isGui3d = isGui3d; this.isSideLit = isSideLit; this.particle = particle; - this.overrides = overrides; this.transforms = transforms; } - public void addLayer(BakedModel model) - { + public void addLayer(BakedModel model) { flushQuads(null); children.add(model); } - private void addLayer(RenderTypeGroup renderTypes, List quads) - { - var modelBuilder = IModelBuilder.of(isAmbientOcclusion, isSideLit, isGui3d, transforms, overrides, particle, renderTypes); + private void addLayer(RenderTypeGroup renderTypes, List quads) { + var modelBuilder = IModelBuilder.of(isAmbientOcclusion, isSideLit, isGui3d, transforms, particle, renderTypes); quads.forEach(modelBuilder::addUnculledFace); children.add(modelBuilder.build()); } - private void flushQuads(RenderTypeGroup renderTypes) - { - if (!Objects.equals(renderTypes, lastRenderTypes)) - { - if (!quads.isEmpty()) - { + private void flushQuads(RenderTypeGroup renderTypes) { + if (!Objects.equals(renderTypes, lastRenderTypes)) { + if (!quads.isEmpty()) { addLayer(lastRenderTypes, quads); quads.clear(); } @@ -280,41 +238,35 @@ public class CompositeModel implements IUnbakedGeometry } } - public Builder setParticle(TextureAtlasSprite particleSprite) - { + public Builder setParticle(TextureAtlasSprite particleSprite) { this.particle = particleSprite; return this; } - public Builder addQuads(RenderTypeGroup renderTypes, BakedQuad... quadsToAdd) - { + public Builder addQuads(RenderTypeGroup renderTypes, BakedQuad... quadsToAdd) { flushQuads(renderTypes); Collections.addAll(quads, quadsToAdd); return this; } - public Builder addQuads(RenderTypeGroup renderTypes, Collection quadsToAdd) - { + public Builder addQuads(RenderTypeGroup renderTypes, Collection quadsToAdd) { flushQuads(renderTypes); quads.addAll(quadsToAdd); return this; } - public BakedModel build() - { - if (!quads.isEmpty()) - { + public BakedModel build() { + if (!quads.isEmpty()) { addLayer(lastRenderTypes, quads); } var childrenBuilder = ImmutableMap.builder(); var itemPassesBuilder = ImmutableList.builder(); int i = 0; - for (var model : this.children) - { + for (var model : this.children) { childrenBuilder.put("model_" + (i++), model); itemPassesBuilder.add(model); } - return new Baked(isGui3d, isSideLit, isAmbientOcclusion, particle, transforms, overrides, childrenBuilder.build(), itemPassesBuilder.build()); + return new Baked(isGui3d, isSideLit, isAmbientOcclusion, particle, transforms, childrenBuilder.build(), itemPassesBuilder.build()); } } @@ -323,20 +275,17 @@ public class CompositeModel implements IUnbakedGeometry /** * A model data container which stores data for child components. */ - public static class Data - { + public static class Data { public static final ModelProperty PROPERTY = new ModelProperty<>(); private final Map partData; - private Data(Map partData) - { + private Data(Map partData) { this.partData = partData; } @Nullable - public ModelData get(String name) - { + public ModelData get(String name) { return partData.get(name); } @@ -347,8 +296,7 @@ public class CompositeModel implements IUnbakedGeometry * @param name The name of the part to get data for * @return The data for the part, or the one passed in if not found */ - public static ModelData resolve(ModelData modelData, String name) - { + public static ModelData resolve(ModelData modelData, String name) { var compositeData = modelData.get(PROPERTY); if (compositeData == null) return modelData; @@ -356,39 +304,31 @@ public class CompositeModel implements IUnbakedGeometry return partData != null ? partData : modelData; } - public static Builder builder() - { + public static Builder builder() { return new Builder(); } - public static final class Builder - { + public static final class Builder { private final Map partData = new IdentityHashMap<>(); - public Builder with(String name, ModelData data) - { + public Builder with(String name, ModelData data) { partData.put(name, data); return this; } - public Data build() - { + public Data build() { return new Data(partData); } } } - public static final class Loader implements IGeometryLoader - { + public static final class Loader implements IGeometryLoader { public static final Loader INSTANCE = new Loader(); - private Loader() - { - } + private Loader() { } @Override - public CompositeModel read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) - { + public CompositeModel read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) { List itemPasses = new ArrayList<>(); ImmutableMap.Builder childrenBuilder = ImmutableMap.builder(); readChildren(jsonObject, "children", deserializationContext, childrenBuilder, itemPasses); @@ -397,8 +337,7 @@ public class CompositeModel implements IUnbakedGeometry if (children.isEmpty()) throw new JsonParseException("Composite model requires a \"children\" element with at least one element."); - if (jsonObject.has("item_render_order")) - { + if (jsonObject.has("item_render_order")) { itemPasses.clear(); for (var element : jsonObject.getAsJsonArray("item_render_order")) { @@ -412,13 +351,11 @@ public class CompositeModel implements IUnbakedGeometry return new CompositeModel(children, ImmutableList.copyOf(itemPasses)); } - private void readChildren(JsonObject jsonObject, String name, JsonDeserializationContext deserializationContext, ImmutableMap.Builder children, List itemPasses) - { + private void readChildren(JsonObject jsonObject, String name, JsonDeserializationContext deserializationContext, ImmutableMap.Builder children, List itemPasses) { if (!jsonObject.has(name)) return; var childrenJsonObject = jsonObject.getAsJsonObject(name); - for (Map.Entry entry : childrenJsonObject.entrySet()) - { + for (Map.Entry entry : childrenJsonObject.entrySet()) { children.put(entry.getKey(), deserializationContext.deserialize(entry.getValue(), BlockModel.class)); itemPasses.add(entry.getKey()); // We can do this because GSON preserves ordering during deserialization } diff --git a/src/main/java/net/minecraftforge/client/model/DynamicFluidContainerModel.java b/src/main/java/net/minecraftforge/client/model/DynamicFluidContainerModel.java index 36cffc1e74..fdec1f902e 100644 --- a/src/main/java/net/minecraftforge/client/model/DynamicFluidContainerModel.java +++ b/src/main/java/net/minecraftforge/client/model/DynamicFluidContainerModel.java @@ -12,7 +12,7 @@ import com.mojang.math.Transformation; import net.minecraft.client.color.item.ItemColor; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.BakedOverrides; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.BlockModelRotation; @@ -56,8 +56,7 @@ import static net.minecraftforge.client.model.geometry.StandaloneGeometryBakingC * * @see Colors */ -public class DynamicFluidContainerModel implements IUnbakedGeometry -{ +public class DynamicFluidContainerModel implements IUnbakedGeometry { // Depth offsets to prevent Z-fighting private static final Transformation FLUID_TRANSFORM = new Transformation(new Vector3f(), new Quaternionf(), new Vector3f(1, 1, 1.002f), new Quaternionf()); private static final Transformation COVER_TRANSFORM = new Transformation(new Vector3f(), new Quaternionf(), new Vector3f(1, 1, 1.004f), new Quaternionf()); @@ -67,16 +66,14 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry spriteGetter, ModelState modelState, ItemOverrides overrides) - { + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState) { Material particleLocation = context.hasMaterial("particle") ? context.getMaterial("particle") : null; Material baseLocation = context.hasMaterial("base") ? context.getMaterial("base") : null; Material fluidMaskLocation = context.hasMaterial("fluid") ? context.getMaterial("fluid") : null; @@ -108,8 +103,7 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry baseSprite, modelState); modelBuilder.addQuads(normalRenderTypes, quads); } - if (fluidMaskLocation != null && fluidSprite != null) - { + if (fluidMaskLocation != null && fluidSprite != null) { TextureAtlasSprite templateSprite = spriteGetter.apply(fluidMaskLocation); - if (templateSprite != null) - { + if (templateSprite != null) { // Fluid layer var transformedState = new SimpleModelState(modelState.getRotation().compose(FLUID_TRANSFORM), modelState.isUvLocked()); var unbaked = UnbakedGeometryHelper.createUnbakedItemMaskElements(1, templateSprite.contents()); // Use template as mask @@ -147,11 +138,9 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry cache = Maps.newHashMap(); // contains all the baked models since they'll never change - private final ItemOverrides nested; + private final BakedOverrides nested; private final ModelBaker baker; private final IGeometryBakingContext owner; private final DynamicFluidContainerModel parent; - private ContainedFluidOverrideHandler(ItemOverrides nested, ModelBaker baker, IGeometryBakingContext owner, DynamicFluidContainerModel parent) - { + private ContainedFluidOverrideHandler(BakedOverrides nested, ModelBaker baker, IGeometryBakingContext owner, DynamicFluidContainerModel parent) { this.nested = nested; this.baker = baker; this.owner = owner; @@ -209,35 +196,32 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry { - Fluid fluid = fluidStack.getFluid(); - String name = ForgeRegistries.FLUIDS.getKey(fluid).toString(); + public BakedModel findOverride(ItemStack stack, @Nullable ClientLevel level, @Nullable LivingEntity entity, int seed) { + BakedModel overridden = nested.findOverride(stack, level, entity, seed); + if (overridden != null) + return overridden; - if (!cache.containsKey(name)) - { - DynamicFluidContainerModel unbaked = this.parent.withFluid(fluid); - BakedModel bakedModel = unbaked.bake(owner, baker, Material::sprite, BlockModelRotation.X0_Y0, originalModel.getOverrides()); - cache.put(name, bakedModel); - return bakedModel; - } + var fluidStack = FluidUtil.getFluidContained(stack).orElse(null); + if (fluidStack == null) + return null; - return cache.get(name); - }) - // not a fluid item apparently - .orElse(originalModel); // empty bucket + Fluid fluid = fluidStack.getFluid(); + String name = ForgeRegistries.FLUIDS.getKey(fluid).toString(); + + if (!cache.containsKey(name)) { + DynamicFluidContainerModel unbaked = this.parent.withFluid(fluid); + BakedModel bakedModel = unbaked.bake(owner, baker, Material::sprite, BlockModelRotation.X0_Y0);//, nested); + cache.put(name, bakedModel); + return bakedModel; + } + + return cache.get(name); } } - public static class Colors implements ItemColor - { + public static class Colors implements ItemColor { @Override - public int getColor(@NotNull ItemStack stack, int tintIndex) - { + public int getColor(@NotNull ItemStack stack, int tintIndex) { if (tintIndex != 1) return 0xFFFFFFFF; return FluidUtil.getFluidContained(stack) .map(fluidStack -> IClientFluidTypeExtensions.of(fluidStack.getFluid()).getTintColor(fluidStack)) diff --git a/src/main/java/net/minecraftforge/client/model/EmptyModel.java b/src/main/java/net/minecraftforge/client/model/EmptyModel.java index 100cc97232..3f0b4c5821 100644 --- a/src/main/java/net/minecraftforge/client/model/EmptyModel.java +++ b/src/main/java/net/minecraftforge/client/model/EmptyModel.java @@ -5,24 +5,18 @@ 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; -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.ModelBaker; import net.minecraft.client.resources.model.ModelState; import net.minecraft.client.resources.model.SimpleBakedModel; -import net.minecraft.client.resources.model.UnbakedModel; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.inventory.InventoryMenu; import net.minecraftforge.client.RenderTypeGroup; import net.minecraftforge.client.model.geometry.IGeometryBakingContext; import net.minecraftforge.client.model.geometry.IGeometryLoader; @@ -35,40 +29,32 @@ import net.minecraftforge.client.textures.UnitTextureAtlasSprite; *

* You can access it as a {@link BakedModel}, an {@link IUnbakedGeometry} or an {@link IGeometryLoader}. */ -public class EmptyModel extends SimpleUnbakedGeometry -{ +public class EmptyModel extends SimpleUnbakedGeometry { public static final BakedModel BAKED = new Baked(); public static final EmptyModel INSTANCE = new EmptyModel(); public static final IGeometryLoader LOADER = (json, ctx) -> INSTANCE; - private EmptyModel() - { - } + private EmptyModel() { } @Override - protected void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBaker baker, Function spriteGetter, ModelState modelTransform) - { + protected void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBaker baker, Function spriteGetter, ModelState modelTransform) { // NO-OP } @Override - public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides) - { + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState) { return BAKED; } - private static class Baked extends SimpleBakedModel - { - private static final Material MISSING_TEXTURE = new Material(TextureAtlas.LOCATION_BLOCKS, MissingTextureAtlasSprite.getLocation()); + private static class Baked extends SimpleBakedModel { + private static final Material MISSING_TEXTURE = new Material(InventoryMenu.BLOCK_ATLAS, MissingTextureAtlasSprite.getLocation()); - public Baked() - { - super(List.of(), Map.of(), false, false, false, UnitTextureAtlasSprite.INSTANCE, ItemTransforms.NO_TRANSFORMS, ItemOverrides.EMPTY, RenderTypeGroup.EMPTY); + public Baked() { + super(List.of(), Map.of(), false, false, false, UnitTextureAtlasSprite.INSTANCE, ItemTransforms.NO_TRANSFORMS, RenderTypeGroup.EMPTY); } @Override - public TextureAtlasSprite getParticleIcon() - { + public TextureAtlasSprite getParticleIcon() { return MISSING_TEXTURE.sprite(); } } diff --git a/src/main/java/net/minecraftforge/client/model/ForgeItemModelShaper.java b/src/main/java/net/minecraftforge/client/model/ForgeItemModelShaper.java deleted file mode 100644 index 374070a028..0000000000 --- a/src/main/java/net/minecraftforge/client/model/ForgeItemModelShaper.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model; - -import com.google.common.collect.Maps; -import net.minecraft.client.renderer.ItemModelShaper; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelManager; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.core.Holder; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraftforge.registries.ForgeRegistries; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; - -/** - * Wrapper around {@link ItemModelShaper} that cleans up the internal maps to respect ID remapping. - */ -public class ForgeItemModelShaper extends ItemModelShaper { - private final Map, ModelResourceLocation> locations = Maps.newHashMap(); - private final Map, BakedModel> models = Maps.newHashMap(); - - public ForgeItemModelShaper(ModelManager manager) { - super(manager); - } - - @Override - @Nullable - public BakedModel getItemModel(Item item) { - return models.get(ForgeRegistries.ITEMS.getDelegateOrThrow(item)); - } - - @Override - public void register(Item item, ModelResourceLocation location) { - Holder.Reference key = ForgeRegistries.ITEMS.getDelegateOrThrow(item); - locations.put(key, location); - models.put(key, getModelManager().getModel(location)); - } - - @Override - public void rebuildCache() { - final ModelManager manager = this.getModelManager(); - for (Map.Entry, ModelResourceLocation> e : locations.entrySet()) { - models.put(e.getKey(), manager.getModel(e.getValue())); - } - } - - public ModelResourceLocation getLocation(@NotNull ItemStack stack) { - ModelResourceLocation location = locations.get(ForgeRegistries.ITEMS.getDelegateOrThrow(stack.getItem())); - return location == null ? ModelBakery.MISSING_MODEL_VARIANT : location; - } -} diff --git a/src/main/java/net/minecraftforge/client/model/IModelBuilder.java b/src/main/java/net/minecraftforge/client/model/IModelBuilder.java index ccb06792f5..a00dc67e39 100644 --- a/src/main/java/net/minecraftforge/client/model/IModelBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/IModelBuilder.java @@ -6,7 +6,6 @@ package net.minecraftforge.client.model; import net.minecraft.client.renderer.block.model.BakedQuad; -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; @@ -22,24 +21,22 @@ import java.util.List; * Provides a generic base implementation via {@link #of(boolean, boolean, boolean, ItemTransforms, ItemOverrides, TextureAtlasSprite, RenderTypeGroup)} * and a quad-collecting alternative via {@link #collecting(List)}. */ -public interface IModelBuilder> -{ +public interface IModelBuilder> { /** * Creates a new model builder that uses the provided attributes in the final baked model. */ static IModelBuilder of(boolean hasAmbientOcclusion, boolean usesBlockLight, boolean isGui3d, - ItemTransforms transforms, ItemOverrides overrides, TextureAtlasSprite particle, - RenderTypeGroup renderTypes) - { - return new Simple(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, overrides, particle, renderTypes); + ItemTransforms transforms, TextureAtlasSprite particle, + RenderTypeGroup renderTypes + ){ + return new Simple(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, particle, renderTypes); } /** * Creates a new model builder that collects quads to the provided list, returning * {@linkplain EmptyModel#BAKED an empty model} if you call {@link #build()}. */ - static IModelBuilder collecting(List quads) - { + static IModelBuilder collecting(List quads) { return new Collecting(quads); } @@ -49,69 +46,58 @@ public interface IModelBuilder> BakedModel build(); - class Simple implements IModelBuilder - { + class Simple implements IModelBuilder { private final SimpleBakedModel.Builder builder; private final RenderTypeGroup renderTypes; private Simple(boolean hasAmbientOcclusion, boolean usesBlockLight, boolean isGui3d, - ItemTransforms transforms, ItemOverrides overrides, TextureAtlasSprite particle, - RenderTypeGroup renderTypes) - { - this.builder = new SimpleBakedModel.Builder(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, overrides).particle(particle); + ItemTransforms transforms, TextureAtlasSprite particle, RenderTypeGroup renderTypes + ) { + this.builder = new SimpleBakedModel.Builder(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms).particle(particle); this.renderTypes = renderTypes; } @Override - public Simple addCulledFace(Direction facing, BakedQuad quad) - { + public Simple addCulledFace(Direction facing, BakedQuad quad) { builder.addCulledFace(facing, quad); return this; } @Override - public Simple addUnculledFace(BakedQuad quad) - { + public Simple addUnculledFace(BakedQuad quad) { builder.addUnculledFace(quad); return this; } @Deprecated @Override - public BakedModel build() - { + public BakedModel build() { return builder.renderTypes(renderTypes).build(); } } - class Collecting implements IModelBuilder - { + class Collecting implements IModelBuilder { private final List quads; - private Collecting(List quads) - { + private Collecting(List quads) { this.quads = quads; } @Override - public Collecting addCulledFace(Direction facing, BakedQuad quad) - { + public Collecting addCulledFace(Direction facing, BakedQuad quad) { quads.add(quad); return this; } @Override - public Collecting addUnculledFace(BakedQuad quad) - { + public Collecting addUnculledFace(BakedQuad quad) { quads.add(quad); return this; } @Override - public BakedModel build() - { + public BakedModel build() { return EmptyModel.BAKED; } } } - diff --git a/src/main/java/net/minecraftforge/client/model/IQuadTransformer.java b/src/main/java/net/minecraftforge/client/model/IQuadTransformer.java index 52d6cdeb9c..a9103c7216 100644 --- a/src/main/java/net/minecraftforge/client/model/IQuadTransformer.java +++ b/src/main/java/net/minecraftforge/client/model/IQuadTransformer.java @@ -52,7 +52,7 @@ public interface IQuadTransformer { private static BakedQuad copy(BakedQuad quad) { var vertices = quad.getVertices(); - return new BakedQuad(Arrays.copyOf(vertices, vertices.length), quad.getTintIndex(), quad.getDirection(), quad.getSprite(), quad.isShade(), quad.hasAmbientOcclusion()); + return new BakedQuad(Arrays.copyOf(vertices, vertices.length), quad.getTintIndex(), quad.getDirection(), quad.getSprite(), quad.isShade(), quad.getLightEmission(), quad.hasAmbientOcclusion()); } private static int findOffset(VertexFormatElement element) { diff --git a/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java b/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java index a80cd90ce4..31f583562b 100644 --- a/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java +++ b/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java @@ -7,14 +7,12 @@ package net.minecraftforge.client.model; import com.google.common.collect.ImmutableList; import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.ItemModelGenerator; -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; @@ -29,7 +27,6 @@ import net.minecraftforge.client.model.geometry.IUnbakedGeometry; import net.minecraftforge.client.model.geometry.UnbakedGeometryHelper; import org.jetbrains.annotations.Nullable; -import java.util.Map; import java.util.function.Function; /** @@ -38,43 +35,36 @@ import java.util.function.Function; * - Not limited to an arbitrary number of layers (5) * - Support for per-layer render types */ -public class ItemLayerModel implements IUnbakedGeometry -{ +public class ItemLayerModel implements IUnbakedGeometry { @Nullable private ImmutableList textures; private final Int2ObjectMap renderTypeNames; - private ItemLayerModel(@Nullable ImmutableList textures, Int2ObjectMap renderTypeNames) - { + private ItemLayerModel(@Nullable ImmutableList textures, Int2ObjectMap renderTypeNames) { this.textures = textures; this.renderTypeNames = renderTypeNames; } @Override - public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides) - { - if (textures == null) - { + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState) { + if (textures == null) { ImmutableList.Builder builder = ImmutableList.builder(); for (int i = 0; context.hasMaterial("layer" + i); i++) - { builder.add(context.getMaterial("layer" + i)); - } textures = builder.build(); } TextureAtlasSprite particle = spriteGetter.apply( - context.hasMaterial("particle") ? context.getMaterial("particle") : textures.get(0) + context.hasMaterial("particle") ? context.getMaterial("particle") : textures.get(0) ); var rootTransform = context.getRootTransform(); if (!rootTransform.isIdentity()) modelState = UnbakedGeometryHelper.composeRootTransformIntoModelState(modelState, rootTransform); var normalRenderTypes = new RenderTypeGroup(RenderType.translucent(), ForgeRenderTypes.ITEM_UNSORTED_TRANSLUCENT.get()); - CompositeModel.Baked.Builder builder = CompositeModel.Baked.builder(context, particle, overrides, context.getTransforms()); - for (int i = 0; i < textures.size(); i++) - { - TextureAtlasSprite sprite = spriteGetter.apply(textures.get(i)); + var builder = CompositeModel.Baked.builder(context, particle, context.getTransforms()); + for (int i = 0; i < textures.size(); i++) { + var sprite = spriteGetter.apply(textures.get(i)); var unbaked = UnbakedGeometryHelper.createUnbakedItemElements(i, sprite.contents()); var quads = UnbakedGeometryHelper.bakeElements(unbaked, $ -> sprite, modelState); var renderTypeName = renderTypeNames.get(i); @@ -85,19 +75,15 @@ public class ItemLayerModel implements IUnbakedGeometry return builder.build(); } - public static final class Loader implements IGeometryLoader - { + public static final class Loader implements IGeometryLoader { public static final Loader INSTANCE = new Loader(); @Override - public ItemLayerModel read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) - { + public ItemLayerModel read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) { var renderTypeNames = new Int2ObjectOpenHashMap(); - if (jsonObject.has("render_types")) - { + if (jsonObject.has("render_types")) { var renderTypes = jsonObject.getAsJsonObject("render_types"); - for (Map.Entry entry : renderTypes.entrySet()) - { + for (var entry : renderTypes.entrySet()) { var renderType = ResourceLocation.parse(entry.getKey()); for (var layer : entry.getValue().getAsJsonArray()) if (renderTypeNames.put(layer.getAsInt(), renderType) != null) @@ -108,15 +94,12 @@ public class ItemLayerModel implements IUnbakedGeometry return new ItemLayerModel(null, renderTypeNames); } - protected void readLayerData(JsonObject jsonObject, String name, Int2ObjectOpenHashMap renderTypeNames, Int2ObjectMap layerData, boolean logWarning) - { + protected void readLayerData(JsonObject jsonObject, String name, Int2ObjectOpenHashMap renderTypeNames, Int2ObjectMap layerData, boolean logWarning) { if (!jsonObject.has(name)) - { return; - } + var fullbrightLayers = jsonObject.getAsJsonObject(name); - for (var entry : fullbrightLayers.entrySet()) - { + for (var entry : fullbrightLayers.entrySet()) { int layer = Integer.parseInt(entry.getKey()); var data = ForgeFaceData.read(entry.getValue(), ForgeFaceData.DEFAULT); layerData.put(layer, data); diff --git a/src/main/java/net/minecraftforge/client/model/SeparateTransformsModel.java b/src/main/java/net/minecraftforge/client/model/SeparateTransformsModel.java index 1a5637cfb7..05208e94b2 100644 --- a/src/main/java/net/minecraftforge/client/model/SeparateTransformsModel.java +++ b/src/main/java/net/minecraftforge/client/model/SeparateTransformsModel.java @@ -17,7 +17,6 @@ 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; -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; @@ -26,7 +25,6 @@ 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; import net.minecraft.util.RandomSource; import net.minecraft.world.item.ItemDisplayContext; @@ -42,112 +40,91 @@ import org.jetbrains.annotations.Nullable; /** * A model composed of multiple sub-models which are picked based on the {@link ItemDisplayContext} being used. */ -public class SeparateTransformsModel implements IUnbakedGeometry -{ +public class SeparateTransformsModel implements IUnbakedGeometry { private final BlockModel baseModel; private final ImmutableMap perspectives; - public SeparateTransformsModel(BlockModel baseModel, ImmutableMap perspectives) - { + public SeparateTransformsModel(BlockModel baseModel, ImmutableMap perspectives) { this.baseModel = baseModel; this.perspectives = perspectives; } @Override - public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides) - { + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState) { return new Baked( - context.useAmbientOcclusion(), context.isGui3d(), context.useBlockLight(), - spriteGetter.apply(context.getMaterial("particle")), overrides, - baseModel.bake(baker, baseModel, spriteGetter, modelState, context.useBlockLight()), - ImmutableMap.copyOf(Maps.transformValues(perspectives, value -> { - return value.bake(baker, value, spriteGetter, modelState, context.useBlockLight()); - })) + context.useAmbientOcclusion(), + context.isGui3d(), + context.useBlockLight(), + spriteGetter.apply(context.getMaterial("particle")), + baseModel.bake(spriteGetter, modelState, context.useBlockLight()), + ImmutableMap.copyOf(Maps.transformValues(perspectives, value -> { + return value.bake(spriteGetter, modelState, context.useBlockLight()); + })) ); } @Override - public void resolveParents(Function modelGetter, IGeometryBakingContext context) - { - baseModel.resolveParents(modelGetter); - perspectives.values().forEach(model -> model.resolveParents(modelGetter)); + public void resolveDependencies(UnbakedModel.Resolver resolver, IGeometryBakingContext context) { + baseModel.resolveDependencies(resolver); + perspectives.values().forEach(model -> model.resolveDependencies(resolver)); } - public static class Baked implements IDynamicBakedModel - { + public static class Baked implements IDynamicBakedModel { private final boolean isAmbientOcclusion; private final boolean isGui3d; private final boolean isSideLit; private final TextureAtlasSprite particle; - private final ItemOverrides overrides; private final BakedModel baseModel; private final ImmutableMap perspectives; - public Baked(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemOverrides overrides, BakedModel baseModel, ImmutableMap perspectives) - { + public Baked(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, BakedModel baseModel, ImmutableMap perspectives) { this.isAmbientOcclusion = isAmbientOcclusion; this.isGui3d = isGui3d; this.isSideLit = isSideLit; this.particle = particle; - this.overrides = overrides; this.baseModel = baseModel; this.perspectives = perspectives; } @NotNull @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull ModelData data, @Nullable RenderType renderType) - { + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull ModelData data, @Nullable RenderType renderType) { return baseModel.getQuads(state, side, rand, data, renderType); } @Override - public boolean useAmbientOcclusion() - { + public boolean useAmbientOcclusion() { return isAmbientOcclusion; } @Override - public boolean isGui3d() - { + public boolean isGui3d() { return isGui3d; } @Override - public boolean usesBlockLight() - { + public boolean usesBlockLight() { return isSideLit; } @Override - public boolean isCustomRenderer() - { + public boolean isCustomRenderer() { return false; } @Override - public TextureAtlasSprite getParticleIcon() - { + public TextureAtlasSprite getParticleIcon() { return particle; } @Override - public ItemOverrides getOverrides() - { - return overrides; - } - - @Override - public ItemTransforms getTransforms() - { + public ItemTransforms getTransforms() { return ItemTransforms.NO_TRANSFORMS; } @Override - public BakedModel applyTransform(ItemDisplayContext cameraTransformType, PoseStack poseStack, boolean applyLeftHandTransform) - { - if (perspectives.containsKey(cameraTransformType)) - { + public BakedModel applyTransform(ItemDisplayContext cameraTransformType, PoseStack poseStack, boolean applyLeftHandTransform) { + if (perspectives.containsKey(cameraTransformType)) { BakedModel p = perspectives.get(cameraTransformType); return p.applyTransform(cameraTransformType, poseStack, applyLeftHandTransform); } @@ -155,32 +132,25 @@ public class SeparateTransformsModel implements IUnbakedGeometry - { + public static final class Loader implements IGeometryLoader { public static final Loader INSTANCE = new Loader(); - private Loader() - { - } + private Loader() { } @Override - public SeparateTransformsModel read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) - { + public SeparateTransformsModel read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) { BlockModel baseModel = deserializationContext.deserialize(GsonHelper.getAsJsonObject(jsonObject, "base"), BlockModel.class); JsonObject perspectiveData = GsonHelper.getAsJsonObject(jsonObject, "perspectives"); Map perspectives = new HashMap<>(); - for (ItemDisplayContext transform : ItemDisplayContext.values()) - { - if (perspectiveData.has(transform.getSerializedName())) - { + for (ItemDisplayContext transform : ItemDisplayContext.values()) { + if (perspectiveData.has(transform.getSerializedName())) { BlockModel perspectiveModel = deserializationContext.deserialize(GsonHelper.getAsJsonObject(perspectiveData, transform.getSerializedName()), BlockModel.class); perspectives.put(transform, perspectiveModel); } diff --git a/src/main/java/net/minecraftforge/client/model/data/ModelData.java b/src/main/java/net/minecraftforge/client/model/data/ModelData.java index a5bbadf913..db529b5a2d 100644 --- a/src/main/java/net/minecraftforge/client/model/data/ModelData.java +++ b/src/main/java/net/minecraftforge/client/model/data/ModelData.java @@ -33,19 +33,16 @@ import java.util.Set; * @see BakedModel#getQuads(BlockState, Direction, RandomSource, ModelData, RenderType) * @see BakedModel#getModelData(BlockAndTintGetter, BlockPos, BlockState, ModelData) */ -public final class ModelData -{ +public final class ModelData { public static final ModelData EMPTY = ModelData.builder().build(); private final Map, Object> properties; - private ModelData(Map, Object> properties) - { + private ModelData(Map, Object> properties) { this.properties = properties; } - public Set> getProperties() - { + public Set> getProperties() { return properties.keySet(); } @@ -54,45 +51,37 @@ public final class ModelData return properties.containsKey(property); } + @SuppressWarnings("unchecked") @Nullable - public T get(ModelProperty property) - { - return (T) properties.get(property); + public T get(ModelProperty property) { + return (T)properties.get(property); } - public Builder derive() - { + public Builder derive() { return new Builder(this); } - public static Builder builder() - { + public static Builder builder() { return new Builder(null); } - public static final class Builder - { + public static final class Builder { private final Map, Object> properties = new IdentityHashMap<>(); - private Builder(@Nullable ModelData parent) - { + private Builder(@Nullable ModelData parent) { if (parent != null) - { properties.putAll(parent.properties); - } } @Contract("_, _ -> this") - public Builder with(ModelProperty property, T value) - { + public Builder with(ModelProperty property, T value) { Preconditions.checkState(property.test(value), "The provided value is invalid for this property."); properties.put(property, value); return this; } @Contract("-> new") - public ModelData build() - { + public ModelData build() { return new ModelData(Collections.unmodifiableMap(properties)); } } diff --git a/src/main/java/net/minecraftforge/client/model/data/ModelDataManager.java b/src/main/java/net/minecraftforge/client/model/data/ModelDataManager.java index 3a54973d94..2598ef35a6 100644 --- a/src/main/java/net/minecraftforge/client/model/data/ModelDataManager.java +++ b/src/main/java/net/minecraftforge/client/model/data/ModelDataManager.java @@ -67,6 +67,11 @@ public class ModelDataManager { return getAt(new ChunkPos(pos)).get(pos); } + public ModelData getAtOrEmpty(BlockPos pos) { + var ret = getAt(pos); + return ret == null ? ModelData.EMPTY : ret; + } + public Map getAt(SectionPos pos) { return getAt(pos.chunk()); } 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 f6b45c4f54..6237e051cd 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java @@ -380,6 +380,7 @@ public class ModelBuilder> extends ModelFile { private RotationBuilder rotation; private boolean shade = true; private ForgeFaceData data = ForgeFaceData.DEFAULT; + private int emission = 0; private void validateCoordinate(float coord, char name) { Preconditions.checkArgument(!(coord < -16.0F) && !(coord > 32.0F), "Position " + name + " out of range, must be within [-16, 32]. Found: %d", coord); @@ -559,14 +560,23 @@ public class ModelBuilder> extends ModelFile { return this; } + public ElementBuilder emission(int value) { + this.emission = value; + return this; + } + private BiConsumer addTexture(String texture) { return ($, f) -> f.texture(texture); } BlockElement build() { - Map faces = this.faces.entrySet().stream() - .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().build(), (k1, k2) -> { throw new IllegalArgumentException(); }, LinkedHashMap::new)); - return new BlockElement(from, to, faces, rotation == null ? null : rotation.build(), shade); + var faces = new LinkedHashMap(); + for (var entry : this.faces.entrySet()) { + if (faces.containsKey(entry.getKey())) + throw new IllegalArgumentException("Multiple faces defined for Direction: " + entry.getKey().getName()); + faces.put(entry.getKey(), entry.getValue().build()); + } + return new BlockElement(from, to, faces, rotation == null ? null : rotation.build(), shade, emission); } public T end() { return self(); } diff --git a/src/main/java/net/minecraftforge/client/model/generators/MultiPartBlockStateBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/MultiPartBlockStateBuilder.java index 0fd0a12e33..0971975895 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/MultiPartBlockStateBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/MultiPartBlockStateBuilder.java @@ -21,9 +21,7 @@ import com.google.gson.JsonObject; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.properties.Property; -public final class MultiPartBlockStateBuilder implements IGeneratedBlockState -{ - +public final class MultiPartBlockStateBuilder implements IGeneratedBlockState { private final List parts = new ArrayList<>(); private final Block owner; @@ -35,7 +33,7 @@ public final class MultiPartBlockStateBuilder implements IGeneratedBlockState * Creates a builder for models to assign to a {@link PartBuilder}, which when * completed via {@link ConfiguredModel.Builder#addModel()} will assign the * resultant set of models to the part and return it for further processing. - * + * * @return the model builder * @see ConfiguredModel.Builder */ @@ -80,7 +78,7 @@ public final class MultiPartBlockStateBuilder implements IGeneratedBlockState /** * Set a condition for this part, which consists of a property and a set of * valid values. Can be called multiple times for multiple different properties. - * + * * @param the type of the property value * @param prop the property * @param values a set of valid values @@ -109,8 +107,7 @@ public final class MultiPartBlockStateBuilder implements IGeneratedBlockState * Allows having nested groups of conditions if there are not any normal conditions. * @throws IllegalStateException if {@code !conditions.isEmpty()} */ - public final ConditionGroup nestedGroup() - { + public final ConditionGroup nestedGroup() { Preconditions.checkState(conditions.isEmpty(), "Can't have nested condition groups if there are already normal conditions"); ConditionGroup group = new ConditionGroup(); this.nestedConditionGroups.add(group); @@ -123,9 +120,7 @@ public final class MultiPartBlockStateBuilder implements IGeneratedBlockState JsonObject out = new JsonObject(); if (!conditions.isEmpty()) { out.add("when", MultiPartBlockStateBuilder.toJson(this.conditions, this.useOr)); - } - else if (!nestedConditionGroups.isEmpty()) - { + } else if (!nestedConditionGroups.isEmpty()) { out.add("when", MultiPartBlockStateBuilder.toJson(this.nestedConditionGroups, this.useOr)); } out.add("apply", models.toJSON()); @@ -136,8 +131,7 @@ public final class MultiPartBlockStateBuilder implements IGeneratedBlockState return b.getStateDefinition().getProperties().containsAll(conditions.keySet()); } - public class ConditionGroup - { + public class ConditionGroup { public final Multimap, Comparable> conditions = MultimapBuilder.linkedHashKeys().arrayListValues().build(); public final List nestedConditionGroups = new ArrayList<>(); private ConditionGroup parent = null; @@ -160,8 +154,7 @@ public final class MultiPartBlockStateBuilder implements IGeneratedBlockState * @throws IllegalStateException if {@code !nestedConditionGroups.isEmpty()} */ @SafeVarargs - public final > ConditionGroup condition(Property prop, T... values) - { + public final > ConditionGroup condition(Property prop, T... values) { Preconditions.checkNotNull(prop, "Property must not be null"); Preconditions.checkNotNull(values, "Value list must not be null"); Preconditions.checkArgument(values.length > 0, "Value list must not be empty"); @@ -176,8 +169,7 @@ public final class MultiPartBlockStateBuilder implements IGeneratedBlockState * Allows having nested groups of conditions if there are not any normal conditions. * @throws IllegalStateException if {@code !conditions.isEmpty()} */ - public ConditionGroup nestedGroup() - { + public ConditionGroup nestedGroup() { Preconditions.checkState(conditions.isEmpty(), "Can't have nested condition groups if there are already normal conditions"); ConditionGroup group = new ConditionGroup(); group.parent = this; @@ -187,23 +179,21 @@ public final class MultiPartBlockStateBuilder implements IGeneratedBlockState /** * Ends this nested condition group and returns the parent condition group - * + * * @throws IllegalStateException If this is not a nested condition group */ - public ConditionGroup endNestedGroup() - { + public ConditionGroup endNestedGroup() { if (parent == null) - throw new IllegalStateException("This condition group is not nested, use end() instead"); + throw new IllegalStateException("This condition group is not nested, use end() instead"); return parent; } /** * Ends this condition group and returns the part builder - * + * * @throws IllegalStateException If this is a nested condition group */ - public MultiPartBlockStateBuilder.PartBuilder end() - { + public MultiPartBlockStateBuilder.PartBuilder end() { if (this.parent != null) throw new IllegalStateException("This is a nested condition group, use endNestedGroup() instead"); return MultiPartBlockStateBuilder.PartBuilder.this; @@ -212,58 +202,45 @@ public final class MultiPartBlockStateBuilder implements IGeneratedBlockState /** * Makes this part get applied if any of the conditions/condition groups are true, instead of all of them needing to be true. */ - public ConditionGroup useOr() - { + public ConditionGroup useOr() { this.useOr = true; return this; } - JsonObject toJson() - { + JsonObject toJson() { if (!this.conditions.isEmpty()) - { return MultiPartBlockStateBuilder.toJson(this.conditions, this.useOr); - } else if (!this.nestedConditionGroups.isEmpty()) - { return MultiPartBlockStateBuilder.toJson(this.nestedConditionGroups, this.useOr); - } return new JsonObject(); } } } - private static JsonObject toJson(List conditions, boolean useOr) - { + private static JsonObject toJson(List conditions, boolean useOr) { JsonObject groupJson = new JsonObject(); JsonArray innerGroupJson = new JsonArray(); groupJson.add(useOr ? "OR" : "AND", innerGroupJson); for (PartBuilder.ConditionGroup group : conditions) - { innerGroupJson.add(group.toJson()); - } return groupJson; } - private static JsonObject toJson(Multimap, Comparable> conditions, boolean useOr) - { + private static JsonObject toJson(Multimap, Comparable> conditions, boolean useOr) { JsonObject groupJson = new JsonObject(); - for (Entry, Collection>> e : conditions.asMap().entrySet()) - { + for (Entry, Collection>> e : conditions.asMap().entrySet()) { StringBuilder activeString = new StringBuilder(); - for (Comparable val : e.getValue()) - { + for (Comparable val : e.getValue()) { if (!activeString.isEmpty()) activeString.append("|"); - activeString.append(((Property) e.getKey()).getName(val)); + activeString.append(getName(e.getKey(), val)); } groupJson.addProperty(e.getKey().getName(), activeString.toString()); } - if (useOr) - { + + if (useOr) { JsonArray innerWhen = new JsonArray(); - for (Entry entry : groupJson.entrySet()) - { + for (Entry entry : groupJson.entrySet()) { JsonObject obj = new JsonObject(); obj.add(entry.getKey(), entry.getValue()); innerWhen.add(obj); @@ -273,4 +250,9 @@ public final class MultiPartBlockStateBuilder implements IGeneratedBlockState } return groupJson; } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + private static String getName(Property key, Comparable value) { + return ((Property)key).getName((Comparable)value); + } } 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 99b560c085..5c30325a53 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/BlockGeometryBakingContext.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/BlockGeometryBakingContext.java @@ -5,23 +5,17 @@ package net.minecraftforge.client.model.geometry; -import com.mojang.datafixers.util.Pair; import com.mojang.math.Transformation; -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; @@ -31,8 +25,7 @@ import org.jetbrains.annotations.Nullable; *

* Users should not be instantiating this themselves. */ -public class BlockGeometryBakingContext implements IGeometryBakingContext -{ +public class BlockGeometryBakingContext implements IGeometryBakingContext { public final BlockModel owner; public final VisibilityData visibilityData = new VisibilityData(); @Nullable @@ -44,111 +37,93 @@ public class BlockGeometryBakingContext implements IGeometryBakingContext private boolean gui3d = true; @ApiStatus.Internal - public BlockGeometryBakingContext(BlockModel owner) - { + public BlockGeometryBakingContext(BlockModel owner) { this.owner = owner; } @Override - public String getModelName() - { + public String getModelName() { return owner.name; } - public boolean hasCustomGeometry() - { + public boolean hasCustomGeometry() { return getCustomGeometry() != null; } @Nullable - public IUnbakedGeometry getCustomGeometry() - { + public IUnbakedGeometry getCustomGeometry() { return owner.parent != null && customGeometry == null ? owner.parent.customData.getCustomGeometry() : customGeometry; } - public void setCustomGeometry(IUnbakedGeometry geometry) - { + public void setCustomGeometry(IUnbakedGeometry geometry) { this.customGeometry = geometry; } @Override - public boolean isComponentVisible(String part, boolean fallback) - { + public boolean isComponentVisible(String part, boolean fallback) { return owner.parent != null && !visibilityData.hasCustomVisibility(part) ? owner.parent.customData.isComponentVisible(part, fallback) : visibilityData.isVisible(part, fallback); } @Override - public boolean hasMaterial(String name) - { + public boolean hasMaterial(String name) { return owner.hasTexture(name); } @Override - public Material getMaterial(String name) - { + public Material getMaterial(String name) { return owner.getMaterial(name); } @Override - public boolean isGui3d() - { + public boolean isGui3d() { return gui3d; } @Override - public boolean useBlockLight() - { + public boolean useBlockLight() { return owner.getGuiLight().lightLikeBlock(); } @Override - public boolean useAmbientOcclusion() - { + public boolean useAmbientOcclusion() { return owner.hasAmbientOcclusion(); } @Override - public ItemTransforms getTransforms() - { + public ItemTransforms getTransforms() { return owner.getTransforms(); } @Override - public Transformation getRootTransform() - { + public Transformation getRootTransform() { if (rootTransform != null) return rootTransform; return owner.parent != null ? owner.parent.customData.getRootTransform() : Transformation.identity(); } - public void setRootTransform(Transformation rootTransform) - { + public void setRootTransform(Transformation rootTransform) { this.rootTransform = rootTransform; } @Nullable @Override - public ResourceLocation getRenderTypeHint() - { + public ResourceLocation getRenderTypeHint() { if (renderTypeHint != null) return renderTypeHint; return owner.parent != null ? owner.parent.customData.getRenderTypeHint() : null; } - public void setRenderTypeHint(ResourceLocation renderTypeHint) - { + public void setRenderTypeHint(ResourceLocation renderTypeHint) { this.renderTypeHint = renderTypeHint; } - public void setGui3d(boolean gui3d) - { + public void setGui3d(boolean gui3d) { this.gui3d = gui3d; } - public void copyFrom(BlockGeometryBakingContext other) - { + public void copyFrom(BlockGeometryBakingContext other) { this.customGeometry = other.customGeometry; this.rootTransform = other.rootTransform; this.visibilityData.copyFrom(other.visibilityData); @@ -156,35 +131,29 @@ public class BlockGeometryBakingContext implements IGeometryBakingContext this.gui3d = other.gui3d; } - public BakedModel bake(ModelBaker baker, Function bakedTextureGetter, ModelState modelTransform, ItemOverrides overrides) - { + public BakedModel bake(ModelBaker baker, Function bakedTextureGetter, ModelState modelTransform) { IUnbakedGeometry geometry = getCustomGeometry(); if (geometry == null) throw new IllegalStateException("Can not use custom baking without custom geometry"); - return geometry.bake(this, baker, bakedTextureGetter, modelTransform, overrides); + return geometry.bake(this, baker, bakedTextureGetter, modelTransform); } - public static class VisibilityData - { + public static class VisibilityData { private final Map data = new HashMap<>(); - public boolean hasCustomVisibility(String part) - { + public boolean hasCustomVisibility(String part) { return data.containsKey(part); } - public boolean isVisible(String part, boolean fallback) - { + public boolean isVisible(String part, boolean fallback) { return data.getOrDefault(part, fallback); } - public void setVisibilityState(String partName, boolean type) - { + public void setVisibilityState(String partName, boolean type) { data.put(partName, type); } - public void copyFrom(VisibilityData visibilityData) - { + public void copyFrom(VisibilityData visibilityData) { data.clear(); data.putAll(visibilityData.data); } diff --git a/src/main/java/net/minecraftforge/client/model/geometry/GeometryLoaderManager.java b/src/main/java/net/minecraftforge/client/model/geometry/GeometryLoaderManager.java index 264e047b54..cf76e90b5f 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/GeometryLoaderManager.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/GeometryLoaderManager.java @@ -8,7 +8,6 @@ package net.minecraftforge.client.model.geometry; import com.google.common.collect.ImmutableMap; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.event.ModelEvent; -import net.minecraftforge.client.model.ElementsModel; import net.minecraftforge.fml.ModLoader; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; @@ -21,8 +20,7 @@ import java.util.stream.Collectors; *

* Provides a lookup. */ -public final class GeometryLoaderManager -{ +public final class GeometryLoaderManager { private static ImmutableMap> LOADERS; private static String LOADER_LIST; @@ -30,22 +28,19 @@ public final class GeometryLoaderManager * Finds the {@link IGeometryLoader} for a given name, or null if not found. */ @Nullable - public static IGeometryLoader get(ResourceLocation name) - { + public static IGeometryLoader get(ResourceLocation name) { return LOADERS.get(name); } /** * Retrieves a comma-separated list of all active loaders, for use in error messages. */ - public static String getLoaderList() - { + public static String getLoaderList() { return LOADER_LIST; } @ApiStatus.Internal - public static void init() - { + public static void init() { var loaders = new HashMap>(); var event = new ModelEvent.RegisterGeometryLoaders(loaders); ModLoader.get().postEventWrapContainerInModOrder(event); @@ -53,7 +48,5 @@ public final class GeometryLoaderManager LOADER_LIST = loaders.keySet().stream().map(ResourceLocation::toString).collect(Collectors.joining(", ")); } - private GeometryLoaderManager() - { - } + private GeometryLoaderManager() { } } diff --git a/src/main/java/net/minecraftforge/client/model/geometry/IGeometryBakingContext.java b/src/main/java/net/minecraftforge/client/model/geometry/IGeometryBakingContext.java index 8df243e43d..e5b17e4306 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/IGeometryBakingContext.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/IGeometryBakingContext.java @@ -21,8 +21,7 @@ import org.jetbrains.annotations.Nullable; * @see StandaloneGeometryBakingContext * @see BlockGeometryBakingContext */ -public interface IGeometryBakingContext -{ +public interface IGeometryBakingContext { /** * {@return the name of the model being baked for logging and caching purposes.} */ @@ -87,8 +86,7 @@ public interface IGeometryBakingContext /** * {@return a {@link RenderTypeGroup} with the given name, or the empty group if not found.} */ - default RenderTypeGroup getRenderType(ResourceLocation name) - { + default RenderTypeGroup getRenderType(ResourceLocation name) { return NamedRenderTypeManager.get(name); } } diff --git a/src/main/java/net/minecraftforge/client/model/geometry/IGeometryLoader.java b/src/main/java/net/minecraftforge/client/model/geometry/IGeometryLoader.java index 17ad5d34b9..044e642fcb 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/IGeometryLoader.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/IGeometryLoader.java @@ -21,7 +21,6 @@ import net.minecraftforge.client.event.RegisterClientReloadListenersEvent; * @see RegisterGeometryLoaders * @see RegisterClientReloadListenersEvent */ -public interface IGeometryLoader> -{ +public interface IGeometryLoader> { T read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) throws JsonParseException; } 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 a489638be5..da9dbb565e 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/IUnbakedGeometry.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/IUnbakedGeometry.java @@ -9,14 +9,12 @@ 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.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; /** * General interface for any model that can be baked, superset of vanilla {@link UnbakedModel}. @@ -27,14 +25,14 @@ import net.minecraft.resources.ResourceLocation; * @see IGeometryBakingContext */ public interface IUnbakedGeometry> { - BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides); + BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState); /** * Resolve parents of nested {@link BlockModel}s which are later used in - * {@link IUnbakedGeometry#bake(IGeometryBakingContext, ModelBaker, Function, ModelState, ItemOverrides)} + * {@link IUnbakedGeometry#bake(IGeometryBakingContext, ModelBaker, Function, ModelState)} * via {@link BlockModel#resolveParents(Function)} */ - default void resolveParents(Function modelGetter, IGeometryBakingContext context) { } + default void resolveDependencies(UnbakedModel.Resolver resolver, IGeometryBakingContext context) { } /** * {@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 cf79fb240d..a81e309d5a 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/SimpleUnbakedGeometry.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/SimpleUnbakedGeometry.java @@ -7,7 +7,6 @@ package net.minecraftforge.client.model.geometry; 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; @@ -21,17 +20,15 @@ import net.minecraftforge.client.model.IModelBuilder; * 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. */ -public abstract class SimpleUnbakedGeometry> implements IUnbakedGeometry -{ +public abstract class SimpleUnbakedGeometry> implements IUnbakedGeometry { @Override - public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides) - { + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState) { TextureAtlasSprite particle = spriteGetter.apply(context.getMaterial("particle")); var renderTypeHint = context.getRenderTypeHint(); var renderTypes = renderTypeHint != null ? context.getRenderType(renderTypeHint) : RenderTypeGroup.EMPTY; IModelBuilder builder = IModelBuilder.of(context.useAmbientOcclusion(), context.useBlockLight(), context.isGui3d(), - context.getTransforms(), overrides, particle, renderTypes); + context.getTransforms(), particle, renderTypes); addQuads(context, builder, baker, spriteGetter, modelState); diff --git a/src/main/java/net/minecraftforge/client/model/geometry/StandaloneGeometryBakingContext.java b/src/main/java/net/minecraftforge/client/model/geometry/StandaloneGeometryBakingContext.java index 208caae29f..26931d6094 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/StandaloneGeometryBakingContext.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/StandaloneGeometryBakingContext.java @@ -10,9 +10,10 @@ import com.mojang.math.Transformation; import it.unimi.dsi.fastutil.objects.Object2BooleanMap; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; -import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.resources.model.Material; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.inventory.InventoryMenu; + import org.jetbrains.annotations.Nullable; import java.util.Map; @@ -23,24 +24,20 @@ import java.util.function.Predicate; /** * A {@linkplain IGeometryBakingContext geometry baking context} that is not bound to block/item model loading. */ -public class StandaloneGeometryBakingContext implements IGeometryBakingContext -{ +public class StandaloneGeometryBakingContext implements IGeometryBakingContext { public static final ResourceLocation LOCATION = ResourceLocation.fromNamespaceAndPath("forge", "standalone"); public static final StandaloneGeometryBakingContext INSTANCE = create(LOCATION); - public static StandaloneGeometryBakingContext create(ResourceLocation modelName) - { + public static StandaloneGeometryBakingContext create(ResourceLocation modelName) { return builder().build(modelName); } - public static StandaloneGeometryBakingContext create(Map textures) - { + public static StandaloneGeometryBakingContext create(Map textures) { return create(LOCATION, textures); } - public static StandaloneGeometryBakingContext create(ResourceLocation modelName, Map textures) - { + public static StandaloneGeometryBakingContext create(ResourceLocation modelName, Map textures) { return builder().withTextures(textures, MissingTextureAtlasSprite.getLocation()).build(modelName); } @@ -56,13 +53,14 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext private final ResourceLocation renderTypeHint; private final BiPredicate visibilityTest; - private StandaloneGeometryBakingContext(ResourceLocation modelName, Predicate materialCheck, - Function materialLookup, boolean isGui3d, - boolean useBlockLight, boolean useAmbientOcclusion, - ItemTransforms transforms, Transformation rootTransform, - @Nullable ResourceLocation renderTypeHint, - BiPredicate visibilityTest) - { + private StandaloneGeometryBakingContext( + ResourceLocation modelName, Predicate materialCheck, + Function materialLookup, boolean isGui3d, + boolean useBlockLight, boolean useAmbientOcclusion, + ItemTransforms transforms, Transformation rootTransform, + @Nullable ResourceLocation renderTypeHint, + BiPredicate visibilityTest + ) { this.modelName = modelName; this.materialCheck = materialCheck; this.materialLookup = materialLookup; @@ -76,79 +74,66 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext } @Override - public String getModelName() - { + public String getModelName() { return modelName.toString(); } @Override - public boolean hasMaterial(String name) - { + public boolean hasMaterial(String name) { return materialCheck.test(name); } @Override - public Material getMaterial(String name) - { + public Material getMaterial(String name) { return materialLookup.apply(name); } @Override - public boolean isGui3d() - { + public boolean isGui3d() { return isGui3d; } @Override - public boolean useBlockLight() - { + public boolean useBlockLight() { return useBlockLight; } @Override - public boolean useAmbientOcclusion() - { + public boolean useAmbientOcclusion() { return useAmbientOcclusion; } @Override - public ItemTransforms getTransforms() - { + public ItemTransforms getTransforms() { return transforms; } @Override - public Transformation getRootTransform() - { + public Transformation getRootTransform() { return rootTransform; } @Nullable @Override - public ResourceLocation getRenderTypeHint() - { + public ResourceLocation getRenderTypeHint() { return renderTypeHint; } @Override - public boolean isComponentVisible(String component, boolean fallback) - { + public boolean isComponentVisible(String component, boolean fallback) { return visibilityTest.test(component, fallback); } - public static Builder builder() - { + public static Builder builder() { return new Builder(); } - public static Builder builder(IGeometryBakingContext parent) - { + public static Builder builder(IGeometryBakingContext parent) { return new Builder(parent); } - public static final class Builder - { - private static final Material NO_MATERIAL = new Material(TextureAtlas.LOCATION_BLOCKS, MissingTextureAtlasSprite.getLocation()); + public static final class Builder { + private static final Material NO_MATERIAL = new Material(InventoryMenu.BLOCK_ATLAS, MissingTextureAtlasSprite.getLocation()); private Predicate materialCheck = Predicates.alwaysFalse(); private Function materialLookup = $ -> NO_MATERIAL; private boolean isGui3d = true; @@ -160,12 +145,9 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext private ResourceLocation renderTypeHint; private BiPredicate visibilityTest = (c, def) -> def; - private Builder() - { - } + private Builder() { } - private Builder(IGeometryBakingContext parent) - { + private Builder(IGeometryBakingContext parent) { this.materialCheck = parent::hasMaterial; this.materialLookup = parent::getMaterial; this.isGui3d = parent.isGui3d(); @@ -177,69 +159,59 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext this.visibilityTest = parent::isComponentVisible; } - public Builder withTextures(Map textures, ResourceLocation defaultTexture) - { - return withTextures(TextureAtlas.LOCATION_BLOCKS, textures, defaultTexture); + public Builder withTextures(Map textures, ResourceLocation defaultTexture) { + return withTextures(InventoryMenu.BLOCK_ATLAS, textures, defaultTexture); } - public Builder withTextures(ResourceLocation atlasLocation, Map textures, ResourceLocation defaultTexture) - { + public Builder withTextures(ResourceLocation atlasLocation, Map textures, ResourceLocation defaultTexture) { this.materialCheck = textures::containsKey; this.materialLookup = name -> new Material(atlasLocation, textures.getOrDefault(name, defaultTexture)); return this; } - public Builder withMaterials(Map materials, Material defaultMaterial) - { + public Builder withMaterials(Map materials, Material defaultMaterial) { this.materialCheck = materials::containsKey; this.materialLookup = name -> materials.getOrDefault(name, defaultMaterial); return this; } - public Builder withGui3d(boolean isGui3d) - { + public Builder withGui3d(boolean isGui3d) { this.isGui3d = isGui3d; return this; } - public Builder withUseBlockLight(boolean useBlockLight) - { + public Builder withUseBlockLight(boolean useBlockLight) { this.useBlockLight = useBlockLight; return this; } - public Builder withUseAmbientOcclusion(boolean useAmbientOcclusion) - { + public Builder withUseAmbientOcclusion(boolean useAmbientOcclusion) { this.useAmbientOcclusion = useAmbientOcclusion; return this; } - public Builder withTransforms(ItemTransforms transforms) - { + public Builder withTransforms(ItemTransforms transforms) { this.transforms = transforms; return this; } - public Builder withRootTransform(Transformation rootTransform) - { + public Builder withRootTransform(Transformation rootTransform) { this.rootTransform = rootTransform; return this; } - public Builder withRenderTypeHint(ResourceLocation renderTypeHint) - { + public Builder withRenderTypeHint(ResourceLocation renderTypeHint) { this.renderTypeHint = renderTypeHint; return this; } - public Builder withVisibleComponents(Object2BooleanMap parts) - { + @SuppressWarnings("deprecation") + public Builder withVisibleComponents(Object2BooleanMap parts) { this.visibilityTest = parts::getOrDefault; return this; } - public StandaloneGeometryBakingContext build(ResourceLocation modelName) - { + public StandaloneGeometryBakingContext build(ResourceLocation modelName) { return new StandaloneGeometryBakingContext(modelName, materialCheck, materialLookup, isGui3d, useBlockLight, useAmbientOcclusion, transforms, rootTransform, renderTypeHint, visibilityTest); } } 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 ff30cf6649..8cdbbd1780 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/UnbakedGeometryHelper.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/UnbakedGeometryHelper.java @@ -13,10 +13,8 @@ import net.minecraft.client.renderer.block.model.BlockElementFace; import net.minecraft.client.renderer.block.model.BlockFaceUV; 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; @@ -24,10 +22,11 @@ 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.client.resources.model.SpecialModels; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.inventory.InventoryMenu; import net.minecraftforge.client.model.ElementsModel; -import net.minecraftforge.client.model.ForgeFaceData; import net.minecraftforge.client.model.IModelBuilder; import net.minecraftforge.client.model.IQuadTransformer; import net.minecraftforge.client.model.QuadTransformers; @@ -47,9 +46,7 @@ import java.util.regex.Pattern; /** * Helper for dealing with unbaked models and geometries. */ -public class UnbakedGeometryHelper -{ - private static final ItemModelGenerator ITEM_MODEL_GENERATOR = new ItemModelGenerator(); +public class UnbakedGeometryHelper { private static final FaceBakery FACE_BAKERY = new FaceBakery(); /** @@ -72,51 +69,51 @@ public class UnbakedGeometryHelper /** * Resolves a material that may have been defined with a filesystem path instead of a proper {@link ResourceLocation}. *

- * The target atlas will always be {@link TextureAtlas#LOCATION_BLOCKS}. + * The target atlas will always be {@link InventoryMenu#BLOCK_ATLAS}. */ - public static Material resolveDirtyMaterial(@Nullable String tex, IGeometryBakingContext owner) - { + public static Material resolveDirtyMaterial(@Nullable String tex, IGeometryBakingContext owner) { if (tex == null) - return new Material(TextureAtlas.LOCATION_BLOCKS, MissingTextureAtlasSprite.getLocation()); + return new Material(InventoryMenu.BLOCK_ATLAS, MissingTextureAtlasSprite.getLocation()); if (tex.startsWith("#")) return owner.getMaterial(tex); // Attempt to convert a common (windows/linux/mac) filesystem path to a ResourceLocation. // This makes no promises, if it doesn't work, too bad, fix your mtl file. Matcher match = FILESYSTEM_PATH_TO_RESLOC.matcher(tex); - if (match.matches()) - { + if (match.matches()) { String namespace = match.group("namespace"); String path = match.group("path").replace("\\", "/"); tex = namespace != null ? namespace + ":" + path : path; } - return new Material(TextureAtlas.LOCATION_BLOCKS, ResourceLocation.parse(tex)); + return new Material(InventoryMenu.BLOCK_ATLAS, ResourceLocation.parse(tex)); } /** * Helper for baking {@link BlockModel} instances. Handles baking custom geometries and deferring item model baking. */ + /* @ApiStatus.Internal - public static BakedModel bake(BlockModel blockModel, ModelBaker modelBaker, BlockModel owner, Function spriteGetter, ModelState modelState, boolean guiLight3d) - { + public static BakedModel bake(BlockModel blockModel, ModelBaker modelBaker, BlockModel owner, Function spriteGetter, ModelState modelState, boolean guiLight3d) { IUnbakedGeometry customModel = blockModel.customData.getCustomGeometry(); if (customModel != null) - return customModel.bake(blockModel.customData, modelBaker, spriteGetter, modelState, blockModel.getOverrides(modelBaker, owner, spriteGetter)); + return customModel.bake(blockModel.customData, modelBaker, spriteGetter, modelState); // 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(modelBaker, blockModel, spriteGetter, modelState, guiLight3d); + if (blockModel.getRootModel() == SpecialModels.GENERATED_MARKER) + return ModelBakery.ITEM_MODEL_GENERATOR.generateBlockModel(spriteGetter, blockModel).bake(modelBaker, blockModel, spriteGetter, modelState, guiLight3d); - if (blockModel.getRootModel() == ModelBakery.BLOCK_ENTITY_MARKER) - { + if (blockModel.getRootModel() == SpecialModels.BLOCK_ENTITY_MARKER) { var particleSprite = spriteGetter.apply(blockModel.getMaterial("particle")); - return new BuiltInModel(blockModel.getTransforms(), blockModel.getOverrides(modelBaker, owner, spriteGetter), particleSprite, blockModel.getGuiLight().lightLikeBlock()); + return new BuiltInModel(blockModel.getTransforms(), particleSprite, blockModel.getGuiLight().lightLikeBlock()); } - var elementsModel = new ElementsModel(blockModel.getElements()); - return elementsModel.bake(blockModel.customData, modelBaker, spriteGetter, modelState, blockModel.getOverrides(modelBaker, owner, spriteGetter)); + @SuppressWarnings("deprecation") + var elements = blockModel.getElements(); + var elementsModel = new ElementsModel(elements); + return elementsModel.bake(blockModel.customData, modelBaker, spriteGetter, modelState); } + */ /** * Creates a list of {@linkplain BlockElement block elements} in the shape of the specified sprite contents. @@ -124,9 +121,8 @@ public class UnbakedGeometryHelper *

* The {@link Direction#NORTH} and {@link Direction#SOUTH} faces take up the whole surface. */ - public static List createUnbakedItemElements(int layerIndex, SpriteContents spriteContents) - { - return ITEM_MODEL_GENERATOR.processFrames(layerIndex, "layer" + layerIndex, spriteContents); + public static List createUnbakedItemElements(int layerIndex, SpriteContents spriteContents) { + return ModelBakery.ITEM_MODEL_GENERATOR.processFrames(layerIndex, "layer" + layerIndex, spriteContents); } /** @@ -135,8 +131,7 @@ public class UnbakedGeometryHelper *

* The {@link Direction#NORTH} and {@link Direction#SOUTH} faces take up only the pixels the texture uses. */ - public static List createUnbakedItemMaskElements(int layerIndex, SpriteContents spriteContents) - { + public static List createUnbakedItemMaskElements(int layerIndex, SpriteContents spriteContents) { var elements = createUnbakedItemElements(layerIndex, spriteContents); elements.remove(0); // Remove north and south faces @@ -152,16 +147,12 @@ public class UnbakedGeometryHelper }); // Scan in search of opaque pixels - for (int y = 0; y < height; y++) - { + for (int y = 0; y < height; y++) { int xStart = -1; - for (int x = 0; x < width; x++) - { + for (int x = 0; x < width; x++) { var opaque = bits.get(x + y * width); - if (opaque == (xStart == -1)) // (opaque && -1) || (!opaque && !-1) - { - if (xStart == -1) - { + if (opaque == (xStart == -1)) { // (opaque && -1) || (!opaque && !-1) + if (xStart == -1) { // We have found the start of a new segment, continue xStart = x; continue; @@ -187,9 +178,7 @@ public class UnbakedGeometryHelper Util.make(new HashMap<>(), map -> { for (Direction direction : Direction.values()) map.put(direction, new BlockElementFace(null, layerIndex, "layer" + layerIndex, new BlockFaceUV(null, 0))); - }), - null, - true + }) )); // Reset xStart @@ -203,13 +192,11 @@ public class UnbakedGeometryHelper /** * Bakes a list of {@linkplain BlockElement block elements} and feeds the baked quads to a {@linkplain IModelBuilder model builder}. */ - public static void bakeElements(IModelBuilder builder, List elements, Function spriteGetter, ModelState modelState) - { - for (BlockElement element : elements) - { + public static void bakeElements(IModelBuilder builder, List elements, Function spriteGetter, ModelState modelState) { + for (BlockElement element : elements) { element.faces.forEach((side, face) -> { - var sprite = spriteGetter.apply(new Material(TextureAtlas.LOCATION_BLOCKS, ResourceLocation.parse(face.texture()))); - var quad = bakeElementFace(element, face, sprite, side, modelState); + var sprite = spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, ResourceLocation.parse(face.texture()))); + var quad = bakeElementFace(element, face, sprite, side, modelState, element.lightEmission); if (face.cullForDirection() == null) builder.addUnculledFace(quad); else @@ -221,8 +208,7 @@ public class UnbakedGeometryHelper /** * Bakes a list of {@linkplain BlockElement block elements} and returns the list of baked quads. */ - public static List bakeElements(List elements, Function spriteGetter, ModelState modelState) - { + public static List bakeElements(List elements, Function spriteGetter, ModelState modelState) { if (elements.isEmpty()) return List.of(); var list = new ArrayList(); @@ -233,9 +219,8 @@ public class UnbakedGeometryHelper /** * Turns a single {@link BlockElementFace} into a {@link BakedQuad}. */ - public static BakedQuad bakeElementFace(BlockElement element, BlockElementFace face, TextureAtlasSprite sprite, Direction direction, ModelState state) - { - return FACE_BAKERY.bakeQuad(element.from, element.to, face, sprite, direction, state, element.rotation, element.shade); + public static BakedQuad bakeElementFace(BlockElement element, BlockElementFace face, TextureAtlasSprite sprite, Direction direction, ModelState state, int lightEmission) { + return FACE_BAKERY.bakeQuad(element.from, element.to, face, sprite, direction, state, element.rotation, element.shade, lightEmission); } /** @@ -246,8 +231,7 @@ public class UnbakedGeometryHelper * @return an {@code IQuadTransformer} that applies the root transform to a baked quad that already has the * transformation of the given {@code ModelState} applied to it */ - public static IQuadTransformer applyRootTransform(ModelState modelState, Transformation rootTransform) - { + public static IQuadTransformer applyRootTransform(ModelState modelState, Transformation rootTransform) { // Move the origin of the ModelState transform and its inverse from the negative corner to the block center // to replicate the way the ModelState transform is applied in the FaceBakery by moving the vertices such that // the negative corner acts as the block center @@ -258,8 +242,7 @@ public class UnbakedGeometryHelper /** * {@return a {@link ModelState} that combines the existing model state and the {@linkplain Transformation root transform}} */ - public static ModelState composeRootTransformIntoModelState(ModelState modelState, Transformation rootTransform) - { + public static ModelState composeRootTransformIntoModelState(ModelState modelState, Transformation rootTransform) { // Move the origin of the root transform as if the negative corner were the block center to match the way the // ModelState transform is applied in the FaceBakery by moving the vertices to be centered on that corner rootTransform = rootTransform.applyOrigin(new Vector3f(-.5F, -.5F, -.5F)); diff --git a/src/main/java/net/minecraftforge/client/model/lighting/ForgeModelBlockRenderer.java b/src/main/java/net/minecraftforge/client/model/lighting/ForgeModelBlockRenderer.java index e801ee02de..6aa86a7faa 100644 --- a/src/main/java/net/minecraftforge/client/model/lighting/ForgeModelBlockRenderer.java +++ b/src/main/java/net/minecraftforge/client/model/lighting/ForgeModelBlockRenderer.java @@ -27,47 +27,34 @@ import java.util.List; /** * Wrapper around {@link ModelBlockRenderer} to allow rendering blocks via Forge's lighting pipeline. */ -public class ForgeModelBlockRenderer extends ModelBlockRenderer -{ +public class ForgeModelBlockRenderer extends ModelBlockRenderer { private static final Direction[] SIDES = Direction.values(); private final ThreadLocal flatLighter, smoothLighter; - public ForgeModelBlockRenderer(BlockColors colors) - { + public ForgeModelBlockRenderer(BlockColors colors) { super(colors); this.flatLighter = ThreadLocal.withInitial(() -> new FlatQuadLighter(colors)); this.smoothLighter = ThreadLocal.withInitial(() -> new SmoothQuadLighter(colors)); } @Override - public void tesselateWithoutAO(BlockAndTintGetter level, BakedModel model, BlockState state, BlockPos pos, PoseStack poseStack, VertexConsumer vertexConsumer, boolean checkSides, RandomSource rand, long seed, int packedOverlay, ModelData modelData, RenderType renderType) - { + public void tesselateWithoutAO(BlockAndTintGetter level, BakedModel model, BlockState state, BlockPos pos, PoseStack poseStack, VertexConsumer vertexConsumer, boolean checkSides, RandomSource rand, long seed, int packedOverlay, ModelData modelData, RenderType renderType) { if (ForgeConfig.CLIENT.experimentalForgeLightPipelineEnabled.get()) - { render(vertexConsumer, flatLighter.get(), level, model, state, pos, poseStack, checkSides, rand, seed, packedOverlay, modelData, renderType); - } else - { super.tesselateWithoutAO(level, model, state, pos, poseStack, vertexConsumer, checkSides, rand, seed, packedOverlay, modelData, renderType); - } } @Override - public void tesselateWithAO(BlockAndTintGetter level, BakedModel model, BlockState state, BlockPos pos, PoseStack poseStack, VertexConsumer vertexConsumer, boolean checkSides, RandomSource rand, long seed, int packedOverlay, ModelData modelData, RenderType renderType) - { + public void tesselateWithAO(BlockAndTintGetter level, BakedModel model, BlockState state, BlockPos pos, PoseStack poseStack, VertexConsumer vertexConsumer, boolean checkSides, RandomSource rand, long seed, int packedOverlay, ModelData modelData, RenderType renderType) { if (ForgeConfig.CLIENT.experimentalForgeLightPipelineEnabled.get()) - { render(vertexConsumer, smoothLighter.get(), level, model, state, pos, poseStack, checkSides, rand, seed, packedOverlay, modelData, renderType); - } else - { super.tesselateWithAO(level, model, state, pos, poseStack, vertexConsumer, checkSides, rand, seed, packedOverlay, modelData, renderType); - } } - public static boolean render(VertexConsumer vertexConsumer, QuadLighter lighter, BlockAndTintGetter level, BakedModel model, BlockState state, BlockPos pos, PoseStack poseStack, boolean checkSides, RandomSource rand, long seed, int packedOverlay, ModelData modelData, RenderType renderType) - { + public static boolean render(VertexConsumer vertexConsumer, QuadLighter lighter, BlockAndTintGetter level, BakedModel model, BlockState state, BlockPos pos, PoseStack poseStack, boolean checkSides, RandomSource rand, long seed, int packedOverlay, ModelData modelData, RenderType renderType) { ForgeModelBlockRenderer renderer = (ForgeModelBlockRenderer)Minecraft.getInstance().getBlockRenderer().getModelRenderer(); var pose = poseStack.last(); var empty = true; @@ -76,64 +63,53 @@ public class ForgeModelBlockRenderer extends ModelBlockRenderer rand.setSeed(seed); List quads = model.getQuads(state, null, rand, modelData, renderType); - if (!quads.isEmpty()) - { + if (!quads.isEmpty()) { empty = false; lighter.setup(level, pos, state); - for (BakedQuad quad : quads) - { - if (smoothLighter && !quad.hasAmbientOcclusion()) - { - if (flatLighter == null) - { + for (BakedQuad quad : quads) { + if (smoothLighter && !quad.hasAmbientOcclusion()) { + if (flatLighter == null) { flatLighter = renderer.flatLighter.get(); flatLighter.setup(level, pos, state); } flatLighter.process(vertexConsumer, pose, quad, packedOverlay); - } - else - { + } else { lighter.process(vertexConsumer, pose, quad, packedOverlay); } } } + var mutable = pos.mutable(); - for (Direction side : SIDES) - { - if (checkSides && !Block.shouldRenderFace(state, level, pos, side, pos.relative(side))) - { + for (Direction side : SIDES) { + mutable.setWithOffset(pos, side); + if (checkSides && !Block.shouldRenderFace(level, pos, state, level.getBlockState(mutable), side)) continue; - } rand.setSeed(seed); quads = model.getQuads(state, side, rand, modelData, renderType); - if (!quads.isEmpty()) - { - if (empty) - { + if (!quads.isEmpty()) { + if (empty) { empty = false; lighter.setup(level, pos, state); } - for (BakedQuad quad : quads) - { - if (smoothLighter && !quad.hasAmbientOcclusion()) - { - if (flatLighter == null) - { + + for (BakedQuad quad : quads) { + if (smoothLighter && !quad.hasAmbientOcclusion()) { + if (flatLighter == null) { flatLighter = renderer.flatLighter.get(); flatLighter.setup(level, pos, state); } flatLighter.process(vertexConsumer, pose, quad, packedOverlay); - } - else - { + } else { lighter.process(vertexConsumer, pose, quad, packedOverlay); } } } } + lighter.reset(); if (flatLighter != null) flatLighter.reset(); + return !empty; } } diff --git a/src/main/java/net/minecraftforge/client/model/lighting/SmoothQuadLighter.java b/src/main/java/net/minecraftforge/client/model/lighting/SmoothQuadLighter.java index a7fadc0ef7..75205260ac 100644 --- a/src/main/java/net/minecraftforge/client/model/lighting/SmoothQuadLighter.java +++ b/src/main/java/net/minecraftforge/client/model/lighting/SmoothQuadLighter.java @@ -21,8 +21,7 @@ import net.minecraft.world.phys.shapes.Shapes; * Implementation of {@link QuadLighter} that lights {@link BakedQuad baked quads} using ambient occlusion and * light interpolation. */ -public class SmoothQuadLighter extends QuadLighter -{ +public class SmoothQuadLighter extends QuadLighter { private static final Direction[] SIDES = Direction.values(); private final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(); @@ -33,23 +32,18 @@ public class SmoothQuadLighter extends QuadLighter private final float[][][][] blockLight = new float[3][2][2][2]; private final float[][][] ao = new float[3][3][3]; - public SmoothQuadLighter(BlockColors colors) - { + public SmoothQuadLighter(BlockColors colors) { super(colors); } @Override - protected void computeLightingAt(BlockAndTintGetter level, BlockPos origin, BlockState state) - { - for (int x = 0; x <= 2; x++) - { - for (int y = 0; y <= 2; y++) - { - for (int z = 0; z <= 2; z++) - { + protected void computeLightingAt(BlockAndTintGetter level, BlockPos origin, BlockState state) { + for (int x = 0; x <= 2; x++) { + for (int y = 0; y <= 2; y++) { + for (int z = 0; z <= 2; z++) { pos.setWithOffset(origin, x - 1, y - 1, z - 1); BlockState neighborState = level.getBlockState(pos); - t[x][y][z] = neighborState.getLightBlock(level, pos) < 15; + t[x][y][z] = neighborState.getLightBlock() < 15; int brightness = LevelRenderer.getLightColor(level, neighborState, pos); s[x][y][z] = LightTexture.sky(brightness); b[x][y][z] = LightTexture.block(brightness); @@ -57,16 +51,20 @@ public class SmoothQuadLighter extends QuadLighter } } } - for (Direction side : SIDES) - { + + for (Direction side : SIDES) { pos.setWithOffset(origin, side); BlockState neighborState = level.getBlockState(pos); BlockState thisStateShape = state.canOcclude() && state.useShapeForLightOcclusion() ? state : Blocks.AIR.defaultBlockState(); BlockState otherStateShape = neighborState.canOcclude() && neighborState.useShapeForLightOcclusion() ? neighborState : Blocks.AIR.defaultBlockState(); - if (neighborState.getLightBlock(level, pos) == 15 || Shapes.faceShapeOccludes(thisStateShape.getFaceOcclusionShape(level, origin, side), otherStateShape.getFaceOcclusionShape(level, pos, side.getOpposite()))) - { + if (neighborState.getLightBlock() == 15 || + Shapes.faceShapeOccludes( + thisStateShape.getFaceOcclusionShape(side), + otherStateShape.getFaceOcclusionShape(side.getOpposite()) + ) + ) { int x = side.getStepX() + 1; int y = side.getStepY() + 1; int z = side.getStepZ() + 1; @@ -74,12 +72,10 @@ public class SmoothQuadLighter extends QuadLighter b[x][y][z] = Math.max(b[1][1][1] - 1, b[x][y][z]); } } - for (int x = 0; x < 2; x++) - { - for (int y = 0; y < 2; y++) - { - for (int z = 0; z < 2; z++) - { + + for (int x = 0; x < 2; x++) { + for (int y = 0; y < 2; y++) { + for (int z = 0; z < 2; z++) { int x1 = x * 2; int y1 = y * 2; int z1 = z * 2; @@ -116,8 +112,7 @@ public class SmoothQuadLighter extends QuadLighter } @Override - protected float calculateBrightness(float[] position) - { + protected float calculateBrightness(float[] position) { float x = position[0], y = position[1], z = position[2]; int sx = x < 0 ? 1 : 2; int sy = y < 0 ? 1 : 2; @@ -142,15 +137,13 @@ public class SmoothQuadLighter extends QuadLighter } @Override - protected int calculateLightmap(float[] position, byte[] normal) - { + protected int calculateLightmap(float[] position, byte[] normal) { var block = (int) (calcLightmap(blockLight, position[0], position[1], position[2]) * 0xF0); var sky = (int) (calcLightmap(skyLight, position[0], position[1], position[2]) * 0xF0); return block | (sky << 16); } - private float combine(int c, int s1, int s2, int s3, boolean t0, boolean t1, boolean t2, boolean t3) - { + private float combine(int c, int s1, int s2, int s3, boolean t0, boolean t1, boolean t2, boolean t3) { if (c == 0 && !t0) c = Math.max(0, Math.max(s1, s2) - 1); if (s1 == 0 && !t1) s1 = Math.max(0, c - 1); if (s2 == 0 && !t2) s2 = Math.max(0, c - 1); @@ -158,14 +151,12 @@ public class SmoothQuadLighter extends QuadLighter return (c + s1 + s2 + s3) / (0xF * 4f); } - protected float calcLightmap(float[][][][] light, float x, float y, float z) - { + protected float calcLightmap(float[][][][] light, float x, float y, float z) { x *= 2; y *= 2; z *= 2; float l2 = x * x + y * y + z * z; - if (l2 > 6 - 2e-2f) - { + if (l2 > 6 - 2e-2f) { float s = (float) Math.sqrt((6 - 2e-2f) / l2); x *= s; y *= s; @@ -176,40 +167,27 @@ public class SmoothQuadLighter extends QuadLighter float az = z > 0 ? z : -z; float e1 = 1 + 1e-4f; if (ax > 2 - 1e-4f && ay <= e1 && az <= e1) - { x = x < 0 ? -2 + 1e-4f : 2 - 1e-4f; - } else if (ay > 2 - 1e-4f && az <= e1 && ax <= e1) - { y = y < 0 ? -2 + 1e-4f : 2 - 1e-4f; - } else if (az > 2 - 1e-4f && ax <= e1 && ay <= e1) - { z = z < 0 ? -2 + 1e-4f : 2 - 1e-4f; - } ax = x > 0 ? x : -x; ay = y > 0 ? y : -y; az = z > 0 ? z : -z; - if (ax <= e1 && ay + az > 3f - 1e-4f) - { + if (ax <= e1 && ay + az > 3f - 1e-4f) { float s = (3f - 1e-4f) / (ay + az); y *= s; z *= s; - } - else if (ay <= e1 && az + ax > 3f - 1e-4f) - { + } else if (ay <= e1 && az + ax > 3f - 1e-4f) { float s = (3f - 1e-4f) / (az + ax); z *= s; x *= s; - } - else if (az <= e1 && ax + ay > 3f - 1e-4f) - { + } else if (az <= e1 && ax + ay > 3f - 1e-4f) { float s = (3f - 1e-4f) / (ax + ay); x *= s; y *= s; - } - else if (ax + ay + az > 4 - 1e-4f) - { + } else if (ax + ay + az > 4 - 1e-4f) { float s = (4 - 1e-4f) / (ax + ay + az); x *= s; y *= s; @@ -219,12 +197,9 @@ public class SmoothQuadLighter extends QuadLighter float l = 0; float s = 0; - for (int ix = 0; ix <= 1; ix++) - { - for (int iy = 0; iy <= 1; iy++) - { - for (int iz = 0; iz <= 1; iz++) - { + for (int ix = 0; ix <= 1; ix++) { + for (int iy = 0; iy <= 1; iy++) { + for (int iz = 0; iz <= 1; iz++) { float vx = x * (1 - ix * 2); float vy = y * (1 - iy * 2); float vz = z * (1 - iz * 2); 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 56dac57d47..cc66d4f7b3 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/ObjModel.java +++ b/src/main/java/net/minecraftforge/client/model/obj/ObjModel.java @@ -431,7 +431,7 @@ public class ObjModel extends SimpleUnbakedGeometry quadBaker.setNormal(normal.x(), normal.y(), normal.z()); if (i == 0) { - quadBaker.setDirection(Direction.getNearest(normal.x(), normal.y(), normal.z())); + quadBaker.setDirection(Direction.getApproximateNearest(normal.x(), normal.y(), normal.z())); } pos[i] = position; norm[i] = normal; diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/QuadBakingVertexConsumer.java b/src/main/java/net/minecraftforge/client/model/pipeline/QuadBakingVertexConsumer.java index 174adab668..8cba3df305 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/QuadBakingVertexConsumer.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/QuadBakingVertexConsumer.java @@ -26,8 +26,7 @@ import java.util.function.Consumer; * This consumer accepts data in {@link com.mojang.blaze3d.vertex.DefaultVertexFormat#BLOCK} and is not picky about * ordering or missing elements, but will not automatically populate missing data (color will be black, for example). */ -public class QuadBakingVertexConsumer implements VertexConsumer -{ +public class QuadBakingVertexConsumer implements VertexConsumer { private final Map ELEMENT_OFFSETS = Util.make(new IdentityHashMap<>(), map -> { int i = 0; for (var element : DefaultVertexFormat.BLOCK.getElements()) @@ -46,15 +45,14 @@ public class QuadBakingVertexConsumer implements VertexConsumer private TextureAtlasSprite sprite = UnitTextureAtlasSprite.INSTANCE; private boolean shade; private boolean hasAmbientOcclusion; + private int lightEmission; - public QuadBakingVertexConsumer(Consumer quadConsumer) - { + public QuadBakingVertexConsumer(Consumer quadConsumer) { this.quadConsumer = quadConsumer; } @Override - public VertexConsumer addVertex(float x, float y, float z) - { + public VertexConsumer addVertex(float x, float y, float z) { if (vertexIndex++ == MAX_VERTICES) build(); @@ -66,8 +64,7 @@ public class QuadBakingVertexConsumer implements VertexConsumer } @Override - public VertexConsumer setNormal(float x, float y, float z) - { + public VertexConsumer setNormal(float x, float y, float z) { int offset = vertexIndex * IQuadTransformer.STRIDE + IQuadTransformer.NORMAL; quadData[offset] = ((int) (x * 127.0f) & 0xFF) | (((int) (y * 127.0f) & 0xFF) << 8) | @@ -76,8 +73,7 @@ public class QuadBakingVertexConsumer implements VertexConsumer } @Override - public VertexConsumer setColor(int r, int g, int b, int a) - { + public VertexConsumer setColor(int r, int g, int b, int a) { int offset = vertexIndex * IQuadTransformer.STRIDE + IQuadTransformer.COLOR; quadData[offset] = ((a & 0xFF) << 24) | ((b & 0xFF) << 16) | @@ -87,8 +83,7 @@ public class QuadBakingVertexConsumer implements VertexConsumer } @Override - public VertexConsumer setUv(float u, float v) - { + public VertexConsumer setUv(float u, float v) { int offset = vertexIndex * IQuadTransformer.STRIDE + IQuadTransformer.UV0; quadData[offset] = Float.floatToRawIntBits(u); quadData[offset + 1] = Float.floatToRawIntBits(v); @@ -96,10 +91,8 @@ public class QuadBakingVertexConsumer implements VertexConsumer } @Override - public VertexConsumer setUv1(int u, int v) - { - if (IQuadTransformer.UV1 >= 0) // Vanilla doesn't support this, but it may be added by a 3rd party - { + public VertexConsumer setUv1(int u, int v) { + if (IQuadTransformer.UV1 >= 0) { // Vanilla doesn't support this, but it may be added by a 3rd party int offset = vertexIndex * IQuadTransformer.STRIDE + IQuadTransformer.UV1; quadData[offset] = (u & 0xFFFF) | ((v & 0xFFFF) << 16); } @@ -107,28 +100,24 @@ public class QuadBakingVertexConsumer implements VertexConsumer } @Override - public VertexConsumer setUv2(int u, int v) - { + public VertexConsumer setUv2(int u, int v) { int offset = vertexIndex * IQuadTransformer.STRIDE + IQuadTransformer.UV2; quadData[offset] = (u & 0xFFFF) | ((v & 0xFFFF) << 16); return this; } @Override - public VertexConsumer misc(VertexFormatElement element, int... rawData) - { + public VertexConsumer misc(VertexFormatElement element, int... rawData) { Integer baseOffset = ELEMENT_OFFSETS.get(element); - if (baseOffset != null) - { + if (baseOffset != null) { int offset = vertexIndex * IQuadTransformer.STRIDE + baseOffset; System.arraycopy(rawData, 0, quadData, offset, rawData.length); } return this; } - public BakedQuad build() - { - BakedQuad quad = new BakedQuad(quadData, tintIndex, direction, sprite, shade, hasAmbientOcclusion); + public BakedQuad build() { + BakedQuad quad = new BakedQuad(quadData, tintIndex, direction, sprite, shade, lightEmission, hasAmbientOcclusion); // We have a full quad, pass it to the consumer and reset quadConsumer.accept(quad); vertexIndex = 0; @@ -136,48 +125,43 @@ public class QuadBakingVertexConsumer implements VertexConsumer return quad; } - public void setTintIndex(int tintIndex) - { + public void setTintIndex(int tintIndex) { this.tintIndex = tintIndex; } - public void setDirection(Direction direction) - { + public void setDirection(Direction direction) { this.direction = direction; } - public void setSprite(TextureAtlasSprite sprite) - { + public void setSprite(TextureAtlasSprite sprite) { this.sprite = sprite; } - public void setShade(boolean shade) - { + public void setShade(boolean shade) { this.shade = shade; } - public void setHasAmbientOcclusion(boolean hasAmbientOcclusion) - { + public void setHasAmbientOcclusion(boolean hasAmbientOcclusion) { this.hasAmbientOcclusion = hasAmbientOcclusion; } - public static class Buffered extends QuadBakingVertexConsumer - { + public void setLightEmission(int value) { + this.lightEmission = value; + } + + public static class Buffered extends QuadBakingVertexConsumer { private final BakedQuad[] output; - public Buffered() - { + public Buffered() { this(new BakedQuad[1]); } - private Buffered(BakedQuad[] output) - { + private Buffered(BakedQuad[] output) { super(q -> output[0] = q); this.output = output; } - public BakedQuad getQuad() - { + public BakedQuad getQuad() { var quad = Preconditions.checkNotNull(output[0], "No quad has been emitted. Vertices in buffer: " + vertexIndex); output[0] = null; return quad; diff --git a/src/main/java/net/minecraftforge/client/settings/KeyConflictContext.java b/src/main/java/net/minecraftforge/client/settings/KeyConflictContext.java index d3415b24c0..53d492a367 100644 --- a/src/main/java/net/minecraftforge/client/settings/KeyConflictContext.java +++ b/src/main/java/net/minecraftforge/client/settings/KeyConflictContext.java @@ -8,22 +8,19 @@ package net.minecraftforge.client.settings; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; -public enum KeyConflictContext implements IKeyConflictContext -{ +public enum KeyConflictContext implements IKeyConflictContext { /** * Universal key bindings are used in every context and will conflict with any other context. * Key Bindings are universal by default. */ UNIVERSAL { @Override - public boolean isActive() - { + public boolean isActive() { return true; } @Override - public boolean conflicts(IKeyConflictContext other) - { + public boolean conflicts(IKeyConflictContext other) { return true; } }, @@ -32,15 +29,14 @@ public enum KeyConflictContext implements IKeyConflictContext * Gui key bindings are only used when a {@link Screen} is open. */ GUI { + @SuppressWarnings("resource") @Override - public boolean isActive() - { + public boolean isActive() { return Minecraft.getInstance().screen != null; } @Override - public boolean conflicts(IKeyConflictContext other) - { + public boolean conflicts(IKeyConflictContext other) { return this == other; } }, @@ -50,14 +46,12 @@ public enum KeyConflictContext implements IKeyConflictContext */ IN_GAME { @Override - public boolean isActive() - { + public boolean isActive() { return !GUI.isActive(); } @Override - public boolean conflicts(IKeyConflictContext other) - { + public boolean conflicts(IKeyConflictContext other) { return this == other; } } diff --git a/src/main/java/net/minecraftforge/common/CreativeModeTabRegistry.java b/src/main/java/net/minecraftforge/common/CreativeModeTabRegistry.java index 9f4ec5ad39..9cb27ac3ae 100644 --- a/src/main/java/net/minecraftforge/common/CreativeModeTabRegistry.java +++ b/src/main/java/net/minecraftforge/common/CreativeModeTabRegistry.java @@ -72,7 +72,7 @@ public final class CreativeModeTabRegistry { */ @Nullable public static CreativeModeTab getTab(ResourceLocation name) { - return BuiltInRegistries.CREATIVE_MODE_TAB.get(name); + return BuiltInRegistries.CREATIVE_MODE_TAB.getValue(name); } /** @@ -178,14 +178,15 @@ public final class CreativeModeTabRegistry { public static void sortTabs() { edges.clear(); - DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.get(CreativeModeTabs.HOTBAR)); - DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.get(CreativeModeTabs.SEARCH)); - DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.get(CreativeModeTabs.OP_BLOCKS)); - DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.get(CreativeModeTabs.INVENTORY)); + DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.getValue(CreativeModeTabs.HOTBAR)); + DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.getValue(CreativeModeTabs.SEARCH)); + DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.getValue(CreativeModeTabs.OP_BLOCKS)); + DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.getValue(CreativeModeTabs.INVENTORY)); - final List> indexed = BuiltInRegistries.CREATIVE_MODE_TAB.holders() - .filter(c -> !DEFAULT_TABS.contains(c.get())) - .collect(Collectors.toList()); + final List> indexed = BuiltInRegistries.CREATIVE_MODE_TAB + .listElements() + .filter(c -> !DEFAULT_TABS.contains(c.get())) + .toList(); int vanillaTabs = 10; for (int i = 0; i < vanillaTabs; i++) { // Vanilla ordering diff --git a/src/main/java/net/minecraftforge/common/ForgeConfig.java b/src/main/java/net/minecraftforge/common/ForgeConfig.java index cdd13b60f1..8aab1b1f11 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfig.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfig.java @@ -104,9 +104,6 @@ public class ForgeConfig { public final BooleanValue calculateAllNormals; - public final BooleanValue stabilizeDirectionGetNearest; - - Client(ForgeConfigSpec.Builder builder) { builder.comment("Client only settings, mostly things related to rendering") .push("client"); @@ -142,11 +139,6 @@ public class ForgeConfig { .translation("forge.configgui.calculateAllNormals") .define("calculateAllNormals", false); - stabilizeDirectionGetNearest = builder - .comment("When enabled, a slightly biased Direction#getNearest calculation will be used to prevent normal fighting on 45 degree angle faces.") - .translation("forge.configgui.stabilizeDirectionGetNearest") - .define("stabilizeDirectionGetNearest", true); - builder.pop(); } diff --git a/src/main/java/net/minecraftforge/common/ForgeHooks.java b/src/main/java/net/minecraftforge/common/ForgeHooks.java index 388acd9b26..cff683126f 100644 --- a/src/main/java/net/minecraftforge/common/ForgeHooks.java +++ b/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -16,6 +16,7 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.Function; +import java.util.function.Predicate; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Stream; @@ -40,15 +41,12 @@ import com.mojang.serialization.Lifecycle; import io.netty.handler.codec.DecoderException; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.commands.CommandSourceStack; -import net.minecraft.commands.Commands; import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.arguments.selector.EntitySelectorParser; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.core.Holder; import net.minecraft.core.HolderLookup; import net.minecraft.core.HolderSet; -import net.minecraft.core.NonNullList; import net.minecraft.core.component.DataComponentMap; import net.minecraft.core.component.DataComponents; import net.minecraft.core.particles.ParticleTypes; @@ -56,12 +54,12 @@ import net.minecraft.core.registries.Registries; import net.minecraft.network.Connection; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.VarInt; 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.PlainTextContents.LiteralContents; -import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.server.level.ServerLevel; import net.minecraft.tags.TagKey; @@ -80,11 +78,10 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.Brain; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.DefaultAttributes; -import net.minecraft.world.entity.monster.EnderMan; +import net.minecraft.world.entity.monster.Monster; import net.minecraft.world.inventory.ContainerLevelAccess; import net.minecraft.world.item.*; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.material.Fluids; @@ -92,6 +89,7 @@ import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.WorldData; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootPool; +import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.entity.item.ItemEntity; @@ -113,7 +111,6 @@ import net.minecraft.network.protocol.login.ClientboundCustomQueryPacket; import net.minecraft.network.protocol.login.ServerboundCustomQueryAnswerPacket; import net.minecraft.stats.Stats; import net.minecraft.world.phys.Vec3; -import net.minecraft.world.level.block.entity.FurnaceBlockEntity; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.phys.AABB; import net.minecraft.world.level.biome.Biome; @@ -139,7 +136,7 @@ import net.minecraftforge.event.RegisterStructureConversionsEvent; import net.minecraftforge.event.entity.EntityAttributeCreationEvent; import net.minecraftforge.event.entity.EntityAttributeModificationEvent; import net.minecraftforge.event.entity.item.ItemTossEvent; -import net.minecraftforge.event.entity.living.EnderManAngerEvent; +import net.minecraftforge.event.entity.living.MonsterDisguiseEvent; import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.event.entity.living.LivingBreatheEvent; import net.minecraftforge.event.entity.living.LivingDamageEvent; @@ -183,7 +180,6 @@ import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; import net.minecraft.ChatFormatting; -import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.damagesource.DamageSource; @@ -551,8 +547,9 @@ public final class ForgeHooks { @NotNull public static ItemStack getCraftingRemainingItem(@NotNull ItemStack stack) { - if (stack.getItem().hasCraftingRemainingItem(stack)) { - stack = stack.getItem().getCraftingRemainingItem(stack); + var remainder = stack.getCraftingRemainder(); + if (!remainder.isEmpty()) { + stack = remainder; if (!stack.isEmpty() && stack.isDamageableItem() && stack.getDamageValue() > stack.getMaxDamage()) { ForgeEventFactory.onPlayerDestroyItem(CRAFTING_PLAYER.get(), stack, (EquipmentSlot)null); return ItemStack.EMPTY; @@ -674,7 +671,7 @@ public final class ForgeHooks { ResourceLocation registryName = ForgeRegistries.ITEMS.getKey(item); String modId = registryName == null ? null : registryName.getNamespace(); if ("minecraft".equals(modId)) { - if (item instanceof EnchantedBookItem) { + if (itemStack.is(Items.ENCHANTED_BOOK)) { var enchants = EnchantmentHelper.getEnchantmentsForCrafting(itemStack); if (enchants.size() == 1) { var enchant = enchants.keySet().iterator().next(); @@ -695,12 +692,9 @@ public final class ForgeHooks { return modId; } - public static boolean onFarmlandTrample(Level level, BlockPos pos, BlockState state, float fallDistance, Entity entity) { - if (entity.canTrample(state, pos, fallDistance)) { - BlockEvent.FarmlandTrampleEvent event = new BlockEvent.FarmlandTrampleEvent(level, pos, state, fallDistance, entity); - MinecraftForge.EVENT_BUS.post(event); - return !event.isCanceled(); - } + public static boolean onFarmlandTrample(ServerLevel level, BlockPos pos, BlockState state, float fallDistance, Entity entity) { + if (entity.canTrample(level, state, pos, fallDistance)) + return !ForgeEventFactory.fireFarmlandTrampleEvent(level, pos, state, fallDistance, entity); return false; } @@ -711,17 +705,6 @@ public final class ForgeHooks { return event.getVanillaNoteId(); } - public static boolean hasNoElements(Ingredient ingredient) { - ItemStack[] items = ingredient.getItems(); - if (items.length == 0) return true; - if (items.length == 1) { - //If we potentially added a barrier due to the ingredient being an empty tag, try and check if it is the stack we added - ItemStack item = items[0]; - return item.getItem() == Items.BARRIER && item.getHoverName() instanceof MutableComponent hoverName && hoverName.getString().startsWith("Empty Tag: "); - } - return false; - } - @Nullable public static EntityDataSerializer getSerializer(int id, CrudeIncrementalIntIdentityHashBiMap> vanilla) { EntityDataSerializer serializer = vanilla.byId(id); @@ -745,34 +728,13 @@ public final class ForgeHooks { return id; } - public static boolean canEntityDestroy(Level level, BlockPos pos, LivingEntity entity) { + public static boolean canEntityDestroy(ServerLevel level, BlockPos pos, LivingEntity entity) { if (!level.isLoaded(pos)) return false; BlockState state = level.getBlockState(pos); return ForgeEventFactory.getMobGriefingEvent(level, entity) && state.canEntityDestroy(level, pos, entity) && ForgeEventFactory.onEntityDestroyBlock(entity, pos, state); } - private static final Map, Integer> VANILLA_BURNS = new HashMap<>(); - - /** - * Gets the burn time of this itemstack. - */ - public static int getBurnTime(ItemStack stack, @Nullable RecipeType recipeType) { - if (stack.isEmpty()) - return 0; - else { - Item item = stack.getItem(); - int ret = stack.getBurnTime(recipeType); - return ForgeEventFactory.getItemBurnTime(stack, ret == -1 ? VANILLA_BURNS.getOrDefault(ForgeRegistries.ITEMS.getDelegateOrThrow(item), 0) : ret, recipeType); - } - } - - @SuppressWarnings("deprecation") - public static synchronized void updateBurns() { - VANILLA_BURNS.clear(); - FurnaceBlockEntity.getFuel().forEach((k, v) -> VANILLA_BURNS.put(ForgeRegistries.ITEMS.getDelegateOrThrow(k), v)); - } - /** * Handles the modification of loot table drops via the registered Global Loot Modifiers, * so that custom effects can be processed. @@ -787,10 +749,10 @@ public final class ForgeHooks { * @apiNote The given context will be modified by this method to also store the ID of the * loot table being queried. */ - public static ObjectArrayList modifyLoot(ResourceLocation lootTableId, ObjectArrayList generatedLoot, LootContext context) { - context.setQueriedLootTableId(lootTableId); // In case the ID was set via copy constructor, this will be ignored: intended + public static ObjectArrayList modifyLoot(LootTable table, ObjectArrayList generatedLoot, LootContext context) { + context.setQueriedLootTableId(table.getLootTableId()); // In case the ID was set via copy constructor, this will be ignored: intended for (var mod : ForgeInternalHandler.getLootModifierManager().getAllLootMods()) - generatedLoot = mod.apply(generatedLoot, context); + generatedLoot = mod.apply(table, generatedLoot, context); return generatedLoot; } @@ -976,8 +938,14 @@ public final class ForgeHooks { throw new IllegalArgumentException("Unknown lifecycle."); } - public static boolean shouldSuppressEnderManAnger(EnderMan enderMan, Player player, ItemStack mask) { - return mask.isEnderMask(player, enderMan) || MinecraftForge.EVENT_BUS.post(new EnderManAngerEvent(enderMan, player)); + public static Predicate isNotDisguised(Monster monster) { + return (entity) -> { + if (!(entity instanceof Player player)) + return true; + + var mask = player.getItemBySlot(EquipmentSlot.HEAD); + return !mask.isMonsterDisguise(player, monster) || MinecraftForge.EVENT_BUS.post(new MonsterDisguiseEvent(monster, player)); + }; } private static final Lazy> FORGE_CONVERSION_MAP = Lazy.concurrentOf(() -> { @@ -1031,6 +999,7 @@ public final class ForgeHooks { * @param refillAirAmount The amount of air to refill when the entity is able to breathe * @implNote This method needs to closely replicate the logic found right after the call site in {@link LivingEntity#baseTick()} as it overrides it. */ + @SuppressWarnings("deprecation") public static void onLivingBreathe(LivingEntity entity, int consumeAirAmount, int refillAirAmount) { // Check things that vanilla considers to be air - these will cause the air supply to be increased. boolean isAir = entity.getEyeInFluidType().isAir() || entity.level().getBlockState(BlockPos.containing(entity.getX(), entity.getEyeY(), entity.getZ())).is(Blocks.BUBBLE_COLUMN); @@ -1160,14 +1129,14 @@ public final class ForgeHooks { @ApiStatus.Internal public static Packet getEntitySpawnPacket(Entity entity) { - if (!(entity instanceof IEntityAdditionalSpawnData add)) + if (!(entity instanceof IEntityAdditionalSpawnData)) throw new IllegalArgumentException(entity.getClass() + " is not an instance of " + IEntityAdditionalSpawnData.class); return NetworkDirection.PLAY_TO_CLIENT.buildPacket(NetworkInitialization.PLAY, new SpawnEntity(entity)); } @ApiStatus.Internal - public static boolean readAndTestCondition(RegistryOps ops, JsonObject json) { + public static boolean readAndTestCondition(DynamicOps ops, JsonObject json) { if (!json.has(ICondition.DEFAULT_FIELD)) return true; @@ -1187,15 +1156,18 @@ public final class ForgeHooks { @Nullable @ApiStatus.Internal - public static JsonObject readConditionalAdvancement(RegistryOps context, JsonObject json) { - var entries = GsonHelper.getAsJsonArray(json, "advancements", null); + public static JsonElement readConditional(DynamicOps context, JsonElement json) { + if (!json.isJsonObject()) + return json; + + var entries = GsonHelper.getAsJsonArray(json.getAsJsonObject(), "forge:conditional", null); if (entries == null) - return readAndTestCondition(context, json) ? json : null; + return readAndTestCondition(context, json.getAsJsonObject()) ? json : null; int idx = 0; for (var ele : entries) { if (!ele.isJsonObject()) - throw new JsonSyntaxException("Invalid advancement entry at index " + idx + " Must be JsonObject"); + throw new JsonSyntaxException("Invalid forge:conditonal entry at index " + idx + " Must be JsonObject"); if (readAndTestCondition(context, ele.getAsJsonObject())) return ele.getAsJsonObject(); @@ -1207,7 +1179,7 @@ public final class ForgeHooks { } @ApiStatus.Internal - public static Codec enhanceIngredientCodec(Codec vanilla) { + public static Codec ingredientBaseCodec(Codec vanilla) { return Codec.lazyInitialized(() -> Codec.either( ForgeRegistries.INGREDIENT_SERIALIZERS.get().getCodec().dispatch(Ingredient::serializer, IIngredientSerializer::codec), @@ -1223,39 +1195,31 @@ public final class ForgeHooks { public static StreamCodec ingredientStreamCodec() { return StreamCodec.of( (buf, value) -> { - if (value.isVanilla()) { - var items = value.getItems(); - ByteBufCodecs.writeCount(buf, items.length, Integer.MAX_VALUE); - for (var item : items) { - ItemStack.STREAM_CODEC.encode(buf, item); - } - } else { - @SuppressWarnings("unchecked") - var serializer = (IIngredientSerializer)value.serializer(); + @SuppressWarnings("unchecked") + var serializer = (IIngredientSerializer)value.serializer(); + if (!value.isVanilla()) { var key = ForgeRegistries.INGREDIENT_SERIALIZERS.get().getKey(serializer); if (key == null) throw new IllegalArgumentException("Tried to write unregistered Ingredient to network: " + value); buf.writeVarInt(-1); // Our Marker buf.writeResourceLocation(key); - serializer.write(buf, value); } + serializer.write(buf, value); }, (buf) -> { - var size = ByteBufCodecs.readCount(buf, Integer.MAX_VALUE); + buf.markReaderIndex(); + var size = VarInt.read(buf); + IIngredientSerializer serializer = Ingredient.VANILLA_SERIALIZER; if (size != -1) { - var ret = NonNullList.createWithCapacity(size); - for (int x = 0; x < size; x++) { - ret.add(ItemStack.STREAM_CODEC.decode(buf)); - } - return Ingredient.fromValues(ret.stream().map(Ingredient.ItemValue::new)); + buf.resetReaderIndex(); } else { var key = buf.readResourceLocation(); - var serializer = ForgeRegistries.INGREDIENT_SERIALIZERS.get().getValue(key); + serializer = ForgeRegistries.INGREDIENT_SERIALIZERS.get().getValue(key); if (serializer == null) throw new DecoderException("Could not read ingredient of type: " + key); - return serializer.read(buf); } + return serializer.read(buf); } ); } diff --git a/src/main/java/net/minecraftforge/common/ForgeI18n.java b/src/main/java/net/minecraftforge/common/ForgeI18n.java index 045f2084e9..163a94a067 100644 --- a/src/main/java/net/minecraftforge/common/ForgeI18n.java +++ b/src/main/java/net/minecraftforge/common/ForgeI18n.java @@ -24,7 +24,7 @@ import java.util.Objects; import java.util.function.BiConsumer; import java.util.regex.Pattern; -//TODO, this should be re-evaluated now that ITextComponents are passed everywhere instaed of strings. +//TODO, this should be re-evaluated now that ITextComponents are passed everywhere instead of strings. public class ForgeI18n { private static final Logger LOGGER = LogManager.getLogger(); // From FontRenderer.renderCharAtPos diff --git a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java index 6d5ddfd601..b0b75292d5 100644 --- a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java +++ b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java @@ -18,16 +18,15 @@ import net.minecraftforge.event.entity.EntityJoinLevelEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.level.ChunkEvent; import net.minecraftforge.event.network.ConnectionStartEvent; +import net.minecraftforge.event.server.ServerStoppingEvent; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.event.TagsUpdatedEvent; -import net.minecraftforge.event.TickEvent; -import net.minecraftforge.event.TickEvent.ClientTickEvent; import net.minecraftforge.event.TickEvent.ServerTickEvent; import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.network.filters.NetworkFilters; import net.minecraftforge.common.util.LogicalSidedProvider; import net.minecraftforge.server.command.ForgeCommand; +import net.minecraftforge.server.permission.events.PermissionGatherEvent; import net.minecraftforge.server.command.ConfigCommand; public class ForgeInternalHandler { @@ -44,7 +43,7 @@ public class ForgeInternalHandler { event.setCanceled(true); @SuppressWarnings("resource") var executor = LogicalSidedProvider.WORKQUEUE.get(event.getLevel().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER); - executor.tell(new TickTask(0, () -> event.getLevel().addFreshEntity(newEntity))); + executor.schedule(new TickTask(0, () -> event.getLevel().addFreshEntity(newEntity))); } } } @@ -85,12 +84,6 @@ public class ForgeInternalHandler { UsernameCache.setUsername(event.getEntity().getUUID(), event.getEntity().getGameProfile().getName()); } - @SubscribeEvent - public void tagsUpdated(TagsUpdatedEvent event) { - if (event.shouldUpdateStaticData()) - ForgeHooks.updateBurns(); - } - @SubscribeEvent public void onCommandsRegister(RegisterCommandsEvent event) { new ForgeCommand(event.getDispatcher()); @@ -126,5 +119,16 @@ public class ForgeInternalHandler { public void onConnectionStart(ConnectionStartEvent event) { NetworkFilters.injectIfNecessary(event.getConnection()); } + + @SubscribeEvent + public void serverStopping(ServerStoppingEvent evt) { + WorldWorkerManager.clear(); + } + + @SubscribeEvent + public void registerPermissionNodes(PermissionGatherEvent.Nodes event) { + event.addNodes(ForgeMod.USE_SELECTORS_PERMISSION); + } + } diff --git a/src/main/java/net/minecraftforge/common/ForgeMod.java b/src/main/java/net/minecraftforge/common/ForgeMod.java index 8ba917d5fb..77e91c74b1 100644 --- a/src/main/java/net/minecraftforge/common/ForgeMod.java +++ b/src/main/java/net/minecraftforge/common/ForgeMod.java @@ -28,7 +28,6 @@ import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.RangedAttribute; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.item.ItemDisplayContext; -import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.BlockGetter; @@ -62,8 +61,8 @@ 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.TagsUpdatedEvent; import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fluids.FluidType; import net.minecraftforge.fluids.ForgeFlowingFluid; import net.minecraftforge.fml.*; @@ -78,11 +77,10 @@ import net.minecraftforge.registries.holdersets.NotHolderSet; import net.minecraftforge.registries.holdersets.OrHolderSet; import net.minecraftforge.network.NetworkInitialization; import net.minecraftforge.network.tasks.ForgeNetworkConfigurationHandler; -import net.minecraftforge.event.server.ServerStoppingEvent; +import net.minecraftforge.event.entity.EntityAttributeModificationEvent; import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.server.command.EnumArgument; import net.minecraftforge.server.command.ModIdArgument; -import net.minecraftforge.server.permission.events.PermissionGatherEvent; import net.minecraftforge.server.permission.nodes.PermissionNode; import net.minecraftforge.server.permission.nodes.PermissionTypes; import net.minecraftforge.unsafe.UnsafeHacks; @@ -393,25 +391,22 @@ public class ForgeMod { modEventBus.addListener(this::gatherData); modEventBus.addListener(this::registerFluids); modEventBus.addListener(this::registerVanillaDisplayContexts); - for (DeferredRegister r : registries) { - r.register(modEventBus); - } + modEventBus.addListener(this::onRegisterAttributes); + ForgeDeferredRegistriesSetup.setup(modEventBus); + for (var reg : registries) + reg.register(modEventBus); - MinecraftForge.EVENT_BUS.addListener(this::serverStopping); context.registerConfig(ModConfig.Type.CLIENT, ForgeConfig.clientSpec); context.registerConfig(ModConfig.Type.SERVER, ForgeConfig.serverSpec); context.registerConfig(ModConfig.Type.COMMON, ForgeConfig.commonSpec); modEventBus.register(ForgeConfig.class); - ForgeDeferredRegistriesSetup.setup(modEventBus); + // Forge does not display problems when the remote is not matching. context.registerDisplayTest(IExtensionPoint.DisplayTest.IGNORE_ALL_VERSION); StartupMessageManager.addModMessage("Forge version "+ForgeVersion.getVersion()); MinecraftForge.EVENT_BUS.addListener(VillagerTradingManager::loadTrades); MinecraftForge.EVENT_BUS.register(MinecraftForge.INTERNAL_HANDLER); - MinecraftForge.EVENT_BUS.addListener(this::mappingChanged); - MinecraftForge.EVENT_BUS.addListener(this::tagsUpdated); - MinecraftForge.EVENT_BUS.addListener(this::registerPermissionNodes); MinecraftForge.EVENT_BUS.register(new ForgeNetworkConfigurationHandler()); ForgeRegistries.ITEMS.tags().addOptionalTagDefaults(Tags.Items.ENCHANTING_FUELS, Set.of(ForgeRegistries.ITEMS.getDelegateOrThrow(Items.LAPIS_LAZULI))); @@ -426,16 +421,13 @@ public class ForgeMod { //VanillaPacketSplitter.register(); } - public void serverStopping(ServerStoppingEvent evt) { - WorldWorkerManager.clear(); - } - public void mappingChanged(IdMappingEvent evt) { - Ingredient.invalidateAll(); - } - - public void tagsUpdated(TagsUpdatedEvent evt) { - Ingredient.invalidateAll(); + @SubscribeEvent + public void onRegisterAttributes(EntityAttributeModificationEvent event) { + for (var type : event.getTypes()) { + event.add(type, ForgeMod.SWIM_SPEED.getHolder().get()); + event.add(type, ForgeMod.NAMETAG_DISTANCE.getHolder().get()); + } } public void gatherData(GatherDataEvent event) { @@ -457,7 +449,7 @@ public class ForgeMod { gen.addProvider(event.includeServer(), new ForgeEntityTypeTagsProvider(packOutput, lookupProvider, existingFileHelper)); gen.addProvider(event.includeServer(), new ForgeFluidTagsProvider(packOutput, lookupProvider, existingFileHelper)); gen.addProvider(event.includeServer(), new ForgeEnchantmentTagsProvider(packOutput, lookupProvider, existingFileHelper)); - gen.addProvider(event.includeServer(), new ForgeRecipeProvider(packOutput, lookupProvider)); + gen.addProvider(event.includeServer(), new ForgeRecipeProvider.Runner(packOutput, lookupProvider)); gen.addProvider(event.includeServer(), new ForgeLootTableProvider(packOutput, lookupProvider)); gen.addProvider(event.includeServer(), new ForgeBiomeTagsProvider(packOutput, lookupProvider, existingFileHelper)); gen.addProvider(event.includeServer(), new ForgeStructureTagsProvider(packOutput, lookupProvider, existingFileHelper)); @@ -526,10 +518,6 @@ public class ForgeMod { public static final PermissionNode USE_SELECTORS_PERMISSION = new PermissionNode<>("forge", "use_entity_selectors", PermissionTypes.BOOLEAN, (player, uuid, contexts) -> player != null && player.hasPermissions(Commands.LEVEL_GAMEMASTERS)); - public void registerPermissionNodes(PermissionGatherEvent.Nodes event) { - event.addNodes(USE_SELECTORS_PERMISSION); - } - /** * TODO: Remove when {@link ForgeRegistry#addAlias(ResourceLocation, ResourceLocation)} is elevated to {@link IForgeRegistry}. */ diff --git a/src/main/java/net/minecraftforge/common/ForgeSpawnEggItem.java b/src/main/java/net/minecraftforge/common/ForgeSpawnEggItem.java index 3e55ffb047..38b930e5e0 100644 --- a/src/main/java/net/minecraftforge/common/ForgeSpawnEggItem.java +++ b/src/main/java/net/minecraftforge/common/ForgeSpawnEggItem.java @@ -7,10 +7,10 @@ package net.minecraftforge.common; import net.minecraft.core.Direction; import net.minecraft.core.dispenser.DispenseItemBehavior; -import net.minecraft.util.FastColor; +import net.minecraft.util.ARGB; +import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SpawnEggItem; import net.minecraft.world.level.block.DispenserBlock; @@ -47,6 +47,7 @@ public class ForgeSpawnEggItem extends SpawnEggItem { return DEFAULT_DISPENSE_BEHAVIOR; } + @SuppressWarnings("deprecation") @Nullable public static SpawnEggItem fromEntityType(@Nullable EntityType type) { SpawnEggItem ret = TYPE_MAP.get(type); @@ -63,7 +64,7 @@ public class ForgeSpawnEggItem extends SpawnEggItem { EntityType type = ((SpawnEggItem)stack.getItem()).getType(stack); try { - type.spawn(source.level(), stack, null, source.pos().relative(face), MobSpawnType.DISPENSER, face != Direction.UP, false); + type.spawn(source.level(), stack, null, source.pos().relative(face), EntitySpawnReason.DISPENSER, face != Direction.UP, false); } catch (Exception exception) { DispenseItemBehavior.LOGGER.error("Error while dispensing spawn egg from dispenser at {}", source.pos(), exception); return ItemStack.EMPTY; @@ -95,8 +96,8 @@ public class ForgeSpawnEggItem extends SpawnEggItem { for (ForgeSpawnEggItem egg : MOD_EGGS) { event.register((stack, layer) -> { int color = egg.getColor(layer); - if (FastColor.ARGB32.alpha(color) == 0) - color = FastColor.ARGB32.opaque(color); + if (ARGB.alpha(color) == 0) + color = ARGB.opaque(color); return color; }, egg); } diff --git a/src/main/java/net/minecraftforge/common/ForgeTier.java b/src/main/java/net/minecraftforge/common/ForgeTier.java deleted file mode 100644 index 86fa764c5a..0000000000 --- a/src/main/java/net/minecraftforge/common/ForgeTier.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.common; - -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Tier; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.level.block.Block; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Supplier; - -/** - * Helper class to define a custom tier - */ -@SuppressWarnings("ClassCanBeRecord") // can't make it a record because the method names will be obfuscated -public final class ForgeTier implements Tier { - private final int uses; - private final float speed; - private final float attackDamageBonus; - private final int enchantmentValue; - @NotNull - private final TagKey tag; - @NotNull - private final Supplier repairIngredient; - @NotNull - public final TagKey incorrectBlocks; - - public ForgeTier(int uses, float speed, float attackDamageBonus, int enchantmentValue, - @NotNull TagKey tag, @NotNull Supplier repairIngredient, - @NotNull TagKey incorrectBlocks) { - this.uses = uses; - this.speed = speed; - this.attackDamageBonus = attackDamageBonus; - this.enchantmentValue = enchantmentValue; - this.tag = tag; - this.repairIngredient = repairIngredient; - this.incorrectBlocks = incorrectBlocks; - } - - @Override - public int getUses() { - return this.uses; - } - - @Override - public float getSpeed() { - return this.speed; - } - - @Override - public float getAttackDamageBonus() { - return this.attackDamageBonus; - } - - @Override - public int getEnchantmentValue() { - return this.enchantmentValue; - } - - @NotNull - public TagKey getTag() { - return this.tag; - } - - @Override - public TagKey getIncorrectBlocksForDrops() { - return this.incorrectBlocks; - } - - @NotNull - @Override - public Ingredient getRepairIngredient() { - return this.repairIngredient.get(); - } - - @Override - public String toString() { - return "ForgeTier[" + - "uses=" + uses + ", " + - "speed=" + speed + ", " + - "attackDamageBonus=" + attackDamageBonus + ", " + - "enchantmentValue=" + enchantmentValue + ", " + - "tag=" + tag + ", " + - "incorrect=" + incorrectBlocks+ ", " + - "repairIngredient=" + repairIngredient + ']'; - } -} diff --git a/src/main/java/net/minecraftforge/common/IMinecartCollisionHandler.java b/src/main/java/net/minecraftforge/common/IMinecartCollisionHandler.java deleted file mode 100644 index e0b21e6b3a..0000000000 --- a/src/main/java/net/minecraftforge/common/IMinecartCollisionHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.common; - -import net.minecraft.world.phys.AABB; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.vehicle.AbstractMinecart; - -/** - * This class defines a replacement for the default minecart collision code. - * Only one handler can be registered at a time. It it registered with AbstractMinecartEntity.registerCollisionHandler(). - * If you use this, make it a configuration option. - * @author CovertJaguar - */ -public interface IMinecartCollisionHandler -{ - - /** - * This basically replaces the function of the same name in EntityMinecart. - * Code in IMinecartHooks.applyEntityCollisionHook is still run. - * @param cart The cart that called the collision. - * @param other The object it collided with. - */ - void onEntityCollision(AbstractMinecart cart, Entity other); - - /** - * This function replaced the function of the same name in EntityMinecart. - * It is used to define whether minecarts collide with specific entities, - * for example items. - * @param cart The cart for which the collision box was requested. - * @param other The entity requesting the collision box. - * @return The collision box or null. - */ - AABB getCollisionBox(AbstractMinecart cart, Entity other); - - /** - * This function is used to define the box used for detecting minecart collisions. - * It is generally bigger that the normal collision box. - * @param cart The cart for which the collision box was requested. - * @return The collision box, cannot be null. - */ - AABB getMinecartCollisionBox(AbstractMinecart cart); - - /** - * This function replaces the function of the same name in EntityMinecart. - * It defines whether minecarts are solid to the player. - * @param cart The cart for which the bounding box was requested. - * @return The bounding box or null. - */ - AABB getBoundingBox(AbstractMinecart cart); -} - diff --git a/src/main/java/net/minecraftforge/common/MinecraftForge.java b/src/main/java/net/minecraftforge/common/MinecraftForge.java index 7b3a4cf155..fd957c6f36 100644 --- a/src/main/java/net/minecraftforge/common/MinecraftForge.java +++ b/src/main/java/net/minecraftforge/common/MinecraftForge.java @@ -23,14 +23,11 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; -import java.util.Optional; import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Supplier; -public class MinecraftForge -{ - +public class MinecraftForge { /** * The EventBus for all the Forge Events. * @@ -46,8 +43,7 @@ public class MinecraftForge /** * Method invoked by FML before any other mods are loaded. */ - public static void initialize() - { + public static void initialize() { LOGGER.info(FORGE,"MinecraftForge v{} Initialized", ForgeVersion.getVersion()); UsernameCache.load(); diff --git a/src/main/java/net/minecraftforge/common/TagConventionMigrationHelper.java b/src/main/java/net/minecraftforge/common/TagConventionMigrationHelper.java index ae1facd48d..a771c73348 100644 --- a/src/main/java/net/minecraftforge/common/TagConventionMigrationHelper.java +++ b/src/main/java/net/minecraftforge/common/TagConventionMigrationHelper.java @@ -5,6 +5,7 @@ package net.minecraftforge.common; +import net.minecraft.core.HolderSet; import net.minecraft.core.RegistryAccess; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; @@ -47,7 +48,10 @@ public final class TagConventionMigrationHelper { registryAccess.registries().forEach(registryEntry -> { if (registryEntry.key().location().getNamespace().equals(ResourceLocation.DEFAULT_NAMESPACE)) { FOUND_LEGACY_TAGS.addAll( - registryEntry.value().getTagNames().filter(TagConventionMappings.MAPPINGS::containsKey).toList() + registryEntry.value().getTags() + .map(HolderSet.Named::key) + .filter(TagConventionMappings.MAPPINGS::containsKey) + .toList() ); } }); @@ -60,7 +64,7 @@ public final class TagConventionMigrationHelper { Warning for mod devs: Found known legacy tags that have direct common convention equivalents - consider migrating these to improve compatibility with other mods. Note: This feature isn't fully comprehensive - see Forge's net.minecraftforge.common.Tags class for a full list of tags. You can disable this message by setting "migrationHelperMode" to "OFF" in Forge's common config. - + Here are some suggestions for replacements:""".stripIndent()); for (var legacyTag : FOUND_LEGACY_TAGS) { diff --git a/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java b/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java index 7e4adfae93..80fc719e8a 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java +++ b/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java @@ -84,7 +84,7 @@ public class ConditionalAdvancement { public JsonObject build(HolderLookup.Provider lookup) { var json = new JsonObject(); var array = new JsonArray(); - json.add("advancements", array); + json.add("forge:conditional", array); var ops = lookup.createSerializationContext(JsonOps.INSTANCE); diff --git a/src/main/java/net/minecraftforge/common/crafting/ConditionalRecipe.java b/src/main/java/net/minecraftforge/common/crafting/ConditionalRecipe.java index a54bc2cfb7..1208d4213b 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ConditionalRecipe.java +++ b/src/main/java/net/minecraftforge/common/crafting/ConditionalRecipe.java @@ -28,17 +28,21 @@ import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementHolder; import net.minecraft.core.HolderLookup; import net.minecraft.core.HolderLookup.Provider; +import net.minecraft.core.registries.Registries; import net.minecraft.data.recipes.RecipeBuilder; import net.minecraft.data.recipes.RecipeOutput; -import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.CraftingInput; +import net.minecraft.world.item.crafting.PlacementInfo; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeBookCategories; +import net.minecraft.world.item.crafting.RecipeBookCategory; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.crafting.conditions.ConditionCodec; import net.minecraftforge.common.crafting.conditions.ICondition; @@ -50,7 +54,7 @@ import org.jetbrains.annotations.Nullable; * disabling the entire recipe, it has sub-recipes that themselves have conditions. * * And when being deserialized it returns the first entry that passes the conditional check. - * This basically means that you can have muultiple variants all use the same recipe name, and + * This basically means that you can have multiple variants all use the same recipe name, and * only one will ever be loaded. * * This also means that you can wrap ALL recipes in a Conditional even those that don't explicitly @@ -67,7 +71,7 @@ public class ConditionalRecipe { private final RecipeOutput bouncer = new RecipeOutput() { @Override - public void accept(ResourceLocation id, Recipe value, @Nullable AdvancementHolder advancement) { + public void accept(ResourceKey> id, Recipe value, @Nullable AdvancementHolder advancement) { recipe(id, value, advancement); } @@ -78,7 +82,7 @@ public class ConditionalRecipe { } @Override - public void accept(ResourceLocation id, Recipe recipe, ResourceLocation advancementId, JsonElement advancement) { + public void accept(ResourceKey> id, Recipe recipe, ResourceLocation advancementId, JsonElement advancement) { AdvancementHolder holder = null; if (advancement != null) { Advancement adv = Advancement.CODEC.parse(JsonOps.INSTANCE, advancement).getOrThrow(JsonParseException::new); @@ -91,6 +95,9 @@ public class ConditionalRecipe { public Provider registry() { return null; } + + @Override + public void includeRootAdvancement() { } }; @Nullable @@ -120,7 +127,7 @@ public class ConditionalRecipe { return this; } - public Builder recipe(ResourceLocation id, Recipe recipe, @Nullable AdvancementHolder advancement) { + public Builder recipe(ResourceKey> id, Recipe recipe, @Nullable AdvancementHolder advancement) { if (condition == null) throw new IllegalStateException("Can not add a recipe with no conditions."); recipes.add(new InnerRecipe(this.condition, recipe)); @@ -163,7 +170,8 @@ public class ConditionalRecipe { advancementId = null; } - out.accept(id, new Wrapper(mainCondition, recipes), advancementId, advancement); + var key = ResourceKey.create(Registries.RECIPE, id); + out.accept(key, new Wrapper(mainCondition, recipes), advancementId, advancement); } } @@ -173,10 +181,14 @@ public class ConditionalRecipe { private static class Wrapper implements Recipe { @Override public boolean matches(CraftingInput inv, Level level) { return false; } @Override public ItemStack assemble(CraftingInput inv, HolderLookup.Provider reg) { return null; } - @Override public boolean canCraftInDimensions(int width, int height) { return false; } - @Override public ItemStack getResultItem(HolderLookup.Provider reg) { return null; } - @Override public RecipeSerializer getSerializer() { return ConditionalRecipe.SERIALZIER; } - @Override public RecipeType getType() { throw new UnsupportedOperationException(); } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public RecipeSerializer> getSerializer() { + return (RecipeSerializer)ConditionalRecipe.SERIALZIER; + } + + @Override public RecipeType> getType() { throw new UnsupportedOperationException(); } @Nullable private final ICondition main; private final List recipes; @@ -185,6 +197,16 @@ public class ConditionalRecipe { this.recipes = recipes; } + @Override + public PlacementInfo placementInfo() { + return PlacementInfo.NOT_PLACEABLE; + } + + @Override + public RecipeBookCategory recipeBookCategory() { + return RecipeBookCategories.STONECUTTER; + } + } private static final MapCodec> CODEC = Codec.of(new MapEncoder.Implementation<>() { @Override diff --git a/src/main/java/net/minecraftforge/common/crafting/conditions/ConditionContext.java b/src/main/java/net/minecraftforge/common/crafting/conditions/ConditionContext.java index 7a4310d75e..2379eb41ba 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/ConditionContext.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/ConditionContext.java @@ -7,36 +7,27 @@ package net.minecraftforge.common.crafting.conditions; import net.minecraft.core.Holder; import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagManager; +import net.minecraft.tags.TagKey; import java.util.Collection; -import java.util.Collections; -import java.util.IdentityHashMap; -import java.util.Map; +import java.util.List; public class ConditionContext implements ICondition.IContext { - private final TagManager tagManager; - private Map, Map>>> loadedTags = null; + private final List> pendingTags; - public ConditionContext(TagManager tagManager) { - this.tagManager = tagManager; + public ConditionContext(List> pendingTags) { + this.pendingTags = pendingTags; } - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public Map>> getAllTags(ResourceKey> registry) { - if (loadedTags == null) { - var tags = tagManager.getResult(); - if (tags.isEmpty()) throw new IllegalStateException("Tags have not been loaded yet."); - - loadedTags = new IdentityHashMap<>(); - for (var loadResult : tags) { - var map = Collections.unmodifiableMap(loadResult.tags()); - loadedTags.put(loadResult.key(), (Map)map); - } + public Collection> getTag(TagKey key) { + for (var entry : this.pendingTags) { + if (entry.key() != key.registry()) + continue; + @SuppressWarnings("unchecked") + var typed = ((Registry.PendingTags)entry); + return typed.getPending(key); } - return (Map)loadedTags.getOrDefault(registry, Collections.emptyMap()); + return List.of(); } } 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 85b42351b3..36a3acaecb 100644 --- a/src/main/java/net/minecraftforge/common/crafting/conditions/ICondition.java +++ b/src/main/java/net/minecraftforge/common/crafting/conditions/ICondition.java @@ -42,14 +42,14 @@ public interface ICondition { IContext EMPTY = new IContext() { @Override - public Map>> getAllTags(ResourceKey> registry) { - return Collections.emptyMap(); + public Collection> getTag(TagKey key) { + return Collections.emptyList(); } }; IContext TAGS_INVALID = new IContext() { @Override - public Map>> getAllTags(ResourceKey> registry) { + public Collection> getTag(TagKey key) { throw new UnsupportedOperationException("Usage of tag-based conditions is not permitted in this context!"); } }; @@ -57,14 +57,6 @@ public interface ICondition { /** * Return the requested tag if available, or an empty tag otherwise. */ - default Collection> getTag(TagKey key) { - return getAllTags(key.registry()).getOrDefault(key.location(), Set.of()); - } - - /** - * Return all the loaded tags for the passed registry, or an empty map if none is available. - * Note that the map and the tags are unmodifiable. - */ - Map>> getAllTags(ResourceKey> registry); + Collection> getTag(TagKey key); } } diff --git a/src/main/java/net/minecraftforge/common/crafting/ingredients/AbstractIngredient.java b/src/main/java/net/minecraftforge/common/crafting/ingredients/AbstractIngredient.java index dadafe5b06..ece557eee0 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ingredients/AbstractIngredient.java +++ b/src/main/java/net/minecraftforge/common/crafting/ingredients/AbstractIngredient.java @@ -5,12 +5,12 @@ package net.minecraftforge.common.crafting.ingredients; +import net.minecraft.core.HolderSet; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.ItemLike; -import java.util.stream.Stream; /** * Extension of {@link Ingredient} which makes most methods custom ingredients need to implement abstract, and removes the static constructors @@ -19,12 +19,11 @@ import java.util.stream.Stream; public abstract class AbstractIngredient extends Ingredient { /** Empty constructor, for the sake of dynamic ingredients */ protected AbstractIngredient() { - super(Stream.of()); + super(HolderSet.empty(), false); } - /** Value constructor, for ingredients that have some vanilla representation */ - protected AbstractIngredient(Stream values) { - super(values); + protected AbstractIngredient(HolderSet items) { + super(items); } @Override @@ -36,12 +35,6 @@ public abstract class AbstractIngredient extends Ingredient { /* Hide vanilla ingredient static constructors to reduce errors with constructing custom ingredients */ - /** @deprecated use {@link Ingredient#fromValues(Stream)} */ - @Deprecated - public static Ingredient fromValues(Stream values) { - throw new UnsupportedOperationException("Use Ingredient.fromValues()"); - } - /** @deprecated use {@link Ingredient#of()} */ @Deprecated public static Ingredient of() { @@ -60,12 +53,6 @@ public abstract class AbstractIngredient extends Ingredient { throw new UnsupportedOperationException("Use Ingredient.of()"); } - /** @deprecated use {@link Ingredient#of(Stream)} (Stream)} */ - @Deprecated - public static Ingredient of(Stream stacks) { - throw new UnsupportedOperationException("Use Ingredient.of()"); - } - /** @deprecated use {@link Ingredient#of(TagKey)} (Stream)} */ @Deprecated public static Ingredient of(TagKey tag) { diff --git a/src/main/java/net/minecraftforge/common/crafting/ingredients/CompoundIngredient.java b/src/main/java/net/minecraftforge/common/crafting/ingredients/CompoundIngredient.java index cfe87cb469..a749add222 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ingredients/CompoundIngredient.java +++ b/src/main/java/net/minecraftforge/common/crafting/ingredients/CompoundIngredient.java @@ -9,15 +9,13 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -import com.google.common.collect.Lists; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntComparators; -import it.unimi.dsi.fastutil.ints.IntList; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.core.Holder; import net.minecraft.network.RegistryFriendlyByteBuf; import org.jetbrains.annotations.NotNull; @@ -36,8 +34,7 @@ public class CompoundIngredient extends AbstractIngredient { } private final List children; - private ItemStack[] stacks; - private IntList itemIds; + private List> items; private final boolean isSimple; private CompoundIngredient(List children) { @@ -47,32 +44,14 @@ public class CompoundIngredient extends AbstractIngredient { @Override @NotNull - public ItemStack[] getItems() { - if (stacks == null) { - List tmp = Lists.newArrayList(); - for (Ingredient child : children) - Collections.addAll(tmp, child.getItems()); - stacks = tmp.toArray(new ItemStack[tmp.size()]); - + public List> items() { + if (this.items == null) { + var tmp = new ArrayList>(); + for (var child : children) + tmp.addAll(child.items()); + this.items = Collections.unmodifiableList(tmp); } - return stacks; - } - - @Override - @NotNull - public IntList getStackingIds() { - boolean childrenNeedInvalidation = false; - for (Ingredient child : children) - childrenNeedInvalidation |= child.checkInvalidation(); - if (childrenNeedInvalidation || this.itemIds == null || checkInvalidation()) { - this.markValid(); - this.itemIds = new IntArrayList(); - for (Ingredient child : children) - this.itemIds.addAll(child.getStackingIds()); - this.itemIds.sort(IntComparators.NATURAL_COMPARATOR); - } - - return this.itemIds; + return this.items; } @Override @@ -80,7 +59,12 @@ public class CompoundIngredient extends AbstractIngredient { if (target == null) return false; - return children.stream().anyMatch(c -> c.test(target)); + for (var child : children) { + if (child.test(target)) + return true; + } + + return false; } @Override @@ -88,11 +72,6 @@ public class CompoundIngredient extends AbstractIngredient { return isSimple; } - @Override - public boolean isEmpty() { - return children.stream().allMatch(Ingredient::isEmpty); - } - @Override public IIngredientSerializer serializer() { return SERIALIZER; @@ -100,7 +79,7 @@ public class CompoundIngredient extends AbstractIngredient { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(builder -> builder.group( - Ingredient.CODEC_NONEMPTY.listOf().fieldOf("children").forGetter(i -> i.children) + Ingredient.CODEC.listOf().fieldOf("children").forGetter(i -> i.children) ).apply(builder, CompoundIngredient::new) ); diff --git a/src/main/java/net/minecraftforge/common/crafting/ingredients/DifferenceIngredient.java b/src/main/java/net/minecraftforge/common/crafting/ingredients/DifferenceIngredient.java index db790810e9..fe96a74140 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ingredients/DifferenceIngredient.java +++ b/src/main/java/net/minecraftforge/common/crafting/ingredients/DifferenceIngredient.java @@ -8,16 +8,16 @@ package net.minecraftforge.common.crafting.ingredients; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntComparators; -import it.unimi.dsi.fastutil.ints.IntList; +import net.minecraft.core.Holder; import net.minecraft.network.RegistryFriendlyByteBuf; -import net.minecraft.world.entity.player.StackedContents; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import org.jetbrains.annotations.Nullable; -import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; /** Ingredient that matches everything from the first ingredient that is not included in the second ingredient */ public class DifferenceIngredient extends AbstractIngredient { @@ -33,8 +33,7 @@ public class DifferenceIngredient extends AbstractIngredient { private final Ingredient base; private final Ingredient subtracted; - private ItemStack[] filteredMatchingStacks; - private IntList packedMatchingStacks; + private List> items = null; private DifferenceIngredient(Ingredient base, Ingredient subtracted) { this.base = base; @@ -48,18 +47,26 @@ public class DifferenceIngredient extends AbstractIngredient { return base.test(stack) && !subtracted.test(stack); } + @SuppressWarnings("deprecation") @Override - public ItemStack[] getItems() { - if (this.filteredMatchingStacks == null) - this.filteredMatchingStacks = Arrays.stream(base.getItems()) - .filter(stack -> !subtracted.test(stack)) - .toArray(ItemStack[]::new); - return filteredMatchingStacks; - } + public List> items() { + if (this.items == null) { + var tmp = new ArrayList>(); - @Override - public boolean isEmpty() { - return base.isEmpty(); + for (var base : this.base.items()) { + boolean match = false; + for (var item : this.subtracted.items()) { + if (base.is(item)) { + match = true; + break; + } + } + if (!match) + tmp.add(base); + } + this.items = Collections.unmodifiableList(tmp); + } + return items; } @Override @@ -67,27 +74,6 @@ public class DifferenceIngredient extends AbstractIngredient { return base.isSimple() && subtracted.isSimple(); } - @Override - protected void invalidate() { - super.invalidate(); - this.filteredMatchingStacks = null; - this.packedMatchingStacks = null; - } - - @Override - public IntList getStackingIds() { - if (this.packedMatchingStacks == null || checkInvalidation()) { - markValid(); - var matchingStacks = getItems(); - this.packedMatchingStacks = new IntArrayList(matchingStacks.length); - for (var stack : matchingStacks) - this.packedMatchingStacks.add(StackedContents.getStackingIndex(stack)); - - this.packedMatchingStacks.sort(IntComparators.NATURAL_COMPARATOR); - } - return packedMatchingStacks; - } - @Override public IIngredientSerializer serializer() { return SERIALIZER; diff --git a/src/main/java/net/minecraftforge/common/crafting/ingredients/IIngredientBuilder.java b/src/main/java/net/minecraftforge/common/crafting/ingredients/IIngredientBuilder.java index 8e99c7125e..781d15c87d 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ingredients/IIngredientBuilder.java +++ b/src/main/java/net/minecraftforge/common/crafting/ingredients/IIngredientBuilder.java @@ -7,6 +7,8 @@ package net.minecraftforge.common.crafting.ingredients; import java.util.Arrays; +import net.minecraft.core.HolderGetter; +import net.minecraft.core.HolderSet; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -25,19 +27,24 @@ public interface IIngredientBuilder { return CompoundIngredient.of(values); } - default Ingredient intersection(@SuppressWarnings("rawtypes") TagKey... values) { - return intersection(Arrays.stream(values).map(Ingredient::of).toArray(Ingredient[]::new)); + @SuppressWarnings("unchecked") + default Ingredient intersection(HolderGetter lookup, @SuppressWarnings("rawtypes") TagKey... values) { + return intersection(Arrays.stream(values).map(k -> holder(lookup, (TagKey)k)).map(Ingredient::of).toArray(Ingredient[]::new)); } default Ingredient intersection(Ingredient... values) { return IntersectionIngredient.of(values); } - default Ingredient difference(TagKey base, TagKey subtracted) { - return difference(Ingredient.of(base), Ingredient.of(subtracted)); + default Ingredient difference(HolderGetter lookup, TagKey base, TagKey subtracted) { + return difference(Ingredient.of(holder(lookup, base)), Ingredient.of(holder(lookup, subtracted))); } default Ingredient difference(Ingredient base, Ingredient subtracted) { return DifferenceIngredient.of(base, subtracted); } + + private static HolderSet holder(HolderGetter lookup, TagKey key) { + return lookup.getOrThrow(key); + } } diff --git a/src/main/java/net/minecraftforge/common/crafting/ingredients/IIngredientSerializer.java b/src/main/java/net/minecraftforge/common/crafting/ingredients/IIngredientSerializer.java index a0e3ea355f..dab86c7d10 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ingredients/IIngredientSerializer.java +++ b/src/main/java/net/minecraftforge/common/crafting/ingredients/IIngredientSerializer.java @@ -5,12 +5,9 @@ package net.minecraftforge.common.crafting.ingredients; -import java.util.Arrays; - import com.mojang.serialization.MapCodec; import net.minecraft.network.RegistryFriendlyByteBuf; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; public interface IIngredientSerializer { @@ -18,22 +15,4 @@ public interface IIngredientSerializer { void write(RegistryFriendlyByteBuf buffer, T value); T read(RegistryFriendlyByteBuf buffer); - - - IIngredientSerializer VANILLA = new IIngredientSerializer<>() { - @Override - public MapCodec codec() { - return Ingredient.VANILLA_MAP_CODEC; - } - - @Override - public void write(RegistryFriendlyByteBuf buffer, Ingredient value) { - ItemStack.LIST_STREAM_CODEC.encode(buffer, Arrays.asList(value.getItems())); - } - - @Override - public Ingredient read(RegistryFriendlyByteBuf buffer) { - return Ingredient.of(ItemStack.LIST_STREAM_CODEC.decode(buffer).stream()); - } - }; } diff --git a/src/main/java/net/minecraftforge/common/crafting/ingredients/IntersectionIngredient.java b/src/main/java/net/minecraftforge/common/crafting/ingredients/IntersectionIngredient.java index c79df879ea..a0007c835c 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ingredients/IntersectionIngredient.java +++ b/src/main/java/net/minecraftforge/common/crafting/ingredients/IntersectionIngredient.java @@ -8,11 +8,9 @@ package net.minecraftforge.common.crafting.ingredients; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntComparators; -import it.unimi.dsi.fastutil.ints.IntList; +import net.minecraft.core.Holder; import net.minecraft.network.RegistryFriendlyByteBuf; -import net.minecraft.world.entity.player.StackedContents; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import org.jetbrains.annotations.Nullable; @@ -40,8 +38,7 @@ public class IntersectionIngredient extends AbstractIngredient { private final List children; private final boolean isSimple; - private ItemStack[] intersectedMatchingStacks = null; - private IntList packedMatchingStacks = null; + private List> items = null; private IntersectionIngredient(List children) { if (children.size() < 2) @@ -62,26 +59,33 @@ public class IntersectionIngredient extends AbstractIngredient { return true; } + @SuppressWarnings("deprecation") @Override - public ItemStack[] getItems() { - if (this.intersectedMatchingStacks == null) { - this.intersectedMatchingStacks = Arrays - .stream(children.get(0).getItems()) - .filter(stack -> { - // the first ingredient is treated as a base, filtered by the second onwards - for (int i = 1; i < children.size(); i++) - if (!children.get(i).test(stack)) - return false; - return true; - }) - .toArray(ItemStack[]::new); - } - return intersectedMatchingStacks; - } + public List> items() { + if (this.items == null) { + var tmp = new ArrayList>(); - @Override - public boolean isEmpty() { - return children.stream().anyMatch(Ingredient::isEmpty); + for (var base : children.get(0).items()) { + boolean allMatch = true; + for (int i = 1; i < children.size(); i++) { + boolean match = false; + for (var item : children.get(i).items()) { + if (base.is(item)) { + match = true; + break; + } + } + if (!match) { + allMatch = false; + break; + } + } + if (allMatch) + tmp.add(base); + } + this.items = Collections.unmodifiableList(tmp); + } + return items; } @Override @@ -89,26 +93,6 @@ public class IntersectionIngredient extends AbstractIngredient { return isSimple; } - @Override - protected void invalidate() { - super.invalidate(); - this.intersectedMatchingStacks = null; - this.packedMatchingStacks = null; - } - - @Override - public IntList getStackingIds() { - if (this.packedMatchingStacks == null || checkInvalidation()) { - markValid(); - var matchingStacks = getItems(); - this.packedMatchingStacks = new IntArrayList(matchingStacks.length); - for (var stack : matchingStacks) - this.packedMatchingStacks.add(StackedContents.getStackingIndex(stack)); - this.packedMatchingStacks.sort(IntComparators.NATURAL_COMPARATOR); - } - return packedMatchingStacks; - } - @Override public IIngredientSerializer serializer() { return SERIALIZER; diff --git a/src/main/java/net/minecraftforge/common/crafting/ingredients/PartialNBTIngredient.java b/src/main/java/net/minecraftforge/common/crafting/ingredients/PartialNBTIngredient.java index 93a78060af..d744d6881f 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ingredients/PartialNBTIngredient.java +++ b/src/main/java/net/minecraftforge/common/crafting/ingredients/PartialNBTIngredient.java @@ -9,21 +9,22 @@ import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.advancements.critereon.NbtPredicate; +import net.minecraft.core.HolderSet; import net.minecraft.core.component.DataComponents; +import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.TagParser; import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.component.CustomData; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.ItemLike; -import net.minecraftforge.registries.ForgeRegistries; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Objects; @@ -33,34 +34,41 @@ public class PartialNBTIngredient extends AbstractIngredient { return new Builder(); } - private final List items; private final CompoundTag nbt; private final NbtPredicate predicate; - private PartialNBTIngredient(List items, CompoundTag nbt) { - super(items.stream().map(item -> { - var stack = new ItemStack(item); - // copy NBT to prevent the stack from modifying the original, as capabilities or vanilla item durability will modify the tag - stack.set(DataComponents.CUSTOM_DATA, CustomData.of(nbt.copy())); - return new Ingredient.ItemValue(stack); - })); + private PartialNBTIngredient(HolderSet items, CompoundTag nbt) { + super(items); - if (items.isEmpty()) + if (items.size() == 0) throw new IllegalArgumentException("Cannot create a PartialNBTIngredient with no items"); - this.items = Collections.unmodifiableList(items); this.nbt = nbt; this.predicate = new NbtPredicate(nbt); } /** Creates a new ingredient matching any item from the list, containing the given NBT */ + @SuppressWarnings("deprecation") public static PartialNBTIngredient of(CompoundTag nbt, ItemLike... items) { - return new PartialNBTIngredient(Arrays.stream(items).map(ItemLike::asItem).toList(), nbt); + return of( + HolderSet.direct( + Arrays.stream(items) + .map(ItemLike::asItem) + .map(Item::builtInRegistryHolder) + .toList() + ), + nbt); } /** Creates a new ingredient matching the given item, containing the given NBT */ + @SuppressWarnings("deprecation") public static PartialNBTIngredient of(ItemLike item, CompoundTag nbt) { - return new PartialNBTIngredient(List.of(item.asItem()), nbt); + return of(HolderSet.direct(item.asItem().builtInRegistryHolder()), nbt); + } + + /** Creates a new ingredient matching the given item, containing the given NBT */ + public static PartialNBTIngredient of(HolderSet items, CompoundTag nbt) { + return new PartialNBTIngredient(items, nbt); } @Override @@ -68,7 +76,7 @@ public class PartialNBTIngredient extends AbstractIngredient { if (input == null) return false; var nbt = input.get(DataComponents.CUSTOM_DATA); - return nbt != null && items.contains(input.getItem()) && predicate.matches(nbt.copyTag()); + return nbt != null && input.is(this.values) && predicate.matches(nbt.copyTag()); } @Override @@ -83,12 +91,14 @@ public class PartialNBTIngredient extends AbstractIngredient { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(builder -> builder.group( - ForgeRegistries.ITEMS.getCodec().listOf().fieldOf("items").forGetter(i -> i.items), + Ingredient.NON_AIR_HOLDER_SET_CODEC.fieldOf("items").forGetter(i -> i.values), TagParser.AS_CODEC.fieldOf("nbt").forGetter(i -> i.nbt) ).apply(builder, PartialNBTIngredient::new) ); public static final IIngredientSerializer SERIALIZER = new IIngredientSerializer<>() { + private final StreamCodec> HOLDER_SET = ByteBufCodecs.holderSet(Registries.ITEM); + @Override public MapCodec codec() { return CODEC; @@ -96,14 +106,14 @@ public class PartialNBTIngredient extends AbstractIngredient { @Override public PartialNBTIngredient read(RegistryFriendlyByteBuf buffer) { - var items = buffer.readList(b -> Item.STREAM_CODEC.decode(buffer).get()); + var items = HOLDER_SET.decode(buffer); var nbt = buffer.readNbt(); return new PartialNBTIngredient(items, Objects.requireNonNull(nbt)); } @Override public void write(RegistryFriendlyByteBuf buffer, PartialNBTIngredient value) { - buffer.writeCollection(value.items, (b, item) -> Item.STREAM_CODEC.encode(buffer, item.builtInRegistryHolder())); + HOLDER_SET.encode(buffer, value.values); buffer.writeNbt(value.nbt); } }; diff --git a/src/main/java/net/minecraftforge/common/crafting/ingredients/StrictNBTIngredient.java b/src/main/java/net/minecraftforge/common/crafting/ingredients/StrictNBTIngredient.java index 91bc754d9e..8654a406db 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ingredients/StrictNBTIngredient.java +++ b/src/main/java/net/minecraftforge/common/crafting/ingredients/StrictNBTIngredient.java @@ -5,8 +5,7 @@ package net.minecraftforge.common.crafting.ingredients; -import java.util.stream.Stream; - +import net.minecraft.core.HolderSet; import net.minecraft.core.component.DataComponents; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.world.item.ItemStack; @@ -24,7 +23,7 @@ public class StrictNBTIngredient extends AbstractIngredient { private final ItemStack stack; private StrictNBTIngredient(ItemStack stack) { - super(Stream.of(new Ingredient.ItemValue(stack))); + super(HolderSet.direct(stack.getItemHolder())); this.stack = stack; } @@ -32,6 +31,7 @@ public class StrictNBTIngredient extends AbstractIngredient { public boolean test(@Nullable ItemStack input) { if (input == null) return false; + //Can't use areItemStacksEqualUsingNBTShareTag because it compares stack size as well var inbt = input.get(DataComponents.CUSTOM_DATA); var tnbt = this.stack.get(DataComponents.CUSTOM_DATA); diff --git a/src/main/java/net/minecraftforge/common/data/ForgeEntityTypeTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeEntityTypeTagsProvider.java index ba5c918d21..8033795ddf 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeEntityTypeTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeEntityTypeTagsProvider.java @@ -27,10 +27,37 @@ public final class ForgeEntityTypeTagsProvider extends EntityTypeTagsProvider { @Override public void addTags(HolderLookup.Provider lookupProvider) { tag(BOSSES) - .add(EntityType.ENDER_DRAGON, EntityType.WITHER) - .addOptionalTag(forgeTagKey("bosses")); - tag(MINECARTS).add(EntityType.MINECART, EntityType.CHEST_MINECART, EntityType.FURNACE_MINECART, EntityType.HOPPER_MINECART, EntityType.SPAWNER_MINECART, EntityType.TNT_MINECART, EntityType.COMMAND_BLOCK_MINECART); - tag(BOATS).add(EntityType.BOAT, EntityType.CHEST_BOAT); + .add(EntityType.ENDER_DRAGON, EntityType.WITHER) + .addOptionalTag(forgeTagKey("bosses")); + tag(MINECARTS).add( + EntityType.MINECART, + EntityType.CHEST_MINECART, + EntityType.FURNACE_MINECART, + EntityType.HOPPER_MINECART, + EntityType.SPAWNER_MINECART, + EntityType.TNT_MINECART, + EntityType.COMMAND_BLOCK_MINECART + ); + tag(BOATS).add( + EntityType.ACACIA_BOAT, + EntityType.ACACIA_CHEST_BOAT, + EntityType.BIRCH_BOAT, + EntityType.BIRCH_CHEST_BOAT, + EntityType.CHERRY_BOAT, + EntityType.CHERRY_CHEST_BOAT, + EntityType.DARK_OAK_BOAT, + EntityType.DARK_OAK_CHEST_BOAT, + EntityType.JUNGLE_BOAT, + EntityType.JUNGLE_CHEST_BOAT, + EntityType.MANGROVE_BOAT, + EntityType.MANGROVE_CHEST_BOAT, + EntityType.OAK_BOAT, + EntityType.OAK_CHEST_BOAT, + EntityType.PALE_OAK_BOAT, + EntityType.PALE_OAK_CHEST_BOAT, + EntityType.SPRUCE_BOAT, + EntityType.SPRUCE_CHEST_BOAT + ); tag(CAPTURING_NOT_SUPPORTED); tag(TELEPORTING_NOT_SUPPORTED); diff --git a/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java index 5dadbd70c8..012a02ec3b 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java @@ -8,7 +8,6 @@ package net.minecraftforge.common.data; import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.PackOutput; -import net.minecraft.data.tags.IntrinsicHolderTagsProvider; import net.minecraft.data.tags.ItemTagsProvider; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; @@ -32,7 +31,7 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider { super(output, lookupProvider, blockTagProvider, "forge", existingFileHelper); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "removal" }) @Override public void addTags(HolderLookup.Provider lookupProvider) { copy(Tags.Blocks.BARRELS, Tags.Items.BARRELS); @@ -518,7 +517,7 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider { for (DyeColor color : DyeColor.values()) { ResourceLocation key = ResourceLocation.fromNamespaceAndPath("minecraft", pattern.replace("{color}", color.getName())); TagKey tag = getForgeItemTag(prefix + color.getName()); - Item item = BuiltInRegistries.ITEM.get(key); + Item item = BuiltInRegistries.ITEM.getValue(key); if (item == null || item == Items.AIR) throw new IllegalStateException("Unknown vanilla item: " + key); tag(tag).add(item); @@ -582,11 +581,11 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider { } private static TagKey forgeBlockTagKey(String path) { - return BlockTags.create(ResourceLocation.fromNamespaceAndPath("forge", path)); + return BlockTags.create(forgeRl(path)); } private static TagKey forgeItemTagKey(String path) { - return ItemTags.create(ResourceLocation.fromNamespaceAndPath("forge", path)); + return ItemTags.create(forgeRl(path)); } @Override diff --git a/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java index 5b5c29c5c7..701e24e53a 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java @@ -8,21 +8,23 @@ package net.minecraftforge.common.data; import com.google.gson.JsonElement; import net.minecraft.advancements.AdvancementHolder; import net.minecraft.advancements.Advancement.Builder; +import net.minecraft.core.Holder; import net.minecraft.core.HolderLookup; import net.minecraft.core.HolderLookup.Provider; -import net.minecraft.data.CachedOutput; +import net.minecraft.core.HolderLookup.RegistryLookup; +import net.minecraft.core.HolderSet; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeOutput; +import net.minecraft.data.recipes.RecipeProvider; import net.minecraft.data.recipes.packs.VanillaRecipeProvider; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.Ingredient.ItemValue; -import net.minecraft.world.item.crafting.Ingredient.TagValue; -import net.minecraft.world.item.crafting.Ingredient.Value; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.ShapedRecipe; import net.minecraft.world.item.crafting.ShapedRecipePattern; @@ -30,10 +32,13 @@ import net.minecraft.world.item.crafting.ShapelessRecipe; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.Blocks; import net.minecraftforge.common.Tags; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.unsafe.UnsafeFieldAccess; +import net.minecraftforge.unsafe.UnsafeHacks; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.Nullable; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -43,19 +48,26 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; public final class ForgeRecipeProvider extends VanillaRecipeProvider { + private static final Logger LOGGER = LogManager.getLogger(); + private final RegistryLookup items; private final Map> replacements = HashMap.newHashMap(12); - private final Set excludes = HashSet.newHashSet(16); + private final Set>> excludes = HashSet.newHashSet(16); + private final UnsafeFieldAccess> INGREDIENTS = UnsafeHacks.findField(ShapelessRecipe.class, "ingredients"); + private final UnsafeFieldAccess PATTERN = UnsafeHacks.findField(ShapedRecipe.class, "pattern"); + private final UnsafeFieldAccess> VALUES = UnsafeHacks.findField(Ingredient.class, "values"); - public ForgeRecipeProvider(PackOutput packOutput, CompletableFuture lookup) { - super(packOutput, lookup); + private ForgeRecipeProvider(HolderLookup.Provider lookup, RecipeOutput output) { + super(lookup, new Wrapped(output)); + ((Wrapped)this.output).setSelf(this); + this.items = lookup.lookupOrThrow(Registries.ITEM); } private void exclude(ItemLike item) { - excludes.add(ForgeRegistries.ITEMS.getKey(item.asItem())); + exclude(BuiltInRegistries.ITEM.getKey(item.asItem()).toString()); } private void exclude(String name) { - excludes.add(ResourceLocation.parse(name)); + excludes.add(ResourceKey.create(Registries.RECIPE, ResourceLocation.parse(name))); } private void replace(ItemLike item, TagKey tag) { @@ -63,7 +75,7 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider { } @Override - protected void buildRecipes(RecipeOutput consumer) { + protected void buildRecipes() { replace(Items.STICK, Tags.Items.RODS_WOODEN); replace(Items.GOLD_INGOT, Tags.Items.INGOTS_GOLD); replace(Items.IRON_INGOT, Tags.Items.INGOTS_IRON); @@ -96,32 +108,11 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider { exclude(Blocks.COBBLED_DEEPSLATE_SLAB); exclude(Blocks.COBBLED_DEEPSLATE_WALL); - super.buildRecipes(new RecipeOutput() { - @Override - public void accept(ResourceLocation id, Recipe recipe, AdvancementHolder advancement) { - var modified = enhance(id, recipe); - if (modified != null) - consumer.accept(id, modified, advancement); - } - - @Override - public Builder advancement() { - return consumer.advancement(); - } - - @Override - public void accept(ResourceLocation id, Recipe recipe, ResourceLocation advancementId, JsonElement advancement) { - } - - @Override - public Provider registry() { - return consumer.registry(); - } - }); + super.buildRecipes(); } @Nullable - private Recipe enhance(ResourceLocation id, Recipe vanilla) { + private Recipe enhance(ResourceKey> id, Recipe vanilla) { if (vanilla instanceof ShapelessRecipe shapeless) return enhance(id, shapeless); if (vanilla instanceof ShapedRecipe shaped) @@ -130,8 +121,8 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider { } @Nullable - private Recipe enhance(ResourceLocation id, ShapelessRecipe vanilla) { - List ingredients = getField(ShapelessRecipe.class, vanilla, 3); + private Recipe enhance(ResourceKey> id, ShapelessRecipe vanilla) { + List ingredients = INGREDIENTS.get(vanilla); boolean modified = false; for (int x = 0; x < ingredients.size(); x++) { Ingredient ing = enhance(id, ingredients.get(x)); @@ -144,21 +135,8 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider { } @Nullable - @Override - protected CompletableFuture saveAdvancement(CachedOutput output, ResourceLocation advancementId, JsonElement advancement) { - // NOOP - We don't replace any of the advancement things yet... - return null; - } - - @Override - protected CompletableFuture buildAdvancement(CachedOutput p_253674_, HolderLookup.Provider p_335995_, AdvancementHolder p_297687_) { - // NOOP - We don't replace any of the advancement things yet... - return CompletableFuture.allOf(); - } - - @Nullable - private Recipe enhance(ResourceLocation id, ShapedRecipe vanilla) { - ShapedRecipePattern pattern = getField(ShapedRecipe.class, vanilla, 2); + private Recipe enhance(ResourceKey> id, ShapedRecipe vanilla) { + ShapedRecipePattern pattern = PATTERN.get(vanilla); var data = pattern.data().orElseThrow(() -> new IllegalStateException("Weird shaped recipe, data is missing? " + id + " " + vanilla)); Map ingredients = data.key(); boolean modified = false; @@ -173,36 +151,92 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider { } @Nullable - private Ingredient enhance(ResourceLocation name, Ingredient vanilla) { + private Ingredient enhance(ResourceKey> name, Ingredient vanilla) { if (excludes.contains(name)) return null; - boolean modified = false; - List items = new ArrayList<>(); - Value[] vanillaItems = getField(Ingredient.class, vanilla, 3); //This will probably crash between versions, if null fix index - for (Value entry : vanillaItems) { - if (entry instanceof ItemValue) { - ItemStack stack = entry.getItems().stream().findFirst().orElse(ItemStack.EMPTY); - TagKey replacement = replacements.get(stack.getItem()); - if (replacement != null) { - items.add(new TagValue(replacement)); - modified = true; - } else - items.add(entry); + HolderSet vanillaItems = VALUES.get(vanilla); + var unwraped = vanillaItems.unwrap(); + + if (unwraped.left().isPresent()) // Already a tag + return null; + + Ingredient ret = null; + var items = new ArrayList>(); + for (var entry : unwraped.right().get()) { + var item = entry.get(); + var replacement = replacements.get(item); + if (replacement != null) { + if (ret != null) { + LOGGER.warn("Failed to enahnce {} ingredient has multiple input items", name); + return null; + } + ret = Ingredient.of(this.items.getOrThrow(replacement)); } else items.add(entry); } - return modified ? Ingredient.fromValues(items.stream()) : null; + + if (ret != null && !items.isEmpty()) { + LOGGER.warn("Failed to enahnce {} ingredient has multiple input items", name); + return null; + } + + return ret; } - @SuppressWarnings("unchecked") - private static R getField(Class clz, T inst, int index) { - Field fld = clz.getDeclaredFields()[index]; - fld.setAccessible(true); - try { - return (R) fld.get(inst); - } catch (IllegalArgumentException | IllegalAccessException e) { - throw new RuntimeException(e); + public static class Runner extends RecipeProvider.Runner { + public Runner(PackOutput output, CompletableFuture registries) { + super(output, registries); + } + + @Override + public String getName() { + return ForgeRecipeProvider.class.getSimpleName(); + } + + @Override + protected RecipeProvider createRecipeProvider(Provider registries, RecipeOutput output) { + return new ForgeRecipeProvider(registries, output); } } + + private static class Wrapped implements RecipeOutput { + private final RecipeOutput wrapped; + private ForgeRecipeProvider self; + + private Wrapped(RecipeOutput wrapped) { + this.wrapped = wrapped; + } + + private void setSelf(ForgeRecipeProvider self) { + this.self = self; + } + + @Override + public void accept(ResourceKey> id, Recipe recipe, AdvancementHolder advancement) { + var modified = self.enhance(id, recipe); + if (modified != null) + wrapped.accept(id, modified, null); + } + + @Override + public Builder advancement() { + return wrapped.advancement(); + } + + @Override + public void accept(ResourceKey> id, Recipe recipe, ResourceLocation advancementId, JsonElement advancement) { + var modified = self.enhance(id, recipe); + if (modified != null) + wrapped.accept(id, modified, null); + } + + @Override + public Provider registry() { + return wrapped.registry(); + } + + @Override + public void includeRootAdvancement() {} + } } diff --git a/src/main/java/net/minecraftforge/common/data/LanguageProvider.java b/src/main/java/net/minecraftforge/common/data/LanguageProvider.java index 11708a2891..5631b0c6fe 100644 --- a/src/main/java/net/minecraftforge/common/data/LanguageProvider.java +++ b/src/main/java/net/minecraftforge/common/data/LanguageProvider.java @@ -80,7 +80,7 @@ public abstract class LanguageProvider implements DataProvider { } public void add(ItemStack key, String name) { - add(key.getDescriptionId(), name); + add(key.getItem().getDescriptionId(), name); } public void addEnchantment(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 f79b6f2f2c..c9b0efb4d1 100644 --- a/src/main/java/net/minecraftforge/common/data/SoundDefinitionsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/SoundDefinitionsProvider.java @@ -26,8 +26,7 @@ import org.apache.logging.log4j.Logger; * Data provider for the {@code sounds.json} file, which identifies sound definitions * for the various sound events in Minecraft. */ -public abstract class SoundDefinitionsProvider implements DataProvider -{ +public abstract class SoundDefinitionsProvider implements DataProvider { private static final Logger LOGGER = LogManager.getLogger(); private final PackOutput output; private final String modId; @@ -42,8 +41,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider * @param modId The mod ID of the current mod. * @param helper The existing file helper provided by the event you are initializing this provider in. */ - protected SoundDefinitionsProvider(final PackOutput output, final String modId, final ExistingFileHelper helper) - { + protected SoundDefinitionsProvider(final PackOutput output, final String modId, final ExistingFileHelper helper) { this.output = output; this.modId = modId; this.helper = helper; @@ -55,13 +53,11 @@ public abstract class SoundDefinitionsProvider implements DataProvider public abstract void registerSounds(); @Override - public CompletableFuture run(CachedOutput cache) - { + public CompletableFuture run(CachedOutput cache) { this.sounds.clear(); this.registerSounds(); this.validate(); - if (!this.sounds.isEmpty()) - { + if (!this.sounds.isEmpty()) { return this.save(cache, this.output.getOutputFolder(PackOutput.Target.RESOURCE_PACK).resolve(this.modId).resolve("sounds.json")); } @@ -69,8 +65,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider } @Override - public String getName() - { + public String getName() { return "Sound Definitions"; } @@ -79,8 +74,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider * Creates a new {@link SoundDefinition}, which will host a set of * {@link SoundDefinition.Sound}s and the necessary parameters. */ - protected static SoundDefinition definition() - { + protected static SoundDefinition definition() { return SoundDefinition.definition(); } @@ -90,8 +84,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider * @param name The name of the sound to create. * @param type The type of sound to create. */ - protected static SoundDefinition.Sound sound(final ResourceLocation name, final SoundDefinition.SoundType type) - { + protected static SoundDefinition.Sound sound(final ResourceLocation name, final SoundDefinition.SoundType type) { return SoundDefinition.Sound.sound(name, type); } @@ -101,8 +94,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider * * @param name The name of the sound to create. */ - protected static SoundDefinition.Sound sound(final ResourceLocation name) - { + protected static SoundDefinition.Sound sound(final ResourceLocation name) { return sound(name, SoundDefinition.SoundType.SOUND); } @@ -112,8 +104,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider * @param name The name of the sound to create. * @param type The type of sound to create. */ - protected static SoundDefinition.Sound sound(final String name, final SoundDefinition.SoundType type) - { + protected static SoundDefinition.Sound sound(final String name, final SoundDefinition.SoundType type) { return sound(ResourceLocation.parse(name), type); } @@ -123,8 +114,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider * * @param name The name of the sound to create. */ - protected static SoundDefinition.Sound sound(final String name) - { + protected static SoundDefinition.Sound sound(final String name) { return sound(ResourceLocation.parse(name)); } @@ -139,8 +129,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider * @param soundEvent A {@code Supplier} for the given {@link SoundEvent}. * @param definition A {@link SoundDefinition} that defines the given sound. */ - protected void add(final Supplier soundEvent, final SoundDefinition definition) - { + protected void add(final Supplier soundEvent, final SoundDefinition definition) { this.add(soundEvent.get(), definition); } @@ -155,9 +144,8 @@ public abstract class SoundDefinitionsProvider implements DataProvider * @param soundEvent A {@link SoundEvent}. * @param definition The {@link SoundDefinition} that defines the given event. */ - protected void add(final SoundEvent soundEvent, final SoundDefinition definition) - { - this.add(soundEvent.getLocation(), definition); + protected void add(final SoundEvent soundEvent, final SoundDefinition definition) { + this.add(soundEvent.location(), definition); } /** @@ -167,8 +155,7 @@ public abstract class SoundDefinitionsProvider implements DataProvider * @param soundEvent The {@link ResourceLocation} that identifies the event. * @param definition The {@link SoundDefinition} that defines the given event. */ - protected void add(final ResourceLocation soundEvent, final SoundDefinition definition) - { + protected void add(final ResourceLocation soundEvent, final SoundDefinition definition) { this.addSounds(soundEvent.getPath(), definition); } @@ -184,42 +171,32 @@ public abstract class SoundDefinitionsProvider implements DataProvider * @param soundEvent The name of the {@link SoundEvent}. * @param definition The {@link SoundDefinition} that defines the given event. */ - protected void add(final String soundEvent, final SoundDefinition definition) - { + protected void add(final String soundEvent, final SoundDefinition definition) { this.add(ResourceLocation.parse(soundEvent), definition); } - private void addSounds(final String soundEvent, final SoundDefinition definition) - { + private void addSounds(final String soundEvent, final SoundDefinition definition) { if (this.sounds.put(soundEvent, definition) != null) - { throw new IllegalStateException("Sound event '" + this.modId + ":" + soundEvent + "' already exists"); - } } // Internal handling stuff - private void validate() - { + private void validate() { final List notValid = this.sounds.entrySet().stream() .filter(it -> !this.validate(it.getKey(), it.getValue())) .map(Map.Entry::getKey) .map(it -> this.modId + ":" + it) .toList(); if (!notValid.isEmpty()) - { throw new IllegalStateException("Found invalid sound events: " + notValid); - } } - private boolean validate(final String name, final SoundDefinition def) - { + private boolean validate(final String name, final SoundDefinition def) { return def.soundList().stream().allMatch(it -> this.validate(name,it)); } - private boolean validate(final String name, final SoundDefinition.Sound sound) - { - switch (sound.type()) - { + private boolean validate(final String name, final SoundDefinition.Sound sound) { + switch (sound.type()) { case SOUND: return this.validateSound(name, sound.name()); case EVENT: return this.validateEvent(name, sound.name()); } @@ -230,34 +207,27 @@ public abstract class SoundDefinitionsProvider implements DataProvider throw new IllegalArgumentException("The given sound '" + sound.name() + "' does not have a valid type: expected either SOUND or EVENT, but found " + sound.type()); } - private boolean validateSound(final String soundName, final ResourceLocation name) - { + private boolean validateSound(final String soundName, final ResourceLocation name) { final boolean valid = this.helper.exists(name, PackType.CLIENT_RESOURCES, ".ogg", "sounds"); - if (!valid) - { + if (!valid) { final String path = name.getNamespace() + ":sounds/" + name.getPath() + ".ogg"; LOGGER.warn("Unable to find corresponding OGG file '{}' for sound event '{}'", path, soundName); } return valid; } - private boolean validateEvent(final String soundName, final ResourceLocation name) - { + private boolean validateEvent(final String soundName, final ResourceLocation name) { final boolean valid = this.sounds.containsKey(soundName) || ForgeRegistries.SOUND_EVENTS.containsKey(name); if (!valid) - { LOGGER.warn("Unable to find event '{}' referenced from '{}'", name, soundName); - } return valid; } - private CompletableFuture save(final CachedOutput cache, final Path targetFile) - { + private CompletableFuture save(final CachedOutput cache, final Path targetFile) { return DataProvider.saveStable(cache, mapToJson(this.sounds), targetFile); } - private static JsonObject mapToJson(final Map map) - { + private static JsonObject mapToJson(final Map map) { final JsonObject obj = new JsonObject(); // namespaces are ignored when serializing map.forEach((k, v) -> obj.add(k, v.serialize())); diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBoat.java b/src/main/java/net/minecraftforge/common/extensions/IForgeAbstractBoat.java similarity index 82% rename from src/main/java/net/minecraftforge/common/extensions/IForgeBoat.java rename to src/main/java/net/minecraftforge/common/extensions/IForgeAbstractBoat.java index e7011c9462..0e56d31e77 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBoat.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeAbstractBoat.java @@ -6,15 +6,14 @@ package net.minecraftforge.common.extensions; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.vehicle.AbstractBoat; import net.minecraft.world.entity.vehicle.Boat; import net.minecraft.world.level.material.FluidState; import net.minecraftforge.fluids.FluidType; -public interface IForgeBoat -{ - private Boat self() - { - return (Boat) this; +public interface IForgeAbstractBoat { + private AbstractBoat self() { + return (AbstractBoat)this; } /** @@ -23,8 +22,7 @@ public interface IForgeBoat * @param state the state of the fluid * @return {@code true} if the boat can be used, {@code false} otherwise */ - default boolean canBoatInFluid(FluidState state) - { + default boolean canBoatInFluid(FluidState state) { return state.supportsBoating(self()); } @@ -34,8 +32,7 @@ public interface IForgeBoat * @param type the type of the fluid * @return {@code true} if the boat can be used, {@code false} otherwise */ - default boolean canBoatInFluid(FluidType type) - { + default boolean canBoatInFluid(FluidType type) { return type.supportsBoating(self()); } @@ -47,8 +44,7 @@ public interface IForgeBoat * @param rider the rider of the boat * @return {@code true} if the fluid height should be updated, {@code false} otherwise */ - default boolean shouldUpdateFluidWhileRiding(FluidState state, Entity rider) - { + default boolean shouldUpdateFluidWhileRiding(FluidState state, Entity rider) { return state.shouldUpdateWhileBoating(self(), rider); } } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeAbstractMinecart.java b/src/main/java/net/minecraftforge/common/extensions/IForgeAbstractMinecart.java index 426f9d6836..d5788eb9e3 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeAbstractMinecart.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeAbstractMinecart.java @@ -10,8 +10,7 @@ import net.minecraft.tags.BlockTags; import net.minecraft.core.BlockPos; import net.minecraft.util.Mth; -public interface IForgeAbstractMinecart -{ +public interface IForgeAbstractMinecart { public static float DEFAULT_MAX_SPEED_AIR_LATERAL = 0.4f; public static float DEFAULT_MAX_SPEED_AIR_VERTICAL = -1.0f; public static double DEFAULT_AIR_DRAG = 0.95f; @@ -23,8 +22,7 @@ public interface IForgeAbstractMinecart /** * Internal, returns the current spot to look for the attached rail. */ - default BlockPos getCurrentRailPosition() - { + default BlockPos getCurrentRailPosition() { int x = Mth.floor(self().getX()); int y = Mth.floor(self().getY()); int z = Mth.floor(self().getZ()); @@ -35,12 +33,6 @@ public interface IForgeAbstractMinecart double getMaxSpeedWithRail(); - /** - * Moved to allow overrides. - * This code handles minecart movement and speed capping when on a rail. - */ - void moveMinecartOnRail(BlockPos pos); - /** * Returns true if this cart can currently use rails. * This function is mainly used to gracefully detach a minecart from a rail. @@ -55,30 +47,6 @@ public interface IForgeAbstractMinecart */ void setCanUseRail(boolean use); - /** - * Return false if this cart should not call onMinecartPass() and should ignore Powered Rails. - * @return True if this cart should call onMinecartPass(). - */ - default boolean shouldDoRailFunctions() { - return true; - } - - /** - * Returns true if this cart is self propelled. - * @return True if powered. - */ - default boolean isPoweredCart() { - return self().getMinecartType() == AbstractMinecart.Type.FURNACE; - } - - /** - * Returns true if this cart can be ridden by an Entity. - * @return True if this cart can be ridden. - */ - default boolean canBeRidden() { - return self().getMinecartType() == AbstractMinecart.Type.RIDEABLE; - } - /** * Returns the carts max speed when traveling on rails. Carts going faster * than 1.1 cause issues with chunk loading. Carts cant traverse slopes or @@ -107,10 +75,6 @@ public interface IForgeAbstractMinecart double getDragAir(); void setDragAir(double value); - default double getSlopeAdjustment() { - return 0.0078125D; - } - /** * Called from Detector Rails to retrieve a redstone power level for comparators. */ diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java index 3bf557a7ac..8a052ce671 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java @@ -666,7 +666,7 @@ public interface IForgeBlock { * @param pos Block position in level * @param explosion The explosion instance affecting the block */ - default void onBlockExploded(BlockState state, Level level, BlockPos pos, Explosion explosion) { + default void onBlockExploded(BlockState state, ServerLevel level, BlockPos pos, Explosion explosion) { level.setBlock(pos, Blocks.AIR.defaultBlockState(), 3); self().wasExploded(level, pos, explosion); } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java index f968f9a5cb..85ae8cc026 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java @@ -575,7 +575,7 @@ public interface IForgeBlockState { * @param pos Block position in level * @param explosion The explosion instance affecting the block */ - default void onBlockExploded(Level level, BlockPos pos, Explosion explosion) { + default void onBlockExploded(ServerLevel level, BlockPos pos, Explosion explosion) { self().getBlock().onBlockExploded(self(), level, pos, explosion); } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java b/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java index babbc574df..3f01d35f4b 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java @@ -11,7 +11,7 @@ import java.util.function.BiPredicate; import net.minecraft.sounds.SoundEvent; import net.minecraft.world.entity.boss.enderdragon.EnderDragon; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.entity.vehicle.AbstractBoat; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.entity.Entity; @@ -19,6 +19,7 @@ import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.item.ItemStack; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.core.BlockPos; import net.minecraft.core.HolderLookup; import net.minecraft.world.level.material.FluidState; @@ -115,7 +116,7 @@ public interface IForgeEntity extends ICapabilitySerializable { * @param fallDistance The fall distance * @return {@code true} if this entity can trample, {@code false} otherwise */ - boolean canTrample(BlockState state, BlockPos pos, float fallDistance); + boolean canTrample(ServerLevel level, BlockState state, BlockPos pos, float fallDistance); /** * Returns The classification of this entity @@ -381,13 +382,13 @@ public interface IForgeEntity extends ICapabilitySerializable { /** * When {@code false}, the fluid will no longer update its height value while - * within a boat while it is not within a fluid ({@link Boat#isUnderWater()}. + * within a boat while it is not within a fluid ({@link AbstractBoat#isUnderWater()}. * * @param state the state of the fluid the rider is within * @param boat the boat the rider is within that is not inside a fluid * @return {@code true} if the fluid height should be updated, {@code false} otherwise */ - default boolean shouldUpdateFluidWhileBoating(FluidState state, Boat boat) { + default boolean shouldUpdateFluidWhileBoating(FluidState state, AbstractBoat boat) { return boat.shouldUpdateFluidWhileRiding(state, self()); } } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java b/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java index a59d48ae04..781df3a2e3 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java @@ -6,13 +6,13 @@ package net.minecraftforge.common.extensions; import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.entity.vehicle.AbstractBoat; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.pathfinder.PathType; @@ -68,7 +68,7 @@ public interface IForgeFluid { * @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, Level level, BlockPos pos) { + default boolean canConvertToSource(FluidState state, ServerLevel level, BlockPos pos) { return getFluidType().canConvertToSource(state, level, pos); } @@ -79,20 +79,20 @@ public interface IForgeFluid { * @param boat the boat trying to be used on the fluid * @return {@code true} if the boat can be used, {@code false} otherwise */ - default boolean supportsBoating(FluidState state, Boat boat) { + default boolean supportsBoating(FluidState state, AbstractBoat boat) { return getFluidType().supportsBoating(state, boat); } /** * When {@code false}, the fluid will no longer update its height value while - * within a boat while it is not within a fluid ({@link Boat#isUnderWater()}. + * within a boat while it is not within a fluid ({@link AbstractBoat#isUnderWater()}. * * @param state the state of the fluid the rider is within * @param boat the boat the rider is within that is not inside a fluid * @param rider the rider of the boat * @return {@code true} if the fluid height should be updated, {@code false} otherwise */ - default boolean shouldUpdateWhileBoating(FluidState state, Boat boat, Entity rider) { + default boolean shouldUpdateWhileBoating(FluidState state, AbstractBoat boat, Entity rider) { return getFluidType().shouldUpdateWhileBoating(state, boat, rider); } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java b/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java index 36f087c474..6598218ac9 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java @@ -6,13 +6,14 @@ package net.minecraftforge.common.extensions; import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.vehicle.AbstractBoat; 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.block.state.BlockState; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.pathfinder.PathType; @@ -67,7 +68,7 @@ public interface IForgeFluidState { * @param pos the location of the fluid * @return {@code true} if the fluid can create a source, {@code false} otherwise */ - default boolean canConvertToSource(Level level, BlockPos pos) { + default boolean canConvertToSource(ServerLevel level, BlockPos pos) { return self().getType().canConvertToSource(self(), level, pos); } @@ -77,7 +78,7 @@ public interface IForgeFluidState { * @param boat the boat trying to be used on the fluid * @return {@code true} if the boat can be used, {@code false} otherwise */ - default boolean supportsBoating(Boat boat) { + default boolean supportsBoating(AbstractBoat boat) { return self().getType().supportsBoating(self(), boat); } @@ -89,7 +90,7 @@ public interface IForgeFluidState { * @param rider the rider of the boat * @return {@code true} if the fluid height should be updated, {@code false} otherwise */ - default boolean shouldUpdateWhileBoating(Boat boat, Entity rider) { + default boolean shouldUpdateWhileBoating(AbstractBoat boat, Entity rider) { return self().getType().shouldUpdateWhileBoating(self(), boat, rider); } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeFriendlyByteBuf.java b/src/main/java/net/minecraftforge/common/extensions/IForgeFriendlyByteBuf.java deleted file mode 100644 index 3e3dfebfba..0000000000 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeFriendlyByteBuf.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.common.extensions; - -import com.google.common.base.Preconditions; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.registries.ForgeRegistry; -import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.RegistryManager; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; - -/** - * Extension-Interface providing methods for writing registry-id's instead of their registry-names. - * / -public interface IForgeFriendlyByteBuf { - private FriendlyByteBuf self() { - return (FriendlyByteBuf)this; - } - - /** - * Writes the given entries integer id to the buffer. Notice however that this will only write the id of the given entry and will not check whether it actually exists - * in the given registry. Therefore no safety checks can be performed whilst reading it and if the entry is not in the registry a default value will be written. - * @param registry The registry containing the given entry - * @param entry The entry who's registryName is to be written - * @param The type of the entry. - * / - default void writeRegistryIdUnsafe(@NotNull IForgeRegistry registry, @NotNull T entry) { - ForgeRegistry forgeRegistry = (ForgeRegistry) registry; - int id = forgeRegistry.getID(entry); - self().writeVarInt(id); - } - - /** - * Writes the given entries integer id to the buffer. Notice however that this will only write the id of the given entry and will not check whether it actually exists - * in the given registry. Therefore no safety checks can be performed whilst reading it and if the entry is not in the registry a default value will be written. - * @param registry The registry containing the entry represented by this key - * @param entryKey The registry-name of an entry in this {@link IForgeRegistry} - * / - default void writeRegistryIdUnsafe(@NotNull IForgeRegistry registry, @NotNull ResourceLocation entryKey) { - ForgeRegistry forgeRegistry = (ForgeRegistry) registry; - int id = forgeRegistry.getID(entryKey); - self().writeVarInt(id); - } - - /** - * Reads an integer value from the buffer, which will be interpreted as an registry-id in the given registry. Notice that if there is no value in the specified registry for the - * read id, that the registry's default value will be returned. - * @param registry The registry containing the entry - * / - default T readRegistryIdUnsafe(@NotNull IForgeRegistry registry) { - ForgeRegistry forgeRegistry = (ForgeRegistry) registry; - int id = self().readVarInt(); - return forgeRegistry.getValue(id); - } - - /** - * Writes a given registry-entry's integer id to the specified buffer in combination with writing the containing registry's id. In contrast to - * {@link #writeRegistryIdUnsafe(IForgeRegistry, Object)} this method checks every single step performed as well as - * writing the registry-id to the buffer, in order to prevent any unexpected behaviour. Therefore this method is to be preferred whenever possible, - * over using the unsafe methods. - * - * @param registry The registry containing the entry - * @param entry The entry to write - * @param The type of the registry-entry - * @throws NullPointerException if the registry or entry was null - * @throws IllegalArgumentException if the registry does not contain the specified value - * / - default void writeRegistryId(@NotNull IForgeRegistry registry, @NotNull T entry) { - Objects.requireNonNull(registry, "Cannot write a null registry key!"); - Objects.requireNonNull(entry,"Cannot write a null registry entry!"); - ResourceLocation name = registry.getRegistryName(); - Preconditions.checkArgument(registry.containsValue(entry), "Cannot find %s in %s", registry.getKey(entry) != null ? registry.getKey(entry) : entry, name); - ForgeRegistry reg = (ForgeRegistry) registry; - self().writeResourceLocation(name); //TODO change to writing a varInt once registries use id's - self().writeVarInt(reg.getID(entry)); - } - - /** - * Reads an registry-entry from the specified buffer. Notice however that the type cannot be checked without providing an additional class parameter - * - see {@link #readRegistryIdSafe(Class)} for an safe version. - * @param The type of the registry-entry. Notice that this should match the actual type written to the buffer. - * @throws NullPointerException if the registry could not be found. - * / - default T readRegistryId() { - ResourceLocation location = self().readResourceLocation(); //TODO change to reading a varInt once registries use id's - ForgeRegistry registry = RegistryManager.ACTIVE.getRegistry(location); - return registry.getValue(self().readVarInt()); - } - - /** - * Reads an registry-entry from the specified buffer. This method also verifies, that the value read is of the appropriate type. - * @param The type of the registry-entry. - * @throws IllegalArgumentException if the retrieved entries registryType doesn't match the one passed in. - * @throws NullPointerException if the registry could not be found. - * / - default T readRegistryIdSafe(Class registrySuperType) { - T value = readRegistryId(); - if (!registrySuperType.isAssignableFrom(value.getClass())) - throw new IllegalArgumentException("Attempted to read an registryValue of the wrong type from the Buffer!"); - return value; - } - - /** - * Writes a FluidStack to the packet buffer, easy enough. If EMPTY, writes a FALSE. - * This behavior provides parity with the ItemStack method in PacketBuffer. - * - * @param stack FluidStack to be written to the packet buffer. - * / - default void writeFluidStack(FluidStack stack) { - if (stack.isEmpty()) - self().writeBoolean(false); - else { - self().writeBoolean(true); - stack.writeToPacket(self()); - } - } - - /** - * Reads a FluidStack from this buffer. - * / - default FluidStack readFluidStack() { - return !self().readBoolean() ? FluidStack.EMPTY : FluidStack.readFromPacket(self()); - } -} -*/ diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeGameTestHelper.java b/src/main/java/net/minecraftforge/common/extensions/IForgeGameTestHelper.java index 07b7620a91..5b8d2b3678 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeGameTestHelper.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeGameTestHelper.java @@ -50,6 +50,7 @@ public interface IForgeGameTestHelper { } }; var connection = new Connection(PacketFlow.SERVERBOUND); + @SuppressWarnings("unused") // The constructor has side effects var channel = new EmbeddedChannel(connection); var server = level.getServer(); diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java index c8f186a8e3..3ee2a78acb 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java @@ -10,25 +10,22 @@ import java.util.function.Consumer; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.item.*; -import net.minecraft.world.item.component.ItemAttributeModifiers; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.phys.AABB; -import net.minecraft.world.level.block.Blocks; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.monster.EnderMan; +import net.minecraft.world.entity.monster.Monster; import net.minecraft.world.entity.monster.piglin.PiglinAi; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.entity.EquipmentSlotGroup; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.InteractionResult; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.ItemTags; import net.minecraft.world.level.Level; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.ToolAction; @@ -43,21 +40,6 @@ public interface IForgeItem { return (Item)this; } - /** - * @deprecated In favor of {@link #getDefaultAttributeModifiers(ItemStack)} as it matches vanilla name, and not all cases that call this has the EquipmentSlot argument - */ - @Deprecated(forRemoval = true, since = "1.21") - default ItemAttributeModifiers getAttributeModifiers(EquipmentSlot slot, ItemStack stack) { - return getDefaultAttributeModifiers(stack); - } - - /** - * ItemStack sensitive version of {@link Item#getDefaultAttributeModifiers} - */ - default ItemAttributeModifiers getDefaultAttributeModifiers(ItemStack stack) { - return self().getDefaultAttributeModifiers(); - } - /** * Called when a player drops the item into the world, returning false from this * will prevent the item from being removed from the players inventory and @@ -110,7 +92,7 @@ public interface IForgeItem { * @return True if piglins are neutral to players wearing this item in an armor slot */ default boolean makesPiglinsNeutral(ItemStack stack, LivingEntity wearer) { - return stack.getItem() instanceof ArmorItem && ((ArmorItem) stack.getItem()).getMaterial() == ArmorMaterials.GOLD; + return stack.is(ItemTags.PIGLIN_SAFE_ARMOR); } /** @@ -163,28 +145,15 @@ public interface IForgeItem { } /** - * ItemStack sensitive version of {@link Item#getCraftingRemainingItem()}. + * ItemStack sensitive version of {@link Item#getCraftingRemainder()}. * Returns a full ItemStack instance of the result. * * @param itemStack The current ItemStack * @return The resulting ItemStack */ @SuppressWarnings("deprecation") - default ItemStack getCraftingRemainingItem(ItemStack itemStack) { - if (!hasCraftingRemainingItem(itemStack)) - return ItemStack.EMPTY; - return new ItemStack(self().getCraftingRemainingItem()); - } - - /** - * ItemStack sensitive version of {@link Item#hasCraftingRemainingItem()}. - * - * @param stack The current item stack - * @return True if this item has a crafting remaining item - */ - @SuppressWarnings("deprecation") - default boolean hasCraftingRemainingItem(ItemStack stack) { - return self().hasCraftingRemainingItem(); + default ItemStack getCraftingRemainder(ItemStack itemStack) { + return self().getCraftingRemainder(); } /** @@ -324,10 +293,12 @@ public interface IForgeItem { * @param inner Weither or not to use the inner texture layer. * @return Path of texture to bind, or null to use default */ + /* @Nullable - default ResourceLocation getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, ArmorMaterial.Layer layer, boolean inner) { + default ResourceLocation getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, EquipmentModel.Layer layer, boolean inner) { return null; } + */ /** * Called when a entity tries to play the 'swing' animation. @@ -350,17 +321,6 @@ public interface IForgeItem { return false; } - /** - * ItemStack sensitive version of {@link Item#getEnchantmentValue()}. - * - * @param stack The ItemStack - * @return the enchantment value - */ - @SuppressWarnings("deprecation") - default int getEnchantmentValue(ItemStack stack) { - return self().getEnchantmentValue(); - } - /** * Checks whether an item can be enchanted with a certain enchantment. This * applies specifically to enchanting an item in the enchanting table and is @@ -512,15 +472,15 @@ public interface IForgeItem { } /** - * Whether this Item can be used to hide player head for enderman. + * Whether this Item can be used to hide player the player from a monster * * @param stack the ItemStack - * @param player The player watching the enderman - * @param endermanEntity The enderman that the player look - * @return true if this Item can be used to hide player head for enderman + * @param player The player watching the monster + * @param monster The monster that the player look + * @return true if this Item can be used to hide player from monsters */ - default boolean isEnderMask(ItemStack stack, Player player, EnderMan endermanEntity) { - return stack.getItem() == Blocks.CARVED_PUMPKIN.asItem(); + default boolean isMonsterDisguise(ItemStack stack, Player player, Monster monster) { + return stack.is(ItemTags.GAZE_DISGUISE_EQUIPMENT); } /** diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java b/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java index d6e89cc4ad..82feb71bd3 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java @@ -6,7 +6,7 @@ package net.minecraftforge.common.extensions; import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.monster.EnderMan; +import net.minecraft.world.entity.monster.Monster; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.block.state.pattern.BlockInWorld; @@ -18,10 +18,8 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.entity.EquipmentSlotGroup; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.component.ItemAttributeModifiers; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.stats.Stats; import net.minecraft.world.InteractionResult; @@ -43,22 +41,13 @@ public interface IForgeItemStack { } /** - * ItemStack sensitive version of {@link Item#getCraftingRemainingItem()}. + * ItemStack sensitive version of {@link Item#getCraftingRemainder()}. * Returns a full ItemStack instance of the result. * * @return The resulting ItemStack */ - default ItemStack getCraftingRemainingItem() { - return self().getItem().getCraftingRemainingItem(self()); - } - - /** - * ItemStack sensitive version of {@link Item#hasCraftingRemainingItem()}. - * - * @return True if this item has a crafting remaining item - */ - default boolean hasCraftingRemainingItem() { - return self().getItem().hasCraftingRemainingItem(self()); + default ItemStack getCraftingRemainder() { + return self().getItem().getCraftingRemainder(self()); } /** @@ -139,15 +128,6 @@ public interface IForgeItemStack { return self().getItem().canApplyAtEnchantingTable(self(), enchantment); } - /** - * ItemStack sensitive version of {@link Item#getEnchantmentValue()}. - * - * @return the enchantment value of this ItemStack - */ - default int getEnchantmentValue() { - return self().getItem().getEnchantmentValue(self()); - } - /** * Override this to set a non-default armor slot for an ItemStack, but do * not use this to get the armor slot of said stack; for that, use @@ -316,14 +296,14 @@ public interface IForgeItemStack { } /** - * Whether this Item can be used to hide player head for enderman. + * Whether this Item can be used to hide player from enderman/Creaking. * * @param player The player watching the enderman - * @param endermanEntity The enderman that the player look + * @param monster The monster you're trying to hide from * @return true if this Item can be used. */ - default boolean isEnderMask(Player player, EnderMan endermanEntity) { - return self().getItem().isEnderMask(self(), player, endermanEntity); + default boolean isMonsterDisguise(Player player, Monster monster) { + return self().getItem().isMonsterDisguise(self(), player, monster); } /** @@ -405,11 +385,4 @@ public interface IForgeItemStack { default boolean canGrindstoneRepair() { return self().getItem().canGrindstoneRepair(self()); } - - /** - * ItemStack and Slot sensitive version of {@link Item#getItemAttributeModifiers} - */ - default ItemAttributeModifiers getDefaultAttributeModifiers() { - return self().getItem().getDefaultAttributeModifiers(self()); - } } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeResourceKey.java b/src/main/java/net/minecraftforge/common/extensions/IForgeResourceKey.java index f815cb1022..eef780c739 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeResourceKey.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeResourceKey.java @@ -37,6 +37,6 @@ public interface IForgeResourceKey { */ default Holder getOrThrow(RegistryAccess registryAccess) { Objects.requireNonNull(registryAccess, "registryAccess was null"); - return registryAccess.registryOrThrow(self().registryKey()).getHolderOrThrow(self()); + return registryAccess.lookupOrThrow(self().registryKey()).getOrThrow(self()); } } diff --git a/src/main/java/net/minecraftforge/common/loot/CanToolPerformAction.java b/src/main/java/net/minecraftforge/common/loot/CanToolPerformAction.java index 88c8695b8e..62129a0ed5 100644 --- a/src/main/java/net/minecraftforge/common/loot/CanToolPerformAction.java +++ b/src/main/java/net/minecraftforge/common/loot/CanToolPerformAction.java @@ -9,9 +9,9 @@ import com.google.common.collect.ImmutableSet; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.util.context.ContextKey; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.storage.loot.LootContext; -import net.minecraft.world.level.storage.loot.parameters.LootContextParam; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType; @@ -35,13 +35,13 @@ public record CanToolPerformAction(ToolAction action) implements LootItemConditi } @Override - public @NotNull Set> getReferencedContextParams() { + public @NotNull Set> getReferencedContextParams() { return ImmutableSet.of(LootContextParams.TOOL); } @Override public boolean test(LootContext ctx) { - ItemStack itemstack = ctx.getParamOrNull(LootContextParams.TOOL); + ItemStack itemstack = ctx.getOptionalParameter(LootContextParams.TOOL); return itemstack != null && itemstack.canPerformAction(this.action); } diff --git a/src/main/java/net/minecraftforge/common/loot/IGlobalLootModifier.java b/src/main/java/net/minecraftforge/common/loot/IGlobalLootModifier.java index 3f55f63f94..b9d4144ab2 100644 --- a/src/main/java/net/minecraftforge/common/loot/IGlobalLootModifier.java +++ b/src/main/java/net/minecraftforge/common/loot/IGlobalLootModifier.java @@ -14,8 +14,8 @@ import com.mojang.serialization.MapCodec; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; -import net.minecraft.world.level.storage.loot.predicates.LootItemConditions; import net.minecraftforge.registries.ForgeRegistries; import org.jetbrains.annotations.NotNull; @@ -49,7 +49,7 @@ public interface IGlobalLootModifier { * @return modified loot drops */ @NotNull - ObjectArrayList apply(ObjectArrayList generatedLoot, LootContext context); + ObjectArrayList apply(LootTable table, ObjectArrayList generatedLoot, LootContext context); /** * Returns the registered codec for this modifier diff --git a/src/main/java/net/minecraftforge/common/loot/LootModifier.java b/src/main/java/net/minecraftforge/common/loot/LootModifier.java index 2bfd13d82e..9d884089d1 100644 --- a/src/main/java/net/minecraftforge/common/loot/LootModifier.java +++ b/src/main/java/net/minecraftforge/common/loot/LootModifier.java @@ -15,6 +15,7 @@ import net.minecraft.Util; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.levelgen.feature.trunkplacers.BendingTrunkPlacer; import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; import org.jetbrains.annotations.NotNull; @@ -51,8 +52,8 @@ public abstract class LootModifier implements IGlobalLootModifier { @NotNull @Override - public final ObjectArrayList apply(ObjectArrayList generatedLoot, LootContext context) { - return this.combinedConditions.test(context) ? this.doApply(generatedLoot, context) : generatedLoot; + public final ObjectArrayList apply(LootTable table, ObjectArrayList generatedLoot, LootContext context) { + return this.combinedConditions.test(context) ? this.doApply(table, generatedLoot, context) : generatedLoot; } /** @@ -63,5 +64,5 @@ public abstract class LootModifier implements IGlobalLootModifier { * @return modified loot drops */ @NotNull - protected abstract ObjectArrayList doApply(ObjectArrayList generatedLoot, LootContext context); + protected abstract ObjectArrayList doApply(LootTable table, ObjectArrayList generatedLoot, LootContext context); } diff --git a/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java b/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java index 619b69b675..32925161a6 100644 --- a/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java +++ b/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java @@ -22,20 +22,21 @@ import com.google.gson.JsonObject; import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener; import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.util.ExtraCodecs; import net.minecraft.util.GsonHelper; -import net.minecraft.core.RegistryAccess; +import net.minecraft.core.HolderLookup; import net.minecraft.resources.ResourceLocation; -public class LootModifierManager extends SimpleJsonResourceReloadListener { +public class LootModifierManager extends SimpleJsonResourceReloadListener { private static final Logger LOGGER = LogManager.getLogger(); private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); private static final String FOLDER = "loot_modifiers"; - private final RegistryAccess registries; + private final HolderLookup.Provider registries; private Map modifiers = ImmutableMap.of(); - public LootModifierManager(RegistryAccess registries) { - super(GSON, FOLDER); + public LootModifierManager(HolderLookup.Provider registries) { + super(registries, ExtraCodecs.JSON, FOLDER); this.registries = registries; } diff --git a/src/main/java/net/minecraftforge/common/util/DummySavedData.java b/src/main/java/net/minecraftforge/common/util/DummySavedData.java deleted file mode 100644 index 5a63675814..0000000000 --- a/src/main/java/net/minecraftforge/common/util/DummySavedData.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.common.util; - -import net.minecraft.core.HolderLookup; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.level.saveddata.SavedData; - -public class DummySavedData extends SavedData { - public static final DummySavedData DUMMY = new DummySavedData(); - private DummySavedData() { - super(); - } - - @Override - public CompoundTag save(final CompoundTag compound, HolderLookup.Provider lookup) { - return null; - } -} diff --git a/src/main/java/net/minecraftforge/common/util/RecipeMatcher.java b/src/main/java/net/minecraftforge/common/util/RecipeMatcher.java index e71030621d..c4866647b0 100644 --- a/src/main/java/net/minecraftforge/common/util/RecipeMatcher.java +++ b/src/main/java/net/minecraftforge/common/util/RecipeMatcher.java @@ -11,8 +11,7 @@ import java.util.List; import java.util.Queue; import java.util.function.Predicate; -public class RecipeMatcher -{ +public class RecipeMatcher { /** * Attempts to match inputs to the specified tests. In the best way that all inputs are used by one test. * Will return null in any of these cases: @@ -23,8 +22,7 @@ public class RecipeMatcher * * @return An array mapping inputs to tests. ret[x] = y means input[x] = test[y] */ - public static int[] findMatches(List inputs, List> tests) - { + public static int[] findMatches(List inputs, List> tests) { int elements = inputs.size(); if (elements != tests.size()) return null; // There will not be a 1:1 mapping of inputs -> tests @@ -35,19 +33,16 @@ public class RecipeMatcher // [UnusedInputs] [UnusedIngredients] [IngredientMatchMask]... BitSet data = new BitSet((elements + 2) * elements); - for (int x = 0; x < elements; x++) - { + for (int x = 0; x < elements; x++) { int matched = 0; int offset = (x + 2) * elements; Predicate test = tests.get(x); - for (int y = 0; y < elements; y++) - { + for (int y = 0; y < elements; y++) { if (data.get(y)) continue; - if (test.test(inputs.get(y))) - { + if (test.test(inputs.get(y))) { data.set(offset + y); matched++; } @@ -56,8 +51,7 @@ public class RecipeMatcher if (matched == 0) return null; //We have an test that matched non of the inputs - if (matched == 1) - { + if (matched == 1) { if (!claim(ret, data, x, elements)) return null; //We failed to claim this index, which means it caused something else to go to 0 matches, which makes the whole thing fail } @@ -66,7 +60,7 @@ public class RecipeMatcher if (data.nextClearBit(0) >= elements) //All items have been used, which means all tests have a match! return ret; - // We should be in a state where multiple tests are satified by multiple inputs. So we need to try a branching recursive test. + // We should be in a state where multiple tests are satisfied by multiple inputs. So we need to try a branching recursive test. // However for performance reasons, we should probably make that check a sub-set of the entire graph. if (backtrack(data, ret, 0, elements)) return ret; @@ -75,13 +69,11 @@ public class RecipeMatcher } // This is bad... need to think of a better cascade, recursion instead of stack? - private static boolean claim(int[] ret, BitSet data, int claimed, int elements) - { + private static boolean claim(int[] ret, BitSet data, int claimed, int elements) { Queue pending = new LinkedList(); pending.add(claimed); - while (pending.peek() != null) - { + while (pending.peek() != null) { int test = pending.poll(); int offset = (test + 2) * elements; int used = data.nextSetBit(offset) - offset; @@ -93,11 +85,9 @@ public class RecipeMatcher data.set(elements + test); ret[used] = test; - for (int x = 0; x < elements; x++) - { + for (int x = 0; x < elements; x++) { offset = (x + 2) * elements; - if (data.get(offset + used) && !data.get(elements + x)) - { + if (data.get(offset + used) && !data.get(elements + x)) { data.clear(offset + used); int count = 0; for (int y = offset; y < offset + elements; y++) @@ -117,32 +107,29 @@ public class RecipeMatcher } //We use recursion here, why? Because I feel like it. Also because we should only ever be working in data sets < 9 - private static boolean backtrack(BitSet data, int[] ret, int start, int elements) - { - int test = data.nextClearBit(elements + start) - elements; - if (test >= elements) - return true; //Could not find the next unused test. + private static boolean backtrack(BitSet data, int[] ret, int start, int elements) { + int test = data.nextClearBit(elements + start) - elements; + if (test >= elements) + return true; //Could not find the next unused test. - if (test < 0) - throw new IllegalStateException("This should never happen, negative test in backtrack!"); + if (test < 0) + throw new IllegalStateException("This should never happen, negative test in backtrack!"); - int offset = (test + 2) * elements; - for (int x = 0; x < elements; x++) - { - if (!data.get(offset + x) || data.get(x)) - continue; + int offset = (test + 2) * elements; + for (int x = 0; x < elements; x++) { + if (!data.get(offset + x) || data.get(x)) + continue; - data.set(x); + data.set(x); - if (backtrack(data, ret, test + 1, elements)) - { - ret[x] = test; - return true; + if (backtrack(data, ret, test + 1, elements)) { + ret[x] = test; + return true; + } + + data.clear(x); } - data.clear(x); - } - - return false; + return false; } } diff --git a/src/main/java/net/minecraftforge/common/world/BiomeGenerationSettingsBuilder.java b/src/main/java/net/minecraftforge/common/world/BiomeGenerationSettingsBuilder.java deleted file mode 100644 index 9412a7ee28..0000000000 --- a/src/main/java/net/minecraftforge/common/world/BiomeGenerationSettingsBuilder.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.common.world; - -import java.util.ArrayList; -import java.util.List; -import net.minecraft.core.Holder; -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; - -public class BiomeGenerationSettingsBuilder extends BiomeGenerationSettings.PlainBuilder -{ - public BiomeGenerationSettingsBuilder(BiomeGenerationSettings orig) - { - for (GenerationStep.Carving k : orig.getCarvingStages()) { - carvers.put(k, new ArrayList<>()); - for (Holder> v : orig.getCarvers(k)) { - carvers.get(k).add(v); - } - } - orig.features().forEach(l -> { - final ArrayList> featureList = new ArrayList<>(); - l.forEach(featureList::add); - features.add(featureList); - }); - } - - public List> getFeatures(GenerationStep.Decoration stage) { - addFeatureStepsUpTo(stage.ordinal()); - return features.get(stage.ordinal()); - } - - public List>> getCarvers(GenerationStep.Carving stage) { - return carvers.computeIfAbsent(stage, key -> new ArrayList<>()); - } -} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java b/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java index be5257d7bd..de68e41557 100644 --- a/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java +++ b/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java @@ -56,7 +56,7 @@ public final class ForgeBiomeModifiers { @Override public void modify(Holder biome, Phase phase, Builder builder) { if (phase == Phase.ADD && this.biomes.contains(biome)) { - BiomeGenerationSettingsBuilder generationSettings = builder.getGenerationSettings(); + var generationSettings = builder.getGenerationSettings(); this.features.forEach(holder -> generationSettings.addFeature(this.step, holder)); } } @@ -105,7 +105,7 @@ public final class ForgeBiomeModifiers { @Override public void modify(Holder biome, Phase phase, Builder builder) { if (phase == Phase.REMOVE && this.biomes.contains(biome)) { - BiomeGenerationSettingsBuilder generationSettings = builder.getGenerationSettings(); + var generationSettings = builder.getGenerationSettings(); for (Decoration step : this.steps) generationSettings.getFeatures(step).removeIf(this.features::contains); } diff --git a/src/main/java/net/minecraftforge/common/world/ModifiableBiomeInfo.java b/src/main/java/net/minecraftforge/common/world/ModifiableBiomeInfo.java index 897386bec6..0d72cf6f4c 100644 --- a/src/main/java/net/minecraftforge/common/world/ModifiableBiomeInfo.java +++ b/src/main/java/net/minecraftforge/common/world/ModifiableBiomeInfo.java @@ -24,76 +24,67 @@ import net.minecraft.world.level.biome.MobSpawnSettings; * Memoizers are not used because it's important to return null * without evaluating the biome info if it's accessed outside of a server context. */ -public class ModifiableBiomeInfo -{ +public class ModifiableBiomeInfo { @NotNull private final BiomeInfo originalBiomeInfo; @Nullable private BiomeInfo modifiedBiomeInfo = null; - + /** * @param originalBiomeInfo BiomeInfo representing the original state of a biome when the biome was constructed. */ - public ModifiableBiomeInfo(@NotNull final BiomeInfo originalBiomeInfo) - { + public ModifiableBiomeInfo(@NotNull final BiomeInfo originalBiomeInfo) { this.originalBiomeInfo = originalBiomeInfo; } - + /** * {@return The modified biome info if modified biome info has been generated, otherwise gets original biome info} */ @NotNull - public BiomeInfo get() - { + public BiomeInfo get() { return this.modifiedBiomeInfo == null ? originalBiomeInfo : modifiedBiomeInfo; } - + /** * {@return The original biome info that the associated biome was created with} */ @NotNull - public BiomeInfo getOriginalBiomeInfo() - { + public BiomeInfo getOriginalBiomeInfo() { return this.originalBiomeInfo; } - + /** * {@return Modified biome info; null if it hasn't been set yet} */ @Nullable - public BiomeInfo getModifiedBiomeInfo() - { + public BiomeInfo getModifiedBiomeInfo() { return this.modifiedBiomeInfo; } - + /** * Internal forge method; the game will crash if mods invoke this. * Creates and caches the modified biome info. * @param biome named biome with original data. * @param biomeModifiers biome modifiers to apply. - * + * * @throws IllegalStateException if invoked more than once. */ @ApiStatus.Internal - public void applyBiomeModifiers(final Holder biome, final List biomeModifiers) - { + public void applyBiomeModifiers(final Holder biome, final List biomeModifiers) { if (this.modifiedBiomeInfo != null) throw new IllegalStateException(String.format(Locale.ENGLISH, "Biome %s already modified", biome)); - - BiomeInfo original = this.getOriginalBiomeInfo(); - final BiomeInfo.Builder builder = BiomeInfo.Builder.copyOf(original); - for (BiomeModifier.Phase phase : BiomeModifier.Phase.values()) - { - for (BiomeModifier modifier : biomeModifiers) - { + + var original = this.getOriginalBiomeInfo(); + var builder = BiomeInfo.Builder.copyOf(original); + for (var phase : BiomeModifier.Phase.values()) { + for (var modifier : biomeModifiers) modifier.modify(biome, phase, builder); - } } this.modifiedBiomeInfo = builder.build(); } - + /** * Record containing raw biome data. * @param climateSettings Weather and temperature settings. @@ -101,26 +92,24 @@ public class ModifiableBiomeInfo * @param generationSettings Worldgen features and carvers. * @param mobSpawnSettings Mob spawn settings. */ - public record BiomeInfo(ClimateSettings climateSettings, BiomeSpecialEffects effects, BiomeGenerationSettings generationSettings, MobSpawnSettings mobSpawnSettings) - { - public static class Builder - { + public record BiomeInfo(ClimateSettings climateSettings, BiomeSpecialEffects effects, BiomeGenerationSettings generationSettings, MobSpawnSettings mobSpawnSettings) { + public static class Builder { private ClimateSettingsBuilder climateSettings; private BiomeSpecialEffectsBuilder effects; - private BiomeGenerationSettingsBuilder generationSettings; + private BiomeGenerationSettings.PlainBuilder generationSettings; private MobSpawnSettingsBuilder mobSpawnSettings; - + /** * @param original the biome to copy * @return A ModifiedBiomeInfo.Builder with a copy of the biome's data */ - public static Builder copyOf(final BiomeInfo original) - { + public static Builder copyOf(final BiomeInfo original) { final ClimateSettingsBuilder climateBuilder = ClimateSettingsBuilder.copyOf(original.climateSettings()); final BiomeSpecialEffectsBuilder effectsBuilder = BiomeSpecialEffectsBuilder.copyOf(original.effects()); - final BiomeGenerationSettingsBuilder generationBuilder = new BiomeGenerationSettingsBuilder(original.generationSettings()); + final var generationBuilder = new BiomeGenerationSettings.PlainBuilder(); + generationBuilder.addFrom(original.generationSettings()); final MobSpawnSettingsBuilder mobSpawnBuilder = new MobSpawnSettingsBuilder(original.mobSpawnSettings()); - + return new Builder( climateBuilder, effectsBuilder, @@ -128,37 +117,31 @@ public class ModifiableBiomeInfo mobSpawnBuilder ); } - - private Builder(final ClimateSettingsBuilder climateSettings, final BiomeSpecialEffectsBuilder effects, final BiomeGenerationSettingsBuilder generationSettings, final MobSpawnSettingsBuilder mobSpawnSettings) - { + + private Builder(final ClimateSettingsBuilder climateSettings, final BiomeSpecialEffectsBuilder effects, final BiomeGenerationSettings.PlainBuilder generationSettings, final MobSpawnSettingsBuilder mobSpawnSettings) { this.climateSettings = climateSettings; this.effects = effects; this.generationSettings = generationSettings; this.mobSpawnSettings = mobSpawnSettings; } - public BiomeInfo build() - { + public BiomeInfo build() { return new BiomeInfo(this.climateSettings.build(), this.effects.build(), this.generationSettings.build(), this.mobSpawnSettings.build()); } - public ClimateSettingsBuilder getClimateSettings() - { + public ClimateSettingsBuilder getClimateSettings() { return climateSettings; } - public BiomeSpecialEffectsBuilder getSpecialEffects() - { + public BiomeSpecialEffectsBuilder getSpecialEffects() { return effects; } - public BiomeGenerationSettingsBuilder getGenerationSettings() - { + public BiomeGenerationSettings.PlainBuilder getGenerationSettings() { return generationSettings; } - public MobSpawnSettingsBuilder getMobSpawnSettings() - { + public MobSpawnSettingsBuilder getMobSpawnSettings() { return mobSpawnSettings; } } diff --git a/src/main/java/net/minecraftforge/event/AddReloadListenerEvent.java b/src/main/java/net/minecraftforge/event/AddReloadListenerEvent.java index d394fed423..db4a53195d 100644 --- a/src/main/java/net/minecraftforge/event/AddReloadListenerEvent.java +++ b/src/main/java/net/minecraftforge/event/AddReloadListenerEvent.java @@ -8,7 +8,6 @@ package net.minecraftforge.event; import com.google.common.collect.ImmutableList; import net.minecraft.core.RegistryAccess; import net.minecraft.server.ReloadableServerResources; -import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.server.packs.resources.PreparableReloadListener; import net.minecraft.server.packs.resources.ResourceManager; import net.minecraftforge.common.MinecraftForge; @@ -80,9 +79,9 @@ public class AddReloadListenerEvent extends Event { } @Override - public CompletableFuture reload(final PreparationBarrier stage, final ResourceManager resourceManager, final ProfilerFiller preparationsProfiler, final ProfilerFiller reloadProfiler, final Executor backgroundExecutor, final Executor gameExecutor) { + public CompletableFuture reload(final PreparationBarrier stage, final ResourceManager resourceManager, final Executor backgroundExecutor, final Executor gameExecutor) { if (ModLoader.isLoadingStateValid()) - return wrapped.reload(stage, resourceManager, preparationsProfiler, reloadProfiler, backgroundExecutor, gameExecutor); + return wrapped.reload(stage, resourceManager, backgroundExecutor, gameExecutor); else return CompletableFuture.completedFuture(null); } diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index 3ed3db2a97..d4acdd2326 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -15,7 +15,10 @@ import java.util.function.BooleanSupplier; import java.util.function.Consumer; import net.minecraft.core.component.DataComponentMap; +import net.minecraft.world.entity.*; import net.minecraft.world.item.Item; +import net.minecraft.world.level.chunk.storage.SerializableChunkData; +import net.minecraftforge.client.event.ToastAddEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; @@ -30,6 +33,7 @@ import com.mojang.brigadier.CommandDispatcher; import net.minecraft.advancements.AdvancementHolder; import net.minecraft.advancements.AdvancementProgress; +import net.minecraft.client.gui.components.toasts.Toast; import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; @@ -63,22 +67,9 @@ import net.minecraft.world.Difficulty; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.entity.AgeableMob; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.entity.ExperienceOrb; -import net.minecraft.world.entity.LightningBolt; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.MobCategory; -import net.minecraft.world.entity.MobSpawnType; -import net.minecraft.world.entity.SlotAccess; -import net.minecraft.world.entity.SpawnGroupData; import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.monster.Zombie; @@ -257,8 +248,8 @@ public final class ForgeEventFactory { return post(event); } - public static NeighborNotifyEvent onNeighborNotify(Level level, BlockPos pos, BlockState state, EnumSet notifiedSides, boolean forceRedstoneUpdate) { - return fire(new NeighborNotifyEvent(level, pos, state, notifiedSides, forceRedstoneUpdate)); + public static boolean onNeighborNotify(Level level, BlockPos pos, BlockState state, EnumSet notifiedSides, boolean forceRedstoneUpdate) { + return post(new NeighborNotifyEvent(level, pos, state, notifiedSides, forceRedstoneUpdate)); } public static boolean doPlayerHarvestCheck(Player player, BlockState state, boolean success) { @@ -278,7 +269,7 @@ public final class ForgeEventFactory { post(new PlayerDestroyItemEvent(player, stack, slot)); } - public static boolean checkSpawnPlacements(EntityType entityType, ServerLevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random, boolean defaultResult) { + public static boolean checkSpawnPlacements(EntityType entityType, ServerLevelAccessor level, EntitySpawnReason spawnType, BlockPos pos, RandomSource random, boolean defaultResult) { var result = fire(new SpawnPlacementCheck(entityType, level, spawnType, pos, random, defaultResult)).getResult(); return result == Result.DEFAULT ? defaultResult : result == Result.ALLOW; } @@ -292,7 +283,7 @@ public final class ForgeEventFactory { * @return True, if the position is valid, as determined by the contract of {@link PositionCheck}. * @see PositionCheck */ - public static boolean checkSpawnPosition(Mob mob, ServerLevelAccessor level, MobSpawnType spawnType) { + public static boolean checkSpawnPosition(Mob mob, ServerLevelAccessor level, EntitySpawnReason spawnType) { var result = fire(new PositionCheck(mob, level, spawnType, null)).getResult(); if (result == Result.DEFAULT) return mob.checkSpawnRules(level, spawnType) && mob.checkSpawnObstruction(level); @@ -304,7 +295,7 @@ public final class ForgeEventFactory { * @see #CheckSpawnPosition * @implNote See in-line comments about custom spawn rules. */ - public static boolean checkSpawnPositionSpawner(Mob mob, ServerLevelAccessor level, MobSpawnType spawnType, SpawnData spawnData, BaseSpawner spawner) { + public static boolean checkSpawnPositionSpawner(Mob mob, ServerLevelAccessor level, EntitySpawnReason spawnType, SpawnData spawnData, BaseSpawner spawner) { var result = fire(new PositionCheck(mob, level, spawnType, null)).getResult(); if (result == Result.DEFAULT) { // Spawners do not evaluate Mob#checkSpawnRules if any custom rules are present. This is despite the fact that these two methods do not check the same things. @@ -345,12 +336,12 @@ public final class ForgeEventFactory { */ @Nullable @SuppressWarnings("deprecation") // Call to deprecated Mob#finalizeSpawn is expected. - public static SpawnGroupData onFinalizeSpawn(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType spawnType, @Nullable SpawnGroupData spawnData) { + public static SpawnGroupData onFinalizeSpawn(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, EntitySpawnReason spawnType, @Nullable SpawnGroupData spawnData) { var event = new MobSpawnEvent.FinalizeSpawn(mob, level, mob.getX(), mob.getY(), mob.getZ(), difficulty, spawnType, spawnData, null, null); boolean cancel = post(event); if (!cancel) - return mob.finalizeSpawn(level, event.getDifficulty(), event.getSpawnType(), event.getSpawnData()); + return mob.finalizeSpawn(level, event.getDifficulty(), event.getSpawnReason(), event.getSpawnData()); return null; } @@ -363,7 +354,7 @@ public final class ForgeEventFactory { */ @Nullable public static MobSpawnEvent.FinalizeSpawn onFinalizeSpawnSpawner(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, @Nullable SpawnGroupData spawnData, @Nullable CompoundTag spawnTag, BaseSpawner spawner) { - return fire(new MobSpawnEvent.FinalizeSpawn(mob, level, mob.getX(), mob.getY(), mob.getZ(), difficulty, MobSpawnType.SPAWNER, spawnData, spawnTag, spawner)); + return fire(new MobSpawnEvent.FinalizeSpawn(mob, level, mob.getX(), mob.getY(), mob.getZ(), difficulty, EntitySpawnReason.SPAWNER, spawnData, spawnTag, spawner)); } public static Result canEntityDespawn(Mob entity, ServerLevelAccessor level) { @@ -469,23 +460,23 @@ public final class ForgeEventFactory { } @Nullable - public static InteractionResultHolder onBucketUse(@NotNull Player player, @NotNull Level level, @NotNull ItemStack stack, @Nullable HitResult target) { + public static InteractionResult onBucketUse(@NotNull Player player, @NotNull Level level, @NotNull ItemStack stack, @Nullable HitResult target) { var event = new FillBucketEvent(player, stack, level, target); if (post(event)) - return new InteractionResultHolder(InteractionResult.FAIL, stack); + return InteractionResult.FAIL; if (event.getResult() == Result.ALLOW) { if (player.getAbilities().instabuild) - return new InteractionResultHolder(InteractionResult.SUCCESS, stack); + return InteractionResult.SUCCESS.heldItemTransformedTo(stack); stack.shrink(1); if (stack.isEmpty()) - return new InteractionResultHolder(InteractionResult.SUCCESS, event.getFilledBucket()); + return InteractionResult.SUCCESS.heldItemTransformedTo(event.getFilledBucket()); if (!player.getInventory().add(event.getFilledBucket())) player.drop(event.getFilledBucket(), false); - return new InteractionResultHolder(InteractionResult.SUCCESS, stack); + return InteractionResult.SUCCESS.heldItemTransformedTo(stack); } return null; } @@ -557,8 +548,8 @@ public final class ForgeEventFactory { return post(new ExplosionEvent.Start(level, explosion)); } - public static void onExplosionDetonate(Level level, Explosion explosion, List list, double diameter) { - post(new ExplosionEvent.Detonate(level, explosion, list)); + public static void onExplosionDetonate(Level level, Explosion explosion, List blocks, List entities, double diameter) { + post(new ExplosionEvent.Detonate(level, explosion, blocks, entities)); } public static boolean onCreateWorldSpawn(Level level, ServerLevelData settings) { @@ -636,10 +627,10 @@ public final class ForgeEventFactory { return canContinueSleep == Result.ALLOW; } - public static InteractionResultHolder onArrowNock(ItemStack item, Level level, Player player, InteractionHand hand, boolean hasAmmo) { + public static InteractionResult onArrowNock(ItemStack item, Level level, Player player, InteractionHand hand, boolean hasAmmo) { var event = new ArrowNockEvent(player, item, hand, level, hasAmmo); if (post(event)) - return new InteractionResultHolder(InteractionResult.FAIL, item); + return InteractionResult.FAIL; return event.getAction(); } @@ -681,7 +672,7 @@ public final class ForgeEventFactory { return !post(new LivingDestroyBlockEvent(entity, pos, state)); } - public static boolean getMobGriefingEvent(Level level, @Nullable Entity entity) { + public static boolean getMobGriefingEvent(ServerLevel level, @Nullable Entity entity) { if (entity == null) return level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); @@ -887,11 +878,11 @@ public final class ForgeEventFactory { post(new LevelEvent.Save(level)); } - public static void onChunkDataSave(ChunkAccess chunk, LevelAccessor world, CompoundTag data) { + public static void onChunkDataSave(ChunkAccess chunk, LevelAccessor world, SerializableChunkData data) { post(new ChunkDataEvent.Save(chunk, world, data)); } - public static void onChunkDataLoad(ChunkAccess chunk, CompoundTag data, ChunkType status) { + public static void onChunkDataLoad(ChunkAccess chunk, SerializableChunkData data, ChunkType status) { post(new ChunkDataEvent.Load(chunk, data, status)); } @@ -1091,4 +1082,8 @@ public final class ForgeEventFactory { public static LootingLevelEvent fireLootingLevel(LivingEntity target, @Nullable DamageSource cause, int level) { return fire(new LootingLevelEvent(target, cause, level)); } + + public static boolean fireFarmlandTrampleEvent(ServerLevel level, BlockPos pos, BlockState state, float fallDistance, Entity entity) { + return post(new BlockEvent.FarmlandTrampleEvent(level, pos, state, fallDistance, entity)); + } } diff --git a/src/main/java/net/minecraftforge/event/ItemAttributeModifierEvent.java b/src/main/java/net/minecraftforge/event/ItemAttributeModifierEvent.java deleted file mode 100644 index 8dfb6b3913..0000000000 --- a/src/main/java/net/minecraftforge/event/ItemAttributeModifierEvent.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.event; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimaps; -import net.minecraftforge.eventbus.api.Event; -import net.minecraft.world.entity.ai.attributes.Attribute; -import net.minecraft.world.entity.ai.attributes.AttributeModifier; -import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.item.ItemStack; -import com.google.common.collect.Multimap; -import org.jetbrains.annotations.Nullable; - -import java.util.Collection; - -/** - * This event is fired when the attributes for an ItemStack are being calculated. - * Attributes are calculated on the server when equipping and unequipping an item to add and remove attributes respectively, both must be consistent. - * Attributes are calculated on the client when rendering an item's tooltip to show relevant attributes. - *
- * Note that this event is fired regardless of if the stack has NBT overriding attributes or not. If your attribute should be - * ignored when attributes are overridden, you can check for the presence of the {@code AttributeModifiers} tag. - *
- * This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}. - * / -public class ItemAttributeModifierEvent extends Event -{ - private final ItemStack stack; - private final EquipmentSlot slotType; - private final Multimap originalModifiers; - private Multimap unmodifiableModifiers; - @Nullable - private Multimap modifiableModifiers; - - public ItemAttributeModifierEvent(ItemStack stack, EquipmentSlot slotType, Multimap modifiers) - { - this.stack = stack; - this.slotType = slotType; - this.unmodifiableModifiers = this.originalModifiers = modifiers; - } - - /** - * Returns an unmodifiable view of the attribute multimap. Use other methods from this event to modify the attributes map. - * Note that adding attributes based on existing attributes may lead to inconsistent results between the tooltip (client) - * and the actual attributes (server) if the listener order is different. Using {@link #getOriginalModifiers()} instead will give more consistent results. - * / - public Multimap getModifiers() - { - return this.unmodifiableModifiers; - } - - /** - * Returns the attribute map before any changes from other event listeners was made. - * / - public Multimap getOriginalModifiers() - { - return this.originalModifiers; - } - - /** - * Gets a modifiable map instance, creating it if the current map is currently unmodifiable - * / - private Multimap getModifiableMap() - { - if (this.modifiableModifiers == null) - { - this.modifiableModifiers = HashMultimap.create(this.originalModifiers); - this.unmodifiableModifiers = Multimaps.unmodifiableMultimap(this.modifiableModifiers); - } - return this.modifiableModifiers; - } - - /** - * Adds a new attribute modifier to the given stack. - * Modifier must have a consistent UUID for consistency between equipping and unequipping items. - * Modifier name should clearly identify the mod that added the modifier. - * @param attribute Attribute - * @param modifier Modifier instance. - * @return True if the attribute was added, false if it was already present - * / - public boolean addModifier(Attribute attribute, AttributeModifier modifier) - { - return getModifiableMap().put(attribute, modifier); - } - - /** - * Removes a single modifier for the given attribute - * @param attribute Attribute - * @param modifier Modifier instance - * @return True if an attribute was removed, false if no change - * / - public boolean removeModifier(Attribute attribute, AttributeModifier modifier) - { - return getModifiableMap().remove(attribute, modifier); - } - - /** - * Removes all modifiers for the given attribute - * @param attribute Attribute - * @return Collection of removed modifiers - * / - public Collection removeAttribute(Attribute attribute) - { - return getModifiableMap().removeAll(attribute); - } - - /** - * Removes all modifiers for all attributes - * / - public void clearModifiers() - { - getModifiableMap().clear(); - } - - /** Gets the slot containing this stack * / - public EquipmentSlot getSlotType() - { - return this.slotType; - } - - /** Gets the item stack instance * / - public ItemStack getItemStack() - { - return this.stack; - } -} -*/ \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/entity/EntityAttributeCreationEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityAttributeCreationEvent.java index 1a18e45b59..1ad31cb0d5 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityAttributeCreationEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityAttributeCreationEvent.java @@ -21,17 +21,14 @@ import net.minecraftforge.fml.event.IModBusEvent; *
* Fired on the Mod bus {@link IModBusEvent}.
**/ -public class EntityAttributeCreationEvent extends Event implements IModBusEvent -{ +public class EntityAttributeCreationEvent extends Event implements IModBusEvent { private final Map, AttributeSupplier> map; - public EntityAttributeCreationEvent(Map, AttributeSupplier> map) - { + public EntityAttributeCreationEvent(Map, AttributeSupplier> map) { this.map = map; } - public void put(EntityType entity, AttributeSupplier map) - { + public void put(EntityType entity, AttributeSupplier map) { if (DefaultAttributes.hasSupplier(entity)) throw new IllegalStateException("Duplicate DefaultAttributes entry: " + entity); this.map.put(entity, map); diff --git a/src/main/java/net/minecraftforge/event/entity/living/MobSpawnEvent.java b/src/main/java/net/minecraftforge/event/entity/living/MobSpawnEvent.java index 471a10a80a..d7ab2211b8 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/MobSpawnEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/MobSpawnEvent.java @@ -5,6 +5,7 @@ package net.minecraftforge.event.entity.living; +import net.minecraft.world.entity.*; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; @@ -13,12 +14,6 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.WorldGenRegion; import net.minecraft.util.RandomSource; import net.minecraft.world.DifficultyInstance; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.MobSpawnType; -import net.minecraft.world.entity.SpawnGroupData; -import net.minecraft.world.entity.SpawnPlacements; import net.minecraft.world.level.BaseSpawner; import net.minecraft.world.level.ServerLevelAccessor; import net.minecraftforge.common.ForgeInternalHandler; @@ -41,16 +36,14 @@ import net.minecraftforge.fml.LogicalSide; *

* {@link AllowDespawn} is not related to the mob spawn event flow, as it fires when a despawn is attempted. */ -public abstract class MobSpawnEvent extends EntityEvent -{ +public abstract class MobSpawnEvent extends EntityEvent { private final ServerLevelAccessor level; private final double x; private final double y; private final double z; @ApiStatus.Internal - protected MobSpawnEvent(Mob mob, ServerLevelAccessor level, double x, double y, double z) - { + protected MobSpawnEvent(Mob mob, ServerLevelAccessor level, double x, double y, double z) { super(mob); this.level = level; this.x = x; @@ -59,40 +52,35 @@ public abstract class MobSpawnEvent extends EntityEvent } @Override - public Mob getEntity() - { - return (Mob) super.getEntity(); + public Mob getEntity() { + return (Mob)super.getEntity(); } /** * @return The level relating to the mob spawn action */ - public ServerLevelAccessor getLevel() - { + public ServerLevelAccessor getLevel() { return this.level; } /** * @return The x-coordinate relating to the mob spawn action */ - public double getX() - { + public double getX() { return this.x; } /** * @return The y-coordinate relating to the mob spawn action */ - public double getY() - { + public double getY() { return this.y; } /** * @return The z-coordinate relating to the mob spawn action */ - public double getZ() - { + public double getZ() { return this.z; } @@ -116,11 +104,10 @@ public abstract class MobSpawnEvent extends EntityEvent * @see SpawnPlacementRegisterEvent */ @HasResult - public static class SpawnPlacementCheck extends Event - { + public static class SpawnPlacementCheck extends Event { private final EntityType entityType; private final ServerLevelAccessor level; - private final MobSpawnType spawnType; + private final EntitySpawnReason spawnReason; private final BlockPos pos; private final RandomSource random; private final boolean defaultResult; @@ -130,11 +117,10 @@ public abstract class MobSpawnEvent extends EntityEvent * @see {@link SpawnPlacements#checkSpawnRules} for the single call site of this event. */ @ApiStatus.Internal - public SpawnPlacementCheck(EntityType entityType, ServerLevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random, boolean defaultResult) - { + public SpawnPlacementCheck(EntityType entityType, ServerLevelAccessor level, EntitySpawnReason spawnReason, BlockPos pos, RandomSource random, boolean defaultResult) { this.entityType = entityType; this.level = level; - this.spawnType = spawnType; + this.spawnReason = spawnReason; this.pos = pos; this.random = random; this.defaultResult = defaultResult; @@ -143,34 +129,30 @@ public abstract class MobSpawnEvent extends EntityEvent /** * @return The type of entity that checks are being performed for. */ - public EntityType getEntityType() - { + public EntityType getEntityType() { return this.entityType; } /** * @return The level relating to the mob spawn action */ - public ServerLevelAccessor getLevel() - { + public ServerLevelAccessor getLevel() { return this.level; } /** * Retrieves the type of mob spawn that is happening. * @return The mob spawn type. - * @see MobSpawnType + * @see EntitySpawnReason */ - public MobSpawnType getSpawnType() - { - return this.spawnType; + public EntitySpawnReason getSpawnReason() { + return this.spawnReason; } /** * @return The position where checks are being evaluated. */ - public BlockPos getPos() - { + public BlockPos getPos() { return this.pos; } @@ -178,8 +160,7 @@ public abstract class MobSpawnEvent extends EntityEvent * In all vanilla cases, this is equal to {@link ServerLevelAccessor#getRandom()}. * @return The random source being used. */ - public RandomSource getRandom() - { + public RandomSource getRandom() { return this.random; } @@ -187,8 +168,7 @@ public abstract class MobSpawnEvent extends EntityEvent * The default vanilla result is useful if an additional check wants to force {@link Result#ALLOW} only if the vanilla check would succeed. * @return The result of the vanilla spawn placement check. */ - public boolean getDefaultResult() - { + public boolean getDefaultResult() { return this.defaultResult; } } @@ -221,38 +201,34 @@ public abstract class MobSpawnEvent extends EntityEvent * @see {@link SpawnPlacementCheck} To modify the result of spawn placements at runtime. */ @HasResult - public static class PositionCheck extends MobSpawnEvent - { + public static class PositionCheck extends MobSpawnEvent { @Nullable private final BaseSpawner spawner; - private final MobSpawnType spawnType; + private final EntitySpawnReason spawnReason; - public PositionCheck(Mob mob, ServerLevelAccessor level, MobSpawnType spawnType, @Nullable BaseSpawner spawner) - { + public PositionCheck(Mob mob, ServerLevelAccessor level, EntitySpawnReason spawnReason, @Nullable BaseSpawner spawner) { super(mob, level, mob.getX(), mob.getY(), mob.getZ()); - this.spawnType = spawnType; + this.spawnReason = spawnReason; this.spawner = spawner; } /** * Retrieves the underlying {@link BaseSpawner} instance if this mob was created by a Mob Spawner of some form. - * This is always null unless {@link #getSpawnType()} is {@link MobSpawnType#SPAWNER}, and may still be null even then. + * This is always null unless {@link #getSpawnReason()} is {@link EntitySpawnReason#SPAWNER}, and may still be null even then. * @return The BaseSpawner responsible for triggering the spawn, or null if none is available. */ @Nullable - public BaseSpawner getSpawner() - { + public BaseSpawner getSpawner() { return spawner; } /** * Retrieves the type of mob spawn that is happening. * @return The mob spawn type. - * @see MobSpawnType + * @see EntitySpawnReason */ - public MobSpawnType getSpawnType() - { - return this.spawnType; + public EntitySpawnReason getSpawnReason() { + return this.spawnReason; } } @@ -269,9 +245,8 @@ public abstract class MobSpawnEvent extends EntityEvent * @apiNote Callers do not need to check if the entity's spawn was cancelled, as the spawn will be blocked by Forge. */ @Cancelable - public static class FinalizeSpawn extends MobSpawnEvent - { - private final MobSpawnType spawnType; + public static class FinalizeSpawn extends MobSpawnEvent { + private final EntitySpawnReason spawnReason; @Nullable private final BaseSpawner spawner; @@ -285,11 +260,10 @@ public abstract class MobSpawnEvent extends EntityEvent * @apiNote Do not construct directly. Access via {@link ForgeEventFactory#onFinalizeSpawn} / {@link ForgeEventFactory#onFinalizeSpawnSpawner}. */ @ApiStatus.Internal - public FinalizeSpawn(Mob entity, ServerLevelAccessor level, double x, double y, double z, DifficultyInstance difficulty, MobSpawnType spawnType, @Nullable SpawnGroupData spawnData, @Nullable CompoundTag spawnTag, @Nullable BaseSpawner spawner) - { + public FinalizeSpawn(Mob entity, ServerLevelAccessor level, double x, double y, double z, DifficultyInstance difficulty, EntitySpawnReason spawnReason, @Nullable SpawnGroupData spawnData, @Nullable CompoundTag spawnTag, @Nullable BaseSpawner spawner) { super(entity, level, x, y, z); this.difficulty = difficulty; - this.spawnType = spawnType; + this.spawnReason = spawnReason; this.spawnData = spawnData; this.spawnTag = spawnTag; this.spawner = spawner; @@ -299,8 +273,7 @@ public abstract class MobSpawnEvent extends EntityEvent * Retrieves the {@link DifficultyInstance} for the chunk where the mob is about to be spawned. * @return The local difficulty instance */ - public DifficultyInstance getDifficulty() - { + public DifficultyInstance getDifficulty() { return this.difficulty; } @@ -309,19 +282,17 @@ public abstract class MobSpawnEvent extends EntityEvent * The difficulty instance controls how likely certain random effects are to occur, or if certain mob abilities are enabled. * @param inst The new difficulty instance. */ - public void setDifficulty(DifficultyInstance inst) - { + public void setDifficulty(DifficultyInstance inst) { this.difficulty = inst; } /** * Retrieves the type of mob spawn that happened (the event that caused the spawn). The enum names are self-explanatory. * @return The mob spawn type. - * @see MobSpawnType + * @see EntitySpawnReason */ - public MobSpawnType getSpawnType() - { - return this.spawnType; + public EntitySpawnReason getSpawnReason() { + return this.spawnReason; } /** @@ -330,8 +301,7 @@ public abstract class MobSpawnEvent extends EntityEvent * @return The spawn group data. */ @Nullable - public SpawnGroupData getSpawnData() - { + public SpawnGroupData getSpawnData() { return this.spawnData; } @@ -340,8 +310,7 @@ public abstract class MobSpawnEvent extends EntityEvent * @param data The new spawn data * @see FinalizeSpawn#getSpawnData */ - public void setSpawnData(@Nullable SpawnGroupData data) - { + public void setSpawnData(@Nullable SpawnGroupData data) { this.spawnData = data; } @@ -351,8 +320,7 @@ public abstract class MobSpawnEvent extends EntityEvent * @return The spawn data this entity was or will be loaded from, if any. */ @Nullable - public CompoundTag getSpawnTag() - { + public CompoundTag getSpawnTag() { return this.spawnTag; } @@ -361,19 +329,17 @@ public abstract class MobSpawnEvent extends EntityEvent * The only vanilla mob known to use this tag for anything in finalize is tropical fish for setting the variant when spawned via bucket. * @param tag The new spawn tag */ - public void setSpawnTag(@Nullable CompoundTag tag) - { + public void setSpawnTag(@Nullable CompoundTag tag) { this.spawnTag = tag; } /** * Retrieves the underlying {@link BaseSpawner} instance if this mob was created by a Mob Spawner of some form. - * This is always null unless {@link #getSpawnType()} is {@link MobSpawnType#SPAWNER}, and may still be null even then. + * This is always null unless {@link #getSpawnReason()} is {@link EntitySpawnReason#SPAWNER}, and may still be null even then. * @return The BaseSpawner responsible for triggering the spawn, or null if none is available. */ @Nullable - public BaseSpawner getSpawner() - { + public BaseSpawner getSpawner() { return spawner; } @@ -384,8 +350,7 @@ public abstract class MobSpawnEvent extends EntityEvent * Usually that has no side effects, but callers should be aware. * @param cancel If the spawn should be cancelled (or not). */ - public void setSpawnCancelled(boolean cancel) - { + public void setSpawnCancelled(boolean cancel) { this.getEntity().setSpawnCancelled(cancel); } @@ -394,8 +359,7 @@ public abstract class MobSpawnEvent extends EntityEvent * @return If this mob's spawn is cancelled or not. * @implNote This is enforced in {@link ForgeInternalHandler#builtinMobSpawnBlocker} and a patch in {@link WorldGenRegion#addEntity} */ - public boolean isSpawnCancelled() - { + public boolean isSpawnCancelled() { return this.getEntity().isSpawnCancelled(); } } @@ -419,12 +383,9 @@ public abstract class MobSpawnEvent extends EntityEvent // TODO: 1.20 Move to standalone class, as it is unrelated to the complex mob spawning flow. // Such a refactor will allow the BaseSpawner and MobSpawnType params to be hoisted to MobSpawnEvent. @HasResult - public static class AllowDespawn extends MobSpawnEvent - { - public AllowDespawn(Mob mob, ServerLevelAccessor level) - { + public static class AllowDespawn extends MobSpawnEvent { + public AllowDespawn(Mob mob, ServerLevelAccessor level) { super(mob, level, mob.getX(), mob.getY(), mob.getZ()); } } - } diff --git a/src/main/java/net/minecraftforge/event/entity/living/EnderManAngerEvent.java b/src/main/java/net/minecraftforge/event/entity/living/MonsterDisguiseEvent.java similarity index 59% rename from src/main/java/net/minecraftforge/event/entity/living/EnderManAngerEvent.java rename to src/main/java/net/minecraftforge/event/entity/living/MonsterDisguiseEvent.java index 7b296dc821..1a52afeacc 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/EnderManAngerEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/MonsterDisguiseEvent.java @@ -5,42 +5,38 @@ package net.minecraftforge.event.entity.living; -import net.minecraft.world.entity.monster.EnderMan; +import net.minecraft.world.entity.monster.Monster; import net.minecraft.world.entity.player.Player; import net.minecraftforge.common.extensions.IForgeItem; import net.minecraftforge.eventbus.api.Cancelable; /** - * This event is fired on the forge bus before an Enderman detects that a player is looking at them. + * This event is fired on the forge bus before an Monster detects that a player is looking at them. * It will not be fired if the detection is already prevented by {@link IForgeItem#isEnderMask} *

* This event is {@link Cancelable}. - * If this event is canceled, the Enderman will not target the player. + * If this event is canceled, the Monster will not target the player. *

* This event does not have a {@link Result}. */ @Cancelable -public class EnderManAngerEvent extends LivingEvent -{ +public class MonsterDisguiseEvent extends LivingEvent { private final Player player; - public EnderManAngerEvent(EnderMan enderman, Player player) - { - super(enderman); + public MonsterDisguiseEvent(Monster monster, Player player) { + super(monster); this.player = player; } /** * The player that is being checked. */ - public Player getPlayer() - { + public Player getPlayer() { return player; } @Override - public EnderMan getEntity() - { - return (EnderMan) super.getEntity(); + public Monster getEntity() { + return (Monster)super.getEntity(); } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java index 8198a39c28..b943b7a1e3 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java @@ -8,8 +8,8 @@ package net.minecraftforge.event.entity.player; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.BowItem; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.level.Level; import net.minecraftforge.common.MinecraftForge; import org.jetbrains.annotations.NotNull; @@ -21,16 +21,14 @@ import org.jetbrains.annotations.NotNull; *
* This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ -public class ArrowNockEvent extends PlayerEvent -{ +public class ArrowNockEvent extends PlayerEvent { private final ItemStack bow; private final InteractionHand hand; private final Level level; private final boolean hasAmmo; - private InteractionResultHolder action; + private InteractionResult action; - public ArrowNockEvent(Player player, @NotNull ItemStack item, InteractionHand hand, Level level, boolean hasAmmo) - { + public ArrowNockEvent(Player player, @NotNull ItemStack item, InteractionHand hand, Level level, boolean hasAmmo) { super(player); this.bow = item; this.hand = hand; @@ -43,13 +41,11 @@ public class ArrowNockEvent extends PlayerEvent public Level getLevel() { return this.level; } public InteractionHand getHand() { return this.hand; } public boolean hasAmmo() { return this.hasAmmo; } - public InteractionResultHolder getAction() - { + public InteractionResult getAction() { return this.action; } - public void setAction(InteractionResultHolder action) - { + public void setAction(InteractionResult action) { this.action = action; } } diff --git a/src/main/java/net/minecraftforge/event/level/BlockEvent.java b/src/main/java/net/minecraftforge/event/level/BlockEvent.java index 074a763e50..7007698059 100644 --- a/src/main/java/net/minecraftforge/event/level/BlockEvent.java +++ b/src/main/java/net/minecraftforge/event/level/BlockEvent.java @@ -9,6 +9,7 @@ import java.util.EnumSet; import java.util.List; import net.minecraft.core.registries.Registries; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.level.block.BaseFireBlock; @@ -338,7 +339,7 @@ public class BlockEvent extends Event { private final Entity entity; private final float fallDistance; - public FarmlandTrampleEvent(Level level, BlockPos pos, BlockState state, float fallDistance, Entity entity) { + public FarmlandTrampleEvent(ServerLevel level, BlockPos pos, BlockState state, float fallDistance, Entity entity) { super(level, pos, state); this.entity = entity; this.fallDistance = fallDistance; diff --git a/src/main/java/net/minecraftforge/event/level/ChunkDataEvent.java b/src/main/java/net/minecraftforge/event/level/ChunkDataEvent.java index e7a725929d..c887c32e0a 100644 --- a/src/main/java/net/minecraftforge/event/level/ChunkDataEvent.java +++ b/src/main/java/net/minecraftforge/event/level/ChunkDataEvent.java @@ -5,14 +5,13 @@ package net.minecraftforge.event.level; -import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.ai.village.poi.PoiManager; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.chunk.status.ChunkType; import net.minecraft.world.level.chunk.ChunkAccess; -import net.minecraft.world.level.chunk.storage.ChunkSerializer; +import net.minecraft.world.level.chunk.storage.SerializableChunkData; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; @@ -27,26 +26,26 @@ import net.minecraftforge.eventbus.api.Event; * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
**/ public class ChunkDataEvent extends ChunkEvent { - private final CompoundTag data; + private final SerializableChunkData data; - public ChunkDataEvent(ChunkAccess chunk, CompoundTag data) { + public ChunkDataEvent(ChunkAccess chunk, SerializableChunkData data) { super(chunk); this.data = data; } - public ChunkDataEvent(ChunkAccess chunk, LevelAccessor world, CompoundTag data) { + public ChunkDataEvent(ChunkAccess chunk, LevelAccessor world, SerializableChunkData data) { super(chunk, world); this.data = data; } - public CompoundTag getData() { + public SerializableChunkData getData() { return data; } /** * ChunkDataEvent.Load is fired when vanilla Minecraft attempts to load Chunk data.
* This event is fired during chunk loading in - * {@link ChunkSerializer#read(ServerLevel, PoiManager, ChunkPos, CompoundTag)} which means it is async, so be careful.
+ * {@link ChunkSerializer#read(ServerLevel, PoiManager, ChunkPos, SerializableChunkData)} which means it is async, so be careful.
*
* This event is not {@link Cancelable}.
*
@@ -57,7 +56,7 @@ public class ChunkDataEvent extends ChunkEvent { public static class Load extends ChunkDataEvent { private ChunkType status; - public Load(ChunkAccess chunk, CompoundTag data, ChunkType status) { + public Load(ChunkAccess chunk, SerializableChunkData data, ChunkType status) { super(chunk, data); this.status = status; } @@ -79,7 +78,7 @@ public class ChunkDataEvent extends ChunkEvent { * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/ public static class Save extends ChunkDataEvent { - public Save(ChunkAccess chunk, LevelAccessor world, CompoundTag data) { + public Save(ChunkAccess chunk, LevelAccessor world, SerializableChunkData data) { super(chunk, world, data); } } diff --git a/src/main/java/net/minecraftforge/event/level/ExplosionEvent.java b/src/main/java/net/minecraftforge/event/level/ExplosionEvent.java index b03105f194..a9fe717250 100644 --- a/src/main/java/net/minecraftforge/event/level/ExplosionEvent.java +++ b/src/main/java/net/minecraftforge/event/level/ExplosionEvent.java @@ -25,24 +25,20 @@ import net.minecraft.world.level.Level; * Children do not use {@link HasResult}.
* Children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
*/ -public class ExplosionEvent extends Event -{ +public class ExplosionEvent extends Event { private final Level level; private final Explosion explosion; - public ExplosionEvent(Level level, Explosion explosion) - { + public ExplosionEvent(Level level, Explosion explosion) { this.level = level; this.explosion = explosion; } - public Level getLevel() - { + public Level getLevel() { return level; } - public Explosion getExplosion() - { + public Explosion getExplosion() { return explosion; } @@ -53,10 +49,8 @@ public class ExplosionEvent extends Event * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
*/ @Cancelable - public static class Start extends ExplosionEvent - { - public Start(Level level, Explosion explosion) - { + public static class Start extends ExplosionEvent { + public Start(Level level, Explosion explosion) { super(level, explosion); } } @@ -67,25 +61,23 @@ public class ExplosionEvent extends Event * This event does not use {@link HasResult}.
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
*/ - public static class Detonate extends ExplosionEvent - { + public static class Detonate extends ExplosionEvent { + private final List blocks; private final List entityList; - public Detonate(Level level, Explosion explosion, List entityList) - { + public Detonate(Level level, Explosion explosion, List blocks, List entityList) { super(level, explosion); + this.blocks = blocks; this.entityList = entityList; } /** return the list of blocks affected by the explosion. */ - public List getAffectedBlocks() - { - return getExplosion().getToBlow(); + public List getAffectedBlocks() { + return blocks; } /** return the list of entities affected by the explosion. */ - public List getAffectedEntities() - { + public List getAffectedEntities() { return entityList; } } diff --git a/src/main/java/net/minecraftforge/event/level/SaplingGrowTreeEvent.java b/src/main/java/net/minecraftforge/event/level/SaplingGrowTreeEvent.java index 8bda026cfa..a2013671c2 100644 --- a/src/main/java/net/minecraftforge/event/level/SaplingGrowTreeEvent.java +++ b/src/main/java/net/minecraftforge/event/level/SaplingGrowTreeEvent.java @@ -30,15 +30,14 @@ import org.jetbrains.annotations.Nullable; */ // TODO: Rename to BlockFeatureGrowEvent in 1.20 @HasResult -public class SaplingGrowTreeEvent extends LevelEvent -{ +@Deprecated(forRemoval = true, since = "1.21.1") // Dont remove, rename +public class SaplingGrowTreeEvent extends LevelEvent { private final RandomSource randomSource; private final BlockPos pos; @Nullable private Holder> feature; - public SaplingGrowTreeEvent(LevelAccessor level, RandomSource randomSource, BlockPos pos, @Nullable Holder> feature) - { + public SaplingGrowTreeEvent(LevelAccessor level, RandomSource randomSource, BlockPos pos, @Nullable Holder> feature) { super(level); this.randomSource = randomSource; this.pos = pos; @@ -48,16 +47,14 @@ public class SaplingGrowTreeEvent extends LevelEvent /** * {@return the random source which initiated the sapling growth} */ - public RandomSource getRandomSource() - { + public RandomSource getRandomSource() { return this.randomSource; } /** * {@return the coordinates of the sapling attempting to grow} */ - public BlockPos getPos() - { + public BlockPos getPos() { return pos; } @@ -65,24 +62,21 @@ public class SaplingGrowTreeEvent extends LevelEvent * {@return the holder of the feature which will be placed, possibly null} */ @Nullable - public Holder> getFeature() - { + public Holder> getFeature() { return feature; } /** * @param feature a {@linkplain Holder} referencing a tree feature to be placed instead of the current feature. */ - public void setFeature(@Nullable Holder> feature) - { + public void setFeature(@Nullable Holder> feature) { this.feature = feature; } /** * @param featureKey a {@linkplain ResourceKey} referencing a tree feature to be placed instead of the current feature. */ - public void setFeature(ResourceKey> featureKey) - { - this.feature = this.getLevel().registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).getHolder(featureKey).orElse(null); + public void setFeature(ResourceKey> featureKey) { + this.feature = this.getLevel().registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).get(featureKey).orElse(null); } } diff --git a/src/main/java/net/minecraftforge/fluids/FluidType.java b/src/main/java/net/minecraftforge/fluids/FluidType.java index 6e34d76938..2696bbcf70 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidType.java +++ b/src/main/java/net/minecraftforge/fluids/FluidType.java @@ -20,7 +20,7 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.entity.vehicle.AbstractBoat; import net.minecraft.world.item.BucketItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Rarity; @@ -323,7 +323,7 @@ public class FluidType { * @param boat the boat trying to be used on the fluid * @return {@code true} if the boat can be used, {@code false} otherwise */ - public boolean supportsBoating(Boat boat) { + public boolean supportsBoating(AbstractBoat boat) { return this.supportsBoating; } @@ -334,20 +334,20 @@ public class FluidType { * @param boat the boat trying to be used on the fluid * @return {@code true} if the boat can be used, {@code false} otherwise */ - public boolean supportsBoating(FluidState state, Boat boat) { + public boolean supportsBoating(FluidState state, AbstractBoat boat) { return this.supportsBoating(boat); } /** * When {@code false}, the fluid will no longer update its height value while - * within a boat while it is not within a fluid ({@link Boat#isUnderWater()}. + * within a boat while it is not within a fluid ({@link AbstractBoat#isUnderWater()}. * * @param state the state of the fluid the rider is within * @param boat the boat the rider is within that is not inside a fluid * @param rider the rider of the boat * @return {@code true} if the fluid height should be updated, {@code false} otherwise */ - public boolean shouldUpdateWhileBoating(FluidState state, Boat boat, Entity rider) { + public boolean shouldUpdateWhileBoating(FluidState state, AbstractBoat boat, Entity rider) { return !this.supportsBoating(state, boat); } diff --git a/src/main/java/net/minecraftforge/fluids/ForgeFlowingFluid.java b/src/main/java/net/minecraftforge/fluids/ForgeFlowingFluid.java index 681f94f153..62213b4e57 100644 --- a/src/main/java/net/minecraftforge/fluids/ForgeFlowingFluid.java +++ b/src/main/java/net/minecraftforge/fluids/ForgeFlowingFluid.java @@ -7,7 +7,6 @@ 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; @@ -20,6 +19,7 @@ import net.minecraft.world.item.Items; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.LevelAccessor; @@ -30,8 +30,7 @@ import org.jetbrains.annotations.Nullable; import java.util.function.Supplier; -public abstract class ForgeFlowingFluid extends FlowingFluid -{ +public abstract class ForgeFlowingFluid extends FlowingFluid { private final Supplier fluidType; private final Supplier flowing; private final Supplier still; @@ -44,8 +43,7 @@ public abstract class ForgeFlowingFluid extends FlowingFluid private final float explosionResistance; private final int tickRate; - protected ForgeFlowingFluid(Properties properties) - { + protected ForgeFlowingFluid(Properties properties) { this.fluidType = properties.fluidType; this.flowing = properties.flowing; this.still = properties.still; @@ -58,82 +56,69 @@ public abstract class ForgeFlowingFluid extends FlowingFluid } @Override - public FluidType getFluidType() - { + public FluidType getFluidType() { return this.fluidType.get(); } @Override - public Fluid getFlowing() - { + public Fluid getFlowing() { return flowing.get(); } @Override - public Fluid getSource() - { + public Fluid getSource() { return still.get(); } @Override - protected boolean canConvertToSource(Level level) - { + protected boolean canConvertToSource(ServerLevel level) { return false; } @Override - public boolean canConvertToSource(FluidState state, Level level, BlockPos pos) - { + public boolean canConvertToSource(FluidState state, ServerLevel level, BlockPos pos) { return this.getFluidType().canConvertToSource(state, level, pos); } @Override - protected void beforeDestroyingBlock(LevelAccessor worldIn, BlockPos pos, BlockState state) - { + protected void beforeDestroyingBlock(LevelAccessor worldIn, BlockPos pos, BlockState state) { BlockEntity blockEntity = state.hasBlockEntity() ? worldIn.getBlockEntity(pos) : null; Block.dropResources(state, worldIn, pos, blockEntity); } @Override - protected int getSlopeFindDistance(LevelReader worldIn) - { + protected int getSlopeFindDistance(LevelReader worldIn) { return slopeFindDistance; } @Override - protected int getDropOff(LevelReader worldIn) - { + protected int getDropOff(LevelReader worldIn) { return levelDecreasePerBlock; } @Override - public Item getBucket() - { + public Item getBucket() { return bucket != null ? bucket.get() : Items.AIR; } @Override - protected boolean canBeReplacedWith(FluidState state, BlockGetter level, BlockPos pos, Fluid fluidIn, Direction direction) - { + protected boolean canBeReplacedWith(FluidState state, BlockGetter level, BlockPos pos, Fluid fluidIn, Direction direction) { // Based on the water implementation, may need to be overriden for mod fluids that shouldn't behave like water. return direction == Direction.DOWN && !isSame(fluidIn); } @Override - public int getTickDelay(LevelReader level) - { + public int getTickDelay(LevelReader level) { return tickRate; } @Override - protected float getExplosionResistance() - { + protected float getExplosionResistance() { return explosionResistance; } @Override - protected BlockState createLegacyBlock(FluidState state) - { + protected BlockState createLegacyBlock(FluidState state) { if (block != null) return block.get().defaultBlockState().setValue(LiquidBlock.LEVEL, getLegacyLevel(state)); return Blocks.AIR.defaultBlockState(); @@ -146,15 +131,12 @@ public abstract class ForgeFlowingFluid extends FlowingFluid @NotNull @Override - public Optional getPickupSound() - { + public Optional getPickupSound() { return Optional.ofNullable(getFluidType().getSound(SoundActions.BUCKET_FILL)); } - public static class Flowing extends ForgeFlowingFluid - { - public Flowing(Properties properties) - { + public static class Flowing extends ForgeFlowingFluid { + public Flowing(Properties properties) { super(properties); registerDefaultState(getStateDefinition().any().setValue(LEVEL, 7)); } @@ -173,10 +155,8 @@ public abstract class ForgeFlowingFluid extends FlowingFluid } } - public static class Source extends ForgeFlowingFluid - { - public Source(Properties properties) - { + public static class Source extends ForgeFlowingFluid { + public Source(Properties properties) { super(properties); } @@ -189,8 +169,7 @@ public abstract class ForgeFlowingFluid extends FlowingFluid } } - public static class Properties - { + public static class Properties { private Supplier fluidType; private Supplier still; private Supplier flowing; @@ -201,45 +180,38 @@ public abstract class ForgeFlowingFluid extends FlowingFluid private float explosionResistance = 1; private int tickRate = 5; - public Properties(Supplier fluidType, Supplier still, Supplier flowing) - { + public Properties(Supplier fluidType, Supplier still, Supplier flowing) { this.fluidType = fluidType; this.still = still; this.flowing = flowing; } - public Properties bucket(Supplier bucket) - { + public Properties bucket(Supplier bucket) { this.bucket = bucket; return this; } - public Properties block(Supplier block) - { + public Properties block(Supplier block) { this.block = block; return this; } - public Properties slopeFindDistance(int slopeFindDistance) - { + public Properties slopeFindDistance(int slopeFindDistance) { this.slopeFindDistance = slopeFindDistance; return this; } - public Properties levelDecreasePerBlock(int levelDecreasePerBlock) - { + public Properties levelDecreasePerBlock(int levelDecreasePerBlock) { this.levelDecreasePerBlock = levelDecreasePerBlock; return this; } - public Properties explosionResistance(float explosionResistance) - { + public Properties explosionResistance(float explosionResistance) { this.explosionResistance = explosionResistance; return this; } - public Properties tickRate(int tickRate) - { + public Properties tickRate(int tickRate) { this.tickRate = tickRate; return this; } diff --git a/src/main/java/net/minecraftforge/fluids/capability/wrappers/FluidBucketWrapper.java b/src/main/java/net/minecraftforge/fluids/capability/wrappers/FluidBucketWrapper.java index 3bf348b09d..109df5f4c6 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/wrappers/FluidBucketWrapper.java +++ b/src/main/java/net/minecraftforge/fluids/capability/wrappers/FluidBucketWrapper.java @@ -21,7 +21,6 @@ import net.minecraft.world.item.BucketItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.item.MilkBucketItem; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -29,54 +28,40 @@ import org.jetbrains.annotations.Nullable; * Wrapper for vanilla and forge buckets. * Swaps between empty bucket and filled bucket of the correct type. */ -public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvider -{ +public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvider { private final LazyOptional holder = LazyOptional.of(() -> this); @NotNull protected ItemStack container; - public FluidBucketWrapper(@NotNull ItemStack container) - { + public FluidBucketWrapper(@NotNull ItemStack container) { this.container = container; } @NotNull @Override - public ItemStack getContainer() - { + public ItemStack getContainer() { return container; } - public boolean canFillFluidType(FluidStack fluid) - { + public boolean canFillFluidType(FluidStack fluid) { if (fluid.getFluid() == Fluids.WATER || fluid.getFluid() == Fluids.LAVA) - { return true; - } return !fluid.getFluid().getFluidType().getBucket(fluid).isEmpty(); } @NotNull - public FluidStack getFluid() - { + public FluidStack getFluid() { Item item = container.getItem(); - if (item instanceof BucketItem) - { - return new FluidStack(((BucketItem)item).getFluid(), FluidType.BUCKET_VOLUME); - } - else if (item instanceof MilkBucketItem && ForgeMod.MILK.isPresent()) - { + if (item instanceof BucketItem bucket) + return new FluidStack(bucket.getFluid(), FluidType.BUCKET_VOLUME); + else if (container.is(Items.MILK_BUCKET) && ForgeMod.MILK.isPresent()) return new FluidStack(ForgeMod.MILK.get(), FluidType.BUCKET_VOLUME); - } else - { return FluidStack.EMPTY; - } } - protected void setFluid(@NotNull FluidStack fluidStack) - { + protected void setFluid(@NotNull FluidStack fluidStack) { if (fluidStack.isEmpty()) container = new ItemStack(Items.BUCKET); else @@ -85,61 +70,46 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide @Override public int getTanks() { - return 1; } @NotNull @Override public FluidStack getFluidInTank(int tank) { - return getFluid(); } @Override public int getTankCapacity(int tank) { - return FluidType.BUCKET_VOLUME; } @Override public boolean isFluidValid(int tank, @NotNull FluidStack stack) { - return true; } @Override - public int fill(FluidStack resource, FluidAction action) - { - if (container.getCount() != 1 || resource.getAmount() < FluidType.BUCKET_VOLUME || container.getItem() instanceof MilkBucketItem || !getFluid().isEmpty() || !canFillFluidType(resource)) - { + public int fill(FluidStack resource, FluidAction action) { + if (container.getCount() != 1 || resource.getAmount() < FluidType.BUCKET_VOLUME || container.is(Items.MILK_BUCKET) || !getFluid().isEmpty() || !canFillFluidType(resource)) return 0; - } if (action.execute()) - { setFluid(resource); - } return FluidType.BUCKET_VOLUME; } @NotNull @Override - public FluidStack drain(FluidStack resource, FluidAction action) - { + public FluidStack drain(FluidStack resource, FluidAction action) { if (container.getCount() != 1 || resource.getAmount() < FluidType.BUCKET_VOLUME) - { return FluidStack.EMPTY; - } FluidStack fluidStack = getFluid(); - if (!fluidStack.isEmpty() && fluidStack.isFluidEqual(resource)) - { + if (!fluidStack.isEmpty() && fluidStack.isFluidEqual(resource)) { if (action.execute()) - { setFluid(FluidStack.EMPTY); - } return fluidStack; } @@ -148,20 +118,14 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide @NotNull @Override - public FluidStack drain(int maxDrain, FluidAction action) - { + public FluidStack drain(int maxDrain, FluidAction action) { if (container.getCount() != 1 || maxDrain < FluidType.BUCKET_VOLUME) - { return FluidStack.EMPTY; - } FluidStack fluidStack = getFluid(); - if (!fluidStack.isEmpty()) - { + if (!fluidStack.isEmpty()) { if (action.execute()) - { setFluid(FluidStack.EMPTY); - } return fluidStack; } @@ -170,8 +134,7 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide @Override @NotNull - public LazyOptional getCapability(@NotNull Capability capability, @Nullable Direction facing) - { + public LazyOptional getCapability(@NotNull Capability capability, @Nullable Direction facing) { return ForgeCapabilities.FLUID_HANDLER_ITEM.orEmpty(capability, holder); } } diff --git a/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java index a972cdd8b6..f6755dab39 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java @@ -14,32 +14,26 @@ import org.jetbrains.annotations.NotNull; * Exposes the player inventory WITHOUT the armor inventory as IItemHandler. * Also takes core of inserting/extracting having the same logic as picking up items. */ -public class PlayerMainInvWrapper extends RangedWrapper -{ +public class PlayerMainInvWrapper extends RangedWrapper { private final Inventory inventoryPlayer; - public PlayerMainInvWrapper(Inventory inv) - { + public PlayerMainInvWrapper(Inventory inv) { super(new InvWrapper(inv), 0, inv.items.size()); inventoryPlayer = inv; } @Override @NotNull - public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) - { + public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) { ItemStack rest = super.insertItem(slot, stack, simulate); - if (rest.getCount()!= stack.getCount()) - { + if (rest.getCount()!= stack.getCount()) { // the stack in the slot changed, animate it ItemStack inSlot = getStackInSlot(slot); - if(!inSlot.isEmpty()) - { - if (getInventoryPlayer().player.level().isClientSide) - { + if(!inSlot.isEmpty()) { + var world = getInventoryPlayer().player.level(); + if (world.isClientSide) { inSlot.setPopTime(5); - } - else if(getInventoryPlayer().player instanceof ServerPlayer) { + } else if (getInventoryPlayer().player instanceof ServerPlayer) { getInventoryPlayer().player.containerMenu.broadcastChanges(); } } @@ -47,8 +41,7 @@ public class PlayerMainInvWrapper extends RangedWrapper return rest; } - public Inventory getInventoryPlayer() - { + public Inventory getInventoryPlayer() { return inventoryPlayer; } } diff --git a/src/main/java/net/minecraftforge/network/PacketDistributor.java b/src/main/java/net/minecraftforge/network/PacketDistributor.java index 7ead06bc42..b05604ef31 100644 --- a/src/main/java/net/minecraftforge/network/PacketDistributor.java +++ b/src/main/java/net/minecraftforge/network/PacketDistributor.java @@ -165,6 +165,7 @@ public record PacketDistributor(BiFunction, T, Consumer< return p -> ((ServerChunkCache)entity.getCommandSenderWorld().getChunkSource()).broadcastAndSend(entity, p); } + @SuppressWarnings("resource") private Consumer> trackingChunk(LevelChunk chunk) { return p -> ((ServerChunkCache)chunk.getLevel().getChunkSource()).chunkMap.getPlayers(chunk.getPos(), false).forEach(e -> e.connection.send(p)); } diff --git a/src/main/java/net/minecraftforge/registries/ForgeRegistry.java b/src/main/java/net/minecraftforge/registries/ForgeRegistry.java index a461cfbbb0..fe3e1cdcc4 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeRegistry.java +++ b/src/main/java/net/minecraftforge/registries/ForgeRegistry.java @@ -252,13 +252,13 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist @NotNull @Override public Optional> getHolder(ResourceKey key) { - return Optional.ofNullable(this.getWrapper()).flatMap(wrapper -> wrapper.getHolder(key)); + return Optional.ofNullable(this.getWrapper()).flatMap(wrapper -> wrapper.get(key)); } @NotNull @Override public Optional> getHolder(ResourceLocation location) { - return Optional.ofNullable(this.getWrapper()).flatMap(wrapper -> wrapper.getHolder(location)); + return Optional.ofNullable(this.getWrapper()).flatMap(wrapper -> wrapper.get(location)); } @NotNull @@ -360,6 +360,7 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist } int add(int id, ResourceLocation key, V value) { + @SuppressWarnings("removal") final String owner = ModLoadingContext.get().getActiveNamespace(); return add(id, key, value, owner); } @@ -497,7 +498,7 @@ 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().holderOwner(), rkey)); + Holder.Reference delegate = delegatesByName.computeIfAbsent(rkey.location(), k -> Holder.Reference.createStandAlone(this.getWrapperOrThrow(), rkey)); delegate.bindKey(rkey); delegate.bindValue(value); delegatesByValue.put(value, delegate); diff --git a/src/main/java/net/minecraftforge/registries/GameData.java b/src/main/java/net/minecraftforge/registries/GameData.java index d894048cfe..3a0ccc56e5 100644 --- a/src/main/java/net/minecraftforge/registries/GameData.java +++ b/src/main/java/net/minecraftforge/registries/GameData.java @@ -316,8 +316,7 @@ public class GameData { } @SuppressWarnings("deprecation") - public static void postRegisterEvents() - { + public static void postRegisterEvents() { Set keySet = new HashSet<>(RegistryManager.ACTIVE.registries.keySet()); keySet.addAll(RegistryManager.getVanillaRegistryKeys()); @@ -326,13 +325,11 @@ public class GameData { ordered.addAll(keySet.stream().sorted(ResourceLocation::compareNamespaced).toList()); RuntimeException aggregate = new RuntimeException(); - for (ResourceLocation rootRegistryName : ordered) - { - try - { + for (ResourceLocation rootRegistryName : ordered) { + try { ResourceKey> registryKey = ResourceKey.createRegistryKey(rootRegistryName); ForgeRegistry forgeRegistry = RegistryManager.ACTIVE.getRegistry(rootRegistryName); - Registry vanillaRegistry = BuiltInRegistries.REGISTRY.get(rootRegistryName); + Registry vanillaRegistry = BuiltInRegistries.REGISTRY.getValue(rootRegistryName); RegisterEvent registerEvent = new RegisterEvent(registryKey, forgeRegistry, vanillaRegistry); StartupMessageManager.modLoaderConsumer().ifPresent(s -> s.accept("REGISTERING " + registryKey.location())); @@ -346,11 +343,11 @@ public class GameData { LOGGER.debug(REGISTRIES, "Applying holder lookups: {}", registryKey.location()); ObjectHolderRegistry.applyObjectHolders(registryKey.location()::equals); LOGGER.debug(REGISTRIES, "Holder lookups applied: {}", registryKey.location()); - } catch (Throwable t) - { + } catch (Throwable t) { aggregate.addSuppressed(t); } } + if (aggregate.getSuppressed().length > 0) { LOGGER.fatal("Failed to register some entries, see suppressed exceptions for details", aggregate); @@ -358,8 +355,7 @@ public class GameData { revertTo(RegistryManager.VANILLA, false); LOGGER.fatal("Detected errors during registry event dispatch, roll back to VANILLA complete"); throw aggregate; - } else - { + } else { ForgeHooks.modifyAttributes(); SpawnPlacements.fireSpawnPlacementEvent(); CreativeModeTabRegistry.sortTabs(); diff --git a/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java b/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java index 750b5fcb38..a948fed80b 100644 --- a/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java +++ b/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java @@ -28,7 +28,7 @@ class NamespacedDefaultedWrapper extends NamespacedWrapper implements Defa // Reading Functions @Override - public T get(@Nullable ResourceLocation name) { + public T getValue(@Nullable ResourceLocation name) { return this.delegate.getValue(name); //getOrDefault } diff --git a/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java b/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java index 3e811e5af4..e64330caf6 100644 --- a/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java +++ b/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java @@ -5,10 +5,9 @@ package net.minecraftforge.registries; +import com.google.common.collect.ImmutableMap; 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; @@ -16,6 +15,7 @@ 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.HolderLookup; import net.minecraft.core.HolderSet; import net.minecraft.core.MappedRegistry; import net.minecraft.core.RegistrationInfo; @@ -23,7 +23,9 @@ import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; +import net.minecraft.tags.TagLoader; import net.minecraft.util.RandomSource; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; @@ -59,6 +61,7 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr private final RegistryManager stage; private volatile Map, HolderSet.Named> tags = new IdentityHashMap<>(); private final Map, RegistrationInfo> registrationInfos = new IdentityHashMap<>(); + private MappedRegistry.TagSet frozenTags = MappedRegistry.TagSet.unbound(); NamespacedWrapper(ForgeRegistry fowner, Function> intrusiveHolderCallback, RegistryManager stage) { super(fowner.getRegistryKey(), Lifecycle.stable(), intrusiveHolderCallback != null); @@ -86,7 +89,7 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr // Reading Functions @Override @Nullable - public T get(@Nullable ResourceLocation name) { + public T getValue(@Nullable ResourceLocation name) { return this.delegate.getRaw(name); //get without default } @@ -97,7 +100,7 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr @Override @Nullable - public T get(@Nullable ResourceKey name) { + public T getValue(@Nullable ResourceKey name) { return name == null ? null : this.delegate.getRaw(name.location()); //get without default } @@ -178,15 +181,20 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr } @Override - public Optional> getHolder(int id) { + public Optional> get(int id) { return id >= 0 && id < this.holdersById.size() ? Optional.ofNullable(this.holdersById.get(id)) : Optional.empty(); } @Override - public Optional> getHolder(ResourceKey key) { + public Optional> get(ResourceKey key) { return Optional.ofNullable(this.holdersByName.get(key.location())); } + @Override + public Optional> get(ResourceLocation p_333710_) { + return Optional.ofNullable(this.holdersByName.get(p_333710_)); + } + @Override public @NotNull Holder wrapAsHolder(@NotNull T value) { final Holder holder = this.holders.get(value); @@ -223,7 +231,7 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr } public HolderSet.Named getOrThrow(TagKey key) { - return NamespacedWrapper.this.getOrCreateTag(key); + return NamespacedWrapper.this.getOrCreateTagForRegistration(key); } }; } @@ -244,7 +252,7 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr throw new IllegalStateException("This registry can't create new holders without value"); } else { this.validateWrite(key); - return Holder.Reference.createStandAlone(this.holderOwner(), key); + return Holder.Reference.createStandAlone(this, key); } }); } @@ -255,41 +263,36 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr } @Override - public Stream> holders() { + public Stream> listElements() { return this.getSortedHolders().stream(); } @Override - public Stream, HolderSet.Named>> getTags() { - return this.tags.entrySet().stream().map(e -> Pair.of(e.getKey(), e.getValue())); + public Stream> getTags() { + return this.frozenTags.getTags(); } @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; + public HolderSet.Named getOrCreateTagForRegistration(TagKey name) { + return this.tags.computeIfAbsent(name, this::createTag); } 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() { + if (frozen) // vanilla calls freeze on frozen registries all the time. which makes things annoying + return this; + this.frozen = true; List unregistered = this.holdersByName.entrySet().stream() .filter(e -> !e.getValue().isBound()) @@ -302,9 +305,51 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr throw new IllegalStateException("Some intrusive holders were not registered: " + this.unregisteredIntrusiveHolders.values() + " Hint: Did you register all your registry objects? Registry stage: " + stage.getName()); } + if (this.frozenTags.isBound()) + throw new IllegalStateException("Tags already present before freezing"); + + var unbound = this.tags.entrySet().stream() + .filter(t -> !t.getValue().isBound()) + .map(t -> t.getKey().location()) + .sorted() + .toList(); + + if (!unbound.isEmpty()) + throw new IllegalStateException("Unbound tags in registry " + this.key() + ": " + unbound); + + this.frozenTags = MappedRegistry.TagSet.fromMap(this.tags); + this.refreshTagsInHoldersForge(); return this; } + private void refreshTagsInHoldersForge() { + Map, List>> map = new IdentityHashMap<>(); + for (var value : this.holdersByName.values()) { + map.put(value, new ArrayList<>()); + } + + this.frozenTags.forEach((key, value) -> { + for (var holder : value) { + var reference = this.validateAndUnwrapTagElement(key, holder); + map.get(reference).add(key); + } + }); + + for (var entry : map.entrySet()) { + entry.getKey().bindTags(entry.getValue()); + } + } + + private Holder.Reference validateAndUnwrapTagElement(TagKey key, Holder value) { + if (!value.canSerializeIn(this)) + throw new IllegalStateException("Can't create named set " + key + " containing value " + value + " from outside registry " + this); + + if (value instanceof Holder.Reference reference) + return reference; + + throw new IllegalStateException("Found direct holder " + value + " value in tag " + key); + } + @Override public Holder.Reference createIntrusiveHolder(T value) { if (!this.isIntrusive()) @@ -316,65 +361,98 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr } @Override - public Optional> getTag(TagKey name) { - return Optional.ofNullable(this.tags.get(name)); + public Optional> get(TagKey name) { + return this.frozenTags.get(name); } @Override - public void bindTags(Map, List>> newTags) { - Map, List>> holderToTag = new IdentityHashMap<>(); - for (Holder.Reference tReference : this.holdersByName.values()) { - holderToTag.put(tReference, new ArrayList<>()); + public void bindTag(TagKey key, List> newTags) { + this.validateWrite(); + this.getOrCreateTagForRegistration(key).bind(newTags); + } + + @Override + public void bindAllTagsToEmpty() { + this.validateWrite(); + for (var tag : this.tags.values()) + tag.bind(List.of()); + } + + @Override + public Registry.PendingTags prepareTagReload(TagLoader.LoadResult data) { + if (!this.frozen) + throw new IllegalStateException("Invalid method used for tag loading"); + + var _old = ImmutableMap., HolderSet.Named>builder(); + var _new = ImmutableMap., List>>builder(); + + for (var entry : data.tags().entrySet()) { + var key = entry.getKey(); + var existing = this.tags.get(key); + if (existing == null) + existing = this.createTag(key); + _old.put(key, existing); + _new.put(key, List.copyOf(entry.getValue())); } - 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"))); + var oldBindings = _old.build(); + var newBindings = _new.build(); - 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()); - for (TagKey name : defaultedTags) { - List> defaults = this.optionalTags.get(name).stream() - .map(valueSupplier -> getHolder(valueSupplier.get()).orElse(null)) - .filter(Objects::nonNull) - .distinct() - .toList(); - for (Holder holder : defaults) { - addTagToHolder(holderToTag, name, holder); + var oldSnapshot = new HolderLookup.RegistryLookup.Delegate() { + @Override + public HolderLookup.RegistryLookup parent() { + return NamespacedWrapper.this; } - tmpTags.computeIfAbsent(name, this::createTag).bind(defaults); - } - holderToTag.forEach(Holder.Reference::bindTags); - this.tags = tmpTags; + @Override + public Optional> get(TagKey p_259486_) { + return Optional.ofNullable(oldBindings.get(p_259486_)); + } - this.delegate.onBindTags(this.tags, defaultedTags); - } + @Override + public Stream> listTags() { + return oldBindings.values().stream(); + } + }; - 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); + return new Registry.PendingTags() { + @Override + public ResourceKey> key() { + return NamespacedWrapper.this.key(); + } - if (!(holder instanceof Holder.Reference)) - throw new IllegalStateException("Found direct holder " + holder + " value in tag " + name); + @Override + public int size() { + return newBindings.size(); + } - holderToTag.get((Holder.Reference) holder).add(name); - } + @Override + public HolderLookup.RegistryLookup lookup() { + return oldSnapshot; + } - @Override - public void resetTags() { - this.tags.values().forEach(t -> t.bind(List.of())); - this.holders.values().forEach(v -> v.bindTags(Set.of())); + @Override + public List> getPending(TagKey key) { + return newBindings.getOrDefault(key, List.of()); + } + + @Override + public void apply() { + for (var entry : oldBindings.entrySet()) { + var newList = newBindings.getOrDefault(entry.getKey(), List.of()); + entry.getValue().bind(newList); + } + + NamespacedWrapper.this.frozenTags = MappedRegistry.TagSet.fromMap(oldBindings); + NamespacedWrapper.this.refreshTagsInHoldersForge(); + } + }; } @Override public void unfreeze() { this.frozen = false; + this.frozenTags = MappedRegistry.TagSet.unbound(); } boolean isFrozen() { @@ -409,14 +487,14 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr } private HolderSet.Named createTag(TagKey name) { - return new HolderSet.Named<>(this.holderOwner(), name); + return new HolderSet.Named<>(this, name); } private Holder.Reference getHolder(ResourceKey key, T value) { if (this.isIntrusive()) return this.intrusiveHolderCallback.apply(value); - return this.holdersByName.computeIfAbsent(key.location(), k -> Holder.Reference.createStandAlone(this.holderOwner(), key)); + return this.holdersByName.computeIfAbsent(key.location(), k -> Holder.Reference.createStandAlone(this, key)); } private List> getSortedHolders() { diff --git a/src/main/java/net/minecraftforge/registries/RegistryObject.java b/src/main/java/net/minecraftforge/registries/RegistryObject.java index 32b28dea4e..7889696c13 100644 --- a/src/main/java/net/minecraftforge/registries/RegistryObject.java +++ b/src/main/java/net/minecraftforge/registries/RegistryObject.java @@ -219,8 +219,8 @@ public final class RegistryObject implements Supplier { var mapped = registry instanceof MappedRegistry m ? m : null; if (registry.containsKey(this.name)) { - this.value = registry.get(this.name); - this.holder = () -> ((Registry)registry).getHolder(this.key).orElse(null); + this.value = registry.getValue(this.name); + this.holder = () -> ((Registry)registry).get(this.key).orElse(null); } else if (mapped != null && !mapped.isIntrusive()) { this.value = null; this.holder = () -> mapped.createRegistrationLookup().getOrThrow(this.key); @@ -241,7 +241,7 @@ public final class RegistryObject implements Supplier { return; } - Registry vanillaRegistry = (Registry) BuiltInRegistries.REGISTRY.get(registryName); + Registry vanillaRegistry = (Registry) BuiltInRegistries.REGISTRY.getValue(registryName); if (vanillaRegistry != null) { updateReference(vanillaRegistry); return; diff --git a/src/main/java/net/minecraftforge/registries/holdersets/AnyHolderSet.java b/src/main/java/net/minecraftforge/registries/holdersets/AnyHolderSet.java index 168b6e93a3..9e74b3ea85 100644 --- a/src/main/java/net/minecraftforge/registries/holdersets/AnyHolderSet.java +++ b/src/main/java/net/minecraftforge/registries/holdersets/AnyHolderSet.java @@ -100,4 +100,9 @@ public record AnyHolderSet(HolderLookup.RegistryLookup registryLookup) imp public String toString() { return "AnySet(" + this.registryLookup.key() + ")"; } + + @Override + public boolean isBound() { + return true; + } } \ 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 6ea64f7fbd..3a1349c6ec 100644 --- a/src/main/java/net/minecraftforge/registries/holdersets/CompositeHolderSet.java +++ b/src/main/java/net/minecraftforge/registries/holdersets/CompositeHolderSet.java @@ -28,8 +28,7 @@ import net.minecraft.util.RandomSource; * When their component holderset(s) invalidate, they clear any cached data and then * invalidate their owner holdersets. */ -public abstract class CompositeHolderSet implements ICustomHolderSet -{ +public abstract class CompositeHolderSet implements ICustomHolderSet { private final List owners = new ArrayList<>(); private final List> components; @@ -38,13 +37,10 @@ public abstract class CompositeHolderSet implements ICustomHolderSet @Nullable private List> list = null; - public CompositeHolderSet(List> components) - { + public CompositeHolderSet(List> components) { this.components = components; for (HolderSet holderset : components) - { holderset.addInvalidationListener(this::invalidate); - } } /** @@ -52,78 +48,60 @@ public abstract class CompositeHolderSet implements ICustomHolderSet */ protected abstract Set> createSet(); - public List> getComponents() - { + public List> getComponents() { return this.components; } - public Set> getSet() - { + public Set> getSet() { Set> thisSet = this.set; - if (thisSet == null) - { + if (thisSet == null) { Set> set = this.createSet(); this.set = set; return set; - } - else - { + } else return thisSet; - } } - public List> getList() - { + public List> getList() { List> thisList = this.list; - if (thisList == null) - { + if (thisList == null) { List> list = List.copyOf(this.getSet()); this.list = list; return list; - } - else - { + } else return thisList; - } } @Override - public void addInvalidationListener(Runnable runnable) - { + public void addInvalidationListener(Runnable runnable) { this.owners.add(runnable); } - private void invalidate() - { + private void invalidate() { this.set = null; this.list = null; - for (Runnable runnable : this.owners) - { + for (Runnable runnable : this.owners) { runnable.run(); } } @Override - public Stream> stream() - { + public Stream> stream() { return this.getList().stream(); } @Override - public int size() - { + public int size() { return this.getList().size(); } @Override - public Either, List>> unwrap() - { + public Either, List>> unwrap() { return Either.right(this.getList()); } @Override - public Optional> getRandomElement(RandomSource rand) - { + public Optional> getRandomElement(RandomSource rand) { List> list = this.getList(); int size = list.size(); return size > 0 @@ -132,48 +110,48 @@ public abstract class CompositeHolderSet implements ICustomHolderSet } @Override - public Holder get(int i) - { + public Holder get(int i) { return this.getList().get(i); } @Override - public boolean contains(Holder holder) - { + public boolean contains(Holder holder) { return this.getSet().contains(holder); } @Override - public boolean canSerializeIn(HolderOwner holderOwner) - { - for (HolderSet component : this.components) - { + public boolean canSerializeIn(HolderOwner holderOwner) { + for (HolderSet component : this.components) { if (!component.canSerializeIn(holderOwner)) - { return false; - } } return true; } @Override - public Optional> unwrapKey() - { + public boolean isBound() { + for (var child : this.getComponents()) + if (!child.isBound()) + return false; + return true; + } + + @Override + public Optional> unwrapKey() { return Optional.empty(); } @Override - public Iterator> iterator() - { + public Iterator> iterator() { return this.getList().iterator(); } - + /** * Maps the sub-holdersets of this composite such that, * if the list contains more than one element, and is non-homogenous, * each element of the list will serialize as an object. * Prevents crashes from trying to serialize non-homogenous lists to NBT. - * + * * Lists are considered non-homogenous if it contains more than one serialization type of holderset. * Holdersets may be serialized as strings, lists, or maps. * @see {@link #isHomogenous} @@ -181,63 +159,48 @@ public abstract class CompositeHolderSet implements ICustomHolderSet * Returns a new List if size > 1 and serialization would be non-homogenous, * otherwise returns the composite's existing List. */ - public List> homogenize() - { + public List> homogenize() { List> components = this.getComponents(); - + if (this.isHomogenous()) - { return components; - } - + List> outputs = new ArrayList<>(); - for (HolderSet holderset : components) - { + for (HolderSet holderset : components) { if (holderset instanceof ICustomHolderSet) // serializes to object already - { outputs.add(holderset); - } else // serializes to string or list - { outputs.add(new OrHolderSet<>(List.of(holderset))); - } } return outputs; } - + /** * @return True if all of our sub-holdersets have the same {@link SerializationType} (string, list, or object). * False if we have more than one holderset AND if either we have more than one serialization type among them, * or any holderset is {@link SerializationType.UNKNOWN}. */ - public boolean isHomogenous() - { + public boolean isHomogenous() { final List> holderSets = this.getComponents(); - + if (holderSets.size() < 2) - { return true; - } - + // Get the first holderset and check if any subsequent holdersets are different SerializationType firstType = holderSets.get(0).serializationType(); - + // If any holderset has an unknown type, then we cannot assume we are homogenous - if (firstType == SerializationType.UNKNOWN) - { + if (firstType == SerializationType.UNKNOWN) { return false; } - + final int size = holderSets.size(); - for (int i = 1; i < size; i++) - { + for (int i = 1; i < size; i++) { final SerializationType type = holderSets.get(i).serializationType(); if (type != firstType) // don't need to check type == UNKNOWN again because type != firstType covers it - { return false; - } } - + return true; } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/registries/holdersets/NotHolderSet.java b/src/main/java/net/minecraftforge/registries/holdersets/NotHolderSet.java index ba727ebb1d..a14caad66a 100644 --- a/src/main/java/net/minecraftforge/registries/holdersets/NotHolderSet.java +++ b/src/main/java/net/minecraftforge/registries/holdersets/NotHolderSet.java @@ -154,4 +154,9 @@ public class NotHolderSet implements ICustomHolderSet { runnable.run(); } } + + @Override + public boolean isBound() { + return this.value.isBound(); + } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/server/LanguageHook.java b/src/main/java/net/minecraftforge/server/LanguageHook.java index ea638a3815..fbd9c1da0b 100644 --- a/src/main/java/net/minecraftforge/server/LanguageHook.java +++ b/src/main/java/net/minecraftforge/server/LanguageHook.java @@ -25,8 +25,7 @@ import java.nio.charset.StandardCharsets; import java.util.*; import java.util.regex.Pattern; -public class LanguageHook -{ +public class LanguageHook { private static final Logger LOGGER = LogManager.getLogger(); private static final Gson GSON = new Gson(); private static final Pattern PATTERN = Pattern.compile("%(\\d+\\$)?[\\d\\.]*[df]"); @@ -35,26 +34,25 @@ public class LanguageHook /** * Loads lang files on the server */ - public static void captureLanguageMap(Map table) - { + public static void captureLanguageMap(Map table) { CAPTURED_TABLES.add(table); - if (modTable != null) { - CAPTURED_TABLES.forEach(t->t.putAll(modTable)); - } + if (modTable != null) + CAPTURED_TABLES.forEach(t -> t.putAll(modTable)); } // The below is based on client side net.minecraft.client.resources.Locale code private static void loadLocaleData(final List allResources) { - allResources.forEach(res -> { - try { - LanguageHook.loadLocaleData(res.open()); - } catch (IOException ignored) {} // TODO: this should not be ignored -C - }); + for (var res : allResources) { + try (var stream = res.open()) { + LanguageHook.loadLocaleData(stream); + } catch(IOException e) { + LOGGER.error("Failed to read locale data from {}", res.toString(), e); + } + } } private static void loadLocaleData(final InputStream inputstream) { - try - { + try { JsonElement jsonelement = GSON.fromJson(new InputStreamReader(inputstream, StandardCharsets.UTF_8), JsonElement.class); JsonObject jsonobject = GsonHelper.convertToJsonObject(jsonelement, "strings"); @@ -62,9 +60,7 @@ public class LanguageHook String s = PATTERN.matcher(GsonHelper.convertToString(entry.getValue(), entry.getKey())).replaceAll("%$1s"); modTable.put(entry.getKey(), s); }); - } - finally - { + } finally { IOUtils.closeQuietly(inputstream); } } @@ -89,16 +85,13 @@ public class LanguageHook final InputStream forge = Thread.currentThread().getContextClassLoader().getResourceAsStream("assets/forge/lang/en_us.json"); loadLocaleData(mc); loadLocaleData(forge); - CAPTURED_TABLES.forEach(t->t.putAll(modTable)); + CAPTURED_TABLES.forEach(t -> t.putAll(modTable)); ForgeI18n.loadLanguageData(modTable); } static void loadLanguagesOnServer(MinecraftServer server) { modTable = new HashMap<>(5000); - // Possible multi-language server support? - for (String lang : Arrays.asList("en_us")) { - loadLanguage(lang, server); - } + loadLanguage("en_us", server); CAPTURED_TABLES.forEach(t->t.putAll(modTable)); ForgeI18n.loadLanguageData(modTable); } diff --git a/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java b/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java index dd2273cf6a..15762289e3 100644 --- a/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java +++ b/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java @@ -16,7 +16,6 @@ import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.Registries; import net.minecraft.gametest.framework.GameTestServer; import net.minecraft.network.Connection; -import net.minecraft.network.ConnectionProtocol; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.handshake.ClientIntent; import net.minecraft.network.protocol.handshake.ClientIntentionPacket; @@ -119,25 +118,25 @@ public class ServerLifecycleHooks { final RegistryAccess registries = server.registryAccess(); // The order of holders() is the order modifiers were loaded in. - final List biomeModifiers = registries.registryOrThrow(ForgeRegistries.Keys.BIOME_MODIFIERS) - .holders() + final List biomeModifiers = registries.lookupOrThrow(ForgeRegistries.Keys.BIOME_MODIFIERS) + .listElements() .map(Holder::value) .toList(); - final List structureModifiers = registries.registryOrThrow(Keys.STRUCTURE_MODIFIERS) - .holders() + final List structureModifiers = registries.lookupOrThrow(Keys.STRUCTURE_MODIFIERS) + .listElements() .map(Holder::value) .toList(); // Apply sorted biome modifiers to each biome. - registries.registryOrThrow(Registries.BIOME).holders().forEach(biomeHolder -> + registries.lookupOrThrow(Registries.BIOME).listElements().forEach(biomeHolder -> biomeHolder.value().modifiableBiomeInfo().applyBiomeModifiers(biomeHolder, biomeModifiers) ); // Rebuild the indexed feature list - registries.registryOrThrow(Registries.LEVEL_STEM).forEach(levelStem -> { + registries.lookupOrThrow(Registries.LEVEL_STEM).forEach(levelStem -> { levelStem.generator().refreshFeaturesPerStep(); }); // Apply sorted structure modifiers to each structure. - registries.registryOrThrow(Registries.STRUCTURE).holders().forEach(structureHolder -> + registries.lookupOrThrow(Registries.STRUCTURE).listElements().forEach(structureHolder -> structureHolder.value().modifiableStructureInfo().applyStructureModifiers(structureHolder, structureModifiers) ); } diff --git a/src/main/java/net/minecraftforge/server/command/ChunkGenWorker.java b/src/main/java/net/minecraftforge/server/command/ChunkGenWorker.java index 0c4b6ff1e6..385885b270 100644 --- a/src/main/java/net/minecraftforge/server/command/ChunkGenWorker.java +++ b/src/main/java/net/minecraftforge/server/command/ChunkGenWorker.java @@ -17,8 +17,7 @@ import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.status.ChunkStatus; import net.minecraftforge.common.WorldWorkerManager.IWorker; -public class ChunkGenWorker implements IWorker -{ +public class ChunkGenWorker implements IWorker { private final CommandSourceStack listener; protected final BlockPos start; protected final int total; @@ -28,10 +27,8 @@ public class ChunkGenWorker implements IWorker private int lastNotification = 0; private long lastNotifcationTime = 0; private int genned = 0; - private Boolean keepingLoaded; - public ChunkGenWorker(CommandSourceStack listener, BlockPos start, int total, ServerLevel dim, int interval) - { + public ChunkGenWorker(CommandSourceStack listener, BlockPos start, int total, ServerLevel dim, int interval) { this.listener = listener; this.start = start; this.total = total; @@ -41,15 +38,13 @@ public class ChunkGenWorker implements IWorker this.lastNotifcationTime = System.currentTimeMillis(); //We also notify at least once every 60 seconds, to show we haven't froze. } - protected Queue buildQueue() - { + protected Queue buildQueue() { Queue ret = new ArrayDeque(); ret.add(start); //This *should* spiral outwards, starting on right side, down, left, up, right, but hey we'll see! int radius = 1; - while (ret.size() < total) - { + while (ret.size() < total) { for (int q = -radius + 1; q <= radius && ret.size() < total; q++) ret.add(start.offset(radius, 0, q)); @@ -67,27 +62,21 @@ public class ChunkGenWorker implements IWorker return ret; } - public MutableComponent getStartMessage(CommandSourceStack sender) - { + public MutableComponent getStartMessage(CommandSourceStack sender) { return Component.translatable("commands.forge.gen.start", total, start.getX(), start.getZ(), dim); } @Override - public boolean hasWork() - { + public boolean hasWork() { return !queue.isEmpty(); } @Override - public boolean doWork() - { + public boolean doWork() { /* TODO: Check how many things are pending save, and slow down world gen if to many AnvilChunkLoader loader = dim.getChunkProvider().chunkLoader instanceof AnvilChunkLoader ? (AnvilChunkLoader)world.getChunkProvider().chunkLoader : null; - if (loader != null && loader.getPendingSaveCount() > 100) - { - - if (lastNotifcationTime < System.currentTimeMillis() - 10*1000) - { + if (loader != null && loader.getPendingSaveCount() > 100) { + if (lastNotifcationTime < System.currentTimeMillis() - 10*1000) { listener.sendFeedback(new TranslationTextComponent("commands.forge.gen.progress", total - queue.size(), total), true); lastNotifcationTime = System.currentTimeMillis(); } @@ -97,16 +86,8 @@ public class ChunkGenWorker implements IWorker BlockPos next = queue.poll(); - if (next != null) - { - // While we work we don't want to cause world load spam so pause unloading the world. - /* TODO: Readd if/when we introduce world unloading, or get Mojang to do it. - if (keepingLoaded == null) - keepingLoaded = DimensionManager.keepLoaded(dim, true); - */ - - if (++lastNotification >= notificationFrequency || lastNotifcationTime < System.currentTimeMillis() - 60*1000) - { + if (next != null) { + if (++lastNotification >= notificationFrequency || lastNotifcationTime < System.currentTimeMillis() - 60*1000) { listener.sendSuccess(() -> Component.translatable("commands.forge.gen.progress", total - queue.size(), total), true); lastNotification = 0; lastNotifcationTime = System.currentTimeMillis(); @@ -124,13 +105,8 @@ public class ChunkGenWorker implements IWorker } } - if (queue.isEmpty()) - { + if (queue.isEmpty()) { listener.sendSuccess(() -> Component.translatable("commands.forge.gen.complete", genned, total, dim.dimension().location()), true); - /* TODO: Readd if/when we introduce world unloading, or get Mojang to do it. - if (keepingLoaded != null && !keepingLoaded) - DimensionManager.keepLoaded(dim, false); - */ return false; } return true; diff --git a/src/main/java/net/minecraftforge/server/command/DimensionsCommand.java b/src/main/java/net/minecraftforge/server/command/DimensionsCommand.java index 914cfccc2b..9fce6630ad 100644 --- a/src/main/java/net/minecraftforge/server/command/DimensionsCommand.java +++ b/src/main/java/net/minecraftforge/server/command/DimensionsCommand.java @@ -22,15 +22,13 @@ import java.util.stream.Collectors; import com.mojang.brigadier.builder.ArgumentBuilder; -class DimensionsCommand -{ - static ArgumentBuilder register() - { +class DimensionsCommand { + static ArgumentBuilder register() { return Commands.literal("dimensions") .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(Registries.DIMENSION_TYPE); + final Registry reg = ctx.getSource().registryAccess().lookupOrThrow(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 f7b593621c..ff00253bc0 100644 --- a/src/main/java/net/minecraftforge/server/command/TPSCommand.java +++ b/src/main/java/net/minecraftforge/server/command/TPSCommand.java @@ -50,7 +50,7 @@ class TPSCommand 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(Registries.DIMENSION_TYPE); + final Registry reg = cs.registryAccess().lookupOrThrow(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()).toString(), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), false); diff --git a/src/main/java/net/minecraftforge/server/command/TagsCommand.java b/src/main/java/net/minecraftforge/server/command/TagsCommand.java index ea25042664..5e9029c112 100644 --- a/src/main/java/net/minecraftforge/server/command/TagsCommand.java +++ b/src/main/java/net/minecraftforge/server/command/TagsCommand.java @@ -14,7 +14,6 @@ import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; import com.mojang.brigadier.suggestion.SuggestionProvider; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; -import com.mojang.datafixers.util.Pair; import net.minecraft.ChatFormatting; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; @@ -55,8 +54,7 @@ import java.util.stream.Stream; * contain the given registry object. * */ -class TagsCommand -{ +class TagsCommand { private static final long PAGE_SIZE = 8; private static final ResourceKey>> ROOT_REGISTRY_KEY = ResourceKey.createRegistryKey(ResourceLocation.parse("root")); @@ -68,8 +66,7 @@ class TagsCommand private static final Dynamic2CommandExceptionType UNKNOWN_ELEMENT = new Dynamic2CommandExceptionType((tag, registry) -> Component.translatable("commands.forge.tags.error.unknown_element", tag, registry)); - public static ArgumentBuilder register() - { + public static ArgumentBuilder register() { /* * /forge tags list [page] * /forge tags get [page] @@ -87,7 +84,7 @@ class TagsCommand ) .then(Commands.literal("get") .then(Commands.argument("tag", ResourceLocationArgument.id()) - .suggests(suggestFromRegistry(r -> r.getTagNames().map(TagKey::location)::iterator)) + .suggests(suggestFromRegistry(r -> r.getTags().map(t -> t.key().location())::iterator)) .executes(ctx -> listTagElements(ctx, 1)) .then(Commands.argument("page", IntegerArgumentType.integer(1)) .executes(ctx -> listTagElements(ctx, IntegerArgumentType.getInteger(ctx, "page"))) @@ -106,11 +103,10 @@ class TagsCommand ); } - private static int listTags(final CommandContext ctx, final int page) throws CommandSyntaxException - { + private static int listTags(final CommandContext ctx, final int page) throws CommandSyntaxException { final ResourceKey> registryKey = getResourceKey(ctx, "registry", ROOT_REGISTRY_KEY) .orElseThrow(); // Expect to be always retrieve a resource key for the root registry (registry key) - final Registry registry = ctx.getSource().getServer().registryAccess().registry(registryKey) + final Registry registry = ctx.getSource().getServer().registryAccess().lookup(registryKey) .orElseThrow(() -> UNKNOWN_REGISTRY.create(registryKey.location())); final long tagCount = registry.getTags().count(); @@ -123,7 +119,6 @@ class TagsCommand page, ChatFormatting.DARK_GREEN, () -> registry.getTags() - .map(Pair::getSecond) .map(s -> s.unwrap().map(k -> k.location().toString(), Object::toString)) ), false); @@ -134,13 +129,13 @@ class TagsCommand { final ResourceKey> registryKey = getResourceKey(ctx, "registry", ROOT_REGISTRY_KEY) .orElseThrow(); // Expect to be always retrieve a resource key for the root registry (registry key) - final Registry registry = ctx.getSource().getServer().registryAccess().registry(registryKey) + final Registry registry = ctx.getSource().getServer().registryAccess().lookup(registryKey) .orElseThrow(() -> UNKNOWN_REGISTRY.create(registryKey.location())); final ResourceLocation tagLocation = ResourceLocationArgument.getId(ctx, "tag"); - final TagKey tagKey = TagKey.create(cast(registryKey), tagLocation); + final TagKey tagKey = TagKey.create(cast(registryKey), tagLocation); - final HolderSet.Named tag = registry.getTag(cast(tagKey)) + final HolderSet.Named tag = registry.get(tagKey) .orElseThrow(() -> UNKNOWN_TAG.create(tagKey.location(), registryKey.location())); ctx.getSource().sendSuccess(() -> createMessage( @@ -158,17 +153,16 @@ class TagsCommand return tag.size(); } - private static int queryElementTags(final CommandContext ctx, final int page) throws CommandSyntaxException - { + private static int queryElementTags(final CommandContext ctx, final int page) throws CommandSyntaxException { final ResourceKey> registryKey = getResourceKey(ctx, "registry", ROOT_REGISTRY_KEY) .orElseThrow(); // Expect to be always retrieve a resource key for the root registry (registry key) - final Registry registry = ctx.getSource().getServer().registryAccess().registry(registryKey) + final Registry registry = ctx.getSource().getServer().registryAccess().lookup(registryKey) .orElseThrow(() -> UNKNOWN_REGISTRY.create(registryKey.location())); final ResourceLocation elementLocation = ResourceLocationArgument.getId(ctx, "element"); - final ResourceKey elementKey = ResourceKey.create(cast(registryKey), elementLocation); + final ResourceKey elementKey = ResourceKey.create(cast(registryKey), elementLocation); - final Holder elementHolder = ((Registry)registry).getHolder((ResourceKey)elementKey) + final Holder elementHolder = registry.get(elementKey) .orElseThrow(() -> UNKNOWN_ELEMENT.create(elementLocation, registryKey.location())); final long containingTagsCount = elementHolder.tags().count(); @@ -194,15 +188,14 @@ class TagsCommand final long count, final long currentPage, final ChatFormatting elementColor, - final Supplier> names) - { + final Supplier> names + ) { final String allElementNames = names.get().sorted().collect(Collectors.joining("\n")); final long totalPages = (count - 1) / PAGE_SIZE + 1; final long actualPage = (long) Mth.clamp(currentPage, 1, totalPages); MutableComponent containsComponent = Component.translatable(containsText, count); - if (count > 0) // Highlight the count text, make it clickable, and append page counters - { + if (count > 0) { // Highlight the count text, make it clickable, and append page counters containsComponent = ComponentUtils.wrapInSquareBrackets(containsComponent.withStyle(s -> s .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, allElementNames)) @@ -225,9 +218,10 @@ class TagsCommand return header.append("\n").append(tagElements); } - private static CompletableFuture suggestRegistries(final CommandContext ctx, - final SuggestionsBuilder builder) - { + private static CompletableFuture suggestRegistries( + final CommandContext ctx, + final SuggestionsBuilder builder + ) { ctx.getSource().registryAccess().registries() .map(RegistryAccess.RegistryEntry::key) .map(ResourceKey::location) @@ -236,31 +230,34 @@ class TagsCommand return builder.buildFuture(); } - private static SuggestionProvider suggestFromRegistry( - final Function, Iterable> namesFunction) - { - return (ctx, builder) -> getResourceKey(ctx, "registry", ROOT_REGISTRY_KEY) - .flatMap(key -> ctx.getSource().registryAccess().registry(key).map(registry -> { - SharedSuggestionProvider.suggestResource(namesFunction.apply(registry), builder); - return builder.buildFuture(); - })) - .orElseGet(builder::buildFuture); + private static SuggestionProvider suggestFromRegistry(final Function, Iterable> namesFunction) { + return (ctx, builder) -> { + var key = getResourceKey(ctx, "registry", ROOT_REGISTRY_KEY).orElse(null); + if (key == null) + return builder.buildFuture(); + + var reg = ctx.getSource().registryAccess().lookup(key).orElse(null); + if (reg == null) + return builder.buildFuture(); + + SharedSuggestionProvider.suggestResource(namesFunction.apply(reg), builder); + return builder.buildFuture(); + }; } - @SuppressWarnings("SameParameterValue") - private static Optional> getResourceKey(final CommandContext ctx, - final String name, - final ResourceKey> registryKey) - { + private static Optional> getResourceKey( + final CommandContext ctx, + final String name, + final ResourceKey> registryKey + ) { // Don't inline to avoid an unchecked cast warning due to raw types final ResourceKey key = ctx.getArgument(name, ResourceKey.class); return key.cast(registryKey); } @SuppressWarnings("unchecked") - private static O cast(final Object input) - { - return (O) input; + private static O cast(final Object input) { + return (O)input; } } diff --git a/src/main/java/net/minecraftforge/server/permission/nodes/PermissionNode.java b/src/main/java/net/minecraftforge/server/permission/nodes/PermissionNode.java index a433307681..416cea81db 100644 --- a/src/main/java/net/minecraftforge/server/permission/nodes/PermissionNode.java +++ b/src/main/java/net/minecraftforge/server/permission/nodes/PermissionNode.java @@ -42,8 +42,7 @@ import java.util.UUID; *

Each node should be registered via the {@link PermissionGatherEvent.Nodes} and stored statically in a field. * That instance should then be reused every-time a permission check needs to be performed via {@link net.minecraftforge.server.permission.PermissionAPI#getPermission(ServerPlayer, PermissionNode, PermissionDynamicContext[])}.

*/ -public final class PermissionNode -{ +public final class PermissionNode { private final String nodeName; private final PermissionType type; private final PermissionResolver defaultResolver; @@ -58,8 +57,7 @@ public final class PermissionNode * Calls {@link PermissionNode#PermissionNode(String, PermissionType, PermissionResolver, PermissionDynamicContextKey[])} * with "namespace.path" as the first parameter */ - public PermissionNode(ResourceLocation nodeName, PermissionType type, PermissionResolver defaultResolver, PermissionDynamicContextKey... dynamics) - { + public PermissionNode(ResourceLocation nodeName, PermissionType type, PermissionResolver defaultResolver, PermissionDynamicContextKey... dynamics) { this(nodeName.getNamespace(), nodeName.getPath(), type, defaultResolver, dynamics); } @@ -67,8 +65,7 @@ public final class PermissionNode * Calls {@link PermissionNode#PermissionNode(String, PermissionType, PermissionResolver, PermissionDynamicContextKey[])} * with "modid.nodename" as the first parameter */ - public PermissionNode(String modID, String nodeName, PermissionType type, PermissionResolver defaultResolver, PermissionDynamicContextKey... dynamics) - { + public PermissionNode(String modID, String nodeName, PermissionType type, PermissionResolver defaultResolver, PermissionDynamicContextKey... dynamics) { this(modID + "." + nodeName, type, defaultResolver, dynamics); } @@ -79,8 +76,7 @@ public final class PermissionNode * @param dynamics PermissionDynamicContextKey is a dynamic component for permission nodes, similar to BlockState Properties. * They must be passed into the constructor if you want to use them. */ - private PermissionNode(String nodeName, PermissionType type, PermissionResolver defaultResolver, PermissionDynamicContextKey... dynamics) - { + private PermissionNode(String nodeName, PermissionType type, PermissionResolver defaultResolver, PermissionDynamicContextKey... dynamics) { this.nodeName = nodeName; this.type = type; this.dynamics = dynamics; @@ -101,8 +97,7 @@ public final class PermissionNode * when using TranslatableComponent, key should be of format {@code "permission.desc."} * @return itself with the new information set. */ - public PermissionNode setInformation(@NotNull Component readableName, @NotNull Component description) - { + public PermissionNode setInformation(@NotNull Component readableName, @NotNull Component description) { Preconditions.checkNotNull(readableName, "Readable name for PermissionNodes must not be null %s", this.nodeName); Preconditions.checkNotNull(description, "Description for PermissionNodes must not be null %s", this.nodeName); @@ -112,35 +107,29 @@ public final class PermissionNode return this; } - public String getNodeName() - { + public String getNodeName() { return nodeName; } - public PermissionType getType() - { + public PermissionType getType() { return type; } - public PermissionDynamicContextKey[] getDynamics() - { + public PermissionDynamicContextKey[] getDynamics() { return dynamics; } - public PermissionResolver getDefaultResolver() - { + public PermissionResolver getDefaultResolver() { return defaultResolver; } @Nullable - public Component getReadableName() - { + public Component getReadableName() { return readableName; } @Nullable - public Component getDescription() - { + public Component getDescription() { return description; } @@ -150,8 +139,7 @@ public final class PermissionNode * @param generic value of the PermissionType of a PermissionNode */ @FunctionalInterface - public interface PermissionResolver - { + public interface PermissionResolver { /** * @param player an online player * @param playerUUID if the player is null, this UUID belongs to an offline player, @@ -163,16 +151,14 @@ public final class PermissionNode } @Override - public boolean equals(Object o) - { + public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof PermissionNode otherNode)) return false; return nodeName.equals(otherNode.nodeName) && type.equals(otherNode.type); } @Override - public int hashCode() - { + public int hashCode() { return Objects.hash(nodeName, type); } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 1b31ddd1ab..f61b24d6ea 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -13,19 +13,20 @@ protected net.minecraft.client.gui.components.DebugScreenOverlay m_286013_(Lnet/ public net.minecraft.client.gui.screens.MenuScreens m_96206_(Lnet/minecraft/world/inventory/MenuType;Lnet/minecraft/client/gui/screens/MenuScreens$ScreenConstructor;)V # register public net.minecraft.client.gui.screens.MenuScreens$ScreenConstructor public net.minecraft.client.gui.screens.Screen f_169369_ # renderables +protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_351642_(Lnet/minecraft/client/gui/GuiGraphics;)V # renderSlotHighlightBack +protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_352078_(Lnet/minecraft/client/gui/GuiGraphics;)V # renderSlotHighlightFront public net.minecraft.client.model.geom.LayerDefinitions f_171106_ # OUTER_ARMOR_DEFORMATION public net.minecraft.client.model.geom.LayerDefinitions f_171107_ # INNER_ARMOR_DEFORMATION public net.minecraft.client.multiplayer.ClientPacketListener f_104899_ # commands public net.minecraft.client.multiplayer.SessionSearchTrees f_336706_ # CREATIVE_TAGS public net.minecraft.client.multiplayer.SessionSearchTrees f_337599_ # CREATIVE_NAMES public net.minecraft.client.multiplayer.SessionSearchTrees$Key -public net.minecraft.client.multiplayer.SessionSearchTrees$Key ()V +public net.minecraft.client.multiplayer.SessionSearchTrees$Key ()V # constructor public net.minecraft.client.particle.ParticleEngine m_107378_(Lnet/minecraft/core/particles/ParticleType;Lnet/minecraft/client/particle/ParticleEngine$SpriteParticleRegistration;)V # register public net.minecraft.client.particle.ParticleEngine m_107381_(Lnet/minecraft/core/particles/ParticleType;Lnet/minecraft/client/particle/ParticleProvider;)V # register public net.minecraft.client.particle.ParticleEngine m_272137_(Lnet/minecraft/core/particles/ParticleType;Lnet/minecraft/client/particle/ParticleProvider$Sprite;)V # register public net.minecraft.client.particle.ParticleEngine$SpriteParticleRegistration -public net.minecraft.client.player.LocalPlayer m_8088_()I # getPermissionLevel -public net.minecraft.client.renderer.GameRenderer m_109128_(Lnet/minecraft/resources/ResourceLocation;)V # loadEffect +public net.minecraft.client.player.LocalPlayer m_9242_()I # getPermissionLevel public net.minecraft.client.renderer.LevelRenderer m_109817_()Z # shouldShowEntityOutlines protected-f net.minecraft.client.renderer.RenderStateShard f_110131_ # setupState public net.minecraft.client.renderer.RenderStateShard$BooleanStateShard @@ -47,6 +48,7 @@ public net.minecraft.client.renderer.RenderStateShard$TransparencyStateShard public net.minecraft.client.renderer.RenderStateShard$WriteMaskStateShard public net.minecraft.client.renderer.RenderType m_173215_(Ljava/lang/String;Lcom/mojang/blaze3d/vertex/VertexFormat;Lcom/mojang/blaze3d/vertex/VertexFormat$Mode;IZZLnet/minecraft/client/renderer/RenderType$CompositeState;)Lnet/minecraft/client/renderer/RenderType$CompositeRenderType; # create public net.minecraft.client.renderer.RenderType$CompositeState +protected net.minecraft.client.renderer.block.model.BakedOverrides ()V # constructor public net.minecraft.client.renderer.block.model.BlockElement m_111320_(Lnet/minecraft/core/Direction;)[F # uvsByFace public net.minecraft.client.renderer.block.model.BlockElement$Deserializer public net.minecraft.client.renderer.block.model.BlockElement$Deserializer ()V # constructor @@ -61,8 +63,6 @@ public net.minecraft.client.renderer.block.model.BlockModel m_111437_(Lnet/minec 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 -public net.minecraft.client.renderer.block.model.ItemOverrides$BakedOverride public net.minecraft.client.renderer.block.model.ItemTransform$Deserializer public net.minecraft.client.renderer.block.model.ItemTransform$Deserializer ()V # constructor public net.minecraft.client.renderer.block.model.ItemTransform$Deserializer f_111769_ # DEFAULT_ROTATION @@ -79,14 +79,14 @@ public net.minecraft.client.renderer.entity.EntityRenderers m_174036_(Lnet/minec 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.entity.layers.ElytraLayer f_116934_ # WINGS_LOCATION +protected net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer m_117078_(Lnet/minecraft/client/renderer/entity/state/HumanoidRenderState;Lnet/minecraft/world/entity/EquipmentSlot;)Lnet/minecraft/client/model/HumanoidModel; # getArmorModel 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.TextureAtlasHolder f_118884_ # textureAtlas -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.resources.model.ModelBakery f_119241_ # ITEM_MODEL_GENERATOR +public net.minecraft.client.resources.model.SimpleBakedModel$Builder (ZZZLnet/minecraft/client/renderer/block/model/ItemTransforms;)V # constructor public net.minecraft.client.sounds.SoundEngine f_120217_ # soundManager public net.minecraft.commands.CommandSourceStack f_81288_ # source public net.minecraft.commands.arguments.selector.EntitySelectorParser m_121229_()V # finalizePredicates @@ -103,14 +103,13 @@ 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 protected net.minecraft.core.MappedRegistry m_245420_(Lnet/minecraft/resources/ResourceKey;)Lnet/minecraft/core/Holder$Reference; # getOrCreateHolderOrThrow +protected net.minecraft.core.MappedRegistry m_354248_(Lnet/minecraft/tags/TagKey;)Lnet/minecraft/core/HolderSet$Named; # getOrCreateTagForRegistration +protected net.minecraft.core.MappedRegistry$TagSet public net.minecraft.core.RegistrySetBuilder$LazyHolder m_247654_(Ljava/lang/Object;)V # bindValue public net.minecraft.core.particles.SimpleParticleType (Z)V # constructor 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_176523_(Lnet/minecraft/data/BlockFamily;Lnet/minecraft/data/BlockFamily$Variant;)Lnet/minecraft/world/level/block/Block; # getBaseBlock 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_176678_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # fenceBuilder @@ -121,6 +120,7 @@ protected net.minecraft.data.recipes.RecipeProvider m_245792_(Lnet/minecraft/dat 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.packs.VanillaRecipeProvider (Lnet/minecraft/core/HolderLookup$Provider;Lnet/minecraft/data/recipes/RecipeOutput;)V # constructor 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 @@ -152,6 +152,7 @@ public net.minecraft.server.packs.repository.FolderRepositorySource$FolderPackDe public net.minecraft.server.packs.repository.FolderRepositorySource$FolderPackDetector (Lnet/minecraft/world/level/validation/DirectoryValidator;)V # constructor 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 +protected net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener (Lcom/mojang/serialization/DynamicOps;Lcom/mojang/serialization/Codec;Ljava/lang/String;)V # constructor public net.minecraft.util.datafix.fixes.StructuresBecomeConfiguredFix$Conversion public net.minecraft.util.thread.BlockableEventLoop m_18689_(Ljava/lang/Runnable;)Ljava/util/concurrent/CompletableFuture; # submitAsync #group public net.minecraft.world.damagesource.DamageSource *() #All methods public, most are already @@ -208,7 +209,7 @@ 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.DiggerItem (Lnet/minecraft/world/item/Tier;Lnet/minecraft/tags/TagKey;Lnet/minecraft/world/item/Item$Properties;)V # constructor +public net.minecraft.world.item.DiggerItem (Lnet/minecraft/world/item/ToolMaterial;Lnet/minecraft/tags/TagKey;FFLnet/minecraft/world/item/Item$Properties;)V # constructor #endgroup private-f net.minecraft.world.item.ItemDisplayContext f_268735_ # id public net.minecraft.world.item.ItemStackLinkedSet f_260558_ # TYPE_AND_TAG @@ -217,13 +218,7 @@ 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 public net.minecraft.world.item.context.UseOnContext (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 public-f net.minecraft.world.item.crafting.Ingredient -protected net.minecraft.world.item.crafting.Ingredient (Ljava/util/stream/Stream;)V # constructor -public net.minecraft.world.item.crafting.Ingredient m_43938_(Ljava/util/stream/Stream;)Lnet/minecraft/world/item/crafting/Ingredient; # fromValues -public net.minecraft.world.item.crafting.Ingredient$ItemValue -public net.minecraft.world.item.crafting.Ingredient$ItemValue (Lnet/minecraft/world/item/ItemStack;)V # constructor -public net.minecraft.world.item.crafting.Ingredient$TagValue -public net.minecraft.world.item.crafting.Ingredient$TagValue (Lnet/minecraft/tags/TagKey;)V # constructor -public net.minecraft.world.item.crafting.Ingredient$Value +protected net.minecraft.world.item.crafting.Ingredient (Lnet/minecraft/core/HolderSet;)V # constructor public net.minecraft.world.level.GameRules m_46189_(Ljava/lang/String;Lnet/minecraft/world/level/GameRules$Category;Lnet/minecraft/world/level/GameRules$Type;)Lnet/minecraft/world/level/GameRules$Key; # register public net.minecraft.world.level.GameRules$BooleanValue m_46250_(Z)Lnet/minecraft/world/level/GameRules$Type; # create public net.minecraft.world.level.GameRules$BooleanValue m_46252_(ZLjava/util/function/BiConsumer;)Lnet/minecraft/world/level/GameRules$Type; # create @@ -270,13 +265,14 @@ public net.minecraft.world.level.block.CakeBlock (Lnet/minecraft/world/lev public net.minecraft.world.level.block.CandleCakeBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.CartographyTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.CarvedPumpkinBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor -public net.minecraft.world.level.block.ChestBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;Ljava/util/function/Supplier;)V # constructor +public net.minecraft.world.level.block.ChestBlock (Ljava/util/function/Supplier;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.ChorusFlowerBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.ChorusPlantBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.CoralFanBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.CoralPlantBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.CoralWallFanBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.CraftingTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.CreakingHeartBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.CropBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.DeadBushBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.DecoratedPotBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor @@ -288,7 +284,6 @@ public net.minecraft.world.level.block.EndGatewayBlock (Lnet/minecraft/wor public net.minecraft.world.level.block.EndPortalBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.EndRodBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.EnderChestBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor -public net.minecraft.world.level.block.EquipableCarvedPumpkinBlock (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/resources/ResourceKey;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor @@ -402,4 +397,4 @@ public net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacerType < protected net.minecraft.world.level.portal.PortalForcer f_77648_ # level public net.minecraft.world.level.storage.LevelResource (Ljava/lang/String;)V # constructor private-f net.minecraft.world.level.storage.loot.LootPool f_79028_ # rolls -private-f net.minecraft.world.level.storage.loot.LootPool f_79029_ # bonusRolls +private-f net.minecraft.world.level.storage.loot.LootPool f_79029_ # bonusRolls \ No newline at end of file diff --git a/src/main/resources/coremods/method_redirector.js b/src/main/resources/coremods/method_redirector.js index 042ff05b94..b5c30fc368 100644 --- a/src/main/resources/coremods/method_redirector.js +++ b/src/main/resources/coremods/method_redirector.js @@ -8,7 +8,7 @@ function finalizeSpawnNode(node){ Opcodes.INVOKESTATIC, "net/minecraftforge/event/ForgeEventFactory", "onFinalizeSpawn", - "(Lnet/minecraft/world/entity/Mob;Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/MobSpawnType;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;", + "(Lnet/minecraft/world/entity/Mob;Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/EntitySpawnReason;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;", false); } diff --git a/src/main/resources/forge.exc b/src/main/resources/forge.exc index cb9e290a36..fd1f4f25b4 100644 --- a/src/main/resources/forge.exc +++ b/src/main/resources/forge.exc @@ -2,10 +2,8 @@ com/mojang/blaze3d/vertex/VertexConsumer.putBulkData(Lcom/mojang/blaze3d/vertex/ net/minecraft/client/Options.processOptionsForge(Lnet/minecraft/client/Options$FieldAccess;)V=|p_168428_ net/minecraft/client/gui/Gui.renderSelectedItemName(Lnet/minecraft/client/gui/GuiGraphics;I)V=|p_283501_,yShift net/minecraft/client/gui/screens/MenuScreens.getScreenFactory(Lnet/minecraft/world/inventory/MenuType;Lnet/minecraft/client/Minecraft;ILnet/minecraft/network/chat/Component;)Ljava/util/Optional;=|p_96202_,p_96203_,p_96204_,p_96205_ -net/minecraft/client/gui/screens/inventory/tooltip/TooltipRenderUtil.renderTooltipBackground(Lnet/minecraft/client/gui/GuiGraphics;IIIIIIIII)V=|p_282666_,p_281901_,p_281846_,p_281559_,p_283336_,p_283422_,backgroundTop,backgroundBottom,borderTop,borderBottom net/minecraft/client/renderer/ScreenEffectRenderer.getOverlayBlock(Lnet/minecraft/world/entity/player/Player;)Lorg/apache/commons/lang3/tuple/Pair;=|p_110717_ net/minecraft/client/renderer/ScreenEffectRenderer.renderFluid(Lnet/minecraft/client/Minecraft;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/resources/ResourceLocation;)V=|p_110726_,p_110727_,texture -net/minecraft/client/renderer/ShaderInstance.(Lnet/minecraft/server/packs/resources/ResourceProvider;Lnet/minecraft/resources/ResourceLocation;Lcom/mojang/blaze3d/vertex/VertexFormat;)V=|p_173336_,shaderLocation,p_173338_ net/minecraft/client/renderer/block/BlockModelShaper.getTexture(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;=|p_110883_,level,pos net/minecraft/client/renderer/block/BlockRenderDispatcher.renderBatched(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;ZLnet/minecraft/util/RandomSource;Lnet/minecraftforge/client/model/data/ModelData;Lnet/minecraft/client/renderer/RenderType;)V=|p_234356_,p_234357_,p_234358_,p_234359_,p_234360_,p_234361_,p_234362_,modelData,renderType net/minecraft/client/renderer/block/BlockRenderDispatcher.renderBreakingTexture(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lnet/minecraftforge/client/model/data/ModelData;)V=|p_110919_,p_110920_,p_110921_,p_110922_,p_110923_,modelData @@ -14,13 +12,10 @@ net/minecraft/client/renderer/block/ModelBlockRenderer.renderModel(Lcom/mojang/b net/minecraft/client/renderer/block/ModelBlockRenderer.tesselateBlock(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_234380_,p_234381_,p_234382_,p_234383_,p_234384_,p_234385_,p_234386_,p_234387_,p_234388_,p_234389_,modelData,renderType net/minecraft/client/renderer/block/ModelBlockRenderer.tesselateWithAO(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_111079_,p_111080_,p_111081_,p_111082_,p_111083_,p_111084_,p_111085_,p_111086_,p_111087_,p_111088_,modelData,renderType 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/BlockElement.(Lorg/joml/Vector3f;Lorg/joml/Vector3f;Ljava/util/Map;Lnet/minecraft/client/renderer/block/model/BlockElementRotation;ZLnet/minecraftforge/client/model/ForgeFaceData;)V=|p_253626_,p_254426_,p_254454_,p_254229_,p_253661_,faceData net/minecraft/client/renderer/block/model/BlockElementFace.(Lnet/minecraft/core/Direction;ILjava/lang/String;Lnet/minecraft/client/renderer/block/model/BlockFaceUV;Lnet/minecraftforge/client/model/ForgeFaceData;)V=|p_111359_,p_111360_,p_111361_,p_111362_,faceData 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/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.(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/registries/RegistriesDatapackGenerator.(Lnet/minecraft/data/PackOutput;Ljava/util/concurrent/CompletableFuture;Ljava/util/Set;)V=|p_256643_,p_255780_,modIds 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 @@ -49,14 +44,9 @@ net/minecraft/server/level/DistanceManager.addRegionTicket(Lnet/minecraft/server net/minecraft/server/level/DistanceManager.removeRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;Z)V=|p_140850_,p_140851_,p_140852_,p_140853_,forceTicks net/minecraft/server/level/ServerChunkCache.addRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;Z)V=|p_8388_,p_8389_,p_8390_,p_8391_,forceTicks net/minecraft/server/level/ServerChunkCache.removeRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;Z)V=|p_8439_,p_8440_,p_8441_,p_8442_,forceTicks -net/minecraft/server/level/ServerPlayer.changeDimension(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/world/entity/Entity;=|p_9180_,teleporter 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/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/Entity.playCombinationStepSounds(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;)V=|p_277472_,p_277630_,primaryPos,secondaryPos -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/projectile/ThrownEnderpearl.changeDimension(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/world/entity/Entity;=|p_37506_,teleporter net/minecraft/world/item/BoneMealItem.applyBonemeal(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/player/Player;)Z=|p_40628_,p_40629_,p_40630_,player net/minecraft/world/item/BucketItem.emptyContents(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/phys/BlockHitResult;Lnet/minecraft/world/item/ItemStack;)Z=|p_150716_,p_150717_,p_150718_,p_150719_,container net/minecraft/world/item/ItemStack.onItemUse(Lnet/minecraft/world/item/context/UseOnContext;Ljava/util/function/Function;)Lnet/minecraft/world/InteractionResult;=|p_41662_,callback diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/conditional_doesnt_load_empty.json b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/conditional_doesnt_load_empty.json index be95984161..1af31920e2 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/conditional_doesnt_load_empty.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/conditional_doesnt_load_empty.json @@ -1,5 +1,5 @@ { - "advancements": [ + "forge:conditional": [ { "parent": "minecraft:recipes/root", "criteria": { diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/conditional_recipe_choice.json b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/conditional_recipe_choice.json index d9cd081033..1c856d2f82 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/conditional_recipe_choice.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/conditional_recipe_choice.json @@ -1,5 +1,5 @@ { - "advancements": [ + "forge:conditional": [ { "parent": "minecraft:recipes/root", "criteria": { diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/cooking_false_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/cooking_false_conditions.json index be95984161..1af31920e2 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/cooking_false_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/cooking_false_conditions.json @@ -1,5 +1,5 @@ { - "advancements": [ + "forge:conditional": [ { "parent": "minecraft:recipes/root", "criteria": { diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/cooking_true_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/cooking_true_conditions.json index 415abef1c2..96d405ee5e 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/cooking_true_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/cooking_true_conditions.json @@ -1,5 +1,5 @@ { - "advancements": [ + "forge:conditional": [ { "parent": "minecraft:recipes/root", "criteria": { diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/shaped_false_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/shaped_false_conditions.json index be95984161..1af31920e2 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/shaped_false_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/shaped_false_conditions.json @@ -1,5 +1,5 @@ { - "advancements": [ + "forge:conditional": [ { "parent": "minecraft:recipes/root", "criteria": { diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/shaped_true_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/shaped_true_conditions.json index 132aae35c9..83bf177ead 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/shaped_true_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/shaped_true_conditions.json @@ -1,5 +1,5 @@ { - "advancements": [ + "forge:conditional": [ { "parent": "minecraft:recipes/root", "criteria": { diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/shapeless_false_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/shapeless_false_conditions.json index 64cb91c38b..171ff54bd3 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/shapeless_false_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/shapeless_false_conditions.json @@ -1,5 +1,5 @@ { - "advancements": [ + "forge:conditional": [ { "parent": "minecraft:recipes/root", "criteria": { diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/shapeless_true_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/shapeless_true_conditions.json index 131fba1ffc..fc2260cf26 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/shapeless_true_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/shapeless_true_conditions.json @@ -1,5 +1,5 @@ { - "advancements": [ + "forge:conditional": [ { "parent": "minecraft:recipes/root", "criteria": { diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/singe_item_true_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/singe_item_true_conditions.json index 131fba1ffc..fc2260cf26 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/singe_item_true_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/singe_item_true_conditions.json @@ -1,5 +1,5 @@ { - "advancements": [ + "forge:conditional": [ { "parent": "minecraft:recipes/root", "criteria": { diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/single_item_false_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/single_item_false_conditions.json index be95984161..1af31920e2 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/single_item_false_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/single_item_false_conditions.json @@ -1,5 +1,5 @@ { - "advancements": [ + "forge:conditional": [ { "parent": "minecraft:recipes/root", "criteria": { diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/tag_empty_condition_doesnt_load.json b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/tag_empty_condition_doesnt_load.json index 2bf78ddbfd..b35b2444a6 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/tag_empty_condition_doesnt_load.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/tag_empty_condition_doesnt_load.json @@ -1,5 +1,5 @@ { - "advancements": [ + "forge:conditional": [ { "parent": "minecraft:recipes/root", "criteria": { diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/tag_empty_condition_loads.json b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/tag_empty_condition_loads.json index ddb8a35ffa..1a4e15423e 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/tag_empty_condition_loads.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/tag_empty_condition_loads.json @@ -1,5 +1,5 @@ { - "advancements": [ + "forge:conditional": [ { "parent": "minecraft:recipes/root", "criteria": { diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/test_encode_all_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/test_encode_all_conditions.json index b5db751247..7690a734b0 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/test_encode_all_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/advancement/recipes/test_encode_all_conditions.json @@ -1,5 +1,5 @@ { - "advancements": [ + "forge:conditional": [ { "parent": "minecraft:recipes/root", "criteria": { diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/conditional_doesnt_load_empty.json b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/conditional_doesnt_load_empty.json index 75a570a747..7691fc96a8 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/conditional_doesnt_load_empty.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/conditional_doesnt_load_empty.json @@ -9,9 +9,7 @@ "type": "minecraft:crafting_shapeless", "category": "misc", "ingredients": [ - { - "item": "minecraft:dirt" - } + "minecraft:dirt" ], "result": { "count": 64, diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/conditional_recipe_choice.json b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/conditional_recipe_choice.json index cbdd1f4b6e..e850d76310 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/conditional_recipe_choice.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/conditional_recipe_choice.json @@ -9,9 +9,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "X": { - "item": "minecraft:dirt" - } + "X": "minecraft:dirt" }, "pattern": [ "XXX", @@ -31,9 +29,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "X": { - "item": "minecraft:oak_log" - } + "X": "minecraft:oak_log" }, "pattern": [ "XXX", diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/cooking_false_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/cooking_false_conditions.json index c95b42a6cc..b5c8b8b418 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/cooking_false_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/cooking_false_conditions.json @@ -10,9 +10,7 @@ "category": "blocks", "cookingtime": 200, "experience": 0.1, - "ingredient": { - "item": "minecraft:dirt" - }, + "ingredient": "minecraft:dirt", "result": { "id": "minecraft:diamond_block" } diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/cooking_true_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/cooking_true_conditions.json index 2d92519498..fd1e0dcd93 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/cooking_true_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/cooking_true_conditions.json @@ -10,9 +10,7 @@ "category": "blocks", "cookingtime": 200, "experience": 0.1, - "ingredient": { - "item": "minecraft:bee_nest" - }, + "ingredient": "minecraft:bee_nest", "result": { "id": "minecraft:diamond_block" } diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/shaped_false_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/shaped_false_conditions.json index 5fda9c0602..45f9b7db70 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/shaped_false_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/shaped_false_conditions.json @@ -9,9 +9,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "X": { - "item": "minecraft:dirt" - } + "X": "minecraft:dirt" }, "pattern": [ "XXX", diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/shaped_true_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/shaped_true_conditions.json index e268db673f..87e16af726 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/shaped_true_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/shaped_true_conditions.json @@ -9,9 +9,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "X": { - "item": "minecraft:oak_log" - } + "X": "minecraft:oak_log" }, "pattern": [ "XXX", diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/shapeless_false_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/shapeless_false_conditions.json index 3a381deb8e..2ef7076198 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/shapeless_false_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/shapeless_false_conditions.json @@ -9,15 +9,9 @@ "type": "minecraft:crafting_shapeless", "category": "misc", "ingredients": [ - { - "item": "minecraft:redstone_ore" - }, - { - "item": "minecraft:redstone_ore" - }, - { - "item": "minecraft:redstone_ore" - } + "minecraft:redstone_ore", + "minecraft:redstone_ore", + "minecraft:redstone_ore" ], "result": { "count": 1, diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/shapeless_true_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/shapeless_true_conditions.json index 694f9eeae4..a09798c3bf 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/shapeless_true_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/shapeless_true_conditions.json @@ -9,18 +9,10 @@ "type": "minecraft:crafting_shapeless", "category": "misc", "ingredients": [ - { - "item": "minecraft:redstone_ore" - }, - { - "item": "minecraft:redstone_ore" - }, - { - "item": "minecraft:redstone_ore" - }, - { - "item": "minecraft:redstone_ore" - } + "minecraft:redstone_ore", + "minecraft:redstone_ore", + "minecraft:redstone_ore", + "minecraft:redstone_ore" ], "result": { "count": 1, diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/singe_item_true_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/singe_item_true_conditions.json index f55f2f98c7..dfb56e5b21 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/singe_item_true_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/singe_item_true_conditions.json @@ -7,9 +7,7 @@ { "recipe": { "type": "minecraft:stonecutting", - "ingredient": { - "item": "minecraft:redstone_ore" - }, + "ingredient": "minecraft:redstone_ore", "result": { "count": 1, "id": "minecraft:diamond_block" diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/single_item_false_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/single_item_false_conditions.json index d381579d12..5024cb0967 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/single_item_false_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/single_item_false_conditions.json @@ -7,9 +7,7 @@ { "recipe": { "type": "minecraft:stonecutting", - "ingredient": { - "item": "minecraft:dirt" - }, + "ingredient": "minecraft:dirt", "result": { "count": 1, "id": "minecraft:diamond_block" diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/tag_empty_condition_doesnt_load.json b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/tag_empty_condition_doesnt_load.json index e929cc3be0..d71142b0b9 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/tag_empty_condition_doesnt_load.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/tag_empty_condition_doesnt_load.json @@ -10,15 +10,9 @@ "type": "minecraft:crafting_shapeless", "category": "misc", "ingredients": [ - { - "item": "minecraft:iron_ore" - }, - { - "item": "minecraft:iron_ore" - }, - { - "item": "minecraft:iron_ore" - } + "minecraft:iron_ore", + "minecraft:iron_ore", + "minecraft:iron_ore" ], "result": { "count": 1, diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/tag_empty_condition_loads.json b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/tag_empty_condition_loads.json index be5c40a843..510b820adf 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/tag_empty_condition_loads.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/tag_empty_condition_loads.json @@ -10,15 +10,9 @@ "type": "minecraft:crafting_shapeless", "category": "misc", "ingredients": [ - { - "item": "minecraft:gold_ore" - }, - { - "item": "minecraft:gold_ore" - }, - { - "item": "minecraft:gold_ore" - } + "minecraft:gold_ore", + "minecraft:gold_ore", + "minecraft:gold_ore" ], "result": { "count": 1, diff --git a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/test_encode_all_conditions.json b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/test_encode_all_conditions.json index b9ff8baf67..72939248d3 100644 --- a/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/test_encode_all_conditions.json +++ b/src/test/generated/conditional_recipe/data/conditional_recipe/recipe/test_encode_all_conditions.json @@ -37,9 +37,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "X": { - "item": "minecraft:dirt" - } + "X": "minecraft:dirt" }, "pattern": [ "XXX", diff --git a/src/test/generated/criterion_test/data/criterion_test/advancement/break_glass_with_fish.json b/src/test/generated/criterion_test/data/criterion_test/advancement/break_glass_with_fish.json index 86cc37ed83..7cdb0f8b10 100644 --- a/src/test/generated/criterion_test/data/criterion_test/advancement/break_glass_with_fish.json +++ b/src/test/generated/criterion_test/data/criterion_test/advancement/break_glass_with_fish.json @@ -5,7 +5,7 @@ "conditions": { "allowOffhand": true, "breakingBlock": { - "blocks": "#forge:glass" + "blocks": "#c:glass_blocks" }, "holdingItem": { "items": "#criterion_test:fish" diff --git a/src/test/generated/custom_ingredients/data/custom_ingredients/recipe/difference_ingredient.json b/src/test/generated/custom_ingredients/data/custom_ingredients/recipe/difference_ingredient.json index 0a8b17be8d..f7d5568ece 100644 --- a/src/test/generated/custom_ingredients/data/custom_ingredients/recipe/difference_ingredient.json +++ b/src/test/generated/custom_ingredients/data/custom_ingredients/recipe/difference_ingredient.json @@ -4,12 +4,8 @@ "key": { "X": { "type": "forge:difference", - "base": { - "tag": "custom_ingredients:left" - }, - "subtracted": { - "tag": "custom_ingredients:right" - } + "base": "#custom_ingredients:left", + "subtracted": "#custom_ingredients:right" } }, "pattern": [ diff --git a/src/test/generated/custom_ingredients/data/custom_ingredients/recipe/intersection_ingredient.json b/src/test/generated/custom_ingredients/data/custom_ingredients/recipe/intersection_ingredient.json index 75ba21f254..7729c0489f 100644 --- a/src/test/generated/custom_ingredients/data/custom_ingredients/recipe/intersection_ingredient.json +++ b/src/test/generated/custom_ingredients/data/custom_ingredients/recipe/intersection_ingredient.json @@ -5,12 +5,8 @@ "X": { "type": "forge:intersection", "children": [ - { - "tag": "custom_ingredients:left" - }, - { - "tag": "custom_ingredients:right" - } + "#custom_ingredients:left", + "#custom_ingredients:right" ] } }, diff --git a/src/test/generated/mdk_datagen/pack.mcmeta b/src/test/generated/mdk_datagen/pack.mcmeta index 6061a13ab0..d5c1bd6c9a 100644 --- a/src/test/generated/mdk_datagen/pack.mcmeta +++ b/src/test/generated/mdk_datagen/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "${mod_id} resources", - "pack_format": 34 + "pack_format": 42 } } \ No newline at end of file diff --git a/src/test/generated/test_helper_mod/pack.mcmeta b/src/test/generated/test_helper_mod/pack.mcmeta index 6239a42009..77feec54eb 100644 --- a/src/test/generated/test_helper_mod/pack.mcmeta +++ b/src/test/generated/test_helper_mod/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "Forge tests resource pack", - "pack_format": 34 + "pack_format": 42 } } \ No newline at end of file diff --git a/src/test/java/net/minecraftforge/debug/client/ObjModelTest.java b/src/test/java/net/minecraftforge/debug/client/ObjModelTest.java index 615bf0fde3..8b53e98d6f 100644 --- a/src/test/java/net/minecraftforge/debug/client/ObjModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/ObjModelTest.java @@ -2,7 +2,7 @@ * Copyright (c) Forge Development LLC and contributors * SPDX-License-Identifier: LGPL-2.1-only */ - +/* package net.minecraftforge.debug.client; import com.mojang.blaze3d.vertex.PoseStack; @@ -16,7 +16,6 @@ import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.phys.Vec3; import net.minecraftforge.client.event.ModelEvent; -import net.minecraftforge.client.event.RenderLevelStageEvent; import net.minecraftforge.client.model.data.ModelData; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; @@ -26,6 +25,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; * Tests loading and rendering an obj-model using the using Forge's {@link net.minecraftforge.client.model.obj.ObjLoader}. * When enabled, this will render a pyramid loaded from an obj model at coordinates 0,0,0. */ +/* @Mod(ObjModelTest.MODID) public class ObjModelTest { private static final boolean ENABLED = true; @@ -77,3 +77,4 @@ public class ObjModelTest { } } } +*/ \ No newline at end of file diff --git a/src/test/java/net/minecraftforge/debug/gameplay/crafting/ConditionalRecipeTest.java b/src/test/java/net/minecraftforge/debug/gameplay/crafting/ConditionalRecipeTest.java index d7e94f0480..ad4af6a32e 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/crafting/ConditionalRecipeTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/crafting/ConditionalRecipeTest.java @@ -8,12 +8,11 @@ package net.minecraftforge.debug.gameplay.crafting; import java.util.concurrent.CompletableFuture; import net.minecraft.core.HolderLookup; +import net.minecraft.core.HolderLookup.Provider; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeCategory; import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.data.recipes.RecipeProvider; -import net.minecraft.data.recipes.ShapedRecipeBuilder; -import net.minecraft.data.recipes.ShapelessRecipeBuilder; import net.minecraft.data.recipes.SimpleCookingRecipeBuilder; import net.minecraft.data.recipes.SingleItemRecipeBuilder; import net.minecraft.data.tags.ItemTagsProvider; @@ -47,7 +46,7 @@ import net.minecraftforge.test.BaseTestMod; @Mod(ConditionalRecipeTest.MODID) public class ConditionalRecipeTest extends BaseTestMod { static final String MODID = "conditional_recipe"; - + public ConditionalRecipeTest(FMLJavaModLoadingContext context) { super(context); } @@ -55,7 +54,7 @@ public class ConditionalRecipeTest extends BaseTestMod { @SubscribeEvent public void gatherData(GatherDataEvent event) { var gen = event.getGenerator(); - gen.addProvider(event.includeServer(), new Recipes(gen.getPackOutput(), event.getLookupProvider())); + gen.addProvider(event.includeServer(), new Recipes.Runner(gen.getPackOutput(), event.getLookupProvider())); var testBlockTags = new TestBlockTags(gen.getPackOutput(), event.getLookupProvider(), event.getExistingFileHelper()); gen.addProvider(event.includeServer(), testBlockTags); gen.addProvider(event.includeServer(), new TestItemTags(gen.getPackOutput(), event.getLookupProvider(), testBlockTags.contentsGetter(), event.getExistingFileHelper())); @@ -66,15 +65,15 @@ public class ConditionalRecipeTest extends BaseTestMod { } private static > void assertFalse(GameTestHelper helper, RecipeType type, C container) { - var recipe = helper.getLevel().getRecipeManager().getRecipeFor(type, container, helper.getLevel()); + var recipe = helper.getLevel().recipeAccess().getRecipeFor(type, container, helper.getLevel()); helper.assertTrue(recipe.isEmpty(), () -> "Found crafting recipe when unexpected: " + recipe.get().id()); helper.succeed(); } private static > void assertTrue(GameTestHelper helper, RecipeType type, C container) { - var recipe = helper.getLevel().getRecipeManager().getRecipeFor(type, container, helper.getLevel()); + var recipe = helper.getLevel().recipeAccess().getRecipeFor(type, container, helper.getLevel()); helper.assertTrue(recipe.isPresent(), "Did not find crafting recipe when expected!"); - helper.assertTrue(recipe.get().id().getNamespace().equals(MODID), "It wasn't our recipe: " + recipe.get().id()); + helper.assertTrue(recipe.get().id().location().getNamespace().equals(MODID), "It wasn't our recipe: " + recipe.get().id()); helper.succeed(); } @@ -157,7 +156,7 @@ public class ConditionalRecipeTest extends BaseTestMod { .build() ); } - + @GameTest(template = "forge:empty3x3x3") public static void tag_empty_condition_with_populated_tag(GameTestHelper helper) { assertFalse(helper, RecipeType.CRAFTING, SimpleCraftingContainer.builder() @@ -166,7 +165,7 @@ public class ConditionalRecipeTest extends BaseTestMod { .build() ); } - + @GameTest(template = "forge:empty3x3x3") public static void tag_empty_condition_with_empty_tag(GameTestHelper helper) { assertTrue(helper, RecipeType.CRAFTING, SimpleCraftingContainer.builder() @@ -175,7 +174,7 @@ public class ConditionalRecipeTest extends BaseTestMod { .build() ); } - + public static class TestBlockTags extends BlockTagsProvider { public TestBlockTags(PackOutput output, CompletableFuture lookupProvider, ExistingFileHelper existingFileHelper) { super(output, lookupProvider, MODID, existingFileHelper); @@ -186,7 +185,7 @@ public class ConditionalRecipeTest extends BaseTestMod { // No block tags needed; just need a block provider content-getter to supply to the item tags generator } } - + public static class TestItemTags extends ItemTagsProvider { public TestItemTags(PackOutput output, CompletableFuture lookupProvider, CompletableFuture> blockTagProvider, ExistingFileHelper existingFileHelper) { super(output, lookupProvider, blockTagProvider, MODID, existingFileHelper); @@ -200,12 +199,12 @@ public class ConditionalRecipeTest extends BaseTestMod { } public static class Recipes extends RecipeProvider implements IConditionBuilder { - public Recipes(PackOutput gen, CompletableFuture lookup) { - super(gen, lookup); + public Recipes(HolderLookup.Provider lookup, RecipeOutput gen) { + super(lookup, gen); } @Override - protected void buildRecipes(RecipeOutput out) { + protected void buildRecipes() { // TODO: Move this to a Condition test instead of using recipe encoders. ConditionalRecipe.builder() .condition( @@ -220,7 +219,7 @@ public class ConditionalRecipeTest extends BaseTestMod { ) ) .recipe( - ShapedRecipeBuilder.shaped(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK, 64) + shaped(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK, 64) .pattern("XXX") .pattern("XXX") .pattern("XXX") @@ -228,12 +227,12 @@ public class ConditionalRecipeTest extends BaseTestMod { .unlockedBy(getHasName(Blocks.DIRT), has(Blocks.DIRT)) ::save ) - .save(out, rl("test_encode_all_conditions")); + .save(this.output, rl("test_encode_all_conditions")); ConditionalRecipe.builder() .condition(FALSE()) .recipe( - ShapedRecipeBuilder.shaped(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK, 64) + shaped(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK, 64) .pattern("XXX") .pattern("XXX") .pattern("XXX") @@ -241,12 +240,12 @@ public class ConditionalRecipeTest extends BaseTestMod { .unlockedBy(getHasName(Blocks.DIRT), has(Blocks.DIRT)) ::save ) - .save(out, rl("shaped_false_conditions")); + .save(this.output, rl("shaped_false_conditions")); ConditionalRecipe.builder() .condition(TRUE()) .recipe( - ShapedRecipeBuilder.shaped(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK, 64) + shaped(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK, 64) .pattern("XXX") .pattern("XXX") .pattern("XXX") @@ -254,24 +253,24 @@ public class ConditionalRecipeTest extends BaseTestMod { .unlockedBy(getHasName(Blocks.OAK_LOG), has(Blocks.OAK_LOG)) ::save ) - .save(out, rl("shaped_true_conditions")); + .save(this.output, rl("shaped_true_conditions")); ConditionalRecipe.builder() .condition(FALSE()) .recipe( - ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK) + shapeless(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK) .requires(Blocks.REDSTONE_ORE) .requires(Blocks.REDSTONE_ORE) .requires(Blocks.REDSTONE_ORE) .unlockedBy(getHasName(Blocks.REDSTONE_ORE), has(Blocks.REDSTONE_ORE)) ::save ) - .save(out, rl("shapeless_false_conditions")); + .save(this.output, rl("shapeless_false_conditions")); ConditionalRecipe.builder() .condition(TRUE()) .recipe( - ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK) + shapeless(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK) .requires(Blocks.REDSTONE_ORE) .requires(Blocks.REDSTONE_ORE) .requires(Blocks.REDSTONE_ORE) @@ -279,7 +278,7 @@ public class ConditionalRecipeTest extends BaseTestMod { .unlockedBy(getHasName(Blocks.REDSTONE_ORE), has(Blocks.REDSTONE_ORE)) ::save ) - .save(out, rl("shapeless_true_conditions")); + .save(this.output, rl("shapeless_true_conditions")); ConditionalRecipe.builder() .condition(FALSE()) @@ -288,7 +287,7 @@ public class ConditionalRecipeTest extends BaseTestMod { .unlockedBy(getHasName(Blocks.DIRT), has(Blocks.DIRT)) ::save ) - .save(out, rl("cooking_false_conditions")); + .save(this.output, rl("cooking_false_conditions")); ConditionalRecipe.builder() .condition(TRUE()) @@ -297,7 +296,7 @@ public class ConditionalRecipeTest extends BaseTestMod { .unlockedBy(getHasName(Blocks.BEE_NEST), has(Blocks.BEE_NEST)) ::save ) - .save(out, rl("cooking_true_conditions")); + .save(this.output, rl("cooking_true_conditions")); ConditionalRecipe.builder() .condition(FALSE()) @@ -306,7 +305,7 @@ public class ConditionalRecipeTest extends BaseTestMod { .unlockedBy(getHasName(Blocks.DIRT), has(Blocks.DIRT)) ::save ) - .save(out, rl("single_item_false_conditions")); + .save(this.output, rl("single_item_false_conditions")); ConditionalRecipe.builder() .condition(TRUE()) @@ -315,7 +314,7 @@ public class ConditionalRecipeTest extends BaseTestMod { .unlockedBy(getHasName(Blocks.REDSTONE_ORE), has(Blocks.REDSTONE_ORE)) ::save ) - .save(out, rl("singe_item_true_conditions")); + .save(this.output, rl("singe_item_true_conditions")); // TODO SmithingTransformRecipeBuilder // TODO SmithingTrimRecipeBuilder @@ -324,7 +323,7 @@ public class ConditionalRecipeTest extends BaseTestMod { ConditionalRecipe.builder() .condition(FALSE()) .recipe( - ShapedRecipeBuilder.shaped(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK, 64) + shaped(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK, 64) .pattern("XXX") .pattern("XX ") .define('X', Blocks.DIRT) @@ -333,48 +332,64 @@ public class ConditionalRecipeTest extends BaseTestMod { ) .condition(TRUE()) .recipe( - ShapedRecipeBuilder.shaped(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK, 64) + shaped(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK, 64) .pattern("XXX") .pattern("XX ") .define('X', Blocks.OAK_LOG) .unlockedBy(getHasName(Blocks.OAK_LOG), has(Blocks.OAK_LOG)) ::save ) - .save(out, rl("conditional_recipe_choice")); + .save(this.output, rl("conditional_recipe_choice")); ConditionalRecipe.builder() .condition(FALSE()) .recipe( - ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK, 64) + shapeless(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK, 64) .requires(Blocks.DIRT) .unlockedBy(getHasName(Blocks.DIRT), has(Blocks.DIRT)) ::save ) - .save(out, rl("conditional_doesnt_load_empty")); + .save(this.output, rl("conditional_doesnt_load_empty")); ConditionalRecipe.builder() .condition(tagEmpty(ItemTags.DIRT)) .recipe( - ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK) + shapeless(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK) .requires(Blocks.IRON_ORE) .requires(Blocks.IRON_ORE) .requires(Blocks.IRON_ORE) .unlockedBy(getHasName(Blocks.IRON_ORE), has(Blocks.IRON_ORE)) ::save ) - .save(out, rl("tag_empty_condition_doesnt_load")); + .save(this.output, rl("tag_empty_condition_doesnt_load")); ConditionalRecipe.builder() .condition(tagEmpty(Tags.Items.EGGS)) .recipe( - ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK) + shapeless(RecipeCategory.MISC, Blocks.DIAMOND_BLOCK) .requires(Blocks.GOLD_ORE) .requires(Blocks.GOLD_ORE) .requires(Blocks.GOLD_ORE) .unlockedBy(getHasName(Blocks.GOLD_ORE), has(Blocks.GOLD_ORE)) ::save ) - .save(out, rl("tag_empty_condition_loads")); + .save(this.output, rl("tag_empty_condition_loads")); + } + + public static class Runner extends RecipeProvider.Runner { + protected Runner(PackOutput output, CompletableFuture registries) { + super(output, registries); + } + + @Override + public String getName() { + return ConditionalRecipeTest.class.getSimpleName() + "-Recipes"; + } + + @Override + protected RecipeProvider createRecipeProvider(Provider registries, RecipeOutput output) { + return new Recipes(registries, output); + } } } diff --git a/src/test/java/net/minecraftforge/debug/gameplay/crafting/CustomIngredientsTest.java b/src/test/java/net/minecraftforge/debug/gameplay/crafting/CustomIngredientsTest.java index 3f234a4f5e..c5bb059c27 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/crafting/CustomIngredientsTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/crafting/CustomIngredientsTest.java @@ -8,12 +8,13 @@ package net.minecraftforge.debug.gameplay.crafting; import java.util.concurrent.CompletableFuture; import java.util.function.Function; -import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.jetbrains.annotations.Nullable; import net.minecraft.core.HolderLookup; +import net.minecraft.core.HolderLookup.Provider; import net.minecraft.core.component.DataComponents; +import net.minecraft.core.registries.Registries; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeCategory; import net.minecraft.data.recipes.RecipeOutput; @@ -23,6 +24,7 @@ import net.minecraft.data.tags.ItemTagsProvider; import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.ItemTags; import net.minecraft.tags.TagKey; @@ -72,7 +74,7 @@ public class CustomIngredientsTest extends BaseTestMod implements INBTBuilder { var blockTags = new BlockTagsGen(out, look, exist); gen.addProvider(event.includeServer(), blockTags); gen.addProvider(event.includeServer(), new ItemTagsGen(out, look, blockTags, exist)); - gen.addProvider(event.includeServer(), new Recipes(out, event.getLookupProvider())); + gen.addProvider(event.includeServer(), new Recipes.Runner(out, event.getLookupProvider())); } private static ResourceLocation rl(String path) { @@ -84,16 +86,16 @@ public class CustomIngredientsTest extends BaseTestMod implements INBTBuilder { } private static > void assertRecipeMiss(GameTestHelper helper, RecipeType type, C container) { - var recipe = helper.getLevel().getRecipeManager().getRecipeFor(type, container, helper.getLevel()); + var recipe = helper.getLevel().recipeAccess().getRecipeFor(type, container, helper.getLevel()); helper.assertTrue(recipe.isEmpty(), () -> "Found crafting recipe when unexpected: " + recipe.get().id()); helper.succeed(); } private static > void assertRecipeMatch(GameTestHelper helper, RecipeType type, C container, String name) { - var recipe = helper.getLevel().getRecipeManager().getRecipeFor(type, container, helper.getLevel()); + var recipe = helper.getLevel().recipeAccess().getRecipeFor(type, container, helper.getLevel()); helper.assertTrue(recipe.isPresent(), "Did not find crafting recipe when expected!"); - helper.assertTrue(recipe.get().id().getNamespace().equals(MODID), "It wasn't our recipe: " + recipe.get().id()); - helper.assertTrue(recipe.get().id().getPath().equals(name), "It wasn't the correct recipe expected: " + name + " got: " + recipe.get().id()); + helper.assertTrue(recipe.get().id().location().getNamespace().equals(MODID), "It wasn't our recipe: " + recipe.get().id()); + helper.assertTrue(recipe.get().id().location().getPath().equals(name), "It wasn't the correct recipe expected: " + name + " got: " + recipe.get().id()); helper.succeed(); } @@ -110,6 +112,7 @@ public class CustomIngredientsTest extends BaseTestMod implements INBTBuilder { .build(); } + @SuppressWarnings("unused") private static ItemStack damaged(ItemLike item) { return tagged(item, damaged()); } @@ -251,19 +254,24 @@ public class CustomIngredientsTest extends BaseTestMod implements INBTBuilder { } } - private static class Recipes extends RecipeProvider implements IConditionBuilder, IIngredientBuilder, INBTBuilder{ - public Recipes(PackOutput gen, CompletableFuture lookup) { - super(gen, lookup); + private static class Recipes extends RecipeProvider implements IConditionBuilder, IIngredientBuilder, INBTBuilder { + public Recipes(HolderLookup.Provider lookup, RecipeOutput gen) { + super(lookup, gen); } - private static ShapedRecipeBuilder shaped() { - return ShapedRecipeBuilder.shaped(RecipeCategory.MISC, Items.DIRT); + private ShapedRecipeBuilder shaped() { + return shaped(RecipeCategory.MISC, Items.DIRT); + } + + private static ResourceKey> rk(String path) { + return ResourceKey.create(Registries.RECIPE, rl(path)); } @Override - protected void buildRecipes(RecipeOutput out) { + protected void buildRecipes() { var hasName = getHasName(Items.DIRT); var has = has(Items.DIRT); + var items = this.registries.lookup(Registries.ITEM).get(); // contains NBT match - should match a stone pickaxe that lost 3 durability, regardless of setting its name shaped() @@ -276,7 +284,7 @@ public class CustomIngredientsTest extends BaseTestMod implements INBTBuilder { .build() ) .unlockedBy(hasName, has) - .save(out, rl("partial_nbt_damage_only")); + .save(this.output, rk("partial_nbt_damage_only")); // contains NBT match - should match a named wood, stone, or iron pickaxe, regardless of damage shaped() @@ -288,7 +296,7 @@ public class CustomIngredientsTest extends BaseTestMod implements INBTBuilder { .build() ) .unlockedBy(hasName, has) - .save(out, rl("partial_nbt_name_only")); + .save(this.output, rk("partial_nbt_name_only")); // compound - should match named dirt or named oak logs shaped() @@ -299,32 +307,48 @@ public class CustomIngredientsTest extends BaseTestMod implements INBTBuilder { strictNbt(named(Items.OAK_LOG)) )) .unlockedBy(hasName, has) - .save(out, rl("compound_ingredient")); + .save(this.output, rk("compound_ingredient")); // strict NBT match - should match an unnamed pickaxe that lost 3 durability shaped() .pattern("XXX") .define('X', strictNbt(named(Items.DIAMOND_PICKAXE))) .unlockedBy(hasName, has) - .save(out, rl("strict_nbt_ingredient")); + .save(this.output, rk("strict_nbt_ingredient")); // intersection - should match STONE only, [dirt, stone] + [stone, gravel] shaped() .pattern("XXX") .pattern("XXX") .pattern(" X ") - .define('X', intersection(LEFT, RIGHT)) + .define('X', intersection(items, LEFT, RIGHT)) .unlockedBy(hasName, has) - .save(out, rl("intersection_ingredient")); + .save(this.output, rk("intersection_ingredient")); // difference - should match DIRT only, [dirt, stone] - [stone, gravel] shaped() .pattern(" X ") .pattern("XXX") .pattern(" X ") - .define('X', difference(LEFT, RIGHT)) + .define('X', difference(items, LEFT, RIGHT)) .unlockedBy(hasName, has) - .save(out, rl("difference_ingredient")); + .save(this.output, rk("difference_ingredient")); + } + + public static class Runner extends RecipeProvider.Runner { + protected Runner(PackOutput output, CompletableFuture registries) { + super(output, registries); + } + + @Override + public String getName() { + return CustomIngredientsTest.class.getSimpleName() + "-Recipes"; + } + + @Override + protected RecipeProvider createRecipeProvider(Provider registries, RecipeOutput output) { + return new Recipes(registries, output); + } } } } diff --git a/src/test/java/net/minecraftforge/debug/gameplay/criterion/CriterionTest.java b/src/test/java/net/minecraftforge/debug/gameplay/criterion/CriterionTest.java index 2d9b1bc18e..3e319e37e8 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/criterion/CriterionTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/criterion/CriterionTest.java @@ -133,6 +133,8 @@ public final class CriterionTest extends BaseTestMod { event.getLookupProvider(), event.getExistingFileHelper(), List.of(((registries, saver, existingFileHelper) -> { + var blocks = registries.lookup(Registries.BLOCK).get(); + var items = registries.lookup(Registries.ITEM).get(); saver.accept(new Advancement.Builder() .display(Items.COD, Component.literal("Fish vs Glass"), @@ -144,8 +146,8 @@ public final class CriterionTest extends BaseTestMod { .parent(STORY_ROOT) .requirements(AdvancementRequirements.Strategy.AND) .addCriterion(TEST_CRITERION_ID, CRITERION.get().instance( - BlockPredicate.Builder.block().of(Tags.Blocks.GLASS_BLOCKS).build(), - ItemPredicate.Builder.item().of(tag).build(), + BlockPredicate.Builder.block().of(blocks, Tags.Blocks.GLASS_BLOCKS).build(), + ItemPredicate.Builder.item().of(items, tag).build(), true )) .build(TEST_ADVANCEMENT_ID)); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/item/GatherComponentsEventTest.java b/src/test/java/net/minecraftforge/debug/gameplay/item/GatherComponentsEventTest.java index 2245215841..2d770f732b 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/item/GatherComponentsEventTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/item/GatherComponentsEventTest.java @@ -8,20 +8,16 @@ package net.minecraftforge.debug.gameplay.item; import net.minecraft.core.component.DataComponents; import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; -import net.minecraft.world.food.FoodProperties; +import net.minecraft.world.food.Foods; import net.minecraft.world.item.Items; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.GatherComponentsEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.test.BaseTestMod; -import java.util.List; -import java.util.Optional; - @GameTestHolder("forge." + GatherComponentsEventTest.MOD_ID) @Mod(GatherComponentsEventTest.MOD_ID) public class GatherComponentsEventTest extends BaseTestMod { @@ -35,14 +31,7 @@ public class GatherComponentsEventTest extends BaseTestMod { public void onItem(GatherComponentsEvent.Item itemEvent) { if (!itemEvent.getOriginalComponentMap().has(DataComponents.FOOD) && itemEvent.getOwner() == Items.IRON_NUGGET) { - itemEvent.register(DataComponents.FOOD, new FoodProperties( - 2, - 7, - true, - 3, - Optional.empty(), - List.of() - )); + itemEvent.register(DataComponents.FOOD, Foods.APPLE); } } diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/ConditionalLootPools.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/ConditionalLootPools.java index b749f090d8..bb5b2e998e 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/ConditionalLootPools.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/ConditionalLootPools.java @@ -22,7 +22,6 @@ import net.minecraft.world.level.storage.loot.entries.LootItem; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.test.BaseTestMod; import net.minecraftforge.fml.common.Mod; @@ -43,7 +42,7 @@ public class ConditionalLootPools extends BaseTestMod { public static final String MODID = "conditional_loot_test"; private static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID); - private static final RegistryObject TEST_BLOCK = BLOCKS.register("test", () -> new Block(BlockBehaviour.Properties.of())); + private static final RegistryObject TEST_BLOCK = BLOCKS.register("test", () -> new Block(name(MODID, "test", BlockBehaviour.Properties.of()))); public ConditionalLootPools(FMLJavaModLoadingContext context) { super(context); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java index bce7db6d98..6d64b0d1ac 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java @@ -48,6 +48,7 @@ import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.crafting.SingleRecipeInput; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootParams; +import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition; @@ -60,7 +61,6 @@ import net.minecraftforge.common.loot.IGlobalLootModifier; import net.minecraftforge.common.loot.LootModifier; import net.minecraftforge.common.loot.LootTableIdCondition; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.test.BaseTestMod; @@ -103,9 +103,9 @@ public class GlobalLootModifiersTest extends BaseTestMod { }); private static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID); - private static final RegistryObject TEST_BLOCK = BLOCKS.register("test", () -> new Block(BlockBehaviour.Properties.of())); + private static final RegistryObject TEST_BLOCK = BLOCKS.register("test", () -> new Block(name(MODID, "test", BlockBehaviour.Properties.of()))); private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); - private static final RegistryObject TEST_ITEM = ITEMS.register("test", () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties())); + private static final RegistryObject TEST_ITEM = ITEMS.register("test", () -> new BlockItem(TEST_BLOCK.get(), name(MODID, "test", new Item.Properties()))); public GlobalLootModifiersTest(FMLJavaModLoadingContext context) { super(context); @@ -211,6 +211,7 @@ public class GlobalLootModifiersTest extends BaseTestMod { @Override protected void start(HolderLookup.Provider registries) { var smelt = registries.lookupOrThrow(Registries.ENCHANTMENT).getOrThrow(SMELT); + var items = registries.lookupOrThrow(Registries.ITEM); // Tested vis breaking a log and checking if we get charcoal add("smelting", new SmeltingEnchantmentModifier( @@ -231,7 +232,7 @@ public class GlobalLootModifiersTest extends BaseTestMod { // This has no game test because it relies on random number generation and I can't be bothered to try and force that right now. add("wheat_harvest", new WheatSeedsConverterModifier( new LootItemCondition[] { - MatchTool.toolMatches(ItemPredicate.Builder.item().of(Items.SHEARS)).build(), + MatchTool.toolMatches(ItemPredicate.Builder.item().of(items, Items.SHEARS)).build(), LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.WHEAT).build() }, 3, Items.WHEAT_SEEDS, Items.WHEAT) @@ -240,14 +241,14 @@ public class GlobalLootModifiersTest extends BaseTestMod { // Tested by verifying that we drop 2 test blocks when broken instead of the default 1 add("multiply_loot", new MultiplyDropsModifier( new LootItemCondition[] { - LootTableIdCondition.builder(TEST_BLOCK.get().getLootTable().location()).build() + LootTableIdCondition.builder(TEST_BLOCK.get().getLootTable().get().location()).build() }, 2) ); // Bamboo silk harvests everything, Tested by breaking glass and seeing if we get glass back. add("bamboo_silk", new SilkTouchTestModifier( new LootItemCondition[] { - MatchTool.toolMatches(ItemPredicate.Builder.item().of(Items.BAMBOO)).build() + MatchTool.toolMatches(ItemPredicate.Builder.item().of(items, Items.BAMBOO)).build() }) ); } @@ -294,19 +295,20 @@ public class GlobalLootModifiersTest extends BaseTestMod { @NotNull @Override - public ObjectArrayList doApply(ObjectArrayList generatedLoot, LootContext context) { + public ObjectArrayList doApply(LootTable table, ObjectArrayList generatedLoot, LootContext context) { var ret = new ObjectArrayList(); generatedLoot.forEach(stack -> ret.add(smelt(stack, context))); return ret; } private static ItemStack smelt(ItemStack stack, LootContext context) { - var mgr = context.getLevel().getRecipeManager(); + var mgr = context.getLevel().recipeAccess(); var reg = context.getLevel().registryAccess(); + var inv = new SingleRecipeInput(stack); return mgr - .getRecipeFor(RecipeType.SMELTING, new SingleRecipeInput(stack), context.getLevel()) + .getRecipeFor(RecipeType.SMELTING, inv, context.getLevel()) .map(holder -> holder.value()) - .map(recipe -> recipe.getResultItem(reg)) + .map(recipe -> recipe.assemble(inv, reg)) .filter(itemStack -> !itemStack.isEmpty()) .map(itemStack -> ItemHandlerHelper.copyStackWithSize(itemStack, stack.getCount() * itemStack.getCount())) .orElse(stack); @@ -335,21 +337,19 @@ public class GlobalLootModifiersTest extends BaseTestMod { @NotNull @Override - public ObjectArrayList doApply(ObjectArrayList generatedLoot, LootContext context) { - var ctxTool = context.getParamOrNull(LootContextParams.TOOL); + public ObjectArrayList doApply(LootTable table, ObjectArrayList generatedLoot, LootContext context) { + var ctxTool = context.getOptionalParameter(LootContextParams.TOOL); //return early if silk-touch is already applied (otherwise we'll get stuck in an infinite loop). var silk = context.getLevel().holderLookup(Registries.ENCHANTMENT).getOrThrow(Enchantments.SILK_TOUCH); var silkLevel = EnchantmentHelper.getItemEnchantmentLevel(silk, ctxTool); if (ctxTool == null || ctxTool.isEmpty() || silkLevel > 0) return generatedLoot; var fakeTool = ctxTool.copy(); fakeTool.enchant(silk, 1); - var params = new LootParams.Builder(context.getLevel()) + var params = new LootParams.Builder(context.getParams()) .withParameter(LootContextParams.TOOL, fakeTool) - .create(LootContextParamSets.EMPTY); + .create(); - return context.getLevel().getServer().reloadableRegistries() - .getLootTable(context.getParamOrNull(LootContextParams.BLOCK_STATE).getBlock().getLootTable()) - .getRandomItems(params); + return table.getRandomItems(params); } @Override @@ -383,7 +383,7 @@ public class GlobalLootModifiersTest extends BaseTestMod { @NotNull @Override - public ObjectArrayList doApply(ObjectArrayList generatedLoot, LootContext context) { + public ObjectArrayList doApply(LootTable table, ObjectArrayList generatedLoot, LootContext context) { // // Additional conditions can be checked, though as much as possible should be parameterized via JSON data. // It is better to write a new ILootCondition implementation than to do things here. @@ -423,11 +423,11 @@ public class GlobalLootModifiersTest extends BaseTestMod { } @Override - protected ObjectArrayList doApply(ObjectArrayList generatedLoot, LootContext context) { - return generatedLoot.stream() - .map(ItemStack::copy) - .peek(stack -> stack.setCount(Math.min(stack.getMaxStackSize(), stack.getCount() * this.multiplicationFactor))) - .collect(Collectors.toCollection(ObjectArrayList::new)); + protected ObjectArrayList doApply(LootTable table, ObjectArrayList generatedLoot, LootContext context) { + var ret = new ObjectArrayList(); + for (var orig : generatedLoot) + ret.add(orig.copyWithCount(Math.min(orig.getMaxStackSize(), orig.getCount() * this.multiplicationFactor))); + return ret; } @Override diff --git a/src/test/java/net/minecraftforge/debug/registries/NetworkDatapackRegistryTest.java b/src/test/java/net/minecraftforge/debug/registries/NetworkDatapackRegistryTest.java index 98978793b0..2b00080d80 100644 --- a/src/test/java/net/minecraftforge/debug/registries/NetworkDatapackRegistryTest.java +++ b/src/test/java/net/minecraftforge/debug/registries/NetworkDatapackRegistryTest.java @@ -7,7 +7,6 @@ package net.minecraftforge.debug.registries; import java.util.Set; -import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.slf4j.Logger; @@ -77,9 +76,9 @@ public class NetworkDatapackRegistryTest extends BaseTestMod { private static void client_has_registry_client_code(GameTestHelper helper) { var mc = Minecraft.getInstance(); var level = mc.level; - var reg = level.registryAccess().registry(REGISTRY_KEY); + var reg = level.registryAccess().lookup(REGISTRY_KEY); helper.assertTrue(reg.isPresent(), "Failed to find " + REGISTRY_KEY.location()); - var entry = reg.get().get(TEST_ENTRY); + var entry = reg.get().getValue(TEST_ENTRY); if (entry == null) helper.fail("Failed to find " + TEST_ENTRY); helper.assertValueEqual(entry.value, TEST_VALUE, "Loaded entry does not contain expected value"); diff --git a/src/test/java/net/minecraftforge/test/BaseTestMod.java b/src/test/java/net/minecraftforge/test/BaseTestMod.java index b103e8b963..d8edb76296 100644 --- a/src/test/java/net/minecraftforge/test/BaseTestMod.java +++ b/src/test/java/net/minecraftforge/test/BaseTestMod.java @@ -10,10 +10,15 @@ import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; import java.util.function.Function; + +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.CreativeModeTab.TabVisibility; +import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -48,6 +53,14 @@ public abstract class BaseTestMod { return ResourceLocation.fromNamespaceAndPath(namespace, path); } + protected static BlockBehaviour.Properties name(String namespace, String name, BlockBehaviour.Properties peops) { + return peops.setId(ResourceKey.create(Registries.BLOCK, rl(namespace, name))); + } + + protected static Item.Properties name(String namespace, String name, Item.Properties peops) { + return peops.setId(ResourceKey.create(Registries.ITEM, rl(namespace, name))); + } + protected void testItem(Function supplier) { this.testItems.add(supplier); }